global ELFEDIT ELFEDITFLAGS LD LDFLAGS NM NMFLAGS OBJCOPY OBJCOPYFLAGS
global OBJDUMP OBJDUMPFLAGS READELF READELFFLAGS STRIP STRIPFLAGS
global copyfile env runtests srcdir subdir verbose
+ global DT_RELR_LDFLAGS NO_DT_RELR_LDFLAGS
if [string match "*/*" $name] {
set file $name
set LDFLAGS {}
}
+if { ![info exists DT_RELR_LDFLAGS] } then {
+ if { [istarget "i?86-*-linux*"] \
+ || [istarget "x86_64-*-linux*"] \
+ || [istarget "i?86-*-gnu**"] } then {
+ set DT_RELR_LDFLAGS "-z pack-relative-relocs"
+ } else {
+ set DT_RELR_LDFLAGS {}
+ }
+}
+
+if { ![info exists DT_RELR_CC_LDFLAGS] } then {
+ if { [istarget "i?86-*-linux*"] \
+ || [istarget "x86_64-*-linux*"] \
+ || [istarget "i?86-*-gnu**"] } then {
+ set DT_RELR_CC_LDFLAGS "-Wl,-z,pack-relative-relocs"
+ } else {
+ set DT_RELR_CC_LDFLAGS {}
+ }
+}
+
+if { ![info exists NO_DT_RELR_LDFLAGS] } then {
+ if { [istarget "i?86-*-linux*"] \
+ || [istarget "x86_64-*-linux*"] \
+ || [istarget "i?86-*-gnu**"] } then {
+ set NO_DT_RELR_LDFLAGS "-z nopack-relative-relocs"
+ } else {
+ set NO_DT_RELR_LDFLAGS {}
+ }
+}
+
+if { ![info exists NO_DT_RELR_CC_LDFLAGS] } then {
+ if { [istarget "i?86-*-linux*"] \
+ || [istarget "x86_64-*-linux*"] \
+ || [istarget "i?86-*-gnu**"] } then {
+ set NO_DT_RELR_CC_LDFLAGS "-Wl,-z,nopack-relative-relocs"
+ } else {
+ set NO_DT_RELR_CC_LDFLAGS {}
+ }
+}
+
# Set LD_CLASS to "64bit" for a 64-bit *host* linker.
if { ![info exists LD_CLASS] } then {
set REAL_LD [findfile $base_dir/.libs/ld-new .libs/ld-new $LD [transform ld]]
clear_xfail bfin-*-linux*
run_ld_link_tests [list \
[list "-Bsymbolic-functions" \
- "-shared -Bsymbolic-functions" "" "$AFLAGS_PIC" \
+ "-shared -Bsymbolic-functions $NO_DT_RELR_LDFLAGS" \
+ "" "$AFLAGS_PIC" \
{symbolic-func.s} {{readelf {-r --wide} symbolic-func.r}} \
"symbolic-func.so"] \
]
run_ld_link_tests [list \
[list \
"$testname (final shared object)" \
- "-shared -Tdata=0x12340000 tmpdir/i386-export-class-ref-r.o tmpdir/i386-export-class-lib.so" "" \
+ "-shared $NO_DT_RELR_LDFLAGS -Tdata=0x12340000 tmpdir/i386-export-class-ref-r.o tmpdir/i386-export-class-lib.so" "" \
"" \
{ ../ld-elf/export-class-dep.s ../ld-elf/export-class-def.s } \
{ \
{{readelf -Ssrl tlsbindesc.rd} {objdump -drj.text tlsbindesc.dd}
{objdump -sj.got tlsbindesc.sd} {objdump -sj.tdata tlsbindesc.td}}
"tlsbindesc"}
- {"TLS -fno-pic -shared"
- "-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.got tlsnopic.sd}} "libtlsnopic.so"}
{"TLS with global dynamic and descriptors"
"-shared -melf_i386 --no-ld-generated-unwind-info \
-z noseparate-code --hash-style=sysv" ""
run_ld_link_tests $i386tests
+run_ld_link_tests [list \
+ [list \
+ "TLS -fno-pic -shared" \
+ "-shared -melf_i386 --no-ld-generated-unwind-info -z notext \
+ -z noseparate-code --hash-style=sysv $NO_DT_RELR_LDFLAGS" \
+ "" "--32" \
+ {tlsnopic1.s tlsnopic2.s} \
+ {{readelf -Ssrl tlsnopic.rd} \
+ {objdump -drj.text tlsnopic.dd} \
+ {objdump -sj.got tlsnopic.sd}} \
+ "libtlsnopic.so" \
+ ] \
+]
+
run_dump_test "abs"
run_dump_test "pcrel8"
run_dump_test "pcrel16"
#source: ibt-plt-2.s
#as: --32
-#ld: -shared -m elf_i386 -z ibtplt --hash-style=sysv -z noseparate-code
+#ld: -shared -m elf_i386 -z ibtplt --hash-style=sysv -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
#source: ibt-plt-3.s
#as: --32
-#ld: -shared -m elf_i386 -z ibtplt --hash-style=sysv -z noseparate-code
+#ld: -shared -m elf_i386 -z ibtplt --hash-style=sysv -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
#source: ibt-plt-3.s
#as: --32
-#ld: -shared -m elf_i386 -z ibtplt --hash-style=sysv -z noseparate-code
+#ld: -shared -m elf_i386 -z ibtplt --hash-style=sysv -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
#as: --32
-#ld: -shared -melf_i386
+#ld: -shared -melf_i386 $NO_DT_RELR_LDFLAGS
#readelf: -r -s --wide
Relocation section '.rel.dyn' at offset 0x[a-f0-9]+ contains 1 entry:
#source: report-reloc-1.s
#as: --32
-#ld: -pie -melf_i386 -z report-relative-reloc
+#ld: -pie -melf_i386 -z report-relative-reloc $NO_DT_RELR_LDFLAGS
#warning_output: report-reloc-1.l
#readelf: -r --wide
#source: ifunc-2-i386.s
-#ld: -z now -m elf_i386 -shared --hash-style=sysv -z noseparate-code
+#ld: -z now -m elf_i386 -shared --hash-style=sysv -z noseparate-code $NO_DT_RELR_LDFLAGS
#as: --32
#objdump: -dw
#target: x86_64-*-* i?86-*-*
#source: ifunc-2-local-i386.s
-#ld: -z now -m elf_i386 -shared --hash-style=sysv -z noseparate-code
+#ld: -z now -m elf_i386 -shared --hash-style=sysv -z noseparate-code $NO_DT_RELR_LDFLAGS
#as: --32
#objdump: -dw
#target: x86_64-*-* i?86-*-*
#source: ifunc-2-local-x86-64.s
#as: --64
-#ld: -z now -shared -melf_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
+#ld: -z now -shared -melf_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
#target: x86_64-*-*
#source: ifunc-2-x86-64.s
#as: --64
-#ld: -z now -shared -melf_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
+#ld: -z now -shared -melf_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
#target: x86_64-*-*
#source: pr17154-x86.s
#as: --64
-#ld: -z now -shared -melf_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
+#ld: -z now -shared -melf_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
#target: x86_64-*-*
#source: pr17154-x86.s
#as: --64
-#ld: -shared -melf_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
+#ld: -shared -melf_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
#target: x86_64-*-*
#source: bnd-branch-1.s -mx86-used-note=no
#as: --64
-#ld: -z now -shared -melf_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
+#ld: -z now -shared -melf_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
#source: bnd-ifunc-1.s
#as: --64 -madd-bnd-prefix -mx86-used-note=no
-#ld: -z now -shared -melf_x86_64 -z bndplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
+#ld: -z now -shared -melf_x86_64 -z bndplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
#source: bnd-ifunc-2.s
#as: --64 -madd-bnd-prefix -mx86-used-note=no
-#ld: -z now -shared -melf_x86_64 -z bndplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
+#ld: -z now -shared -melf_x86_64 -z bndplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
#as: --64 -madd-bnd-prefix -mx86-used-note=no
-#ld: -shared -melf_x86_64 -z bndplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
+#ld: -shared -melf_x86_64 -z bndplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
#...
#source: bnd-branch-1.s
#as: --64 -mx86-used-note=no
-#ld: -z now -shared -melf_x86_64 -z bndplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
+#ld: -z now -shared -melf_x86_64 -z bndplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
#source: bnd-branch-1.s
#as: --64 -mx86-used-note=no
-#ld: -shared -melf_x86_64 -z bndplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
+#ld: -shared -melf_x86_64 -z bndplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
}
proc x86_64_export_class_test { abi flag emul } {
+ global NO_DT_RELR_LDFLAGS
set testname "x86-64 $abi symbol export class test"
run_ld_link_tests [list \
[list \
"$testname (final shared object)" \
- "$LDFLAGS -shared -Tdata=0x12340000 tmpdir/x86-64-$abi-export-class-ref-r.o tmpdir/x86-64-$abi-export-class-lib.so" "" \
+ "$LDFLAGS $NO_DT_RELR_LDFLAGS -shared -Tdata=0x12340000 tmpdir/x86-64-$abi-export-class-ref-r.o tmpdir/x86-64-$abi-export-class-lib.so" "" \
"$AFLAGS" \
{ ../ld-elf/export-class-dep.s ../ld-elf/export-class-def.s } \
[list \
#source: ibt-plt-2.s
#as: --x32
-#ld: -shared -m elf32_x86_64 -z ibtplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
+#ld: -shared -m elf32_x86_64 -z ibtplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
#source: ibt-plt-2.s
#as: --64 -defsym __64_bit__=1
-#ld: -shared -m elf_x86_64 -z ibtplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
+#ld: -shared -m elf_x86_64 -z ibtplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
#source: ibt-plt-3.s
#as: --x32
-#ld: -shared -m elf32_x86_64 -z ibtplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
+#ld: -shared -m elf32_x86_64 -z ibtplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
#source: ibt-plt-3.s
#as: --64 -defsym __64_bit__=1
-#ld: -shared -m elf_x86_64 -z ibtplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
+#ld: -shared -m elf_x86_64 -z ibtplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
#as: --x32
-#ld: -m elf32_x86_64 -shared --no-ld-generated-unwind-info --hash-style=sysv
+#ld: -m elf32_x86_64 -shared --no-ld-generated-unwind-info --hash-style=sysv $NO_DT_RELR_LDFLAGS
#readelf: -d -S --wide
#target: x86_64-*-linux*
#source: load1.s
#as: --64
-#ld: -shared -melf_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
+#ld: -shared -melf_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
#source: load1.s
#as: --x32
-#ld: -shared -melf32_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
+#ld: -shared -melf32_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
#source: pr13082-2.s
#name: PR ld/13082-2 (b)
#as: --x32
-#ld: -pie -melf32_x86_64
+#ld: -pie -melf32_x86_64 $NO_DT_RELR_LDFLAGS
#readelf: -r --wide
Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entry:
#name: PR ld/14207
#as: --64
-#ld: -melf_x86_64 -shared -z relro -z now --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
+#ld: -melf_x86_64 -shared -z relro -z now --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#readelf: -l --wide
#target: x86_64-*-linux*
#name: PR ld/18176
#as: --64
-#ld: -melf_x86_64 -shared -z relro -T pr18176.t -z max-page-size=0x200000 -z common-page-size=0x1000
+#ld: -melf_x86_64 -shared -z relro -T pr18176.t -z max-page-size=0x200000 -z common-page-size=0x1000 $NO_DT_RELR_LDFLAGS
#readelf: -l --wide
#target: x86_64-*-linux*
#source: pr19162a.s
#source: pr19162b.s
#as: --64
-#ld: -melf_x86_64 -shared -z noseparate-code -z max-page-size=0x200000 -z common-page-size=0x1000 --hash-style=sysv
+#ld: -melf_x86_64 -shared -z noseparate-code -z max-page-size=0x200000 -z common-page-size=0x1000 --hash-style=sysv $NO_DT_RELR_LDFLAGS
#readelf: -l --wide
#target: x86_64-*-linux*
#source: pr19636-2.s
#as: --64 -mrelax-relocations=no
-#ld: -pie -m elf_x86_64 --no-dynamic-linker --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
+#ld: -pie -m elf_x86_64 --no-dynamic-linker --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
#source: pr19636-2.s
#as: --64 -mrelax-relocations=no
-#ld: -pie -m elf_x86_64 --no-dynamic-linker --hash-style=sysv -z dynamic-undefined-weak -z max-page-size=0x200000 -z noseparate-code
+#ld: -pie -m elf_x86_64 --no-dynamic-linker --hash-style=sysv -z dynamic-undefined-weak -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
#warning: -z dynamic-undefined-weak ignored
#source: pr20253-1.s
#as: --64
-#ld: -pie -melf_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
+#ld: -pie -melf_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
#source: pr20253-1.s
#as: --64
-#ld: -shared -melf_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
+#ld: -shared -melf_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
#source: pr20253-1.s
#as: --x32
-#ld: -pie -melf32_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
+#ld: -pie -melf32_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
#source: pr20253-1.s
#as: --x32
-#ld: -shared -melf32_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
+#ld: -shared -melf32_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code $NO_DT_RELR_LDFLAGS
#objdump: -dw
.*: +file format .*
#source: report-reloc-1.s
#as: --x32
-#ld: -pie -melf32_x86_64 -z report-relative-reloc
+#ld: -pie -melf32_x86_64 -z report-relative-reloc $NO_DT_RELR_LDFLAGS
#warning_output: report-reloc-1.l
#readelf: -r --wide
#source: report-reloc-1.s
#as: --64
-#ld: -pie -melf_x86_64 -z report-relative-reloc
+#ld: -pie -melf_x86_64 -z report-relative-reloc $NO_DT_RELR_LDFLAGS
#warning_output: report-reloc-1.l
#readelf: -r --wide
{"basic PLT generation"
"-melf_x86_64 tmpdir/libpltlib.so" "" "--64" {plt.s}
{{objdump -drj.plt plt.pd}} "plt"}
- {"TLS -fpic -shared transitions"
- "-shared -melf_x86_64 --no-ld-generated-unwind-info \
- -z noseparate-code -z max-page-size=0x200000 --hash-style=sysv" ""
- "--64" {tlspic1.s tlspic2.s}
- {{readelf -WSsrl tlspic.rd} {objdump -drj.text\ -Mintel64 tlspic.dd}
- {objdump -sj.got tlspic.sd} {objdump -sj.tdata tlspic.td}}
- "libtlspic.so"}
- {"TLS -fpic -shared transitions with r15 as GOT base"
- "-shared -melf_x86_64 --no-ld-generated-unwind-info \
- -z noseparate-code -z max-page-size=0x200000 --hash-style=sysv" ""
- "--64 -mrelax-relocations=yes"
- {tlspic3.s tlspic2.s}
- {{readelf -WSsrl tlspic2.rd} {objdump -drj.text\ -Mintel64 tlspic2.dd}
- {objdump -sj.got tlspic2.sd} {objdump -sj.tdata tlspic2.td}}
- "libtlspic2.so"}
- {"TLS descriptor -fpic -shared transitions"
- "-shared -melf_x86_64 --no-ld-generated-unwind-info \
- -z noseparate-code -z max-page-size=0x200000 --hash-style=sysv" ""
- "--64" {tlsdesc.s tlspic2.s}
- {{readelf -WSsrld tlsdesc.rd} {objdump -drj.text tlsdesc.dd}
- {objdump "-s -j.got -j.got.plt" tlsdesc.sd} {objdump -sj.tdata tlsdesc.td}
- {objdump -drj.plt tlsdesc.pd}} "libtlsdesc.so"}
{"Helper shared library" "-shared -melf_x86_64" ""
"--64" {tlslib.s} {} "libtlslib.so"}
{"TLS -fpic and -fno-pic exec transitions"
run_ld_link_tests $x86_64tests
+run_ld_link_tests [list \
+ [list \
+ "TLS -fpic -shared transitions" \
+ "-shared -melf_x86_64 --no-ld-generated-unwind-info \
+ -z noseparate-code -z max-page-size=0x200000 --hash-style=sysv \
+ $NO_DT_RELR_LDFLAGS" \
+ "" "--64" \
+ {tlspic1.s tlspic2.s} \
+ {{readelf -WSsrl tlspic.rd} \
+ {objdump {-drj.text -Mintel64} tlspic.dd} \
+ {objdump -sj.got tlspic.sd} \
+ {objdump -sj.tdata tlspic.td}} \
+ "libtlspic.so" \
+ ] \
+ [list \
+ "TLS -fpic -shared transitions with r15 as GOT base" \
+ "-shared -melf_x86_64 --no-ld-generated-unwind-info \
+ -z noseparate-code -z max-page-size=0x200000 --hash-style=sysv \
+ $NO_DT_RELR_LDFLAGS" \
+ "" "--64 -mrelax-relocations=yes" \
+ {tlspic3.s tlspic2.s} \
+ {{readelf -WSsrl tlspic2.rd} \
+ {objdump {-drj.text -Mintel64} tlspic2.dd} \
+ {objdump -sj.got tlspic2.sd} \
+ {objdump -sj.tdata tlspic2.td}} \
+ "libtlspic2.so" \
+ ] \
+ [list \
+ "TLS descriptor -fpic -shared transitions" \
+ "-shared -melf_x86_64 --no-ld-generated-unwind-info \
+ -z noseparate-code -z max-page-size=0x200000 --hash-style=sysv \
+ $NO_DT_RELR_LDFLAGS" \
+ "" "--64" \
+ {tlsdesc.s tlspic2.s} \
+ {{readelf -WSsrld tlsdesc.rd} \
+ {objdump -drj.text tlsdesc.dd} \
+ {objdump {-s -j.got -j.got.plt} tlsdesc.sd} \
+ {objdump -sj.tdata tlsdesc.td} \
+ {objdump -drj.plt tlsdesc.pd}} \
+ "libtlsdesc.so" \
+ ] \
+]
+
set test_name "Mixed x86_64 and i386 input test 1"
set test mixed1
if { ![ld_link $ld tmpdir/$test "-m$emul tmpdir/${test}a.o tmpdir/${test}b.o"] } {