feat(ppc64): REL24 local entry plus REL32/ADDR32/REL64#1999
Merged
Conversation
| RelocationKind::Absolute, | ||
| RelocationSize::ByteSize(4), | ||
| // Can represent either a signed or an unsigned 32-bit value. | ||
| AllowedRange::new(-(2i64.pow(31)), 2i64.pow(32)), |
Member
There was a problem hiding this comment.
Does a negative absolute address make sense? What does it mean?
Contributor
Author
There was a problem hiding this comment.
I merely match the binutils' complain_overflow_bitfield. The R_AARCH64_ABS32 in linker-utils/src/aarch64.rs is also the same. Hence my decision to keep it that way for consistency. Having said that I am more than happy to make it stricter as you suggested.
ELFv2 functions that set up r2 have a separate local entry point. For a direct call that already shares the callee's TOC, branch to that local entry (skipping the global-entry prologue) by adding the callee's st_other local-entry offset to the branch target. Functions with no separate local entry (offset 0) are unaffected.
REL32 (32-bit PC-relative, used pervasively by .eh_frame) and ADDR32 (32-bit absolute). Both are simple 4-byte values.
R_PPC64_REL64 (64-bit PC-relative), an 8-byte value mirroring REL32.
davidlattimore
approved these changes
May 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extends the ppc64le static-relocation support added in #1977 with the
remaining pieces needed for a static link to come out correct on ELFv2:
REL24 local entry. An ELFv2 callee that sets up r2 has a separate
local entry point. A direct call that already shares the callee's TOC
should branch there, skipping the global-entry prologue. The offset is
encoded in the callee's
st_other(STO_PPC64_LOCAL); functions withno separate local entry (offset 0) are unaffected.
REL32 / ADDR32. 32-bit PC-relative and absolute. REL32 is what
.eh_frameis built out of, so without it nothing with exceptiontables links cleanly.
REL64. 64-bit PC-relative — same shape as REL32 but 8 bytes.
A small generic hook
Arch::local_entry_offset(st_other)is added so theREL24 path can ask the target which entry to bias the branch by; default
is 0 (no other architecture cares).