-
Notifications
You must be signed in to change notification settings - Fork 13.4k
indicate ppc64 elf abi in e_flags #142321
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
base: master
Are you sure you want to change the base?
Conversation
r? @Nadrieril rustbot has assigned @Nadrieril. Use |
Some changes occurred in compiler/rustc_codegen_ssa |
I don't think we have any business with Power's ELFv1 format. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if we do have anything to do with it, we shouldn't be guessing.
I marked this as a draft because there's now a problem that I really dislike (and ppc64 targets are currently broken):
Compiling the above mentioned program with this target file again produces the broken binary because the abi field is not passed to llvm (powerpc64-unknown-none-elf uses ELFv1 in llvm). |
This comment has been minimized.
This comment has been minimized.
@ostylk This is determined by llvm_abiname, not target.abi. |
Yeah, there are cases where they match but in general target.abi is a cfg option for Rust userspace and target.llvm_abiname is the codegen control. |
Oh thanks, I somehow overlooked llvm_abiname. I changed it to use llvm_abiname, because it really matters what the llvm codegen does. Also I changed the existing ppc64 targets to set llvm_abiname and abi (in case an app needs that information) accordingly. |
These commits modify compiler targets. |
This comment has been minimized.
This comment has been minimized.
@rustbot ready |
Attempts to fix #85589 (also more information is there).
Basically the problem is that ld.lld assumes that all ppc64 object files with e_flags=0 are object files which use the ELFv2 ABI (this here is the check https://github.com/llvm/llvm-project/blob/main/lld/ELF/Arch/PPC64.cpp#L639).
This pull request sets the correct e_flags to indicate the used ABI so ld.lld errors out when encountering ELFv1 ABI files instead of generating a broken binary.
For example compare code generation for this program (file name
min.rs
):Compile with
rustc --target=powerpc64-unknown-linux-gnu -C linker=ld.lld -C relocation-model=static min.rs
Before change:
The branch instructions
bl 0x10030378
andbl 0x10030390
are jumping into the.opd
section which is data. That is a broken binary (because fixing those branches is the task of the linker).After change:
Which is correct because ld.lld doesn't support ELFv1 ABI.