[PATCH] ld/ELF: explicitly place .note.gnu.property
Matthieu Longo
matthieu.longo@arm.com
Fri Aug 15 15:03:31 GMT 2025
On 2025-08-15 13:23, Jan Beulich wrote:
> x86 gas may produce .note.gnu.property by default. Hence the default
> linker script would better also deal with that section, rather than
> causing diagnostics when using --orphan-handling=. As the origin of the
> (seemingly mis-spelled) .note.gnu-property there is unclear, leave that
> in place.
> ---
> Furthermore, the comment ahead of this block of directives has gone
> stale with, afaict, the placement of .note.gnu.build-id near the
> program headers: Orphan note sections are placed adjacent to that one if
> --build-id= is in use. This pretty certainly wasn't intended, so may
> also want/need fixing.
>
> The testsuite adjustment is likely wrong to make, but I can't seem to
> be able to figure what's going on for powerpc64-linux: .eh_frame,
> despite being empty as before, suddenly has SEC_KEEP set (by
> gc_section_callback() as invoked from lang_gc_sections_1(), in
> accordance with the linker script using KEEP() on the section), and
> hence maybe_strip_output() wouldn't remove it anymore. It thus
> unexpectedly appears as constituent of the GNU_PROPERTY segment.
>
> Whether the two Arm64 linker tests that use .note.gnu-property are also
> screwed I can't easily tell. The linker script fragment (back then in
> miscsections.sc) appeared "out of the blue" (7ecf0250f7f0 ["Improve the
> placement of orphan note sections"]), so whether some target uses that
> section name isn't quite easy to tell. Similarly the addition to the two
> testsuite linker scripts appeared with no explanation at all
> (1905f68578fa ["AArch64 BTI/PAC PLT tests: remove RWX permissions on
> segments"]).
>
> --- a/ld/scripttempl/elf.sc
> +++ b/ld/scripttempl/elf.sc
> @@ -735,6 +735,7 @@ cat <<EOF
> .note.build-id : { *(.note.build-id) } ${RELOCATING+${REGION}}
> .note.GNU-stack : { *(.note.GNU-stack) } ${RELOCATING+${REGION}}
> .note.gnu-property : { *(.note.gnu-property) } ${RELOCATING+${REGION}}
> + .note.gnu.property : { *(.note.gnu.property) } ${RELOCATING+${REGION}}
> .note.ABI-tag : { *(.note.ABI-tag) } ${RELOCATING+${REGION}}
> .note.package : { *(.note.package) } ${RELOCATING+${REGION}}
> .note.dlopen : { *(.note.dlopen) } ${RELOCATING+${REGION}}
> --- a/ld/testsuite/ld-elf/elf.exp
> +++ b/ld/testsuite/ld-elf/elf.exp
> @@ -86,6 +86,9 @@ run_ld_link_tests [list \
>
> if [is_elf64 tmpdir/symbol3w.a] {
> set ASFLAGS "$ASFLAGS --defsym ALIGN=3"
> + if { [istarget powerpc*-*-linux*] } {
> + set LDFLAGS "$LDFLAGS --no-ld-generated-unwind-info"
> + }
> set pr23900_1_exp "pr23900-1-64.rd"
> set pr25490_2_exp "pr25490-2-64.rd"
> set pr25490_3_exp "pr25490-3-64.rd"
The two occurrences of ".note.gnu-property" in the linker scripts used
by the tests is a misspelling.
Please feel free to fix it as a part of this patch.
Matthieu
More information about the Binutils
mailing list