+2020-05-25 H.J. Lu <hongjiu.lu@intel.com>
+
+ * testsuite/ld-elf/eh6.d: Pass -z notext to linker.
+ * testsuite/ld-elf/ehdr_start-shared.d: Likewise.
+ * testsuite/ld-elf/pr19539.d: Likewise.
+ * testsuite/ld-elfvers/vers.exp: Likewise.
+ * testsuite/ld-elfvsb/elfvsb.exp: Likewise.
+ * testsuite/ld-i386/i386.exp: Likewise.
+ * testsuite/ld-i386/nogot1.d: Likewise.
+ * testsuite/ld-i386/pr19539.d: Likewise.
+ * testsuite/ld-i386/pr19636-2a.d: Likewise.
+ * testsuite/ld-i386/pr19636-2b.d: Likewise.
+ * testsuite/ld-i386/pr19636-2c.d: Likewise.
+ * testsuite/ld-i386/pr19636-2d.d: Likewise.
+ * testsuite/ld-i386/pr19636-2e.d: Likewise.
+ * testsuite/ld-i386/pr19636-3d.d: Likewise.
+ * testsuite/ld-i386/pr19636-3e.d: Likewise.
+ * testsuite/ld-i386/pr19939b.d: Likewise.
+ * testsuite/ld-i386/undefweaka.d: Likewise.
+ * testsuite/ld-i386/undefweakb.d: Likewise.
+ * testsuite/ld-shared/shared.exp: Likewise.
+ * testsuite/ld-size/size.exp: Likewise.
+ * testsuite/ld-unique/unique.exp: Likewise.
+ * testsuite/ld-x86-64/pie1.d: Likewise.
+ * testsuite/ld-x86-64/pr19539a.d: Likewise.
+ * testsuite/ld-x86-64/pr19539b.d: Likewise.
+ * testsuite/ld-x86-64/pr19636-1d.d: Likewise.
+ * testsuite/ld-x86-64/pr19636-1e.d: Likewise.
+ * testsuite/ld-x86-64/pr19807-1a.d: Likewise.
+ * testsuite/ld-x86-64/pr19807-1b.d: Likewise.
+ * testsuite/ld-x86-64/pr19807-2b.d: Likewise.
+ * testsuite/ld-x86-64/pr19807-2c.d: Likewise.
+ * testsuite/ld-x86-64/pr19807-2d.d: Likewise.
+ * testsuite/ld-x86-64/pr19807-2e.d: Likewise.
+ * testsuite/ld-x86-64/pr19939b.d: Likewise.
+ * testsuite/ld-x86-64/x86-64.exp: Likewise.
+
2020-05-24 Fangrui Song <maskray@google.com>
PR ld/26018
#source: eh6.s
-#ld: --gc-sections -shared
+#ld: --gc-sections -shared -z notext
#readelf: -wf -rW
#target: x86_64-*-linux-gnu* i?86-*-linux-gnu i?86-*-gnu*
#source: ehdr_start.s
-#ld: -e _start -shared
+#ld: -e _start -shared -z notext
#nm: -n
#target: *-*-linux* *-*-gnu* *-*-nacl* arm*-*-uclinuxfdpiceabi
#xfail: cris*-*-* frv-*-* ![check_shared_lib_support]
#source: start.s
#source: pr19539.s
-#ld: -pie -T pr19539.t
+#ld: -pie -T pr19539.t -z notext
#readelf : --dyn-syms --wide
#target: *-*-linux* *-*-gnu* *-*-solaris* arm*-*-uclinuxfdpiceabi
#xfail: cris*-*-* ![check_pie_support]
global shared
# Make sure that PLT is used since PLT is expected.
global PLT_CFLAGS
- build_binary $shared $PLT_CFLAGS $test $source $libname $other $mapfile $verexp $versymexp $symexp ""
+ build_binary "$shared -z notext" $PLT_CFLAGS $test $source $libname $other $mapfile $verexp $versymexp $symexp ""
}
proc build_vers_lib_pic { test source libname other mapfile verexp versymexp symexp } {
if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
set shared "-bM:SRE -bE:$tmpdir/xcoff.exp"
}
+ if { [is_elf_format] && [check_shared_lib_support] } {
+ append shared " -Wl,-z,notext"
+ }
if {![ld_link $CC $tmpdir/$progname.so "$shared $shldflags $tmpdir/$sh1 $tmpdir/$sh2"]} {
if { [ string match $visibility "hidden_undef" ]
&& [regexp "undefined reference to \`\.?visibility\'" $link_output]
{objdump -sj.got tlsbindesc.sd} {objdump -sj.tdata tlsbindesc.td}}
"tlsbindesc"}
{"TLS -fno-pic -shared"
- "-shared -melf_i386 --no-ld-generated-unwind-info \
+ "-shared -melf_i386 --no-ld-generated-unwind-info -z notext \
-z noseparate-code --hash-style=sysv" ""
"--32" {tlsnopic1.s tlsnopic2.s}
{{readelf -Ssrl tlsnopic.rd} {objdump -drj.text tlsnopic.dd}
{{objdump -sj.debug_foobar tlsg.sd}} "tlsg"}
{"TLS @indntpoff with %eax" "-melf_i386" "" "--32" {tlsindntpoff.s}
{{objdump -drj.text tlsindntpoff.dd}} "tlsindntpoff"}
- {"Reloc section order" "-shared -melf_i386 -z nocombreloc" "" "--32"
+ {"Reloc section order"
+ "-shared -melf_i386 -z nocombreloc -z notext" "" "--32"
{reloc.s} {{objdump -hw reloc.d}} "reloc.so"}
{"Basic --emit-relocs support" "-shared -melf_i386 --emit-relocs" "" "--32"
{emit-relocs.s} {{readelf --relocs emit-relocs.rd}} "emit-relocs.so"}
{"Build pr19827b.so" "-melf_i386 -shared" ""
"--32 -mx86-used-note=yes"
{ pr19827b.S } {} "pr19827b.so"}
- {"Build pr19827" "-melf_i386 -pie tmpdir/pr19827a.o tmpdir/pr19827b.so" ""
+ {"Build pr19827"
+ "-melf_i386 -pie -z notext tmpdir/pr19827a.o tmpdir/pr19827b.so"
+ ""
"--32 -mx86-used-note=yes"
{ dummy.s } {{readelf {-rW} pr19827.rd}} "pr19827"}
- {"Build pr19827.so" "-melf_i386 -shared -Bsymbolic" ""
+ {"Build pr19827.so"
+ "-melf_i386 -shared -Bsymbolic -z notext" ""
"--32 -mx86-used-note=yes"
{ pr19827a.S } {{readelf {-rW} pr19827.rd}} "pr19827.so"}
}
run_cc_link_tests [list \
[list \
"Build pr22001-1.so" \
- "-shared" \
+ "-shared -Wl,-z,notext" \
"-Wa,-mx86-used-note=yes" \
{ pr22001-1a.c } \
{} \
] \
[list \
"Run pr22001-1" \
- "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
+ "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed,-z,notext tmpdir/pr22001-1.so" \
"-Wa,-mx86-used-note=yes" \
{ pr22001-1b.c } \
"pr22001-1" \
] \
[list \
"Run pr21997-1" \
- "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
+ "$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,notext tmpdir/pr21997-1.so" \
"-Wa,-mx86-used-note=yes" \
{ pr21997-1b.c } \
"pr21997-1" \
-#ld: --shared -melf_i386
+#ld: --shared -melf_i386 -z notext
#readelf: -S --wide
#as: --32
#as: --32
-#ld: -pie -m elf_i386 -T pr19539.t
+#ld: -pie -m elf_i386 -T pr19539.t -z notext
#readelf: -r --wide
Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 1 entry:
#source: pr19636-2.s
#as: --32 -mrelax-relocations=no
-#ld: -pie -m elf_i386
+#ld: -pie -m elf_i386 -z notext
#readelf : -r --wide -x .got -x .got.plt --dyn-syms
Relocation section '\.rel\.dyn' at offset [0x0-9a-f]+ contains 1 entry:
#source: pr19636-2.s
#as: --32 -mrelax-relocations=no
-#ld: -pie -E -m elf_i386
+#ld: -pie -E -m elf_i386 -z notext
#readelf : -r --wide -x .got -x .got.plt --dyn-syms
Relocation section '\.rel\.dyn' at offset [0x0-9a-f]+ contains 1 entry:
#source: pr19636-2.s
#as: --32 -mrelax-relocations=no
-#ld: -pie -m elf_i386
+#ld: -pie -m elf_i386 -z notext
#objdump: -dw
#notarget: i?86-*-nacl* x86_64-*-nacl*
#source: pr19636-2.s
#as: --32 -mrelax-relocations=no
-#ld: -shared -m elf_i386
+#ld: -shared -m elf_i386 -z notext
#readelf : -r --wide --dyn-syms
#notarget: i?86-*-nacl* x86_64-*-nacl*
#source: pr19636-2.s
#as: --32 -mrelax-relocations=no
-#ld: -shared -Bsymbolic -m elf_i386
+#ld: -shared -Bsymbolic -m elf_i386 -z notext
#readelf : -r --wide --dyn-syms
#notarget: i?86-*-nacl* x86_64-*-nacl*
#source: pr19636-3.s
#as: --32
-#ld: -shared -m elf_i386
+#ld: -shared -m elf_i386 -z notext
#readelf : -r --wide --dyn-syms
Relocation section '\.rela?\..*' at offset 0x[0-9a-f]+ contains [0-9]+ entr(y|ies):
#source: pr19636-3.s
#as: --32
-#ld: -shared -Bsymbolic -m elf_i386
+#ld: -shared -Bsymbolic -m elf_i386 -z notext
#readelf : -r --wide --dyn-syms
Relocation section '\.rela?\..*' at offset 0x[0-9a-f]+ contains [0-9]+ entr(y|ies):
#source: pr19939.s
#as: --32
-#ld: -melf_i386 -shared
+#ld: -melf_i386 -shared -z notext
#readelf: -d --wide
#...
#source: undefweak.s
#as: --32
-#ld: -shared -melf_i386
+#ld: -shared -melf_i386 -z notext
#readelf: -r --wide
Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 2 entries:
#source: undefweak.s
#as: --32
-#ld: -pie -melf_i386
+#ld: -pie -melf_i386 -z notext
#readelf: -r --wide -x .data.rel.ro
Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 1 entry:
if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
set shared "-bM:SRE -bE:$tmpdir/xcoff.exp"
}
+ if { [is_elf_format] && [check_shared_lib_support] } {
+ append shared " -Wl,-z,notext"
+ }
if {![ld_link $CC $tmpdir/$progname.so "$shared $shldflags $tmpdir/$sh1 $tmpdir/$sh2"]} {
fail "$testname"
return
] \
[list \
"Build size-7" \
- "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libsize-7.so" \
+ "$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,notext tmpdir/libsize-7.so" \
"$NOPIE_CFLAGS" \
{size-7a.c} \
{{readelf -rW size-7.rd}} \
] \
[list \
"Build size-8" \
- "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libsize-8.so" \
+ "$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,notext tmpdir/libsize-8.so" \
"$NOPIE_CFLAGS" \
{size-8a.c} \
{{readelf -rW size-8.rd}} \
] \
[list \
"Run size-8" \
- "$NOPIE_LDFLAGS -Wl,--no-as-needed,--hash-styl=gnu \
+ "$NOPIE_LDFLAGS -Wl,--no-as-needed,--hash-styl=gnu,-z,notext \
tmpdir/libsize-8.so" \
"" \
{size-8a.c} \
}
# Create shared library containing unique symbol with reference.
-if {![ld_link $ld "tmpdir/libunique_shared_ref.so" "-shared tmpdir/unique_shared.o tmpdir/unique_empty.o"] } {
+if {![ld_link $ld "tmpdir/libunique_shared_ref.so" "-shared -z notext tmpdir/unique_shared.o tmpdir/unique_empty.o"] } {
fail "Could not create a shared library containing an unique symbol with reference"
set fails [expr $fails + 1]
}
#name: PIE with undefined symbol
#as: --64
-#ld: -pie -melf_x86_64 --noinhibit-exec
+#ld: -pie -melf_x86_64 --noinhibit-exec -z notext
#readelf: -s --wide
#warning: \A[^\n]*\.o[^\n]*in function `_start':\n[^\n]*: undefined reference to `foo'\Z
#source: pr19539.s
#as: --64
-#ld: -pie -m elf_x86_64 -T pr19539.t
+#ld: -pie -m elf_x86_64 -T pr19539.t -z notext
#readelf: -r --wide
Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entry:
#source: pr19539.s
#as: --x32
-#ld: -pie -m elf32_x86_64 -T pr19539.t
+#ld: -pie -m elf32_x86_64 -T pr19539.t -z notext
#readelf: -r --wide
Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entry:
#source: pr19636-1.s
#as: --64
-#ld: -shared -m elf_x86_64
+#ld: -shared -m elf_x86_64 -z notext
#readelf : -r --wide --dyn-syms
Relocation section '\.rela?\..*' at offset 0x[0-9a-f]+ contains [0-9]+ entr(y|ies):
#source: pr19636-1.s
#as: --64
-#ld: -shared -Bsymbolic -m elf_x86_64
+#ld: -shared -Bsymbolic -m elf_x86_64 -z notext
#readelf : -r --wide --dyn-syms
Relocation section '\.rela?\..*' at offset 0x[0-9a-f]+ contains [0-9]+ entr(y|ies):
#source: pr19807-1.s
#as: --64
-#ld: -pie -melf_x86_64 -z noreloc-overflow
+#ld: -pie -melf_x86_64 -z noreloc-overflow -z notext
#objdump: -dw
.*: +file format .*
#source: pr19807-1.s
#as: --x32
-#ld: -pie -melf32_x86_64 -z noreloc-overflow
+#ld: -pie -melf32_x86_64 -z noreloc-overflow -z notext
#objdump: -dw
.*: +file format .*
#source: pr19807-2.s
#as: --x32
-#ld: -pie -melf32_x86_64
+#ld: -pie -melf32_x86_64 -z notext
#readelf: -r --wide
Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entry:
#source: pr19807-2.s
#as: --x32
-#ld: -pie -melf32_x86_64
+#ld: -pie -melf32_x86_64 -z notext
#objdump: -dw
.*: +file format .*
#source: pr19807-2.s
#as: --64
-#ld: -pie -melf_x86_64 -z noreloc-overflow
+#ld: -pie -melf_x86_64 -z noreloc-overflow -z notext
#readelf: -r --wide
Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entry:
#source: pr19807-2.s
#as: --64
-#ld: -pie -melf_x86_64 -z noreloc-overflow
+#ld: -pie -melf_x86_64 -z noreloc-overflow -z notext
#objdump: -dw
.*: +file format .*
#source: pr19939.s
#as: --64
-#ld: -melf_x86_64 -shared
+#ld: -melf_x86_64 -shared -z notext
#readelf: -d --wide
#...
"--64" { pr19827a.S }}
{"Build pr19827b.so" "-melf_x86_64 -shared" ""
"--64" { pr19827b.S } {} "pr19827b.so"}
- {"Build pr19827" "-melf_x86_64 -pie tmpdir/pr19827a.o tmpdir/pr19827b.so" ""
+ {"Build pr19827"
+ "-melf_x86_64 -pie -z notext tmpdir/pr19827a.o tmpdir/pr19827b.so"
+ ""
"--64" { dummy.s } {{readelf {-rW} pr19827.rd}} "pr19827"}
- {"Build pr19827.so" "-melf_x86_64 -shared -Bsymbolic" ""
+ {"Build pr19827.so"
+ "-melf_x86_64 -shared -Bsymbolic -z notext" ""
"--64" { pr19827a.S } {{readelf {-rW} pr19827.rd}} "pr19827.so"}
{"Build pr19969.so" "-melf_x86_64 -shared" ""
"--64" { pr19969a.S } {} "pr19969.so"}
"--64" { pr20550a.s }}
{"Build pr20550b.so" "-melf_x86_64 -shared" ""
"--64" { pr20550b.s } {} "pr20550b.so"}
- {"Build pr20550" "-melf_x86_64 -pie tmpdir/pr20550a.o tmpdir/pr20550b.so" ""
+ {"Build pr20550"
+ "-melf_x86_64 -pie -z notext tmpdir/pr20550a.o tmpdir/pr20550b.so"
+ ""
"--64" { dummy.s } {} "pr20550"}
}
] \
[list \
"Build pr22001-1a" \
- "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
+ "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed,-z,notext tmpdir/pr22001-1.so" \
"$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
{ pr22001-1b.c } \
{{error_output "pr22001-1a.err"}} \
] \
[list \
"Build pr21997-1a" \
- "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
+ "$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,notext tmpdir/pr21997-1.so" \
"$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
{ pr21997-1b.c } \
{{error_output "pr21997-1a.err"}} \
] \
[list \
"Build pr22791-1" \
- "-pie -Wl,--no-as-needed tmpdir/pr22791-1.so" \
+ "-pie -Wl,--no-as-needed,-z,notext tmpdir/pr22791-1.so" \
"$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
{ pr22791-1b.s } \
{{error_output "pr22791-1.err"}} \
run_ld_link_exec_tests [list \
[list \
"Run pr22001-1b" \
- "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
+ "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed,-z,notext tmpdir/pr22001-1.so" \
"-Wa,-mx86-used-note=yes" \
{ pr22001-1c.c } \
"pr22001-1b" \
] \
[list \
"Run pr21997-1b" \
- "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
+ "$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,notext tmpdir/pr21997-1.so" \
"-Wa,-mx86-used-note=yes" \
{ pr21997-1c.c } \
"pr21997-1b" \
] \
[list \
"Run pr25416-5f (PIE GDesc -> LE -maddress-mode=short)" \
- "-pie tmpdir/pr25416-5b.o tmpdir/pr25416-5d.o" \
+ "-pie -Wl,-z,notext tmpdir/pr25416-5b.o tmpdir/pr25416-5d.o" \
"-Wa,-mx86-used-note=yes" \
{ pr25416-5a.c } \
"pr25416-5f" \
] \
[list \
"Run pr25416-5g (PIE GDesc -> LE -maddress-mode=long)" \
- "-pie tmpdir/pr25416-5c.o tmpdir/pr25416-5d.o" \
+ "-pie -Wl,-z,notext tmpdir/pr25416-5c.o tmpdir/pr25416-5d.o" \
"-Wa,-mx86-used-note=yes" \
{ pr25416-5a.c } \
"pr25416-5g" \