Skip to content

Conversation

@smithp35
Copy link
Contributor

The R_AARCH64_GOTPCREL32 relocation, currently used in clang when relative vtables are enabled, has a signed offset so is limited to 2 GiB range. This limits the range of GOT from the vtables to 2GiB.

Document this restriction in the tables for the small and medium code model. Add a note to explain the reason, so that if code generation does not use the relocation the distance to the GOT can be increased.

Fixes #343

The R_AARCH64_GOTPCREL32 relocation, currently used in clang when
relative vtables are enabled, has a signed offset so is limited to
2 GiB range. This limits the range of GOT from the vtables to 2GiB.

Document this restriction in the tables for the small and medium
code model. Add a note to explain the reason, so that if code
generation does not use the relocation the distance to the GOT can
be increased.

Fixes ARM-software#343
Comment on lines 760 to 761
6. The distance to the GOT in the small and medium code model is
limited to 2GiB by the R_AARCH64_GOTPCREL32 relocations.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically in all cases (including large model) the max distance from text to GOT is 2GB if R_AARCH64_GOTPCREL32 is used. It is 4GB otherwise as the basic range of ADRP.

So I think it doesn't really need to be added to the table since there is no difference between the code models.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main reason I did that was the large code model (need to expand the text of the diff to see) says

| large  | 2GiB           | no restriction | max distance from text |
|        |                |                | to GOT < 4 GiB         |

If I take the table entries out, I'll need to take that out too. Will update the PR.

As all code-models have the same restriction. Only use the note
to describe the 2GiB limit.
Copy link
Contributor

@Wilco1 Wilco1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@smithp35 smithp35 merged commit 8e73a1c into ARM-software:main Aug 21, 2025
1 check passed
@smeenai
Copy link
Contributor

smeenai commented Aug 21, 2025

Thank you! Taking out the table entries also addresses #288, right?

@smithp35
Copy link
Contributor Author

Yes, it looks like it does. I'll leave a comment and will close #288

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.

Can the small code model assume the GOT is within 2 GiB of text?

3 participants