[PATCH v3] x86-64: Estimate output section layout before sizing dynamic sections

H.J. Lu hjl.tools@gmail.com
Thu Feb 6 22:01:07 GMT 2025


On Tue, Feb 4, 2025 at 1:19 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> When sizing dynamic sections, elf_x86_64_scan_relocs converts GOTPCREL
> relocations to R_X86_64_PC32, R_X86_64_32S or R_X86_64_32 for local
> symbols.  But at that time, since the output section layout is unknown,
> the local symbol values can't be determined.  Later linker issues an
> error if the converted relocation overflows when resolving relocations
> against these local symbols.  Update the x86-64 ELF linker to estimate
> output section layout before sizing dynamic sections and use the
> preliminary output section layout info to skip the GOTPCREL relocation
> conversion if the converted relocation overflows.
>
> bfd/
>
> PR ld/32591
> * elf64-x86-64.c (elf_x86_64_convert_load_reloc): Add an input
> section argument.  Use the lowest-addressed section to estimate
> the __ehdr_start symbol value.  Don't convert relocation if the
> converted relocation will overflow.
>
> ld/
>
> PR ld/32591
> * emultempl/elf-x86.em (elf_x86_64_before_allocation):
> New.  Defined for x86-64.
> (LDEMUL_BEFORE_ALLOCATION): Likewise.
> * testsuite/ld-x86-64/pr19609-2a.d: Don't fail.
> * testsuite/ld-x86-64/pr19609-2b.d: Likewise.
> * testsuite/ld-x86-64/pr19609-4a.d: Likewise.
> * testsuite/ld-x86-64/pr19609-5d.d: Likewise.
> * testsuite/ld-x86-64/pr19609-7a.d: Likewise.
> * testsuite/ld-x86-64/pr19609-7c.d: Likewise.
> * testsuite/ld-x86-64/pr32591-1.s: New file.
> * testsuite/ld-x86-64/pr32591-1a-x32.d: Likewise.
> * testsuite/ld-x86-64/pr32591-1a.d: Likewise.
> * testsuite/ld-x86-64/pr32591-1a.t: Likewise.
> * testsuite/ld-x86-64/pr32591-1b-x32.d: Likewise.
> * testsuite/ld-x86-64/pr32591-1b.d: Likewise.
> * testsuite/ld-x86-64/pr32591-1b.t: Likewise.
> * testsuite/ld-x86-64/pr32591-1c-x32.d: Likewise.
> * testsuite/ld-x86-64/pr32591-1c.d: Likewise.
> * testsuite/ld-x86-64/pr32591-1c.t: Likewise.
> * testsuite/ld-x86-64/pr32591-1d-x32.d: Likewise.
> * testsuite/ld-x86-64/pr32591-1d.d: Likewise.
> * testsuite/ld-x86-64/pr32591-1d.t: Likewise.
> * testsuite/ld-x86-64/pr32591-2.s: Likewise.
> * testsuite/ld-x86-64/pr32591-2-x32.d: Likewise.
> * testsuite/ld-x86-64/pr32591-2.d: Likewise.
> * testsuite/ld-x86-64/pr32591-2.t: Likewise.
> * testsuite/ld-x86-64/pr32591-3.s: Likewise.
> * testsuite/ld-x86-64/pr32591-3-x32.d: Likewise.
> * testsuite/ld-x86-64/pr32591-3.d: Likewise.
> * testsuite/ld-x86-64/pr32591-3.t: Likewise.
> * testsuite/ld-x86-64/pr32591-4.s: Likewise.
> * testsuite/ld-x86-64/pr32591-4-x32.d: Likewise.
> * testsuite/ld-x86-64/pr32591-4.d: Likewise.
> * testsuite/ld-x86-64/x86-64.exp: Run PR ld/32591 tests.
>
> --
> H.J.

I am checking it in.

-- 
H.J.


More information about the Binutils mailing list