[PATCH v2] x86-64: Estimate output section layout before sizing dynamic sections
Jan Beulich
jbeulich@suse.com
Mon Feb 3 07:24:04 GMT 2025
On 03.02.2025 02:50, H.J. Lu 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 ldelf_before_allocation to take
> a function pointer argument and run it before sizing dynamic sections
> if it isn't NULL. Update the x86-64 ELF linker to estimate output
> section layout before sizing dynamic sections and use the preliminary
> section layout info to skip the GOTPCREL relocation conversion if the
> converted relocation overflows.
>
> NB: We can't estimate the __ehdr_start value before allocation since it
> is computed in assign_file_positions_for_load_sections during the final
> link.
Isn't this aspect alone already sufficient indication that this is the
wrong approach to the issue at hand (as indicated before)?
Jan
More information about the Binutils
mailing list