]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
ld/ELF: leave note sections alone for relocatable linking
authorJan Beulich <jbeulich@suse.com>
Fri, 12 Dec 2025 07:02:12 +0000 (08:02 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 12 Dec 2025 07:02:12 +0000 (08:02 +0100)
commit8709351936f7308b460b3d417dd1ff2dba4858cd
tree768b2185e4461ea957fb06a7037d406608c2a6c5
parentd95258ac4b268c09a2ee6d01cec7dcbe62bfc070
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.
ld/scripttempl/elf.sc