[PATCH 2/2] ld: fold .note.GNU-stack during relocatable linking

John David Anglin dave.anglin@bell.net
Thu Jan 29 14:41:50 GMT 2026


Based on ld/configure.tgt, I believe the hppa xfails should be hppa*-*-*elf*
and hppa*-*-lites*.

Dave

On 2026-01-29 2:18 a.m., Jan Beulich wrote:
> PR ld/33851
> 
> While in all binutils components we've switched the section to be of
> SHT_NOTE type, assembly sources as well as other tools may still generate
> SHT_PROGBITS instances. When doing relocatable links, input sections with
> differing types would cause multiple output sections to be created, which
> some tools choke upon. Fold incoming sections into a single one, the type
> of which will be the type of the first section encountered.
> ---
> cr16 and crx have empty *.xr (explicitly forced so), while hppa-elf uses
> extremely shrunk down scripts. XFAIL the negative tests for all of those,
> for the time being. I wonder if all of them wouldn't better use elf.sc
> for -r and -Ur script generation.
> 
> --- a/ld/scripttempl/misc-sections.sc
> +++ b/ld/scripttempl/misc-sections.sc
> @@ -31,3 +31,7 @@ cat <<EOF
>    .gnu.build.attributes : { *(.gnu.build.attributes${RELOCATING+ .gnu.build.attributes.*}) }
>  
>  EOF
> +
> +test -z "${CONSTRUCTING}" && cat <<EOF
> +  .note.GNU-stack : { *(.note.GNU-stack) }
> +EOF
> --- /dev/null
> +++ b/ld/testsuite/ld-elf/note3.s
> @@ -0,0 +1 @@
> +	.section .note.GNU-stack, "", %progbits
> --- /dev/null
> +++ b/ld/testsuite/ld-elf/note3a.d
> @@ -0,0 +1,10 @@
> +#name: .note.GNU-stack ld -r SHT_NOTE + SHT_PROGBITS (positive)
> +#source: empty.s --noexecstack
> +#source: note3.s
> +#as: --generate-missing-build-notes=no
> +#ld: -r
> +#readelf: -SW
> +
> +#...
> + *\[[ 0-9]+\] \.note\.GNU-stack +NOTE .*
> +#pass
> --- /dev/null
> +++ b/ld/testsuite/ld-elf/note3b.d
> @@ -0,0 +1,14 @@
> +#name: .note.GNU-stack ld -r SHT_NOTE + SHT_PROGBITS (negative)
> +#source: empty.s --noexecstack
> +#source: note3.s
> +#as: --generate-missing-build-notes=no
> +#ld: -r
> +#readelf: -SW
> +#failif
> +# cr16 and crx force entirely empty scripts for -r, while hppa-elf re-uses
> +# a significantly shrunk down script also for -r.
> +#xfail: cr16-*-elf* crx-*-elf* hppa-*-elf*
> +
> +#...
> + *\[[ 0-9]+\] \.note\.GNU-stack +PROGBITS .*
> +#pass
> --- /dev/null
> +++ b/ld/testsuite/ld-elf/note3c.d
> @@ -0,0 +1,10 @@
> +#name: .note.GNU-stack ld -r SHT_PROGBITS + SHT_NOTE (positive)
> +#source: note3.s
> +#source: empty.s --noexecstack
> +#as: --generate-missing-build-notes=no
> +#ld: -r
> +#readelf: -SW
> +
> +#...
> + *\[[ 0-9]+\] \.note\.GNU-stack +PROGBITS .*
> +#pass
> --- /dev/null
> +++ b/ld/testsuite/ld-elf/note3d.d
> @@ -0,0 +1,14 @@
> +#name: .note.GNU-stack ld -r SHT_PROGBITS + SHT_NOTE (negative)
> +#source: note3.s
> +#source: empty.s --noexecstack
> +#as: --generate-missing-build-notes=no
> +#ld: -r
> +#readelf: -SW
> +#failif
> +# cr16 and crx force entirely empty scripts for -r, while hppa-elf re-uses
> +# a significantly shrunk down script also for -r.
> +#xfail: cr16-*-elf* crx-*-elf* hppa-*-elf*
> +
> +#...
> + *\[[ 0-9]+\] \.note\.GNU-stack +NOTE .*
> +#pass
> 


-- 
John David Anglin  dave.anglin@bell.net


More information about the Binutils mailing list