Skip to content

Conversation

@smithp35
Copy link
Contributor

@smithp35 smithp35 commented Aug 7, 2025

Define the expression for R_AARCH64_GOTPCREL32 as GDAT(S)-P+A. This matches the only implementation in clang and lld.

The relocation is used to calculate the offset from the start of the vtable to a GOT entry that contains the address of the RTTI object. As the table entry for the RTTI pointer is at an offset from the start of the vtable the relocation addend contains -offset to cancel out.

Previously in #272 the relocation definition of relocations using GDAT(S+A) were changed to require A to be 0 as lld and GNU ld were implementing GDAT(S+A) as GDAT(S) + A and GDAT(S) + 0 respectively.

As this specific relocation is only implemented in clang and lld it is safe to update the description to match the implementation without affecting portability.

We use GDAT(S)-P+A rather than GDAT(S) + A - P as the latter implies that we are calculating an offset to a different GOT slot to GDAT(S) rather than an offset from P.

Discussion and example: #272

Define the expression for R_AARCH64_GOTPCREL32 as GDAT(S)-P+A.
This matches the only implementation in clang and lld.

The relocation is used to calculate the offset from the start of
the vtable to a GOT entry that contains the address of the RTTI
object. As the table entry for the RTTI pointer is at an offset
from the start of the vtable the relocation addend contains
-offset to cancel out.

Previously in ARM-software#272
the relocation definition of relocations using GDAT(S+A) were
changed to require A to be 0 as lld and GNU ld were implementing
GDAT(S+A) as GDAT(S) + A and GDAT(S) + 0 respectively.

As this specific relocation is only implemented in clang and lld
it is safe to update the description to match the implementation
without affecting portability.

We use GDAT(S)-P+A rather than GDAT(S) + A - P as the latter
implies that we are calculating an offset to a different GOT
slot to GDAT(S) rather than an offset from P.

Discussion and example: ARM-software#272
@smeenai
Copy link
Contributor

smeenai commented Aug 7, 2025

Thanks!

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.

3 participants