Ignore section symbols without a BFD section
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 4 Sep 2012 12:35:35 +0000 (12:35 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 4 Sep 2012 12:35:35 +0000 (12:35 +0000)
bfd/

PR binutils/14493
* elf.c (ignore_section_sym): Also ignore section symbols without
a BFD section.

binutils/

PR binutils/14493
* readelf.c (get_symbol_index_type): Check bad section index.

bfd/ChangeLog
bfd/elf.c
binutils/ChangeLog
binutils/readelf.c

index 189d52d1a6580cdbe035f8864a6c992cb52ae733..a7165020e4362f163df8252c6e37f4a7a70c3599 100644 (file)
@@ -1,3 +1,9 @@
+2012-09-04  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/14493
+       * elf.c (ignore_section_sym): Also ignore section symbols without
+       a BFD section.
+
 2012-09-03  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
 
        * elf32-s390.c (elf_s390_relocate_section): Handle PLTOFF for
index 0208e05ec1fdcc08f109e45c18ef217403ecb1d6..b4043b129281de336268546e209f5fe616f4c593 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -3264,13 +3264,21 @@ sym_is_global (bfd *abfd, asymbol *sym)
 }
 
 /* Don't output section symbols for sections that are not going to be
-   output, or that are duplicates.  */
+   output, that are duplicates or there is no BFD section.  */
 
 static bfd_boolean
 ignore_section_sym (bfd *abfd, asymbol *sym)
 {
-  return ((sym->flags & BSF_SECTION_SYM) != 0
-         && !(sym->section->owner == abfd
+  elf_symbol_type *type_ptr;
+
+  if ((sym->flags & BSF_SECTION_SYM) == 0)
+    return FALSE;
+
+  type_ptr = elf_symbol_from (abfd, sym);
+  return ((type_ptr != NULL
+          && type_ptr->internal_elf_sym.st_shndx != 0
+          && bfd_is_abs_section (sym->section))
+         || !(sym->section->owner == abfd
               || (sym->section->output_section->owner == abfd
                   && sym->section->output_offset == 0)
               || bfd_is_abs_section (sym->section)));
index 922396acf7b0de7aae710467f9a9950dbf0e9e3e..5c6fcb7f70b558572a6156b8cc9e241f88899f3a 100644 (file)
@@ -1,3 +1,8 @@
+2012-09-04  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/14493
+       * readelf.c (get_symbol_index_type): Check bad section index.
+
 2012-08-24  Matthew Gretton-Dann  <matthew.gretton-dann@arm.com>
 
        * readelf.c (arm_attr_tag_CPU_arch): Update for ARMv8.
        * bfdtest1.c: New file.
 
 2012-08-13  Ian Bolton  <ian.bolton@arm.com>
-            Laurent Desnogues  <laurent.desnogues@arm.com>
-            Jim MacArthur  <jim.macarthur@arm.com>
-            Marcus Shawcroft  <marcus.shawcroft@arm.com>
-            Nigel Stephens  <nigel.stephens@arm.com>
-            Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
-            Richard Earnshaw  <rearnsha@arm.com>
-            Sofiane Naci  <sofiane.naci@arm.com>
-            Tejas Belagod  <tejas.belagod@arm.com>
-            Yufeng Zhang  <yufeng.zhang@arm.com>
+           Laurent Desnogues  <laurent.desnogues@arm.com>
+           Jim MacArthur  <jim.macarthur@arm.com>
+           Marcus Shawcroft  <marcus.shawcroft@arm.com>
+           Nigel Stephens  <nigel.stephens@arm.com>
+           Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
+           Richard Earnshaw  <rearnsha@arm.com>
+           Sofiane Naci  <sofiane.naci@arm.com>
+           Tejas Belagod  <tejas.belagod@arm.com>
+           Yufeng Zhang  <yufeng.zhang@arm.com>
 
        * readelf.c (guess_is_rela): Handle EM_AARCH64.
        (get_machine_name): Likewise.
 2012-07-24  Teresa Johnson  <tejohnson@google.com>
 
        * addr2line.c (find_address_in_section): Invoke
-        bfd_find_nearest_line_discriminator to get the discriminator.
+       bfd_find_nearest_line_discriminator to get the discriminator.
        (find_offset_in_section): Likewise.
        (translate_addresses): Print discriminator if it is non-zero.
        * objdump.c (show_line): Invoke
-        bfd_find_nearest_line_discriminator to get the discriminator,
-        and keep track of prev_discriminator. Print discriminator
-        if it is non-zero.
+       bfd_find_nearest_line_discriminator to get the discriminator,
+       and keep track of prev_discriminator. Print discriminator
+       if it is non-zero.
        (disassemble_data): Initialize prev_discriminator.
        (dump_reloc_set): Invoke bfd_find_nearest_line_discriminator
-        to get the discriminator, and keep track of last_discriminator.
-        Print discriminator if it is non-zero.
+       to get the discriminator, and keep track of last_discriminator.
+       Print discriminator if it is non-zero.
 
 2012-07-17  Nick Clifton  <nickc@redhat.com>
 
 
 2012-04-11  Ryan Mansfield  <rmansfield@qnx.com>
 
-        * objdump.c (dump_bfd): If defaulting to dwarf call
-        dwarf_select_sections_all to enable displays.
+       * objdump.c (dump_bfd): If defaulting to dwarf call
+       dwarf_select_sections_all to enable displays.
 
 2012-04-06  Roland McGrath  <mcgrathr@google.com>
 
index 89cff2477eb1efea9b205faa4318871e151c5394..2fbf2ae6e85ea3b7c78b6af9c0100f3c6447300f 100644 (file)
@@ -8974,6 +8974,8 @@ get_symbol_index_type (unsigned int type)
        sprintf (buff, "OS [0x%04x]", type & 0xffff);
       else if (type >= SHN_LORESERVE)
        sprintf (buff, "RSV[0x%04x]", type & 0xffff);
+      else if (type >= elf_header.e_shnum)
+       sprintf (buff, "bad section index[%3d]", type);
       else
        sprintf (buff, "%3d", type);
       break;