aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2021-04-21 10:34:32 +0100
committerNick Clifton <nickc@redhat.com>2021-04-21 10:34:32 +0100
commit23356397449a8aa65afead0a895a20be53b3c6b0 (patch)
tree25d812e38a7c6ceed295eaad76eb91aa140e3408 /binutils
parent9c7c5f1e5c4da62d5eacfdc3bc4a1444d9060a5c (diff)
downloadgdb-23356397449a8aa65afead0a895a20be53b3c6b0.zip
gdb-23356397449a8aa65afead0a895a20be53b3c6b0.tar.gz
gdb-23356397449a8aa65afead0a895a20be53b3c6b0.tar.bz2
Adjust readelf's output so that section symbols without a name as shown with their section name.
binutils* readelf.c (print_dynamic_symbol): Print the section name for section symbols without a name of their own. * testsuite/binutils-all/mips/global-local-symtab-sort-n64t.d: Adjust expected output to allow for named section symbols. * testsuite/binutils-all/mips/global-local-symtab-sort-o32t.d: Likewise. * testsuite/binutils-all/readelf.s-64: Likewise. * testsuite/binutils-all/readelf.ss-64-unused: Likewise. * testsuite/binutils-all/readelf.ss-tmips: Likewise. * testsuite/binutils-all/readelf.ss-unused: Likewise. ld * testsuite/ld-aarch64/variant_pcs-now.d: Adjust expected output to allow for named section symbols. * testsuite/ld-aarch64/variant_pcs-r.d: Likewise. * testsuite/ld-aarch64/variant_pcs-shared.d: Likewise. * testsuite/ld-alpha/tlsbin.rd: Likewise. * testsuite/ld-alpha/tlsbinr.rd: Likewise. * testsuite/ld-alpha/tlspic.rd: Likewise. * testsuite/ld-arm/rodata-merge-map.sym: Likewise. * testsuite/ld-arm/script-type.sym: Likewise. * testsuite/ld-cris/libdso-2.d: Likewise. * testsuite/ld-cris/pr16044.d: Likewise. * testsuite/ld-elf/sec64k.exp: Likewise. * testsuite/ld-ia64/tlsbin.rd: Likewise. * testsuite/ld-ia64/tlspic.rd: Likewise. * testsuite/ld-mips-elf/global-local-symtab-sort-n64t.d: Likewise. * testsuite/ld-mips-elf/global-local-symtab-sort-o32t.d: Likewise. * testsuite/ld-mmix/bspec1.d: Likewise. * testsuite/ld-mmix/bspec2.d: Likewise. * testsuite/ld-mmix/local1.d: Likewise. * testsuite/ld-mmix/local3.d: Likewise. * testsuite/ld-mmix/local5.d: Likewise. * testsuite/ld-mmix/local7.d: Likewise. * testsuite/ld-mmix/undef-3.d: Likewise. * testsuite/ld-powerpc/tlsso.r: Likewise. * testsuite/ld-powerpc/tlsso32.r: Likewise. * testsuite/ld-powerpc/tlstocso.r: Likewise. * testsuite/ld-s390/tlsbin.rd: Likewise. * testsuite/ld-s390/tlsbin_64.rd: Likewise. * testsuite/ld-s390/tlspic.rd: Likewise. * testsuite/ld-s390/tlspic_64.rd: Likewise. * testsuite/ld-sparc/gotop32.rd: Likewise. * testsuite/ld-sparc/gotop64.rd: Likewise. * testsuite/ld-sparc/tlssunbin32.rd: Likewise. * testsuite/ld-sparc/tlssunbin64.rd: Likewise. * testsuite/ld-sparc/tlssunnopic32.rd: Likewise. * testsuite/ld-sparc/tlssunnopic64.rd: Likewise. * testsuite/ld-sparc/tlssunpic32.rd: Likewise. * testsuite/ld-sparc/tlssunpic64.rd: Likewise. * testsuite/ld-tic6x/common.d: Likewise. * testsuite/ld-tic6x/shlib-1.rd: Likewise. * testsuite/ld-tic6x/shlib-1b.rd: Likewise. * testsuite/ld-tic6x/shlib-1r.rd: Likewise. * testsuite/ld-tic6x/shlib-1rb.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1b.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1r.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1rb.rd: Likewise. * testsuite/ld-tic6x/shlib-noindex.rd: Likewise. * testsuite/ld-tic6x/static-app-1.rd: Likewise. * testsuite/ld-tic6x/static-app-1b.rd: Likewise. * testsuite/ld-tic6x/static-app-1r.rd: Likewise. * testsuite/ld-tic6x/static-app-1rb.rd: Likewise. gas * testsuite/gas/aarch64/dwarf.d: Adjust expected output to allow for named section symbols. * testsuite/gas/arm/thumbver.d: Likewise. * testsuite/gas/bfin/loop_temps.d: Likewise. * testsuite/gas/elf/section2.e-arc: Likewise. * testsuite/gas/elf/section2.e-arm: Likewise. * testsuite/gas/elf/section2.e-csky: Likewise. * testsuite/gas/elf/section2.e-m32r: Likewise. * testsuite/gas/elf/section2.e-mips: Likewise. * testsuite/gas/elf/section2.e-msp430: Likewise. * testsuite/gas/elf/section2.e-riscv: Likewise. * testsuite/gas/elf/section2.e-rl78: Likewise. * testsuite/gas/elf/section2.e-rx: Likewise. * testsuite/gas/elf/section2.e-score: Likewise. * testsuite/gas/elf/section2.e-tic6x: Likewise. * testsuite/gas/elf/section2.e-unused: Likewise. * testsuite/gas/elf/section2.e-v850: Likewise. * testsuite/gas/elf/section2.e-xtensa: Likewise. * testsuite/gas/ia64/alias-ilp32.d: Likewise. * testsuite/gas/ia64/alias.d: Likewise. * testsuite/gas/ia64/global.d: Likewise. * testsuite/gas/microblaze/relax_size.elf: Likewise. * testsuite/gas/microblaze/relax_size2.elf: Likewise. * testsuite/gas/mips/global-local-symtab-sort-n64t.d: Likewise. * testsuite/gas/mips/global-local-symtab-sort-o32t.d: Likewise. * testsuite/gas/mmix/bspec-1.d: Likewise. * testsuite/gas/mmix/byte-1.d: Likewise. * testsuite/gas/mmix/comment-1.d: Likewise. * testsuite/gas/mmix/loc-1.d: Likewise. * testsuite/gas/mmix/loc-2.d: Likewise. * testsuite/gas/mmix/loc-3.d: Likewise. * testsuite/gas/mmix/loc-4.d: Likewise. * testsuite/gas/mmix/loc-5.d: Likewise. * testsuite/gas/tic6x/scomm-directive-4.d: Likewise.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog16
-rw-r--r--binutils/readelf.c18
-rw-r--r--binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n64t.d2
-rw-r--r--binutils/testsuite/binutils-all/mips/global-local-symtab-sort-o32t.d2
-rw-r--r--binutils/testsuite/binutils-all/readelf.s-642
-rw-r--r--binutils/testsuite/binutils-all/readelf.ss-64-unused6
-rw-r--r--binutils/testsuite/binutils-all/readelf.ss-tmips32
-rw-r--r--binutils/testsuite/binutils-all/readelf.ss-unused6
8 files changed, 57 insertions, 27 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index d1d87cc..033dd58 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,19 @@
+2021-04-21 Nick Clifton <nickc@redhat.com>
+
+ * testsuite/binutils-all/mips/global-local-symtab-sort-n64t.d:
+ Adjust expected output to allow for named section symbols.
+ * testsuite/binutils-all/mips/global-local-symtab-sort-o32t.d:
+ Likewise.
+ * testsuite/binutils-all/readelf.s-64: Likewise.
+ * testsuite/binutils-all/readelf.ss-64-unused: Likewise.
+ * testsuite/binutils-all/readelf.ss-tmips: Likewise.
+ * testsuite/binutils-all/readelf.ss-unused: Likewise.
+
+2021-04-21 Luo Longjun <luolongjun@huawei.com>
+
+ * readelf.c (print_dynamic_symbol): Print the section name for
+ section symbols without a name of their own.
+
2021-04-20 Andreas Krebbel <krebbel@linux.ibm.com>
* MAINTAINERS: Remove Martin Schwidefsky as s390 maintainer and
diff --git a/binutils/readelf.c b/binutils/readelf.c
index b404ca7..c8a76de 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -12381,6 +12381,8 @@ print_dynamic_symbol (Filedata *filedata, unsigned long si,
const char *version_string;
enum versioned_symbol_info sym_info;
unsigned short vna_other;
+ bool is_valid;
+ const char * sstr;
Elf_Internal_Sym *psym = symtab + si;
printf ("%6ld: ", si);
@@ -12404,8 +12406,20 @@ print_dynamic_symbol (Filedata *filedata, unsigned long si,
}
printf (" %4s ", get_symbol_index_type (filedata, psym->st_shndx));
- bool is_valid = VALID_SYMBOL_NAME (strtab, strtab_size, psym->st_name);
- const char * sstr = is_valid ? strtab + psym->st_name : _("<corrupt>");
+ if (ELF_ST_TYPE (psym->st_info) == STT_SECTION
+ && psym->st_shndx < filedata->file_header.e_shnum
+ && psym->st_name == 0)
+ {
+ is_valid = SECTION_NAME_VALID (filedata->section_headers + psym->st_shndx);
+ sstr = is_valid ?
+ SECTION_NAME_PRINT (filedata->section_headers + psym->st_shndx)
+ : _("<corrupt>");
+ }
+ else
+ {
+ is_valid = VALID_SYMBOL_NAME (strtab, strtab_size, psym->st_name);
+ sstr = is_valid ? strtab + psym->st_name : _("<corrupt>");
+ }
version_string
= get_symbol_version_string (filedata,
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
index e38f789..53d04b4 100644
--- a/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n64t.d
+++ b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n64t.d
@@ -9,6 +9,6 @@
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
+ 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-o32t.d b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-o32t.d
index d97322f..47978a5 100644
--- a/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-o32t.d
+++ b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-o32t.d
@@ -9,6 +9,6 @@
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
+ 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/readelf.s-64 b/binutils/testsuite/binutils-all/readelf.s-64
index 5582d77..92ec05f 100644
--- a/binutils/testsuite/binutils-all/readelf.s-64
+++ b/binutils/testsuite/binutils-all/readelf.s-64
@@ -11,7 +11,7 @@ Section Headers:
+000000000000001. +000000000000001. +I +. +1 +8
+\[ 3\] .data +PROGBITS +0000000000000000 +000000(48|50)
+000000000000000[48] +0000000000000000 +WA +0 +0 +.*
- +\[ 4\] .bss +NOBITS +0000000000000000 +000000(4c|50|54|58)
+ +\[ 4\] .bss +NOBITS +0000000000000000 +000000(4c|50|54|58|68)
+0000000000000000 +0000000000000000 +WA +0 +0 +.*
# x86 targets may put .note.gnu.property here.
#...
diff --git a/binutils/testsuite/binutils-all/readelf.ss-64-unused b/binutils/testsuite/binutils-all/readelf.ss-64-unused
index bd10cab..f48a4b2 100644
--- a/binutils/testsuite/binutils-all/readelf.ss-64-unused
+++ b/binutils/testsuite/binutils-all/readelf.ss-64-unused
@@ -2,9 +2,9 @@
Symbol table '.symtab' contains .* 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 +3
- +3: 0000000000000000 +0 +SECTION +LOCAL +DEFAULT +4
+ +1: 0000000000000000 +0 +SECTION +LOCAL +DEFAULT +1.*
+ +2: 0000000000000000 +0 +SECTION +LOCAL +DEFAULT +3.*
+ +3: 0000000000000000 +0 +SECTION +LOCAL +DEFAULT +4.*
+4: 0000000000000000 +0 +NOTYPE +LOCAL +DEFAULT +1 static_text_symbol
# aarch64-elf targets add the $d mapping symbol here...
#...
diff --git a/binutils/testsuite/binutils-all/readelf.ss-tmips b/binutils/testsuite/binutils-all/readelf.ss-tmips
index 4fd7fe0..87ec138 100644
--- a/binutils/testsuite/binutils-all/readelf.ss-tmips
+++ b/binutils/testsuite/binutils-all/readelf.ss-tmips
@@ -1,19 +1,19 @@
Symbol table '.symtab' contains 16 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 +3
- +3: 00000000 +0 +SECTION +LOCAL +DEFAULT +4
- +4: 00000000 +0 +NOTYPE +LOCAL +DEFAULT +1 static_text_symbol
- +5: 00000000 +0 +NOTYPE +LOCAL +DEFAULT +3 static_data_symbol
- +6: 00000000 +0 +SECTION +LOCAL +DEFAULT +5
- +7: 00000000 +0 +SECTION +LOCAL +DEFAULT +6
- +8: 00000000 +0 +SECTION +LOCAL +DEFAULT +7
- +9: 00000000 +0 +SECTION +LOCAL +DEFAULT +8
- +10: 00000000 +0 +NOTYPE +GLOBAL +DEFAULT +1 text_symbol
- +11: 00000000 +0 +NOTYPE +GLOBAL +DEFAULT +UND external_symbol
- +12: 00000000 +0 +NOTYPE +GLOBAL +DEFAULT +3 data_symbol
- +13: 00000004 +4 +(COMMON|OBJECT) +GLOBAL +DEFAULT +(PRC|COM) common_symbol
- +14: 00000008 +0 +NOTYPE +GLOBAL +DEFAULT +. text_symbol2
- +15: 0000000c +0 +NOTYPE +GLOBAL +DEFAULT +. text_symbol3
+ +0: 0+000000 +0 +NOTYPE +LOCAL +DEFAULT +UND
+ +1: 0+000000 +0 +SECTION +LOCAL +DEFAULT +1.*
+ +2: 0+000000 +0 +SECTION +LOCAL +DEFAULT +3.*
+ +3: 0+000000 +0 +SECTION +LOCAL +DEFAULT +4.*
+ +4: 0+000000 +0 +NOTYPE +LOCAL +DEFAULT +1 static_text_symbol
+ +5: 0+000000 +0 +NOTYPE +LOCAL +DEFAULT +3 static_data_symbol
+ +6: 0+000000 +0 +SECTION +LOCAL +DEFAULT +5.*
+ +7: 0+000000 +0 +SECTION +LOCAL +DEFAULT +6.*
+ +8: 0+000000 +0 +SECTION +LOCAL +DEFAULT +7.*
+ +9: 0+000000 +0 +SECTION +LOCAL +DEFAULT +8.*
+ +10: 0+000000 +0 +NOTYPE +GLOBAL +DEFAULT +1 text_symbol
+ +11: 0+000000 +0 +NOTYPE +GLOBAL +DEFAULT +UND external_symbol
+ +12: 0+000000 +0 +NOTYPE +GLOBAL +DEFAULT +3 data_symbol
+ +13: 0+000004 +4 +(COMMON|OBJECT) +GLOBAL +DEFAULT +(PRC|COM) common_symbol
+ +14: 0+000008 +0 +NOTYPE +GLOBAL +DEFAULT +. text_symbol2
+ +15: 0+00000c +0 +NOTYPE +GLOBAL +DEFAULT +. text_symbol3
diff --git a/binutils/testsuite/binutils-all/readelf.ss-unused b/binutils/testsuite/binutils-all/readelf.ss-unused
index acc6d93..3107af9 100644
--- a/binutils/testsuite/binutils-all/readelf.ss-unused
+++ b/binutils/testsuite/binutils-all/readelf.ss-unused
@@ -2,9 +2,9 @@
Symbol table '.symtab' contains .* 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 +[34]
- +3: 00000000 +0 +SECTION +LOCAL +DEFAULT +[45]
+ +1: 00000000 +0 +SECTION +LOCAL +DEFAULT +1.*
+ +2: 00000000 +0 +SECTION +LOCAL +DEFAULT +[34].*
+ +3: 00000000 +0 +SECTION +LOCAL +DEFAULT +[45].*
+4: 00000000 +0 +NOTYPE +LOCAL +DEFAULT +1 static_text_symbol
# ARM targets add the $d mapping symbol here...
# NDS32 targets add the $d2 mapping symbol here...