From: Maciej W. Rozycki Date: Wed, 29 Jul 2020 19:56:41 +0000 (+0100) Subject: MIPS: Make the IRIX naming of local section symbols consistent X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c77cb2a09c5532ad6d3b94fccca93eb02f7cc0d8;p=binutils-gdb.git MIPS: Make the IRIX naming of local section symbols consistent Make the MIPS/IRIX naming of local section symbols consistent between files produced by generic ELF code and ELF linker code, complementing commit 174fd7f95561 ("New bfd elf hook: force naming of local section symbols"), . Local section symbols have no names in the standard ELF gABI, however the lack of a name causes problems with IRIX's MIPSpro linker. To work around the issue we give them names, however we do that in generic ELF code only, based on what the `elf_backend_name_local_section_symbols' hook returns if present. That makes objects created by GAS or `objdump' work correctly, however not ones created by `ld -r'. That would not normally cause issues with IRIX systems using GAS and `objdump' only with the MIPSpro linker, however if GNU LD was used for whatever reason in producing objects later fed to IRIX's MIPSpro linker, then things would break. Modify ELF linker code accordingly then, using the same hook. Adjust the `ld-elf/64ksec-r' test accordingly so that it also accepts a section symbol with a name. Also modify the hook itself so that only actual ET_REL objects have names assigned to local section symbols. Other kinds of ELF files are not ever supposed to be relocated with the MIPSpro linker, so we can afford producing more standard output. Add suitable GAS, LD and `objcopy' test cases to the relevant testsuites to keep these tools consistently verified. This change also fixes: FAIL: objcopy executable (pr25662) across MIPS targets using the IRIX compatibility mode. bfd/ * elflink.c (bfd_elf_final_link): Give local symbols a name if so requested. * elfxx-mips.c (_bfd_mips_elf_name_local_section_symbols): Only return TRUE if making ET_REL output. binutils/ * testsuite/binutils-all/mips/global-local-symtab-sort-o32.d: New test. * testsuite/binutils-all/mips/global-local-symtab-sort-o32t.d: New test. * testsuite/binutils-all/mips/global-local-symtab-sort-n32.d: New test. * testsuite/binutils-all/mips/global-local-symtab-sort-n32t.d: New test. * testsuite/binutils-all/mips/global-local-symtab-sort-n64.d: New test. * testsuite/binutils-all/mips/global-local-symtab-sort-n64t.d: New test. * testsuite/binutils-all/mips/global-local-symtab-final-o32.d: New test. * testsuite/binutils-all/mips/global-local-symtab-final-n32.d: New test. * testsuite/binutils-all/mips/global-local-symtab-final-n64.d: New test. * testsuite/binutils-all/mips/mips.exp: Run the new tests. gas/ * testsuite/gas/mips/global-local-symtab-sort-o32.d: New test. * testsuite/gas/mips/global-local-symtab-sort-o32t.d: New test. * testsuite/gas/mips/global-local-symtab-sort-n32.d: New test. * testsuite/gas/mips/global-local-symtab-sort-n32t.d: New test. * testsuite/gas/mips/global-local-symtab-sort-n64.d: New test. * testsuite/gas/mips/global-local-symtab-sort-n64t.d: New test. * testsuite/gas/mips/mips.exp: Run the new tests. ld/ * testsuite/ld-elf/sec64k.exp: Also accept a section symbol with a name. * testsuite/ld-mips-elf/global-local-symtab-sort-o32.d: New test. * testsuite/ld-mips-elf/global-local-symtab-sort-o32t.d: New test. * testsuite/ld-mips-elf/global-local-symtab-sort-n32.d: New test. * testsuite/ld-mips-elf/global-local-symtab-sort-n32t.d: New test. * testsuite/ld-mips-elf/global-local-symtab-sort-n64.d: New test. * testsuite/ld-mips-elf/global-local-symtab-sort-n64t.d: New test. * testsuite/ld-mips-elf/global-local-symtab-final-o32.d: New test. * testsuite/ld-mips-elf/global-local-symtab-final-n32.d: New test. * testsuite/ld-mips-elf/global-local-symtab-final-n64.d: New test. * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 63499ef6aef..1ac0bab3970 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2020-07-29 Maciej W. Rozycki + + * elflink.c (bfd_elf_final_link): Give local symbols a name if + so requested. + * elfxx-mips.c (_bfd_mips_elf_name_local_section_symbols): Only + return TRUE if making ET_REL output. + 2020-07-29 Maciej W. Rozycki * elf-bfd.h (elf_backend_data): Add diff --git a/bfd/elflink.c b/bfd/elflink.c index 32a2d6d7c19..ae5ff50ed62 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -12268,6 +12268,9 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) if (info->strip != strip_all || emit_relocs) { + bfd_boolean name_local_sections; + const char *name; + file_ptr off = elf_next_file_pos (abfd); _bfd_elf_assign_file_position_for_section (symtab_hdr, off, TRUE); @@ -12290,10 +12293,15 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) /* Output a symbol for each section. We output these even if we are discarding local symbols, since they are used for relocs. These - symbols have no names. We store the index of each one in the - index field of the section, so that we can find it again when + symbols usually have no names. We store the index of each one in + the index field of the section, so that we can find it again when outputting relocs. */ + name_local_sections + = (bed->elf_backend_name_local_section_symbols + && bed->elf_backend_name_local_section_symbols (abfd)); + + name = NULL; elfsym.st_size = 0; elfsym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION); elfsym.st_other = 0; @@ -12308,7 +12316,9 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) elfsym.st_shndx = i; if (!bfd_link_relocatable (info)) elfsym.st_value = o->vma; - if (elf_link_output_symstrtab (&flinfo, NULL, &elfsym, o, + if (name_local_sections) + name = o->name; + if (elf_link_output_symstrtab (&flinfo, name, &elfsym, o, NULL) != 1) goto error_return; } diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 160febec94c..7bf425783bb 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -7262,7 +7262,7 @@ _bfd_mips_elf_eh_frame_address_size (bfd *abfd, const asection *sec) bfd_boolean _bfd_mips_elf_name_local_section_symbols (bfd *abfd) { - return SGI_COMPAT (abfd); + return elf_elfheader (abfd)->e_type == ET_REL && SGI_COMPAT (abfd); } /* Work over a section just before writing it out. This routine is diff --git a/binutils/ChangeLog b/binutils/ChangeLog index a5efafc0fea..4e66a1361fc 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,25 @@ +2020-07-29 Maciej W. Rozycki + + * testsuite/binutils-all/mips/global-local-symtab-sort-o32.d: + New test. + * testsuite/binutils-all/mips/global-local-symtab-sort-o32t.d: + New test. + * testsuite/binutils-all/mips/global-local-symtab-sort-n32.d: + New test. + * testsuite/binutils-all/mips/global-local-symtab-sort-n32t.d: + New test. + * testsuite/binutils-all/mips/global-local-symtab-sort-n64.d: + New test. + * testsuite/binutils-all/mips/global-local-symtab-sort-n64t.d: + New test. + * testsuite/binutils-all/mips/global-local-symtab-final-o32.d: + New test. + * testsuite/binutils-all/mips/global-local-symtab-final-n32.d: + New test. + * testsuite/binutils-all/mips/global-local-symtab-final-n64.d: + New test. + * testsuite/binutils-all/mips/mips.exp: Run the new tests. + 2020-07-29 Maciej W. Rozycki * testsuite/binutils-all/mips/global-local-symtab-o32.d: New diff --git a/binutils/testsuite/binutils-all/mips/global-local-symtab-final-n32.d b/binutils/testsuite/binutils-all/mips/global-local-symtab-final-n32.d new file mode 100644 index 00000000000..0623ddc7b2b --- /dev/null +++ b/binutils/testsuite/binutils-all/mips/global-local-symtab-final-n32.d @@ -0,0 +1,9 @@ +#PROG: objcopy +#DUMPPROG: readelf +#name: MIPS symbol table sort and section symbol names (fully linked) (n32) +#as: -n32 -mno-pdr -mips3 +#ld: -e 0 -T ../../../../ld/testsuite/ld-mips-elf/global-local-symtab.ld +#objcopy: -j .data -j .symtab -j .strtab -j .shstrtab +#readelf: -s +#source: ../../../../gas/testsuite/gas/mips/global-local-symtab.s +#dump: global-local-symtab-sort-o32t.d diff --git a/binutils/testsuite/binutils-all/mips/global-local-symtab-final-n64.d b/binutils/testsuite/binutils-all/mips/global-local-symtab-final-n64.d new file mode 100644 index 00000000000..eaee0081fb9 --- /dev/null +++ b/binutils/testsuite/binutils-all/mips/global-local-symtab-final-n64.d @@ -0,0 +1,9 @@ +#PROG: objcopy +#DUMPPROG: readelf +#name: MIPS symbol table sort and section symbol names (fully linked) (n64) +#as: -64 -mno-pdr -mips3 +#ld: -e 0 -T ../../../../ld/testsuite/ld-mips-elf/global-local-symtab.ld +#objcopy: -j .data -j .symtab -j .strtab -j .shstrtab +#readelf: -s +#source: ../../../../gas/testsuite/gas/mips/global-local-symtab.s +#dump: global-local-symtab-sort-n64t.d diff --git a/binutils/testsuite/binutils-all/mips/global-local-symtab-final-o32.d b/binutils/testsuite/binutils-all/mips/global-local-symtab-final-o32.d new file mode 100644 index 00000000000..580acb0ce86 --- /dev/null +++ b/binutils/testsuite/binutils-all/mips/global-local-symtab-final-o32.d @@ -0,0 +1,9 @@ +#PROG: objcopy +#DUMPPROG: readelf +#name: MIPS symbol table sort and section symbol names (fully linked) (o32) +#as: -32 -mno-pdr +#ld: -e 0 -T ../../../../ld/testsuite/ld-mips-elf/global-local-symtab.ld +#objcopy: -j .data -j .symtab -j .strtab -j .shstrtab +#readelf: -s +#source: ../../../../gas/testsuite/gas/mips/global-local-symtab.s +#dump: global-local-symtab-sort-o32t.d diff --git a/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n32.d b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n32.d new file mode 100644 index 00000000000..818d7919d44 --- /dev/null +++ b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n32.d @@ -0,0 +1,8 @@ +#PROG: objcopy +#DUMPPROG: readelf +#name: MIPS symbol table sort and section symbol names (relocatable) (n32) +#as: -n32 -mno-pdr -mips3 +#objcopy: -j .data -j .symtab -j .strtab -j .shstrtab +#readelf: -s +#source: ../../../../gas/testsuite/gas/mips/global-local-symtab.s +#dump: global-local-symtab-sort-o32.d diff --git a/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n32t.d b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n32t.d new file mode 100644 index 00000000000..a6f6548c778 --- /dev/null +++ b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n32t.d @@ -0,0 +1,8 @@ +#PROG: objcopy +#DUMPPROG: readelf +#name: MIPS symbol table sort and section symbol names (relocatable) (n32) +#as: -n32 -mno-pdr -mips3 +#objcopy: -j .data -j .symtab -j .strtab -j .shstrtab +#readelf: -s +#source: ../../../../gas/testsuite/gas/mips/global-local-symtab.s +#dump: global-local-symtab-sort-o32t.d diff --git a/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n64.d b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n64.d new file mode 100644 index 00000000000..dcb5c23c7d5 --- /dev/null +++ b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n64.d @@ -0,0 +1,14 @@ +#PROG: objcopy +#DUMPPROG: readelf +#name: MIPS symbol table sort and section symbol names (relocatable) (n64) +#as: -64 -mno-pdr -mips3 +#objcopy: -j .data -j .symtab -j .strtab -j .shstrtab +#readelf: -s +#source: ../../../../gas/testsuite/gas/mips/global-local-symtab.s + +Symbol table '\.symtab' contains 4 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND + 1: 0000000000000000 0 SECTION LOCAL DEFAULT 1 \.data + 2: 0000000000000004 4 OBJECT LOCAL DEFAULT 1 bar + 3: 0000000000000000 4 OBJECT GLOBAL DEFAULT 1 foo diff --git a/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n64t.d b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n64t.d new file mode 100644 index 00000000000..e38f78909ac --- /dev/null +++ b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n64t.d @@ -0,0 +1,14 @@ +#PROG: objcopy +#DUMPPROG: readelf +#name: MIPS symbol table sort and section symbol names (relocatable) (n64) +#as: -64 -mno-pdr -mips3 +#objcopy: -j .data -j .symtab -j .strtab -j .shstrtab +#readelf: -s +#source: ../../../../gas/testsuite/gas/mips/global-local-symtab.s + +Symbol table '\.symtab' contains 4 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND + 1: 0000000000000000 0 SECTION LOCAL DEFAULT 1 + 2: 0000000000000004 4 OBJECT LOCAL DEFAULT 1 bar + 3: 0000000000000000 4 OBJECT GLOBAL DEFAULT 1 foo diff --git a/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-o32.d b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-o32.d new file mode 100644 index 00000000000..d46fccde405 --- /dev/null +++ b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-o32.d @@ -0,0 +1,14 @@ +#PROG: objcopy +#DUMPPROG: readelf +#name: MIPS symbol table sort and section symbol names (relocatable) (o32) +#as: -32 -mno-pdr +#objcopy: -j .data -j .symtab -j .strtab -j .shstrtab +#readelf: -s +#source: ../../../../gas/testsuite/gas/mips/global-local-symtab.s + +Symbol table '\.symtab' contains 4 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 00000000 0 NOTYPE LOCAL DEFAULT UND + 1: 00000000 0 SECTION LOCAL DEFAULT 1 \.data + 2: 00000000 4 OBJECT GLOBAL DEFAULT 1 foo + 3: 00000004 4 OBJECT LOCAL DEFAULT 1 bar diff --git a/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-o32t.d b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-o32t.d new file mode 100644 index 00000000000..d97322f6106 --- /dev/null +++ b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-o32t.d @@ -0,0 +1,14 @@ +#PROG: objcopy +#DUMPPROG: readelf +#name: MIPS symbol table sort and section symbol names (relocatable) (o32) +#as: -32 -mno-pdr +#objcopy: -j .data -j .symtab -j .strtab -j .shstrtab +#readelf: -s +#source: ../../../../gas/testsuite/gas/mips/global-local-symtab.s + +Symbol table '\.symtab' contains 4 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 00000000 0 NOTYPE LOCAL DEFAULT UND + 1: 00000000 0 SECTION LOCAL DEFAULT 1 + 2: 00000004 4 OBJECT LOCAL DEFAULT 1 bar + 3: 00000000 4 OBJECT GLOBAL DEFAULT 1 foo diff --git a/binutils/testsuite/binutils-all/mips/mips.exp b/binutils/testsuite/binutils-all/mips/mips.exp index eed1dd12489..e30473762ad 100644 --- a/binutils/testsuite/binutils-all/mips/mips.exp +++ b/binutils/testsuite/binutils-all/mips/mips.exp @@ -252,3 +252,9 @@ run_dump_test_n32 "mips-reginfo-n32" 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" +run_dump_test_o32 "global-local-symtab-sort-o32${tmips}" +run_dump_test_n32 "global-local-symtab-sort-n32${tmips}" +run_dump_test_n64 "global-local-symtab-sort-n64${tmips}" +run_dump_test_o32 "global-local-symtab-final-o32" useld +run_dump_test_n32 "global-local-symtab-final-n32" useld +run_dump_test_n64 "global-local-symtab-final-n64" useld diff --git a/gas/ChangeLog b/gas/ChangeLog index 1da85af7fa8..c83800a2f51 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,13 @@ +2020-07-29 Maciej W. Rozycki + + * testsuite/gas/mips/global-local-symtab-sort-o32.d: New test. + * testsuite/gas/mips/global-local-symtab-sort-o32t.d: New test. + * testsuite/gas/mips/global-local-symtab-sort-n32.d: New test. + * testsuite/gas/mips/global-local-symtab-sort-n32t.d: New test. + * testsuite/gas/mips/global-local-symtab-sort-n64.d: New test. + * testsuite/gas/mips/global-local-symtab-sort-n64t.d: New test. + * testsuite/gas/mips/mips.exp: Run the new tests. + 2020-07-29 Maciej W. Rozycki * testsuite/gas/mips/global-local-symtab-o32.d: New test. diff --git a/gas/testsuite/gas/mips/global-local-symtab-sort-n32.d b/gas/testsuite/gas/mips/global-local-symtab-sort-n32.d new file mode 100644 index 00000000000..2c78bc0906c --- /dev/null +++ b/gas/testsuite/gas/mips/global-local-symtab-sort-n32.d @@ -0,0 +1,6 @@ +#DUMPPROG: readelf +#readelf: -s +#name: MIPS global/local symbol table sort and section symbol names (n32) +#as: -n32 -mno-pdr -mips3 +#source: global-local-symtab.s +#dump: global-local-symtab-sort-o32.d diff --git a/gas/testsuite/gas/mips/global-local-symtab-sort-n32t.d b/gas/testsuite/gas/mips/global-local-symtab-sort-n32t.d new file mode 100644 index 00000000000..43e8be900f7 --- /dev/null +++ b/gas/testsuite/gas/mips/global-local-symtab-sort-n32t.d @@ -0,0 +1,6 @@ +#DUMPPROG: readelf +#readelf: -s +#name: MIPS global/local symbol table sort and section symbol names (n32) +#as: -n32 -mno-pdr -mips3 +#source: global-local-symtab.s +#dump: global-local-symtab-sort-o32t.d diff --git a/gas/testsuite/gas/mips/global-local-symtab-sort-n64.d b/gas/testsuite/gas/mips/global-local-symtab-sort-n64.d new file mode 100644 index 00000000000..220af2f2f65 --- /dev/null +++ b/gas/testsuite/gas/mips/global-local-symtab-sort-n64.d @@ -0,0 +1,17 @@ +#DUMPPROG: readelf +#readelf: -s +#name: MIPS global/local symbol table sort and section symbol names (n64) +#as: -64 -mno-pdr -mips3 +#source: global-local-symtab.s + +Symbol table '\.symtab' contains 9 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND + 1: 0000000000000000 0 SECTION LOCAL DEFAULT 1 \.text + 2: 0000000000000000 0 SECTION LOCAL DEFAULT 2 \.data + 3: 0000000000000000 0 SECTION LOCAL DEFAULT 3 \.bss + 4: 0000000000000004 4 OBJECT LOCAL DEFAULT 2 bar + 5: 0000000000000000 0 SECTION LOCAL DEFAULT 4 \.MIPS\.options + 6: 0000000000000000 0 SECTION LOCAL DEFAULT 5 \.MIPS\.abiflags + 7: 0000000000000000 0 SECTION LOCAL DEFAULT 6 \.gnu\.attributes + 8: 0000000000000000 4 OBJECT GLOBAL DEFAULT 2 foo diff --git a/gas/testsuite/gas/mips/global-local-symtab-sort-n64t.d b/gas/testsuite/gas/mips/global-local-symtab-sort-n64t.d new file mode 100644 index 00000000000..904d626037f --- /dev/null +++ b/gas/testsuite/gas/mips/global-local-symtab-sort-n64t.d @@ -0,0 +1,17 @@ +#DUMPPROG: readelf +#readelf: -s +#name: MIPS global/local symbol table sort and section symbol names (n64) +#as: -64 -mno-pdr -mips3 +#source: global-local-symtab.s + +Symbol table '\.symtab' contains 9 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND + 1: 0000000000000000 0 SECTION LOCAL DEFAULT 1 + 2: 0000000000000000 0 SECTION LOCAL DEFAULT 2 + 3: 0000000000000000 0 SECTION LOCAL DEFAULT 3 + 4: 0000000000000004 4 OBJECT LOCAL DEFAULT 2 bar + 5: 0000000000000000 0 SECTION LOCAL DEFAULT 4 + 6: 0000000000000000 0 SECTION LOCAL DEFAULT 5 + 7: 0000000000000000 0 SECTION LOCAL DEFAULT 6 + 8: 0000000000000000 4 OBJECT GLOBAL DEFAULT 2 foo diff --git a/gas/testsuite/gas/mips/global-local-symtab-sort-o32.d b/gas/testsuite/gas/mips/global-local-symtab-sort-o32.d new file mode 100644 index 00000000000..f93cbb7ff61 --- /dev/null +++ b/gas/testsuite/gas/mips/global-local-symtab-sort-o32.d @@ -0,0 +1,17 @@ +#DUMPPROG: readelf +#readelf: -s +#name: MIPS global/local symbol table sort and section symbol names (o32) +#as: -32 -mno-pdr +#source: global-local-symtab.s + +Symbol table '\.symtab' contains 9 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 00000000 0 NOTYPE LOCAL DEFAULT UND + 1: 00000000 0 SECTION LOCAL DEFAULT 1 \.text + 2: 00000000 0 SECTION LOCAL DEFAULT 2 \.data + 3: 00000000 0 SECTION LOCAL DEFAULT 3 \.bss + 4: 00000000 0 SECTION LOCAL DEFAULT 4 \.reginfo + 5: 00000000 0 SECTION LOCAL DEFAULT 5 \.MIPS\.abiflags + 6: 00000000 0 SECTION LOCAL DEFAULT 6 \.gnu\.attributes + 7: 00000000 4 OBJECT GLOBAL DEFAULT 2 foo + 8: 00000004 4 OBJECT LOCAL DEFAULT 2 bar diff --git a/gas/testsuite/gas/mips/global-local-symtab-sort-o32t.d b/gas/testsuite/gas/mips/global-local-symtab-sort-o32t.d new file mode 100644 index 00000000000..1c37cbaf21b --- /dev/null +++ b/gas/testsuite/gas/mips/global-local-symtab-sort-o32t.d @@ -0,0 +1,17 @@ +#DUMPPROG: readelf +#readelf: -s +#name: MIPS global/local symbol table sort and section symbol names (o32) +#as: -32 -mno-pdr +#source: global-local-symtab.s + +Symbol table '\.symtab' contains 9 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 00000000 0 NOTYPE LOCAL DEFAULT UND + 1: 00000000 0 SECTION LOCAL DEFAULT 1 + 2: 00000000 0 SECTION LOCAL DEFAULT 2 + 3: 00000000 0 SECTION LOCAL DEFAULT 3 + 4: 00000004 4 OBJECT LOCAL DEFAULT 2 bar + 5: 00000000 0 SECTION LOCAL DEFAULT 4 + 6: 00000000 0 SECTION LOCAL DEFAULT 5 + 7: 00000000 0 SECTION LOCAL DEFAULT 6 + 8: 00000000 4 OBJECT GLOBAL DEFAULT 2 foo diff --git a/gas/testsuite/gas/mips/mips.exp b/gas/testsuite/gas/mips/mips.exp index f16d1b16446..69c10e5ba0b 100644 --- a/gas/testsuite/gas/mips/mips.exp +++ b/gas/testsuite/gas/mips/mips.exp @@ -2094,8 +2094,11 @@ if { [istarget mips*-*-vxworks*] } { run_dump_test "insn-isa-mode" run_dump_test "insn-isa-mode" run_dump_test "global-local-symtab-o32${tmips}" + run_dump_test "global-local-symtab-sort-o32${tmips}" if $has_newabi { run_dump_test "global-local-symtab-n32${tmips}" run_dump_test "global-local-symtab-n64" + run_dump_test "global-local-symtab-sort-n32${tmips}" + run_dump_test "global-local-symtab-sort-n64${tmips}" } } diff --git a/ld/ChangeLog b/ld/ChangeLog index 96edfb38b11..6b619f240fd 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,27 @@ +2020-07-29 Maciej W. Rozycki + + * testsuite/ld-elf/sec64k.exp: Also accept a section symbol with + a name. + * testsuite/ld-mips-elf/global-local-symtab-sort-o32.d: New + test. + * testsuite/ld-mips-elf/global-local-symtab-sort-o32t.d: New + test. + * testsuite/ld-mips-elf/global-local-symtab-sort-n32.d: New + test. + * testsuite/ld-mips-elf/global-local-symtab-sort-n32t.d: New + test. + * testsuite/ld-mips-elf/global-local-symtab-sort-n64.d: New + test. + * testsuite/ld-mips-elf/global-local-symtab-sort-n64t.d: New + test. + * testsuite/ld-mips-elf/global-local-symtab-final-o32.d: New + test. + * testsuite/ld-mips-elf/global-local-symtab-final-n32.d: New + test. + * testsuite/ld-mips-elf/global-local-symtab-final-n64.d: New + test. + * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests. + 2020-07-29 Maciej W. Rozycki * testsuite/ld-mips-elf/global-local-symtab-o32.d: New test. diff --git a/ld/testsuite/ld-elf/sec64k.exp b/ld/testsuite/ld-elf/sec64k.exp index 7c85979e578..f17a11890db 100644 --- a/ld/testsuite/ld-elf/sec64k.exp +++ b/ld/testsuite/ld-elf/sec64k.exp @@ -145,7 +145,7 @@ if { ![istarget "m32r-*-*"] } then { puts $ofd " \\\[65279\\\] (.rel\[a\]?)?\\.foo\\.\[0-9\]+ .*" puts $ofd " \\\[65280\\\] (.rel\[a\]?)?\\.foo\\.\[0-9\]+ .*" puts $ofd "#..." - puts $ofd " 340..: 0+\[ \]+0\[ \]+SECTION\[ \]+LOCAL\[ \]+DEFAULT\[ \]+68... " + puts $ofd " 340..: 0+\[ \]+0\[ \]+SECTION\[ \]+LOCAL\[ \]+DEFAULT\[ \]+68... .*" puts $ofd "#..." puts $ofd " 340..: 0+(2|4|8)\[ \]+0\[ \]+NOTYPE\[ \]+LOCAL\[ \]+DEFAULT\[ \]+\[2-7\] bar_1$" puts $ofd "#..." diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab-final-n32.d b/ld/testsuite/ld-mips-elf/global-local-symtab-final-n32.d new file mode 100644 index 00000000000..411057777cf --- /dev/null +++ b/ld/testsuite/ld-mips-elf/global-local-symtab-final-n32.d @@ -0,0 +1,6 @@ +#name: MIPS symbol table sort and section symbol names (fully linked) (n32) +#source: ../../../gas/testsuite/gas/mips/global-local-symtab.s +#as: -mno-pdr +#ld: -e 0 -T global-local-symtab.ld +#readelf: -sW +#dump: global-local-symtab-sort-o32t.d diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab-final-n64.d b/ld/testsuite/ld-mips-elf/global-local-symtab-final-n64.d new file mode 100644 index 00000000000..6e14ee9524c --- /dev/null +++ b/ld/testsuite/ld-mips-elf/global-local-symtab-final-n64.d @@ -0,0 +1,6 @@ +#name: MIPS symbol table sort and section symbol names (fully linked) (n64) +#source: ../../../gas/testsuite/gas/mips/global-local-symtab.s +#as: -mno-pdr +#ld: -e 0 -T global-local-symtab.ld +#readelf: -sW +#dump: global-local-symtab-sort-n64t.d diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab-final-o32.d b/ld/testsuite/ld-mips-elf/global-local-symtab-final-o32.d new file mode 100644 index 00000000000..411057777cf --- /dev/null +++ b/ld/testsuite/ld-mips-elf/global-local-symtab-final-o32.d @@ -0,0 +1,6 @@ +#name: MIPS symbol table sort and section symbol names (fully linked) (n32) +#source: ../../../gas/testsuite/gas/mips/global-local-symtab.s +#as: -mno-pdr +#ld: -e 0 -T global-local-symtab.ld +#readelf: -sW +#dump: global-local-symtab-sort-o32t.d diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n32.d b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n32.d new file mode 100644 index 00000000000..3ea40b58be3 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n32.d @@ -0,0 +1,6 @@ +#name: MIPS symbol table sort and section symbol names (relocatable) (n32) +#source: ../../../gas/testsuite/gas/mips/global-local-symtab.s +#as: -mno-pdr +#ld: -r -T global-local-symtab.ld +#readelf: -sW +#dump: global-local-symtab-sort-o32.d diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n32t.d b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n32t.d new file mode 100644 index 00000000000..0d14ddcf224 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n32t.d @@ -0,0 +1,6 @@ +#name: MIPS symbol table sort and section symbol names (relocatable) (n32) +#source: ../../../gas/testsuite/gas/mips/global-local-symtab.s +#as: -mno-pdr +#ld: -r -T global-local-symtab.ld +#readelf: -sW +#dump: global-local-symtab-sort-o32t.d diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n64.d b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n64.d new file mode 100644 index 00000000000..6491bca3b44 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n64.d @@ -0,0 +1,13 @@ +#name: MIPS symbol table sort and section symbol names (relocatable) (n64) +#source: ../../../gas/testsuite/gas/mips/global-local-symtab.s +#as: -mno-pdr +#ld: -r -T global-local-symtab.ld +#readelf: -sW + +Symbol table '\.symtab' contains 5 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND + 1: 0000000000000000 0 SECTION LOCAL DEFAULT 1 \.data + 2: 0000000000000000 0 FILE LOCAL DEFAULT ABS tmpdir/global-local-symtab\.o + 3: 0000000000000004 4 OBJECT LOCAL DEFAULT 1 bar + 4: 0000000000000000 4 OBJECT GLOBAL DEFAULT 1 foo diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n64t.d b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n64t.d new file mode 100644 index 00000000000..90d37ec2c68 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n64t.d @@ -0,0 +1,13 @@ +#name: MIPS symbol table sort and section symbol names (relocatable) (n64) +#source: ../../../gas/testsuite/gas/mips/global-local-symtab.s +#as: -mno-pdr +#ld: -r -T global-local-symtab.ld +#readelf: -sW + +Symbol table '\.symtab' contains 5 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND + 1: 0000000000000000 0 SECTION LOCAL DEFAULT 1 + 2: 0000000000000000 0 FILE LOCAL DEFAULT ABS tmpdir/global-local-symtab\.o + 3: 0000000000000004 4 OBJECT LOCAL DEFAULT 1 bar + 4: 0000000000000000 4 OBJECT GLOBAL DEFAULT 1 foo diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab-sort-o32.d b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-o32.d new file mode 100644 index 00000000000..1e6ff20c03d --- /dev/null +++ b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-o32.d @@ -0,0 +1,13 @@ +#name: MIPS symbol table sort and section symbol names (relocatable) (n32) +#source: ../../../gas/testsuite/gas/mips/global-local-symtab.s +#as: -mno-pdr +#ld: -r -T global-local-symtab.ld +#readelf: -sW + +Symbol table '\.symtab' contains 5 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 00000000 0 NOTYPE LOCAL DEFAULT UND + 1: 00000000 0 SECTION LOCAL DEFAULT 1 \.data + 2: 00000000 0 FILE LOCAL DEFAULT ABS tmpdir/global-local-symtab\.o + 3: 00000004 4 OBJECT LOCAL DEFAULT 1 bar + 4: 00000000 4 OBJECT GLOBAL DEFAULT 1 foo diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab-sort-o32t.d b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-o32t.d new file mode 100644 index 00000000000..9e7ceaa76e8 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-o32t.d @@ -0,0 +1,13 @@ +#name: MIPS symbol table sort and section symbol names (relocatable) (n32) +#source: ../../../gas/testsuite/gas/mips/global-local-symtab.s +#as: -mno-pdr +#ld: -r -T global-local-symtab.ld +#readelf: -sW + +Symbol table '\.symtab' contains 5 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 00000000 0 NOTYPE LOCAL DEFAULT UND + 1: 00000000 0 SECTION LOCAL DEFAULT 1 + 2: 00000000 0 FILE LOCAL DEFAULT ABS tmpdir/global-local-symtab\.o + 3: 00000004 4 OBJECT LOCAL DEFAULT 1 bar + 4: 00000000 4 OBJECT GLOBAL DEFAULT 1 foo diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp index 4b257c31e65..388fbd3f1b1 100644 --- a/ld/testsuite/ld-mips-elf/mips-elf.exp +++ b/ld/testsuite/ld-mips-elf/mips-elf.exp @@ -1663,3 +1663,9 @@ run_dump_test_o32 "reloc-pcrel-r6" 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" +run_dump_test_o32 "global-local-symtab-sort-o32${tmips}" +run_dump_test_n32 "global-local-symtab-sort-n32${tmips}" +run_dump_test_n64 "global-local-symtab-sort-n64${tmips}" +run_dump_test_o32 "global-local-symtab-final-o32" +run_dump_test_n32 "global-local-symtab-final-n32" +run_dump_test_n64 "global-local-symtab-final-n64"