Skip to content

Add support for --no-warn-mismatch for ELF#1167

Open
Steven6798 wants to merge 1 commit into
qualcomm:mainfrom
Steven6798:issue-1098
Open

Add support for --no-warn-mismatch for ELF#1167
Steven6798 wants to merge 1 commit into
qualcomm:mainfrom
Steven6798:issue-1098

Conversation

@Steven6798
Copy link
Copy Markdown
Contributor

@Steven6798 Steven6798 commented May 12, 2026

Allow users to suppress warnings about incompatible or mismatched input files using the --no-warn-mismatch option. This change disables mismatch diagnostics while preserving normal link behavior and outcomes.

Fix: #1214

@Steven6798 Steven6798 force-pushed the issue-1098 branch 2 times, most recently from 8f3dcad to 32d6c33 Compare May 12, 2026 17:05
@Steven6798 Steven6798 changed the title Allow users to suppress warnings about incompatible or mismatched Add support for --no-warn-mismatch May 12, 2026
@Steven6798 Steven6798 marked this pull request as ready for review May 12, 2026 18:44
@Steven6798 Steven6798 requested a review from quic-areg May 12, 2026 18:44
Comment thread lib/Readers/ELFReader.cpp Outdated
Comment thread lib/Readers/ELFReader.cpp Outdated
Comment thread lib/Target/RISCV/RISCVInfo.cpp
@Steven6798 Steven6798 marked this pull request as draft May 18, 2026 13:17
@Steven6798
Copy link
Copy Markdown
Contributor Author

This PR will address file mismatches using header information. Architecture specific changes will be handled in another issue/PR.

@Steven6798
Copy link
Copy Markdown
Contributor Author

While updating the tests I noticed that the dynamic version of the test crashes in the readDynamic function in the DynamicELFReader.cpp file. I think this is unrelated to the issue at hand so I will raise an issue about it.

@Steven6798
Copy link
Copy Markdown
Contributor Author

I updated the RISCV FloatABI and Emulation tests since they were expecting --warn-mismatch to be enabled.

@Steven6798 Steven6798 requested a review from parth-07 May 19, 2026 20:37
@Steven6798 Steven6798 marked this pull request as ready for review May 19, 2026 20:37
Copy link
Copy Markdown
Contributor

@quic-areg quic-areg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For aarch64, arm, and riscv, the default behavior (with no flag at all) silently accepts any object:

# before
ld.eld -m aarch64linux a.arm.o       # cannot recognize the format ... (exit 1)
ld.eld -m elf32lriscv  a.rv64.o          # Error: Invalid ELF file ...           (exit 1)

# after
ld.eld -m aarch64linux a.arm.o    # succeeds
ld.eld -m elf32lriscv  a.rv64.o     # succeeds (32-bit ELF output with rv64 contents merged)

This is really confusing imo and unsafe. Ideally, we would match GNU ld where --no-warn-mismatch is opt-in. This would remove the 3-state enum to a simple boolean and fix the aarch64/arm/riscv default regression.

GNU ld's no-warn-mismatch also differs from this patch in that it does not allow ELFs of different classes to be mixed, while we do. I think we should follow the GNU linker and not relax the checkClass() check. It is also probably unsafe: a 64-bit object in a 32-bit link gets parsed by the 32-bit parser.

Comment thread docs/userguide/documentation/linker_faq.rst Outdated
@Steven6798
Copy link
Copy Markdown
Contributor Author

For aarch64, arm, and riscv, the default behavior (with no flag at all) silently accepts any object:

I think it is best that the team meets up next week to discuss this since there are multiple opinions about how to address this issue. I'll schedule everything with Shankar. Thanks for the feedback.

@Steven6798 Steven6798 changed the title Add support for --no-warn-mismatch Add support for --no-warn-mismatch for ELF May 26, 2026
Allow users to suppress warnings about incompatible or mismatched
input files using the --no-warn-mismatch option. This change
disables mismatch diagnostics while preserving normal link
behavior and outcomes.

Fix: qualcomm#1214

Signed-off-by: Steven Ramirez Rosa <ramirezr@qti.qualcomm.com>
@Steven6798
Copy link
Copy Markdown
Contributor Author

Steven6798 commented May 26, 2026

This PR only addresses --no-warn-mismatch and how it handled ELF information conflicts. It follows GNU's ld. Keep the feedback focus on this, as anything else will need to be handled in another issue/PR.

@Steven6798 Steven6798 requested a review from quic-areg May 26, 2026 16:28
@quic-areg
Copy link
Copy Markdown
Contributor

I was mistaken on GNU ld not allowing different ELF classes to be mixed with its --no-warn-mismatch, please disregard that. But the other part of my comment still applies:

# before
ld.eld -m aarch64linux a.arm.o       # cannot recognize the format ... (exit 1)
ld.eld -m elf32lriscv  a.rv64.o          # Error: Invalid ELF file ...           (exit 1)

# after
ld.eld -m aarch64linux a.arm.o    # succeeds
ld.eld -m elf32lriscv  a.rv64.o     # succeeds

--no-warn-mismatch should be opt-in and not default for this case.

@Steven6798
Copy link
Copy Markdown
Contributor Author

Steven6798 commented May 26, 2026

--no-warn-mismatch should be opt-in and not default for this case.

Each architecture defines the default value differently if no flag is passed. This should be handled in another issue/PR. I can look into it as soon as I'm done with --no-warn-mismatch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for --no-warn-mismatch for ELF information

4 participants