[PATCH] x86: Drop an empty .relr.dyn from segments given by PHDRS
Jan Beulich
jbeulich@suse.com
Fri Nov 20 13:27:41 GMT 2026
On 14.11.2026 07:49, mintsuki wrote:
> With -z pack-relative-relocs, ld reports this when the output needs no
> relative relocations and the linker script has PHDRS:
>
> ld: a.out: section `.relr.dyn' can't be allocated in segment 0
> LOAD: .text .interp .note.gnu.property .dynsym .dynstr .hash .gnu.hash .relr.dyn .dynamic
>
> _bfd_elf_x86_size_relative_relocs removes the empty .relr.dyn output
> section from the section list, but unlike
> strip_excluded_output_sections, maybe_strip_output in elf64-ppc.c and
> _bfd_elf_final_link, which also remove output sections, it does not
> set SEC_EXCLUDE on it. Without PHDRS that does no harm, as the segment
> map is built from the section list after the removal. A segment map
> from PHDRS is set up by lang_record_phdrs before .relr.dyn is sized,
> though, and elf_modify_segment_map only drops excluded sections from
> it. The removed section stays in its segment, where
> assign_file_positions_for_load_sections reports it, and when it is the
> last section there, the segment is extended to its aligned address.
>
> Set SEC_EXCLUDE on it before removing it, as those do.
>
> bfd/
> * elfxx-x86.c (_bfd_elf_x86_size_relative_relocs): Set SEC_EXCLUDE
> on the empty .relr.dyn output section before removing it.
>
> ld/
> * testsuite/ld-i386/dt-relr-3.d: New file.
> * testsuite/ld-i386/i386.exp: Run dt-relr-3.
> * testsuite/ld-x86-64/dt-relr-3-x32.d: New file.
> * testsuite/ld-x86-64/dt-relr-3.d: Likewise.
> * testsuite/ld-x86-64/dt-relr-3.t: Likewise.
> * testsuite/ld-x86-64/x86-64.exp: Run dt-relr-3 and dt-relr-3-x32.
>
> Generated-By: Claude Opus 5.5 (claude-opus-5-5)
> Signed-off-by: Mintsuki <mintsuki@protonmail.com>
While the patch is okay, I fear it violates [1]. Can you please explicitly
confirm that, despite the patch having been generated by Opus, you hold the
copyright on the patch and you're willing to submit it to the FSF?
Jan
[1] https://sourceware.org/binutils/wiki/LLM_Generated_Content
More information about the Binutils
mailing list