From ae6a4c3f1d5caeba962d2c1748a8d2b3bebb1007 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sat, 21 Sep 2024 03:44:22 +0800 Subject: [PATCH] ld: Use --no-rosegment to ld for PR ld/22393 tests The commit bf6d7087de0 ld: Move the .note.build-id section to near the start of the memory map moves the .note.build-id section before text sections. When --rosegment and -z separate-code are used together, the .note.gnu.property section is placed between the .note.build-id section and text sections in the same PT_LOAD segment by orphan placement. Pass --no-rosegment to ld for PR ld/22393 tests to avoid linker test failures. PR ld/32190 * testsuite/ld-elf/pr22393-2a.rd: Pass --no-rosegment to ld. * testsuite/ld-elf/pr22393-2b.rd: Likewise. * testsuite/ld-elf/shared.exp: Pass --no-rosegment to ld when building pr22393-2 tests. * testsuite/ld-x86-64/pr22393-3a.rd: Pass --no-rosegment to ld. * testsuite/ld-x86-64/pr22393-3b.rd: Likewise. * testsuite/ld-x86-64/x86-64.exp: Pass --no-rosegment to ld when building pr22393-3 tests. Signed-off-by: H.J. Lu --- ld/testsuite/ld-elf/pr22393-2a.rd | 2 +- ld/testsuite/ld-elf/pr22393-2b.rd | 2 +- ld/testsuite/ld-elf/shared.exp | 10 +++++----- ld/testsuite/ld-x86-64/pr22393-3a.rd | 2 +- ld/testsuite/ld-x86-64/pr22393-3b.rd | 2 +- ld/testsuite/ld-x86-64/x86-64.exp | 10 +++++----- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ld/testsuite/ld-elf/pr22393-2a.rd b/ld/testsuite/ld-elf/pr22393-2a.rd index 0050f1bdad2..a9c5478bb71 100644 --- a/ld/testsuite/ld-elf/pr22393-2a.rd +++ b/ld/testsuite/ld-elf/pr22393-2a.rd @@ -1,5 +1,5 @@ #source: pr22393-1.s -#ld: -shared -z separate-code +#ld: -shared -z separate-code --no-rosegment #readelf: -l --wide #target: *-*-linux-gnu *-*-gnu* *-*-nacl* diff --git a/ld/testsuite/ld-elf/pr22393-2b.rd b/ld/testsuite/ld-elf/pr22393-2b.rd index 0050f1bdad2..a9c5478bb71 100644 --- a/ld/testsuite/ld-elf/pr22393-2b.rd +++ b/ld/testsuite/ld-elf/pr22393-2b.rd @@ -1,5 +1,5 @@ #source: pr22393-1.s -#ld: -shared -z separate-code +#ld: -shared -z separate-code --no-rosegment #readelf: -l --wide #target: *-*-linux-gnu *-*-gnu* *-*-nacl* diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp index 281c3f5d93c..e13e7e0588c 100644 --- a/ld/testsuite/ld-elf/shared.exp +++ b/ld/testsuite/ld-elf/shared.exp @@ -1410,7 +1410,7 @@ if { [istarget *-*-linux*] ] \ [list \ "Build pr22393-2a.so" \ - "-shared -Wl,-z,separate-code" \ + "-shared -Wl,-z,separate-code,--no-rosegment" \ "-fPIC" \ {pr22393-2a.c} \ {{readelf -lW pr22393-2a.rd} \ @@ -1419,7 +1419,7 @@ if { [istarget *-*-linux*] ] \ [list \ "Build pr22393-2a-now.so" \ - "-shared -Wl,-z,separate-code,-z,now" \ + "-shared -Wl,-z,separate-code,-z,now,--no-rosegment" \ "-fPIC" \ {pr22393-2a.c} \ {{readelf -lW pr22393-2a.rd} \ @@ -1428,7 +1428,7 @@ if { [istarget *-*-linux*] ] \ [list \ "Build pr22393-2" \ - "$NOPIE_LDFLAGS -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a.so" \ + "$NOPIE_LDFLAGS -Wl,-z,separate-code,--no-rosegment,--no-as-needed tmpdir/pr22393-2a.so" \ "$NOPIE_CFLAGS" \ {pr22393-2b.c} \ {{readelf -lW pr22393-2a.rd} \ @@ -1437,7 +1437,7 @@ if { [istarget *-*-linux*] ] \ [list \ "Build pr22393-2 (PIE)" \ - "-pie -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a-now.so" \ + "-pie -Wl,-z,separate-code,--no-rosegment,--no-as-needed tmpdir/pr22393-2a-now.so" \ "-fPIE" \ {pr22393-2b.c} \ {{readelf -lW pr22393-2a.rd} \ @@ -1446,7 +1446,7 @@ if { [istarget *-*-linux*] ] \ [list \ "Build pr22393-2 (static)" \ - "-static -Wl,-z,separate-code" \ + "-static -Wl,-z,separate-code,--no-rosegment" \ "" \ {pr22393-2a.c pr22393-2b.c} \ {{readelf -lW pr22393-2a.rd} \ diff --git a/ld/testsuite/ld-x86-64/pr22393-3a.rd b/ld/testsuite/ld-x86-64/pr22393-3a.rd index b17e09b06db..4027ed3443b 100644 --- a/ld/testsuite/ld-x86-64/pr22393-3a.rd +++ b/ld/testsuite/ld-x86-64/pr22393-3a.rd @@ -1,5 +1,5 @@ #source: pr22393-1.s -#ld: -shared -z separate-code +#ld: -shared -z separate-code --no-rosegment #readelf: -l --wide #target: *-*-linux-gnu *-*-gnu* diff --git a/ld/testsuite/ld-x86-64/pr22393-3b.rd b/ld/testsuite/ld-x86-64/pr22393-3b.rd index b17e09b06db..4027ed3443b 100644 --- a/ld/testsuite/ld-x86-64/pr22393-3b.rd +++ b/ld/testsuite/ld-x86-64/pr22393-3b.rd @@ -1,5 +1,5 @@ #source: pr22393-1.s -#ld: -shared -z separate-code +#ld: -shared -z separate-code --no-rosegment #readelf: -l --wide #target: *-*-linux-gnu *-*-gnu* diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index d87ab1f8916..cf78fffe29f 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -1219,7 +1219,7 @@ if { [isnative] && [check_compiler_available] } { ] \ [list \ "Build pr22393-3a.so" \ - "-shared -Wl,-z,separate-code,-z,max-page-size=0x1000" \ + "-shared -Wl,-z,separate-code,-z,max-page-size=0x1000,--no-rosegment" \ "-fPIC -Wa,-mx86-used-note=yes" \ {pr22393-3a.c} \ {{readelf -lW pr22393-3a.rd} \ @@ -1228,7 +1228,7 @@ if { [isnative] && [check_compiler_available] } { ] \ [list \ "Build pr22393-3a-now.so" \ - "-shared -Wl,-z,separate-code,-z,now,-z,max-page-size=0x1000" \ + "-shared -Wl,-z,separate-code,-z,now,-z,max-page-size=0x1000,--no-rosegment" \ "-fPIC -Wa,-mx86-used-note=yes" \ {pr22393-3a.c} \ {{readelf -lW pr22393-3a.rd} \ @@ -1237,7 +1237,7 @@ if { [isnative] && [check_compiler_available] } { ] \ [list \ "Build pr22393-3" \ - "$NOPIE_LDFLAGS -Wl,-z,separate-code,-z,max-page-size=0x1000,--no-as-needed tmpdir/pr22393-3a.so" \ + "$NOPIE_LDFLAGS -Wl,-z,separate-code,-z,max-page-size=0x1000,--no-rosegment,--no-as-needed tmpdir/pr22393-3a.so" \ "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \ {pr22393-3b.c} \ {{readelf -lW pr22393-3a.rd} \ @@ -1246,7 +1246,7 @@ if { [isnative] && [check_compiler_available] } { ] \ [list \ "Build pr22393-3 (PIE)" \ - "-pie -Wl,-z,separate-code,-z,max-page-size=0x1000,--no-as-needed tmpdir/pr22393-3a-now.so" \ + "-pie -Wl,-z,separate-code,-z,max-page-size=0x1000,--no-rosegment,--no-as-needed tmpdir/pr22393-3a-now.so" \ "-fPIE -Wa,-mx86-used-note=yes" \ {pr22393-3b.c} \ {{readelf -lW pr22393-3a.rd} \ @@ -1255,7 +1255,7 @@ if { [isnative] && [check_compiler_available] } { ] \ [list \ "Build pr22393-3 (static)" \ - "-static -Wl,-z,separate-code,-z,max-page-size=0x1000" \ + "-static -Wl,-z,separate-code,-z,max-page-size=0x1000,--no-rosegment" \ "-Wa,-mx86-used-note=yes" \ {pr22393-3a.c pr22393-3b.c} \ {{readelf -lW pr22393-3a.rd} \ -- 2.39.5