2009-03-12 Andrew Stubbs <ams@codesourcery.com>
authorAndrew Stubbs <andrew.stubbs@st.com>
Thu, 12 Mar 2009 10:57:18 +0000 (10:57 +0000)
committerAndrew Stubbs <andrew.stubbs@st.com>
Thu, 12 Mar 2009 10:57:18 +0000 (10:57 +0000)
* dwarf2.c (read_section): Always check the offset, even when the
section has been read before.

bfd/ChangeLog
bfd/dwarf2.c

index afc0177dc437ad6dac627b51bc7f1af7860e662b..3cc217a5dc6debfc80e2a652501d0469cd2d4c47 100644 (file)
@@ -1,3 +1,8 @@
+2009-03-12  Andrew Stubbs  <ams@codesourcery.com>
+
+       * dwarf2.c (read_section): Always check the offset, even when the
+       section has been read before.
+
 2009-03-11  H.J. Lu  <hongjiu.lu@intel.com>
 
        * elf32-i386.c (elf_i386_check_tls_transition): Fix a typo in
index 0c18253405092ef61f914aa3ac2d65b08db8f350..40b83b717518b9d121f7570c4e334e402f70b9c1 100644 (file)
@@ -417,49 +417,49 @@ read_section (bfd *           abfd,
   bfd_boolean section_is_compressed = FALSE;
 
   /* read_section is a noop if the section has already been read.  */
-  if (*section_buffer)
-    return TRUE;
-
-  msec = bfd_get_section_by_name (abfd, section_name);
-  if (! msec && compressed_section_name)
-    {
-      msec = bfd_get_section_by_name (abfd, compressed_section_name);
-      section_is_compressed = TRUE;
-    }
-  if (! msec)
-    {
-      (*_bfd_error_handler) (_("Dwarf Error: Can't find %s section."), section_name);
-      bfd_set_error (bfd_error_bad_value);
-      return FALSE;
-    }
-
-  if (syms)
-    {
-      *section_size = msec->size;
-      *section_buffer
-         = bfd_simple_get_relocated_section_contents (abfd, msec, NULL, syms);
-      if (! *section_buffer)
-       return FALSE;
-    }
-  else
+  if (!*section_buffer)
     {
-      *section_size = msec->rawsize ? msec->rawsize : msec->size;
-      *section_buffer = bfd_malloc (*section_size);
-      if (! *section_buffer)
-       return FALSE;
-      if (! bfd_get_section_contents (abfd, msec, *section_buffer,
-                                     0, *section_size))
-       return FALSE;
-    }
-
-  if (section_is_compressed)
-    {
-      if (! bfd_uncompress_section_contents (section_buffer, section_size))
+      msec = bfd_get_section_by_name (abfd, section_name);
+      if (! msec && compressed_section_name)
+       {
+         msec = bfd_get_section_by_name (abfd, compressed_section_name);
+         section_is_compressed = TRUE;
+       }
+      if (! msec)
        {
-         (*_bfd_error_handler) (_("Dwarf Error: unable to decompress %s section."), compressed_section_name);
+         (*_bfd_error_handler) (_("Dwarf Error: Can't find %s section."), section_name);
          bfd_set_error (bfd_error_bad_value);
          return FALSE;
        }
+
+      if (syms)
+       {
+         *section_size = msec->size;
+         *section_buffer
+             = bfd_simple_get_relocated_section_contents (abfd, msec, NULL, syms);
+         if (! *section_buffer)
+           return FALSE;
+       }
+      else
+       {
+         *section_size = msec->rawsize ? msec->rawsize : msec->size;
+         *section_buffer = bfd_malloc (*section_size);
+         if (! *section_buffer)
+           return FALSE;
+         if (! bfd_get_section_contents (abfd, msec, *section_buffer,
+                                         0, *section_size))
+           return FALSE;
+       }
+
+      if (section_is_compressed)
+       {
+         if (! bfd_uncompress_section_contents (section_buffer, section_size))
+           {
+             (*_bfd_error_handler) (_("Dwarf Error: unable to decompress %s section."), compressed_section_name);
+             bfd_set_error (bfd_error_bad_value);
+             return FALSE;
+           }
+       }
     }
 
   /* It is possible to get a bad value for the offset into the section