]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add --dyn-syms to readelf
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 11 Jan 2010 14:45:42 +0000 (14:45 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 11 Jan 2010 14:45:42 +0000 (14:45 +0000)
binutils/

2010-01-11  H.J. Lu  <hongjiu.lu@intel.com>

PR ld/11146
* NEWS: Mention --dyn-syms for readelf.

* readelf.c (do_dyn_syms): New.
(OPTION_DYN_SYMS): Likewise.
(options): Add "dyn-syms".
(usage): Add --dyn-syms.
(parse_args): Handle OPTION_DYN_SYMS.
(process_symbol_table): Handle do_dyn_syms.
(process_object): Likewise.
(process_archive): Likewise.

* doc/binutils.texi: Document --dyn-syms for readelf.  Mention
symbol hash tables for -D.

ld/testsuite/

2010-01-11  H.J. Lu  <hongjiu.lu@intel.com>

PR ld/11146
* ld-elf/dynsym1.d: New.

binutils/ChangeLog
binutils/NEWS
binutils/doc/binutils.texi
binutils/readelf.c
ld/testsuite/ChangeLog
ld/testsuite/ld-elf/dynsym1.d [new file with mode: 0644]

index 312afa62fc6ac4362196c4f80605be8d806b8005..7ea8b3bbd2717510f2315f6a9d3c947dcfbe64d0 100644 (file)
@@ -1,3 +1,35 @@
+2010-01-11  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/11146
+       * NEWS: Mention --dyn-syms for readelf.
+
+       * readelf.c (do_dyn_syms): New.
+       (OPTION_DYN_SYMS): Likewise.
+       (options): Add "dyn-syms".
+       (usage): Add --dyn-syms.
+       (parse_args): Handle OPTION_DYN_SYMS.
+       (process_symbol_table): Handle do_dyn_syms.
+       (process_object): Likewise.
+       (process_archive): Likewise.
+
+       * doc/binutils.texi: Document --dyn-syms for readelf.  Mention
+       symbol hash tables for -D.
+
+2010-01-11  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/11146
+       * readelf.c (do_dyn_syms): New.
+       (OPTION_DYN_SYMS): Likewise.
+       (options): Add "dyn-syms".
+       (usage): Add --dyn-syms.
+       (parse_args): Handle OPTION_DYN_SYMS.
+       (process_symbol_table): Handle do_dyn_syms.
+       (process_object): Likewise.
+       (process_archive): Likewise.
+
+       * doc/binutils.texi: Document --dyn-syms for readelf.  Mention
+       symbol hash tables for -D.
+
 2010-01-11  Nick Clifton  <nickc@redhat.com>
 
        * NEWS: Mention addition of elfedit.
index 511e51f308e1a2c88953e9402f8058d485b84a98..351ffdfe441f90c871259e1575ab0fa2afc97239 100644 (file)
@@ -1,4 +1,7 @@
 -*- text -*-
+
+* Add --dyn-syms to readelf to dump dynamic symbol table.
+
 * A new tool - elfedit - has been added to directly manipulate ELF format
   binaries.
 
index aedb80f9263b60884fdd4c9a2dc959ec7a2f2494..b0df698226ed5564259b4af7b194f016eccee717 100644 (file)
@@ -3894,6 +3894,7 @@ readelf [@option{-a}|@option{--all}]
         [@option{-t}|@option{--section-details}]
         [@option{-e}|@option{--headers}]
         [@option{-s}|@option{--syms}|@option{--symbols}]
+        [@option{--dyn-syms}]
         [@option{-n}|@option{--notes}]
         [@option{-r}|@option{--relocs}]
         [@option{-u}|@option{--unwind}]
@@ -3982,6 +3983,11 @@ Displays the detailed section information. Implies @option{-S}.
 @cindex ELF symbol table information
 Displays the entries in symbol table section of the file, if it has one.
 
+@item --dyn-syms
+@cindex ELF dynamic symbol table information
+Displays the entries in dynamic symbol table section of the file, if it
+has one.
+
 @item -e
 @itemx --headers
 Display all the headers in the file.  Equivalent to @option{-h -l -S}.
@@ -4021,8 +4027,8 @@ is any.
 @item -D
 @itemx --use-dynamic
 When displaying symbols, this option makes @command{readelf} use the
-symbol table in the file's dynamic section, rather than the one in the
-symbols section.
+symbol hash tables in the file's dynamic section, rather than the
+symbol table sections.
 
 @item -x <number or name>
 @itemx --hex-dump=<number or name>
index 8550c310f38bbcb44c5e77e2f1b2cb001df1321b..122bd7357dd8268728d1e44e346c972f8fb82f32 100644 (file)
@@ -178,6 +178,7 @@ static Elf_Internal_Shdr * symtab_shndx_hdr;
 static int show_name;
 static int do_dynamic;
 static int do_syms;
+static int do_dyn_syms;
 static int do_reloc;
 static int do_sections;
 static int do_section_groups;
@@ -2923,6 +2924,7 @@ get_section_type_name (unsigned int sh_type)
 }
 
 #define OPTION_DEBUG_DUMP      512
+#define OPTION_DYN_SYMS                513
 
 static struct option options[] =
 {
@@ -2939,6 +2941,7 @@ static struct option options[] =
   {"full-section-name",no_argument, 0, 'N'},
   {"symbols",         no_argument, 0, 's'},
   {"syms",            no_argument, 0, 's'},
+  {"dyn-syms",        no_argument, 0, OPTION_DYN_SYMS},
   {"relocs",          no_argument, 0, 'r'},
   {"notes",           no_argument, 0, 'n'},
   {"dynamic",         no_argument, 0, 'd'},
@@ -2978,6 +2981,7 @@ usage (FILE * stream)
   -e --headers           Equivalent to: -h -l -S\n\
   -s --syms              Display the symbol table\n\
      --symbols           An alias for --syms\n\
+  --dyn-syms             Display the dynamic symbol table\n\
   -n --notes             Display the core notes (if present)\n\
   -r --relocs            Display the relocations (if present)\n\
   -u --unwind            Display the unwind info (if present)\n\
@@ -3202,6 +3206,9 @@ parse_args (int argc, char ** argv)
              dwarf_select_sections_by_names (optarg);
            }
          break;
+       case OPTION_DYN_SYMS:
+         do_dyn_syms++;
+         break;
 #ifdef SUPPORT_DISASSEMBLY
        case 'i':
          request_dump (DISASS_DUMP);
@@ -3228,7 +3235,8 @@ parse_args (int argc, char ** argv)
   if (!do_dynamic && !do_syms && !do_reloc && !do_unwind && !do_sections
       && !do_segments && !do_header && !do_dump && !do_version
       && !do_histogram && !do_debugging && !do_arch && !do_notes
-      && !do_section_groups && !do_archive_index)
+      && !do_section_groups && !do_archive_index
+      && !do_dyn_syms)
     usage (stderr);
   else if (argc < 3)
     {
@@ -7343,12 +7351,14 @@ process_symbol_table (FILE * file)
   bfd_vma * gnuchains = NULL;
   bfd_vma gnusymidx = 0;
 
-  if (! do_syms && !do_histogram)
+  if (!do_syms && !do_dyn_syms && !do_histogram)
     return 1;
 
   if (dynamic_info[DT_HASH]
       && (do_histogram
-         || (do_using_dynamic && dynamic_strings != NULL)))
+         || (do_using_dynamic
+             && !do_dyn_syms
+             && dynamic_strings != NULL)))
     {
       unsigned char nb[8];
       unsigned char nc[8];
@@ -7404,7 +7414,9 @@ process_symbol_table (FILE * file)
 
   if (dynamic_info_DT_GNU_HASH
       && (do_histogram
-         || (do_using_dynamic && dynamic_strings != NULL)))
+         || (do_using_dynamic
+             && !do_dyn_syms
+             && dynamic_strings != NULL)))
     {
       unsigned char nb[16];
       bfd_vma i, maxchain = 0xffffffff, bitmaskwords;
@@ -7561,7 +7573,7 @@ process_symbol_table (FILE * file)
              }
        }
     }
-  else if (do_syms && !do_using_dynamic)
+  else if (do_dyn_syms || (do_syms && !do_using_dynamic))
     {
       unsigned int i;
 
@@ -7575,8 +7587,10 @@ process_symbol_table (FILE * file)
          Elf_Internal_Sym * symtab;
          Elf_Internal_Sym * psym;
 
-         if (   section->sh_type != SHT_SYMTAB
-             && section->sh_type != SHT_DYNSYM)
+         if ((section->sh_type != SHT_SYMTAB
+              && section->sh_type != SHT_DYNSYM)
+             || (!do_syms
+                 && section->sh_type == SHT_SYMTAB))
            continue;
 
          printf (_("\nSymbol table '%s' contains %lu entries:\n"),
@@ -10859,7 +10873,7 @@ process_object (char * file_name, FILE * file)
       do_unwind = do_version = do_dump = do_arch = 0;
 
       if (! do_using_dynamic)
-       do_syms = do_reloc = 0;
+       do_syms = do_dyn_syms = do_reloc = 0;
     }
 
   if (! process_section_groups (file))
@@ -11463,7 +11477,7 @@ process_archive (char * file_name, FILE * file, bfd_boolean is_thin_archive)
       if (!do_dynamic && !do_syms && !do_reloc && !do_unwind && !do_sections
          && !do_segments && !do_header && !do_dump && !do_version
          && !do_histogram && !do_debugging && !do_arch && !do_notes
-         && !do_section_groups)
+         && !do_section_groups && !do_dyn_syms)
        {
          ret = 0; /* Archive index only.  */
          goto out;
index 24ab471b23923478f48977d85907cd9a0ab572a5..51783a6103d7388e391095a653dac6f15f7fbec8 100644 (file)
@@ -1,3 +1,8 @@
+2010-01-11  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/11146
+       * ld-elf/dynsym1.d: New.
+
 2010-01-07  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/11138
diff --git a/ld/testsuite/ld-elf/dynsym1.d b/ld/testsuite/ld-elf/dynsym1.d
new file mode 100644 (file)
index 0000000..88037ef
--- /dev/null
@@ -0,0 +1,8 @@
+#source: empty.s
+#ld: -shared
+#readelf: --dyn-syms
+#target: *-*-linux*
+
+#...
+ +[0-9]+: +[0-9a-f]+ +[0-9]+ +FUNC +GLOBAL +DEFAULT +[1-9] _start
+#pass