From: Jan Beulich Date: Fri, 12 Dec 2025 07:02:12 +0000 (+0100) Subject: ld/ELF: leave note sections alone for relocatable linking X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8709351936f7308b460b3d417dd1ff2dba4858cd;p=thirdparty%2Fbinutils-gdb.git ld/ELF: leave note sections alone for relocatable linking Commit 023e60ced0c8 ("ld: Move note sections after .rodata section") had a rather undesirable effect for relocatable links (which typically wouldn't use a custom linker script): .note.GNU-stack, which isn't even a proper notes sections (it's SHT_PROGBITS instead, which likely will want correcting independently), would be moved immediately past .text and .rodata (and alike), ahead of any custom notes sections. A later final link, possibly simply combining all .note and .note.* sections, would then find .note.GNU-stack first, resulting in the output section to also become SHT_PROGBITS. This way consumers looking for SHT_NOTE wouldn't find the data they're after. The goal of mentioning some known .note.* in the linker scripts is to avoid orphan section diagnostics. That's not typically of interest for relocatable links, though (people caring about this will want to have custom scripts anyway, much like they may need to if they had any custom .note.* sections). Therefore suppress that part of the linker script for relocatable links. --- diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc index 6d34912e45d..7ecf536f06a 100644 --- a/ld/scripttempl/elf.sc +++ b/ld/scripttempl/elf.sc @@ -727,23 +727,25 @@ cat <