Skip to content
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

Medium code model PIC restrictions seem misleading #288

Open
mmalcomson opened this issue Sep 30, 2024 · 2 comments
Open

Medium code model PIC restrictions seem misleading #288

mmalcomson opened this issue Sep 30, 2024 · 2 comments

Comments

@mmalcomson
Copy link
Contributor

The table Code Models in the section https://github.com/ARM-software/abi-aa/blob/main/sysvabi64/sysvabi64.rst#7code-models of the sysvabi64 seems to say that there are no restrictions on the GOT for PIC code.

The entry for the large model in this column mentions that the max distance between the GOT and text must be <4GiB.

From what I could see in the text there doesn't seem to be any mention of the medium code model having some special handling of a GOT being further than 4GiB away from the code access to it.

Is there a reason that I'm missing that this limitation needed for the large model is not needed for the medium model?
Or is the "no additional GOT restrictions" mention overlooking that 4GiB limit on distance between text and GOT?

@smithp35
Copy link
Contributor

This looks like an oversight to me. My understanding is that the restriction "max distance from text to GOT < 4 GiB" is that the linker generated PLT entries use ADRP so the .got.plt needs to be within 4 GiB of the .got. This will remain true for the medium code-model. I'd also expect the .text sections to access the .got via ADRP too, further strengthening the case for putting the same restriction on the medium code model.

@Wilco1
Copy link
Contributor

Wilco1 commented Sep 30, 2024

Yes this restriction applies to all models. However the maximum .text size of 2GB means that the GOT is always within 4GB as long as you don't create a gap between code and data that is larger than 2GB. Note both medium and large code models assume you place data after code and got sections before .data and .bss.

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

No branches or pull requests

3 participants