aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-elf
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2018-06-14 08:59:12 +0930
committerAlan Modra <amodra@gmail.com>2018-06-14 11:32:01 +0930
commit7f923b7fd2a7c55f2337b3b79a2b2081a7bbe22b (patch)
treeaad8e15a309500a29959a760efe168e09026ec33 /ld/testsuite/ld-elf
parentff91d2f0e20fc91b6b101a0b20cbd38ab2d7fb50 (diff)
downloadgdb-7f923b7fd2a7c55f2337b3b79a2b2081a7bbe22b.zip
gdb-7f923b7fd2a7c55f2337b3b79a2b2081a7bbe22b.tar.gz
gdb-7f923b7fd2a7c55f2337b3b79a2b2081a7bbe22b.tar.bz2
ELF dynsyms
Many ELF targets arrange to emit a number of section symbols in .dynsym for use by dynamic relocations. This happens before the dynamic relocations are output, and the need for those symbols determined. In most cases they are not needed. A proper analysis of the need for dynamic section symbols is target specific and tedious, so this patch just excludes them in the obvious case when no dynamic relocations are present. The patch also runs the new pr23161 and pr23162 tests on more targets. bfd/ * elf-bfd.h (struct elf_link_hash_table): Add "dynamic_relocs". * elflink.c (_bfd_elf_init_2_index_sections): Comment fix. (_bfd_elf_add_dynamic_entry): Set "dynamic_relocs". (_bfd_elf_link_renumber_dynsyms): Exclude all section symbols when "dynamic_relocs" is not set. * elfxx-mips.c (count_section_dynsyms): Likewise. ld/ * testsuite/ld-elf/readelf.exp: Delete DUMP and selection of variant ver_def.vd. * testsuite/ld-elf/ver_def-tic6x.vd: Delete. * testsuite/ld-elf/shared.exp: Run most pr23161 and pr23162 tests for linux, nacl and gnu targets. * testsuite/ld-mips-elf/mips-elf.exp: Set base_syms to 1. * testsuite/ld-elf/pr23161a.rd: Don't check reloc type. Allow any order of __bss_start, _edata and _end. * testsuite/ld-elf/pr23161b.rd: Don't check plt and dyn relocs. Allow and order of __bss_start, _edata and _end. * testsuite/ld-elf/pr23162.rd: Fail if __bss_start, _edata or _end relocs are present rather than testing for no relocations. * testsuite/ld-aarch64/gc-plt-relocs.d, * testsuite/ld-aarch64/ifunc-1-local.d, * testsuite/ld-aarch64/ifunc-1.d, * testsuite/ld-aarch64/ifunc-2-local.d, * testsuite/ld-aarch64/ifunc-2.d, * testsuite/ld-aarch64/ifunc-21.d, * testsuite/ld-aarch64/ifunc-3a.d, * testsuite/ld-arm/farcall-mixed-lib-v4t.d, * testsuite/ld-arm/farcall-mixed-lib.d, * testsuite/ld-arm/gc-hidden-1.d, * testsuite/ld-arm/tls-gdesc-got.d, * testsuite/ld-arm/tls-lib-loc.d, * testsuite/ld-arm/tls-longplt-lib.d, * testsuite/ld-arm/tls-thumb1.d, * testsuite/ld-cris/libdso-10.d, * testsuite/ld-cris/libdso-11.d, * testsuite/ld-cris/libdso-13b.d, * testsuite/ld-cris/libdso-14.d, * testsuite/ld-cris/libdso-15.d, * testsuite/ld-cris/pic-gc-72.d, * testsuite/ld-cris/pic-gc-73.d, * testsuite/ld-cris/tls-gc-71.d, * testsuite/ld-mips-elf/mips16-pic-4a.nd, * testsuite/ld-mips-elf/pic-and-nonpic-3a.dd, * testsuite/ld-mips-elf/pie-n32.d, * testsuite/ld-mips-elf/pie-n64.d, * testsuite/ld-mips-elf/pie-o32.d: Update for removed dynamic section symbols.
Diffstat (limited to 'ld/testsuite/ld-elf')
-rw-r--r--ld/testsuite/ld-elf/pr23161a.rd15
-rw-r--r--ld/testsuite/ld-elf/pr23161b.rd15
-rw-r--r--ld/testsuite/ld-elf/pr23162.rd9
-rw-r--r--ld/testsuite/ld-elf/readelf.exp6
-rw-r--r--ld/testsuite/ld-elf/shared.exp32
-rw-r--r--ld/testsuite/ld-elf/ver_def-tic6x.vd20
6 files changed, 39 insertions, 58 deletions
diff --git a/ld/testsuite/ld-elf/pr23161a.rd b/ld/testsuite/ld-elf/pr23161a.rd
index 1a7e563..df89da1 100644
--- a/ld/testsuite/ld-elf/pr23161a.rd
+++ b/ld/testsuite/ld-elf/pr23161a.rd
@@ -1,19 +1,16 @@
Relocation section '\.rel(a|)\.dyn' at offset 0x[0-9a-f]+ contains [0-9]+ entries:
- +Offset +Info +Type +Sym.* Value +Sym.* Name( \+ Addend|)
#...
-[a-f0-9]+ +[0-9a-f]+ +R_.*_GLOB_DAT +[a-f0-9]+ +__bss_start(@@FOO|)( \+ 0|)
+.* _?_(_bss_start|edata|end)(@@FOO|)( \+ 0|)
#...
-[a-f0-9]+ +[0-9a-f]+ +R_.*_GLOB_DAT +[a-f0-9]+ +_edata(@@FOO|)( \+ 0|)
+.* _?_(_bss_start|edata|end)(@@FOO|)( \+ 0|)
#...
-[a-f0-9]+ +[0-9a-f]+ +R_.*_GLOB_DAT +[a-f0-9]+ +_end(@@FOO|)( \+ 0|)
+.* _?_(_bss_start|edata|end)(@@FOO|)( \+ 0|)
#...
Symbol table '\.dynsym' contains [0-9]+ entries:
- +Num: +Value +Size Type +Bind +Vis +Ndx Name
- +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND +
#...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +_edata(@@FOO|)
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +_?_(_bss_start|edata|end)(@@FOO|)
#...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +_end(@@FOO|)
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +_?_(_bss_start|edata|end)(@@FOO|)
#...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +__bss_start(@@FOO|)
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +_?_(_bss_start|edata|end)(@@FOO|)
#...
diff --git a/ld/testsuite/ld-elf/pr23161b.rd b/ld/testsuite/ld-elf/pr23161b.rd
index c8529a5..ba777f7 100644
--- a/ld/testsuite/ld-elf/pr23161b.rd
+++ b/ld/testsuite/ld-elf/pr23161b.rd
@@ -1,14 +1,7 @@
-Relocation section '\.rel(a|)\.plt' at offset 0x[0-9a-f]+ contains 1 entry:
- +Offset +Info +Type +Sym.* Value +Sym.* Name( \+ Addend|)
-[a-f0-9]+ +[0-9a-f]+ +R_.*_JUMP_SLOT +[a-f0-9]+ +foo(@FOO|)( \+ 0|)
-
-Symbol table '\.dynsym' contains [0-9]+ entries:
- +Num: +Value +Size Type +Bind +Vis +Ndx Name
- +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND +
#...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +_edata
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT.* [0-9]+ +_?_(_bss_start|edata|end)
#...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +_end
-#...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +__bss_start
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT.* [0-9]+ +_?_(_bss_start|edata|end)
#...
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT.* [0-9]+ +_?_(_bss_start|edata|end)
+#pass
diff --git a/ld/testsuite/ld-elf/pr23162.rd b/ld/testsuite/ld-elf/pr23162.rd
index 48351ff..be0b2c5 100644
--- a/ld/testsuite/ld-elf/pr23162.rd
+++ b/ld/testsuite/ld-elf/pr23162.rd
@@ -1,5 +1,4 @@
-There are no relocations in this file\.
-
-Symbol table '\.dynsym' contains 1 entry:
- +Num: +Value +Size Type +Bind +Vis +Ndx Name
- +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND +
+#failif
+#...
+[a-f0-9]+ +[0-9a-f]+ +R_[^ ]* +[a-f0-9]+ _?_(_bss_start|edata|end)(@@FOO|)( \+ 0|)
+#...
diff --git a/ld/testsuite/ld-elf/readelf.exp b/ld/testsuite/ld-elf/readelf.exp
index 2e5d4ab..a8762c1 100644
--- a/ld/testsuite/ld-elf/readelf.exp
+++ b/ld/testsuite/ld-elf/readelf.exp
@@ -31,12 +31,10 @@ if ![is_elf_format] {
}
# This target requires a non-default emulation for successful shared
-# library/executable builds, and has dump variances.
+# library/executable builds.
set LFLAGS ""
-set DUMP ""
if [istarget "tic6x-*-*"] {
append LFLAGS " -melf32_tic6x_le"
- set DUMP "-tic6x"
}
if [check_shared_lib_support] {
@@ -47,6 +45,6 @@ if [check_shared_lib_support] {
--hash-style=sysv --version-script=ver_def.ver" \
"" "" \
{ver_def.s} \
- [list [list readelf --version-info ver_def$DUMP.vd]] \
+ [list [list readelf --version-info ver_def.vd]] \
"ver_def"]]
}
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index f357b86..8ec73ef 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -1350,8 +1350,16 @@ proc mix_pic_and_non_pic {xfails cflags ldflags exe} {
mix_pic_and_non_pic [list "arm*-*-*" "aarch64*-*-*"] "" "" "pr19719"
mix_pic_and_non_pic [] "-fPIE" "-pie" "pr19719pie"
-if { ([istarget "i?86-*-*"]
- || [istarget "x86_64-*-*"]) } {
+set AFLAGS_PIE ""
+if { [istarget "i?86-*-*"]
+ || [istarget "x86_64-*-*"] } {
+ set AFLAGS_PIE "-mrelax-relocations=yes"
+}
+
+if { ([istarget "*-*-linux*"]
+ || [istarget "*-*-nacl*"]
+ || [istarget "*-*-gnu*"])
+ && ![istarget "mips*-*-*"] } {
run_ld_link_tests [list \
[list \
"Build libpr23162a.so" \
@@ -1367,9 +1375,9 @@ if { ([istarget "i?86-*-*"]
"Build pr23162a" \
"-pie --no-as-needed tmpdir/libpr23162a.so" \
"" \
- "-mrelax-relocations=yes" \
+ $AFLAGS_PIE \
{ pr23162b.c } \
- {{readelf {--dyn-syms -rW} pr23162.rd}} \
+ {{readelf {-rW} pr23162.rd}} \
"pr23162a" \
"-fPIC -O0" \
] \
@@ -1387,9 +1395,9 @@ if { ([istarget "i?86-*-*"]
"Build pr23162b" \
"-pie --no-as-needed tmpdir/libpr23162b.so" \
"" \
- "-mrelax-relocations=yes" \
+ $AFLAGS_PIE \
{ pr23162b.c } \
- {{readelf {--dyn-syms -rW} pr23162.rd}} \
+ {{readelf {-rW} pr23162.rd}} \
"pr23162b" \
"-fPIC -O0" \
] \
@@ -1407,7 +1415,7 @@ if { ([istarget "i?86-*-*"]
"Build pr23161a" \
"-pie --no-as-needed tmpdir/libpr23161a.so" \
"" \
- "-mrelax-relocations=yes" \
+ $AFLAGS_PIE \
{ pr23161b.c } \
{{readelf {--dyn-syms -rW} pr23161b.rd}} \
"pr23161a" \
@@ -1427,12 +1435,18 @@ if { ([istarget "i?86-*-*"]
"Build pr23161b" \
"-pie --no-as-needed tmpdir/libpr23161b.so" \
"" \
- "-mrelax-relocations=yes" \
+ $AFLAGS_PIE \
{ pr23161b.c } \
{{readelf {--dyn-syms -rW} pr23161b.rd}} \
"pr23161b" \
"-fPIC -O0" \
] \
+ ]
+}
+
+if { [istarget "i?86-*-*"]
+ || [istarget "x86_64-*-*"] } {
+ run_ld_link_tests [list \
[list \
"Build libpr23161c.so" \
"-shared" \
@@ -1447,7 +1461,7 @@ if { ([istarget "i?86-*-*"]
"Build pr23161c" \
"-pie --no-as-needed tmpdir/libpr23161c.so" \
"" \
- "-mrelax-relocations=yes" \
+ $AFLAGS_PIE \
{ pr23161b.c } \
{{readelf {--dyn-syms -rW} pr23161d.rd}} \
"pr23161c" \
diff --git a/ld/testsuite/ld-elf/ver_def-tic6x.vd b/ld/testsuite/ld-elf/ver_def-tic6x.vd
deleted file mode 100644
index 9c3e535..0000000
--- a/ld/testsuite/ld-elf/ver_def-tic6x.vd
+++ /dev/null
@@ -1,20 +0,0 @@
-# Verify correct version information output from `readelf' and that there
-# is no:
-#
-# Version definition past end of section
-#
-# line at the end in particular (hence #pass must not be used here).
-
-# TI C6X special variant covering an extra `.got.plt' dynamic symbol
-# table entry and consequently its `.gnu.version' record made as a
-# result of unusual processing in `elf32_tic6x_link_omit_section_dynsym'.
-
-Version symbols section '\.gnu\.version' contains 5 entries:
- Addr: [0-9a-f]+ +Offset: 0x[0-9a-f]+ +Link: 2 \(\.dynsym\)
- +000: +0 \(\*local\*\) +0 \(\*local\*\) +2 \(ver_foo\) +1 \(\*global\*\) +
- +004: +2 \(ver_foo\) +
-
-Version definition section '\.gnu\.version_d' contains 2 entries:
- +Addr: 0x[0-9a-f]+ +Offset: 0x[0-9a-f]+ +Link: 3 \(\.dynstr\)
- +000000: Rev: 1 +Flags: BASE +Index: 1 +Cnt: 1 +Name: ver_def
- +0x001c: Rev: 1 +Flags: none +Index: 2 +Cnt: 1 +Name: ver_foo