Skip to content

Medium code model PIC restrictions seem misleading #288

Closed

Description

@mmalcomson

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?

Activity

  1. smithp35 commented on Sep 30, 2024

    @smithp35
    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.

  2. Wilco1 commented on Sep 30, 2024

    @Wilco1
    Contributor

    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.

  3. smithp35 commented on Aug 21, 2025

    @smithp35
    Contributor

    We've removed the GOT distance from the tables in #345 this addresses this ticket too, so we can close it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions