aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-mips-elf
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@linux-mips.org>2020-07-29 20:56:41 +0100
committerMaciej W. Rozycki <macro@linux-mips.org>2020-07-29 20:56:41 +0100
commit3f1b17bbf022a34f92f3dc32d742e4901816708e (patch)
tree9d2364860d1573e12b4114557e2832f747ca0d9c /ld/testsuite/ld-mips-elf
parent9811697376b3f1950419ab13b19e2995703b839b (diff)
downloadfsf-binutils-gdb-3f1b17bbf022a34f92f3dc32d742e4901816708e.zip
fsf-binutils-gdb-3f1b17bbf022a34f92f3dc32d742e4901816708e.tar.gz
fsf-binutils-gdb-3f1b17bbf022a34f92f3dc32d742e4901816708e.tar.bz2
MIPS/LD: Set symtab's `sh_info' correctly for IRIX emulations
Correct ELF linker code so as to set the `sh_info' value of the static symbol table section according to the section symbols vs other symbols split where required by the selection of the IRIX compatibility mode for MIPS target. Add a `elf_backend_elfsym_local_is_section' hook for that purpose, returning TRUE if it is only STB_LOCAL/STT_SECTION symbols that are to be considered local for the purpose of this split rather than all STB_LOCAL symbols. We do it already in generic ELF code, and have done it since 1993, with the `elf_backend_sym_is_global' hook, affecting GAS and `objcopy', so these tools produce correct ELF output in the IRIX compatibility mode, however if such output is fed as input to `ld -r', then the linker's output is no longer valid for that mode. The relevant changes to generic ELF code are: commit 062189c6eab72c7ba1bab1cf30fdb27d67a7d668 Author: Ian Lance Taylor <ian@airs.com> Date: Thu Nov 18 17:12:47 1993 +0000 and: commit 6e07e54f1b347f885cc6c021c3fd912c79bdaf55 Author: Ian Lance Taylor <ian@airs.com> Date: Thu Jan 6 20:01:42 1994 +0000 (split across two GIT commits likely due to repository conversion peculiarities). The `elf_backend_sym_is_global' hook however operates on BFD rather than ELF symbols, making it unsuitable for the ELF linker as the linker does not convert any symbol tables processed into the BFD format. Converting the hook to operate on ELF symbols would in principle be possible, but it would still require a considerable rewrite of `bfd_elf_final_link' to adapt to the interface. Therefore, especially given that no new use for the IRIX compatibility mode is expected, minimize changes made to the ELF linker code and just add an entirely new hook, and wire it in the o32 and n32 MIPS backends accordingly; the n64 backend never uses the IRIX compatibility mode. Since we have no coverage here at all add suitable GAS, LD and `objcopy' test cases to the relevant testsuites to keep these tools consistently verified. bfd/ * elf-bfd.h (elf_backend_data): Add `elf_backend_elfsym_local_is_section' member. * elfxx-target.h (elf_backend_elfsym_local_is_section): New macro. (elfNN_bed): Add `elf_backend_elfsym_local_is_section' member. * elflink.c (bfd_elf_final_link): Use it to determine whether set the `.symtab' section's `sh_info' value to the index of the first non-local or non-section symbol. * elf32-mips.c (mips_elf32_elfsym_local_is_section): New function. (elf_backend_elfsym_local_is_section): New macro. * elfn32-mips.c (mips_elf_n32_elfsym_local_is_section): New function. (elf_backend_elfsym_local_is_section): New macro. binutils/ * testsuite/binutils-all/mips/global-local-symtab-o32.d: New test. * testsuite/binutils-all/mips/global-local-symtab-o32t.d: New test. * testsuite/binutils-all/mips/global-local-symtab-n32.d: New test. * testsuite/binutils-all/mips/global-local-symtab-n32t.d: New test. * testsuite/binutils-all/mips/global-local-symtab-n64.d: New test. * testsuite/binutils-all/mips/mips.exp: Run the new tests. gas/ * testsuite/gas/mips/global-local-symtab-o32.d: New test. * testsuite/gas/mips/global-local-symtab-o32t.d: New test. * testsuite/gas/mips/global-local-symtab-n32.d: New test. * testsuite/gas/mips/global-local-symtab-n32t.d: New test. * testsuite/gas/mips/global-local-symtab-n64.d: New test. * testsuite/gas/mips/global-local-symtab.s: New test source. * testsuite/gas/mips/mips.exp: Run the new tests. ld/ * testsuite/ld-mips-elf/global-local-symtab-o32.d: New test. * testsuite/ld-mips-elf/global-local-symtab-o32t.d: New test. * testsuite/ld-mips-elf/global-local-symtab-n32.d: New test. * testsuite/ld-mips-elf/global-local-symtab-n32t.d: New test. * testsuite/ld-mips-elf/global-local-symtab-n64.d: New test. * testsuite/ld-mips-elf/global-local-symtab.ld: New test linker script. * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
Diffstat (limited to 'ld/testsuite/ld-mips-elf')
-rw-r--r--ld/testsuite/ld-mips-elf/global-local-symtab-n32.d6
-rw-r--r--ld/testsuite/ld-mips-elf/global-local-symtab-n32t.d6
-rw-r--r--ld/testsuite/ld-mips-elf/global-local-symtab-n64.d8
-rw-r--r--ld/testsuite/ld-mips-elf/global-local-symtab-o32.d8
-rw-r--r--ld/testsuite/ld-mips-elf/global-local-symtab-o32t.d8
-rw-r--r--ld/testsuite/ld-mips-elf/global-local-symtab.ld8
-rw-r--r--ld/testsuite/ld-mips-elf/mips-elf.exp6
7 files changed, 50 insertions, 0 deletions
diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab-n32.d b/ld/testsuite/ld-mips-elf/global-local-symtab-n32.d
new file mode 100644
index 0000000..619295e
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/global-local-symtab-n32.d
@@ -0,0 +1,6 @@
+#name: MIPS global/local symbol table split (n32)
+#source: ../../../gas/testsuite/gas/mips/global-local-symtab.s
+#as: -mno-pdr
+#ld: -r -T global-local-symtab.ld
+#readelf: -S
+#dump: global-local-symtab-o32.d
diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab-n32t.d b/ld/testsuite/ld-mips-elf/global-local-symtab-n32t.d
new file mode 100644
index 0000000..a87c1d6
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/global-local-symtab-n32t.d
@@ -0,0 +1,6 @@
+#name: MIPS global/local symbol table split (n32)
+#source: ../../../gas/testsuite/gas/mips/global-local-symtab.s
+#as: -mno-pdr
+#ld: -r -T global-local-symtab.ld
+#readelf: -S
+#dump: global-local-symtab-o32t.d
diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab-n64.d b/ld/testsuite/ld-mips-elf/global-local-symtab-n64.d
new file mode 100644
index 0000000..b77625c
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/global-local-symtab-n64.d
@@ -0,0 +1,8 @@
+#name: MIPS global/local symbol table split (n64)
+#source: ../../../gas/testsuite/gas/mips/global-local-symtab.s
+#as: -mno-pdr
+#ld: -r -T global-local-symtab.ld
+#readelf: -SW
+#...
+ *\[ *[0-9]+\] +\.symtab +SYMTAB +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +18 +3 +4 +8
+#pass
diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab-o32.d b/ld/testsuite/ld-mips-elf/global-local-symtab-o32.d
new file mode 100644
index 0000000..c7e1cd2
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/global-local-symtab-o32.d
@@ -0,0 +1,8 @@
+#name: MIPS global/local symbol table split (o32)
+#source: ../../../gas/testsuite/gas/mips/global-local-symtab.s
+#as: -mno-pdr
+#ld: -r -T global-local-symtab.ld
+#readelf: -S
+#...
+ *\[ *[0-9]+\] +\.symtab +SYMTAB +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +10 +3 +2 +4
+#pass
diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab-o32t.d b/ld/testsuite/ld-mips-elf/global-local-symtab-o32t.d
new file mode 100644
index 0000000..612d557
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/global-local-symtab-o32t.d
@@ -0,0 +1,8 @@
+#name: MIPS global/local symbol table split (o32)
+#source: ../../../gas/testsuite/gas/mips/global-local-symtab.s
+#as: -mno-pdr
+#ld: -r -T global-local-symtab.ld
+#readelf: -S
+#...
+ *\[ *[0-9]+\] +\.symtab +SYMTAB +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +10 +3 +4 +4
+#pass
diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab.ld b/ld/testsuite/ld-mips-elf/global-local-symtab.ld
new file mode 100644
index 0000000..57ea4de
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/global-local-symtab.ld
@@ -0,0 +1,8 @@
+SECTIONS
+{
+ .data : { *(.data) }
+ .symtab : { *(.symtab) }
+ .strtab : { *(.strtab) }
+ .shstrtab : { *(.shstrtab) }
+ /DISCARD/ : { *(*) }
+}
diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp
index e98429c..4b257c3 100644
--- a/ld/testsuite/ld-mips-elf/mips-elf.exp
+++ b/ld/testsuite/ld-mips-elf/mips-elf.exp
@@ -248,6 +248,7 @@ if {[istarget *-*-openbsd*] } {
set abi_asflags(o32) -32
set irixemul 1
}
+set tmips [expr $irixemul ? {""} : {"t"}]
if { $linux_gnu } {
run_ld_link_tests [list \
@@ -1657,3 +1658,8 @@ run_dump_test_n64 "pic-reloc-7" [list [list name (microMIPS)] \
[list as "-mmicromips"]]
run_dump_test_o32 "reloc-pcrel-r6"
+
+# Global/local symbol table split tests.
+run_dump_test_o32 "global-local-symtab-o32${tmips}"
+run_dump_test_n32 "global-local-symtab-n32${tmips}"
+run_dump_test_n64 "global-local-symtab-n64"