bfd/
[deliverable/binutils-gdb.git] / binutils / objdump.c
index b05c384717abae5fd7173d8040ccfae6e64fd9e5..265a8ead44f7467211a1b893fd2fb6faefd235a7 100644 (file)
@@ -1898,7 +1898,7 @@ disassemble_section (bfd *abfd, asection *section, void *info)
       bfd_boolean insns;
 
       addr = section->vma + addr_offset;
-      addr = (addr ^ sign_adjust) - sign_adjust;
+      addr = ((addr & ((sign_adjust << 1) - 1)) ^ sign_adjust) - sign_adjust;
 
       if (sym != NULL && bfd_asymbol_value (sym) <= addr)
        {
@@ -1961,7 +1961,8 @@ disassemble_section (bfd *abfd, asection *section, void *info)
       else
        nextstop_offset = bfd_asymbol_value (nextsym) - section->vma;
 
-      if (nextstop_offset > stop_offset)
+      if (nextstop_offset > stop_offset
+         || nextstop_offset <= addr_offset)
        nextstop_offset = stop_offset;
 
       /* If a symbol is explicitly marked as being an object
@@ -1984,7 +1985,7 @@ disassemble_section (bfd *abfd, asection *section, void *info)
       disassemble_bytes (pinfo, paux->disassemble_fn, insns, data,
                         addr_offset, nextstop_offset,
                         rel_offset, &rel_pp, rel_ppend);
-
+      
       addr_offset = nextstop_offset;
       sym = nextsym;
     }
@@ -2122,12 +2123,12 @@ disassemble_data (bfd *abfd)
   free (sorted_syms);
 }
 \f
-int
-load_debug_section (enum dwarf_section_display_enum debug, void *file)
+static int
+load_specific_debug_section (enum dwarf_section_display_enum debug,
+                            asection *sec, void *file)
 {
   struct dwarf_section *section = &debug_displays [debug].section;
   bfd *abfd = file;
-  asection *sec;
   bfd_boolean ret;
   int section_is_compressed;
 
@@ -2135,18 +2136,6 @@ load_debug_section (enum dwarf_section_display_enum debug, void *file)
   if (section->start != NULL)
     return 1;
 
-  /* Locate the debug section.  */
-  sec = bfd_get_section_by_name (abfd, section->uncompressed_name);
-  if (sec != NULL)
-    section->name = section->uncompressed_name;
-  else
-    {
-      sec = bfd_get_section_by_name (abfd, section->compressed_name);
-      if (sec != NULL)
-       section->name = section->compressed_name;
-    }
-  if (sec == NULL)
-    return 0;
   section_is_compressed = section->name == section->compressed_name;
 
   section->address = 0;
@@ -2182,7 +2171,34 @@ load_debug_section (enum dwarf_section_display_enum debug, void *file)
       section->size = size;
     }
 
-  return ret;
+  return 1;
+}
+
+int
+load_debug_section (enum dwarf_section_display_enum debug, void *file)
+{
+  struct dwarf_section *section = &debug_displays [debug].section;
+  bfd *abfd = file;
+  asection *sec;
+
+  /* If it is already loaded, do nothing.  */
+  if (section->start != NULL)
+    return 1;
+
+  /* Locate the debug section.  */
+  sec = bfd_get_section_by_name (abfd, section->uncompressed_name);
+  if (sec != NULL)
+    section->name = section->uncompressed_name;
+  else
+    {
+      sec = bfd_get_section_by_name (abfd, section->compressed_name);
+      if (sec != NULL)
+        section->name = section->compressed_name;
+    }
+  if (sec == NULL)
+    return 0;
+
+  return load_specific_debug_section (debug, sec, file);
 }
 
 void
@@ -2222,7 +2238,11 @@ dump_dwarf_section (bfd *abfd, asection *section,
          {
            struct dwarf_section *sec = &debug_displays [i].section;
 
-           if (load_debug_section (i, abfd))
+           if (strcmp (sec->uncompressed_name, match) == 0)
+             sec->name = sec->uncompressed_name;
+           else
+             sec->name = sec->compressed_name;
+           if (load_specific_debug_section (i, section, abfd))
              {
                debug_displays [i].display (sec, abfd);
 
This page took 0.025299 seconds and 4 git commands to generate.