Skip to content

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

@smeenai

Description

@smeenai

https://github.com/ARM-software/abi-aa/blob/main/sysvabi64/sysvabi64.rst#code-models explicitly states that for the large code model, the max distance from text to GOT has to be under 4 GiB. #288 clarifies that this should also apply to the medium code model. For the small code model, is it reasonable to assume a distance of 2 GiB or less?

I'm asking because the R_AARCH64_GOTPCREL32 relocation introduced in #223 appears to implicitly make this assumption. I want to use the same assumption to encode Clang's indirect references to the personality function and typeinfo objects inside eh_frame sections as sdata4 instead of sdata8 (see my LLVM Discourse post for more details if interested), and I'm wondering how safe that is. Note 2 of https://github.com/ARM-software/abi-aa/blob/main/sysvabi64/sysvabi64.rst#code-models states:

The definition of the text segment includes the shareable PLT, code and read-only data sections.

The GOT isn't technically read-only since relocations need to be applied to it, but if you're using RELRO (which I imagine is the case more often than not) then it's functionally read-only, so it seems useful to make the max text segment size of 2 GiB apply to the GOT as well, at least for the small code model. Are there problems I'm not foreseeing with this?

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