-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
CREL relocation table contains addends even for RELA-type psABIs #131705
Comments
Thank you for your interest in CREL! While implicit addends work well for dynamic relocations, I don’t find them as beneficial for static relocations. I touched on this in my post:
I conducted some experiments with CREL static relocations using implicit addends (there is a stale branch, more updated one is lost: https://github.com/MaskRay/llvm-project/commits/demo-crel-rela-only-for-code/), but I recall that compressed debug sections might actually grow larger. There could be minor savings in code and data sections, though, overall, I think it's a poor fit. Implicit addend static relocations are not worth the effort of adapting assemblers, linkers, and dumpers.
While implementations might be REL only, aaelf32 explicitly supports RELA relocations. Anyhow, I believe that the toolchains for these architectures adopted REL primarily for space efficiency, a benefit that diminishes with the transition to CREL. |
I think my argument is that you are making CREL more than just a compact relocation table format; you're effectively introducing a significant psABI change by attempting to require all psABIS to support not only REL but also RELA. Is that really necessary? In my view, it’s better to maintain the idea that CREL is simply a compact relocation format that works exactly the same way as existing ones, rather than combining two independent changes into one. Maybe ELF shouldn't have had two different relocation table formats in the first place—perhaps REL should never have been invented—but unfortunately, we're stuck with it forever. In my opinion, trying to "fix" it with CREL isn't a wise way to use resources. |
As noted, psABIs do not need to specify whether RELA is used. If CREL relied solely on explicit addends, it wouldn’t impose any restriction. However, supporting CREL static relocations with implicit addends would actually cause more burden to assemblers, binary utilities, and linkers that support both REL/RELA for one single architecture. I reviewed mold, and it seems that for each architecture, only one of REL or RELA is supported ( That said, we might not need to worry about whether AArch32 or i386 users want to switch to CREL. These architectures aren’t typically used in large projects, so the size of build-time relocations is unlikely to be a concern for users. (The i386 is largely relegated to retro-computing these days. I once brought up something about R_386_PC32, and H.J. responded firmly, saying i386 is legacy and best left alone. |
Multi-platform apps tend to use the same command line options to build (that's what Chromium does), so even though CREL's benefit would be limited on ARM32, we would still need to support it on ARM32. Since REL is effectively the standard on ARM32, many tools would assume so, creating obstacles to the smooth adoption of the CREL extension. I don't think all implementations supporting CREL need to support reading implicit addends from sections. Instead, could you require the assembler to write addends to both CREL and the relocated locations for psABIs that use REL-type relocations? It may not be the most elegant solution to the problem, but from a practical standpoint, it would eliminate a major roadblock for many tools. |
Requiring this could complicate assembler design and testing, while also diverging from standard RELA behavior (zero in the operand). Yeah, I strongly believe we shouldn’t burden assemblers with yet another variant involving implicit addends. |
It looks like CREL relocation tables contain addends even for ARM32 and i386. This deviates from their psABIs, where addends are typically stored at relocated places.
For REL-type psABIs, can LLVM store addends at relocated places instead of in CREL tables?
I see two reasons for doing so:
The text was updated successfully, but these errors were encountered: