Skip to content

[lld/ELF] eh_frame_hdr generation only supports 32-bit values #172777

@aeubanks

Description

@aeubanks

trying the large code model on some binaries, we're running into lld complaining about eh_frame_hdr values not fitting in 32 bits:

$ cat /tmp/a.c
int main() {}
$ cat /tmp/bigtext.lds 
SECTIONS
{
    .ltext :
    {
        *(.ltext)
        *(.ltext.*)

        . = ALIGN(4);

        . = MAX(., 0x100000000);

    }
}
$ clang -fuse-ld=lld -mcmodel=large -T /tmp/bigtext.lds /tmp/a.c -o /tmp/a
ld.lld: error: /tmp/a-bdc8cb.o:(.eh_frame): PC offset is too large: 0xffffffff000002ac

according to https://refspecs.linuxfoundation.org/LSB_1.3.0/gLSB/gLSB/ehframehdr.html, 64 bit values are allowed by specifying DW_EH_PE_sdata8

lld code that assumes 32 bit eh_frame_hdr values:

if (!isInt<32>(pc - va)) {

hdrBuf[1] = DW_EH_PE_pcrel | DW_EH_PE_sdata4; // eh_frame_ptr_enc

would lld be ok with going to 64 bit values in eh_frame_hdr when any value doesn't fit in 32 bits?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions