binutils: readelf: when dumping CTF, load strtab and symtab automatically
authorNick Alcock <nick.alcock@oracle.com>
Sat, 13 Jul 2019 18:47:11 +0000 (19:47 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Thu, 3 Oct 2019 16:04:55 +0000 (17:04 +0100)
We were only loading them when explicitly requested, which leads to
strings that point off into empty space (into the non-loaded "external"
ELF string table).  Avoid this unfortunate consequence by loading the
strtab and symtab by default, unless a blank name is given.

binutils/
* readelf.c (dump_ctf_symtab_name): Give default value.
(dump_ctf_strtab_name): Likewise.
(dump_section_as_ctf): Allow for the null string.

binutils/ChangeLog
binutils/doc/binutils.texi
binutils/readelf.c

index 356eb0592be507ee46abd1580f415aac82cf6b59..629e1566d01a1fd617d27a8d526e521a387c049f 100644 (file)
@@ -1,3 +1,9 @@
+2019-07-13  Nick Alcock  <nick.alcock@oracle.com>
+
+       * readelf.c (dump_ctf_symtab_name): Give default value.
+       (dump_ctf_strtab_name): Likewise.
+       (dump_section_as_ctf): Allow for the null string.
+
 2019-07-08  Nick Alcock  <nick.alcock@oracle.com>
 
        * objdump.c (dump_ctf_archive_member): Dump the CTF header.
index b0de3d061d11d46b4c6cd380f025dd7bb8b4b378..81d8bc1b91da50f9ba36fdd37e00d1a167eaca8d 100644 (file)
@@ -4850,7 +4850,8 @@ command to @command{ar}, but without using the BFD library.  @xref{ar}.
 @item --ctf-symbols=@var{section}
 @item --ctf-strings=@var{section}
 Specify the name of another section from which the CTF file can inherit
-strings and symbols.
+strings and symbols.  By default, the @code{.symtab} and its linked
+string table are used.
 
 If either of @option{--ctf-symbols} or @option{--ctf-strings} is specified, the
 other must be specified as well.
index 7e2b3adcf7b9cfb3b21ccab31dc3b36e31dbdd89..cecad76f16705141f50bbc6a499ed0049e79477f 100644 (file)
@@ -13944,7 +13944,13 @@ dump_section_as_ctf (Elf_Internal_Shdr * section, Filedata * filedata)
   data = get_section_contents (section, filedata);
   ctfsect.cts_data = data;
 
-  if (dump_ctf_symtab_name)
+  if (!dump_ctf_symtab_name)
+    dump_ctf_symtab_name = strdup (".symtab");
+
+  if (!dump_ctf_strtab_name)
+    dump_ctf_strtab_name = strdup (".strtab");
+
+  if (dump_ctf_symtab_name && dump_ctf_symtab_name[0] != 0)
     {
       if ((symtab_sec = find_section (filedata, dump_ctf_symtab_name)) == NULL)
        {
@@ -13959,7 +13965,7 @@ dump_section_as_ctf (Elf_Internal_Shdr * section, Filedata * filedata)
       symsectp = shdr_to_ctf_sect (&symsect, symtab_sec, filedata);
       symsect.cts_data = symdata;
     }
-  if (dump_ctf_strtab_name)
+  if (dump_ctf_strtab_name && dump_ctf_symtab_name[0] != 0)
     {
       if ((strtab_sec = find_section (filedata, dump_ctf_strtab_name)) == NULL)
        {
This page took 0.057232 seconds and 4 git commands to generate.