Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Describe the behaviour of the linker for ABI mismatches #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

compnerd
Copy link

Certain ABI requirements of the code contained in an object file are
described by the e_flags field of the ELF header in an ELF object
file. An ELF linker is able to inspect this and provide validation that
ABI mismatches do not accidentally occur.

Describe how the mismatches should be validated so that different
toolchains perform the validation similarly. Currently the BFD linker
is more lenient about the check, permitting inconsequential object files
(files which do not contribute to the text segment) to be excluded from
the requirements while lld is overly restrictive and does not permit the
mismatch for any input.

Certain ABI requirements of the code contained in an object file are
described by the `e_flags` field of the ELF header in an ELF object
file.  An ELF linker is able to inspect this and provide validation that
ABI mismatches do not accidentally occur.

Describe how the mismatches should be validated so that different
toolchains perform the validation similarly.  Currently the BFD linker
is more lenient about the check, permitting inconsequential object files
(files which do not contribute to the text segment) to be excluded from
the requirements while lld is overly restrictive and does not permit the
mismatch for any input.
@compnerd
Copy link
Author

CC: @asb @jim-wilson

@asb
Copy link
Contributor

asb commented Aug 19, 2021

@jrtc27 @kito-cheng: any thoughts on this one?

@jrtc27
Copy link

jrtc27 commented Aug 19, 2021

I dispute the "overly restrictive" part; you can come up with C inputs that aren't compatible yet BFD won't give an error for because it's trying to support other use cases that can be done an equivalent way (turning a binary blob into an ELF; historically people do things like ld -b binary or objcopy -I binary -O elfNN-foo, with no way to pass -march/-mabi information that then gets recorded in the output, but these days you can use .incbin in an assembly file as a much more flexible and robust version).

@asb
Copy link
Contributor

asb commented Aug 19, 2021

+@MaskRay too

because the impact of the calling convention is limited to the code
contributions of an object file, any empty object file (i.e. containing no
sections) or any object file which does not contribute any text sections which
are loaded at runtime shall be excluded from the requirement that the floating
Copy link

Choose a reason for hiding this comment

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

To be clear: this is not what LLD does and I am personally of the view it should continue to not do this. Just because BFD does something doesn't mean it's the right thing to do. There are ways to avoid this issue entirely and I am loathe to provide users with more footguns than necessary in the LLVM ecosystem, regardless of what GNU developers chose to do 5 years ago.

are loaded at runtime shall be excluded from the requirement that the floating
point passing convention and the use of RVE match across all the object files.

### Issues for consideration
Copy link

Choose a reason for hiding this comment

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

I think this should go away entirely. It's certainly not normative text, and linking files with different floating point ABIs that have code in them is definitely asking for so much trouble that you can't just disable the checking. This is how you end up with users building programs that blow up and complaining at toolchain developers that the compiler doesn't work.

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.

None yet

4 participants