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
Support DT_RELR using standard -z pack-relative-relocs cmdline flag #653
Comments
If someone really has a trouble with these flags, I'll consider, but I don't think we should add a new flag for a hypothetical use. It's somewhat an evolutionary process; if a flag doesn't become popular enough, it won't be supported by many implementations, and its use will diminish. So I don't think we should try to support all flags beforehand. |
When adding
That seems quite complicated, so I agree with you that waiting is probably better... For context, the same issue has been raised before in the lld project: llvm/llvm-project#53775. |
Thank you for sharing the link! I agree with you that what GNU ld does seems quite complicated. |
b365d6b added -z pack-relative-relocs without GLIBC_ABI_DT_RELR, which leads to the error mentioned in #653 (comment) ... |
I was experiencing the error mentioned in #653 (comment) in the 2.0.0 release build when building firefox 116. This issue appears to have been fixed by f467ad1, but a new error pops up:
Could this possibly be related? PS: here is a link to a report on the same bug on firefox's issue tracker: https://bugzilla.mozilla.org/show_bug.cgi?id=1847697. |
No, that's different. What target did you get this error for? If it's for x86-64 or ARM64, it is actually odd if an object file contains a REL-type relocation section instead of RELA-type one. |
This is on x86-64, a ryzen 5 5600G to be exact. Do you want me to create a new issue, since it is unrelated? |
Can reproduce this issue on FF-117 as well
|
It looks like LLVM generates REL-type relocations instead of RELA-type ones for LLVM. It's very likely that it's a bug in LLVM. Can you report it to LLVM? |
Sure, in the process of rebuilding manually (w/o ebuild) to isolate and confirm the issue, Will file one once I have confirmation |
Is this really a bug w/ LLVM? Compiling w/ LLVM succeeds
But on adding -fuse-ld=mold
|
Yes, it's a bug in LLVM, please report it to LLVM. x86-64 is defined to use RELA-type relocations by its psABI, so creating a REL-type relocation type is illegal even if other linkers happen to not complain. |
@rui314 Some additional guidance please, looking at https://github.com/llvm/llvm-project/blob/631e2911ea298bc12564df8acd16bba89790426a/lld/test/ELF/relocation-none.test#L38
This is exactly where mold is failing, and seems to be documented behavior |
Even if it's documented, it still violates the spec. As quoted from x86-64 psABI p.72, "The AMD64 LP64 ABI architecture uses only Elf64_Rela relocation entries with explicit addends." While they have the option not to conform to the standard, doing so would lead to compatibility issues for obvious reasons. |
Yes, but that would be unlikely. Even the kernel has patches to ignore modpost checks on call-graph-profile And here's the rationale behind it |
Alright, how about we simply ignore the REL relocation tables in psABIs where RELA is mandated? It seems that by doing so, we'll resolve the issue. |
I genuinely do not understand any of this enough to comment. This issue was my first attempt at even trying to go through a compiler/linker source, so I'm not sure what the correct approach is here. |
I believe ignoring a relocation table with an incompatible type should be fine because in this case all relocations in the incompatible table is R_*_NONE type, which is a no-op relocation. mold used to silently ignore incompatible relocation tables, so it's not new. |
Specifically, .llvm.call-graph-profile is always REL even on x86-64. We can safely ignore the relocation table because it contains only R_NONE relocations. Fixes #653
Specifically, .llvm.call-graph-profile is always REL even on x86-64. We can safely ignore the relocation table because it contains only R_NONE relocations. Fixes rui314#653
In bfd and gold, packed dynamic relocations are toggled with the
-z pack-relative-relocs
and-z nopack-relative-relocs
cmd line flags, while mold uses-pack-dyn-relocs=none|relr
. For compatibility it would be simpler if mold aligned to the other linkers, can the standard flag also be supported, or used instead of-pack-dyn-relocs
?The text was updated successfully, but these errors were encountered: