* readelf.c (byte_get_little_endian): Comment typo fix.
authorAlan Modra <amodra@gmail.com>
Mon, 4 Nov 2002 03:18:41 +0000 (03:18 +0000)
committerAlan Modra <amodra@gmail.com>
Mon, 4 Nov 2002 03:18:41 +0000 (03:18 +0000)
(print_symbol): Constify "symbol" arg.  Don't pass "symbol" to printf
as the format string.
(dump_relocations): Correct section sym names.
(process_section_headers): Clear symtab_shndx_hdr.
(read_and_display_attr_value): Don't pass indirect string to printf
as the format string.
(display_debug_frames): Indicate when zero terminator found.  Decode
DW_EH_PE_pcrel addresses.

binutils/ChangeLog
binutils/readelf.c

index 617d164..33b1c3f 100644 (file)
@@ -1,3 +1,15 @@
+2002-11-04  Alan Modra  <amodra@bigpond.net.au>
+
+       * readelf.c (byte_get_little_endian): Comment typo fix.
+       (print_symbol): Constify "symbol" arg.  Don't pass "symbol" to printf
+       as the format string.
+       (dump_relocations): Correct section sym names.
+       (process_section_headers): Clear symtab_shndx_hdr.
+       (read_and_display_attr_value): Don't pass indirect string to printf
+       as the format string.
+       (display_debug_frames): Indicate when zero terminator found.  Decode
+       DW_EH_PE_pcrel addresses.
+
 2002-10-23  Svein E. Seldal  <Svein.Seldal@solidas.com>
 
        * configure.in: Define SKIP_ZEROES as 32 for tic4x target in
index 8cbc8fa..ab5955f 100644 (file)
@@ -161,7 +161,7 @@ print_mode;
 
 /* Forward declarations for dumb compilers.  */
 static void              print_vma                   PARAMS ((bfd_vma, print_mode));
-static void              print_symbol                PARAMS ((int, char *));
+static void              print_symbol                PARAMS ((int, const char *));
 static bfd_vma (*         byte_get)                   PARAMS ((unsigned char *, int));
 static bfd_vma            byte_get_little_endian      PARAMS ((unsigned char *, int));
 static bfd_vma            byte_get_big_endian         PARAMS ((unsigned char *, int));
@@ -406,7 +406,7 @@ byte_get_little_endian (field, size)
     case 8:
       /* We want to extract data from an 8 byte wide field and
         place it into a 4 byte wide field.  Since this is a little
-        endian source we can juts use the 4 byte extraction code.  */
+        endian source we can just use the 4 byte extraction code.  */
       /* Fall through.  */
 #endif
     case 4:
@@ -535,10 +535,10 @@ print_vma (vma, mode)
 static void
 print_symbol (width, symbol)
      int width;
-     char * symbol;
+     const char * symbol;
 {
   if (do_wide)
-    printf (symbol);
+    printf ("%s", symbol);
   else if (width < 0)
     printf ("%-*.*s", width, width, symbol);
   else
@@ -1166,7 +1166,35 @@ dump_relocations (file, rel_offset, rel_size, symtab, nsyms, strtab, is_rela)
              printf (is_32bit_elf ? "   " : " ");
 
              if (psym->st_name == 0)
-               print_symbol (22, SECTION_NAME (section_headers + psym->st_shndx));
+               {
+                 const char *sec_name = "<null>";
+                 char name_buf[40];
+
+                 if (ELF_ST_TYPE (psym->st_info) == STT_SECTION)
+                   {
+                     bfd_vma sec_index = (bfd_vma) -1;
+
+                     if (psym->st_shndx < SHN_LORESERVE)
+                       sec_index = psym->st_shndx;
+                     else if (psym->st_shndx > SHN_LORESERVE)
+                       sec_index = psym->st_shndx - (SHN_HIRESERVE + 1
+                                                     - SHN_LORESERVE);
+
+                     if (sec_index != (bfd_vma) -1)
+                       sec_name = SECTION_NAME (section_headers + sec_index);
+                     else if (psym->st_shndx == SHN_ABS)
+                       sec_name = "ABS";
+                     else if (psym->st_shndx == SHN_COMMON)
+                       sec_name = "COMMON";
+                     else
+                       {
+                         sprintf (name_buf, "<section 0x%x>",
+                                  (unsigned int) psym->st_shndx);
+                         sec_name = name_buf;
+                       }
+                   }
+                 print_symbol (22, sec_name);
+               }
              else if (strtab == NULL)
                printf (_("<string table index %3ld>"), psym->st_name);
              else
@@ -3414,6 +3442,7 @@ process_section_headers (file)
   dynamic_symbols = NULL;
   dynamic_strings = NULL;
   dynamic_syminfo = NULL;
+  symtab_shndx_hdr = NULL;
 
   for (i = 0, section = section_headers;
        i < elf_header.e_shnum;
@@ -7740,8 +7769,8 @@ read_and_display_attr_value (attribute, form, data, cu_offset, pointer_size)
       break;
 
     case DW_FORM_strp:
-      printf (_(" (indirect string, offset: 0x%lx): "), uvalue);
-      printf (fetch_indirect_string (uvalue));
+      printf (_(" (indirect string, offset: 0x%lx): %s"),
+             uvalue, fetch_indirect_string (uvalue));
       break;
 
     case DW_FORM_indirect:
@@ -8380,7 +8409,11 @@ display_debug_frames (section, start, file)
       length = byte_get (start, 4); start += 4;
 
       if (length == 0)
-       return 1;
+       {
+         printf ("\n%08lx ZERO terminator\n\n",
+                   (unsigned long)(saved_start - section_start));
+         return 1;
+       }
 
       if (length == 0xffffffff)
        {
@@ -8534,6 +8567,8 @@ display_debug_frames (section, start, file)
            encoded_ptr_size = size_of_encoded_value (fc->fde_encoding);
 
          fc->pc_begin = byte_get (start, encoded_ptr_size);
+         if ((fc->fde_encoding & 0x70) == DW_EH_PE_pcrel)
+           fc->pc_begin += section->sh_addr + (start - section_start);
          start += encoded_ptr_size;
          fc->pc_range = byte_get (start, encoded_ptr_size);
          start += encoded_ptr_size;
@@ -8713,6 +8748,8 @@ display_debug_frames (section, start, file)
 
            case DW_CFA_set_loc:
              vma = byte_get (start, encoded_ptr_size);
+             if ((fc->fde_encoding & 0x70) == DW_EH_PE_pcrel)
+               vma += section->sh_addr + (start - section_start);
              start += encoded_ptr_size;
              if (do_debug_frames_interp)
                frame_display_row (fc, &need_col_headers, &max_regs);