2009-05-28 Nick Clifton <nickc@redhat.com>
[deliverable/binutils-gdb.git] / binutils / readelf.c
index a7e7b05a50f46a5b3686cdcdabd4cca4d0bbd588..4727a840cbcf35a65c10de328162ecc1eeda6faa 100644 (file)
@@ -1238,9 +1238,38 @@ dump_relocations (FILE * file,
 
              printf (" ");
 
-             print_vma (psym->st_value, LONG_HEX);
+             if (ELF_ST_TYPE (psym->st_info) == STT_GNU_IFUNC)
+               {
+                 const char * name;
+                 unsigned int len;
+                 unsigned int width = is_32bit_elf ? 8 : 14;
+
+                 /* Relocations against GNU_IFUNC symbols do not use the value
+                    of the symbol as the address to relocate against.  Instead
+                    they invoke the function named by the symbol and use its
+                    result as the address for relocation.
+
+                    To indicate this to the user, do not display the value of
+                    the symbol in the "Symbols's Value" field.  Instead show
+                    its name followed by () as a hint that the symbol is
+                    invoked.  */
+
+                 if (strtab == NULL
+                     || psym->st_name == 0
+                     || psym->st_name >= strtablen)
+                   name = "??";
+                 else
+                   name = strtab + psym->st_name;
+
+                 len = print_symbol (width, name);
+                 printf ("()%-*s", len <= width ? (width + 1) - len : 1, " ");
+               }
+             else
+               {
+                 print_vma (psym->st_value, LONG_HEX);
 
-             printf (is_32bit_elf ? "   " : " ");
+                 printf (is_32bit_elf ? "   " : " ");
+               }
 
              if (psym->st_name == 0)
                {
@@ -6913,6 +6942,12 @@ get_symbol_type (unsigned int type)
                return "HP_STUB";
            }
 
+         if (type == STT_GNU_IFUNC
+             && (elf_header.e_ident[EI_OSABI] == ELFOSABI_LINUX
+                 /* GNU/Linux is still using the default value 0.  */
+                 || elf_header.e_ident[EI_OSABI] == ELFOSABI_NONE))
+           return "IFUNC";
+
          snprintf (buff, sizeof (buff), _("<OS specific>: %d"), type);
        }
       else
@@ -8504,6 +8539,15 @@ display_debug_section (Elf_Internal_Shdr * section, FILE * file)
       printf (_("\nSection '%s' has no debugging data.\n"), name);
       return 0;
     }
+  if (section->sh_type == SHT_NOBITS)
+    {
+      /* There is no point in dumping the contents of a debugging section
+        which has the NOBITS type - the bits in the file will be random.
+        This can happen when a file containing a .eh_frame section is
+        stripped with the --only-keep-debug command line option.  */
+      printf (_("section '%s' has the NOBITS type - its contents are unreliable.\n"), name);
+      return 0;
+    }
 
   if (const_strneq (name, ".gnu.linkonce.wi."))
     name = ".debug_info";
This page took 0.024173 seconds and 4 git commands to generate.