* readelf.c (process_program_headers): Use dynamic segment unless
authorAlan Modra <amodra@gmail.com>
Wed, 24 Oct 2007 02:27:15 +0000 (02:27 +0000)
committerAlan Modra <amodra@gmail.com>
Wed, 24 Oct 2007 02:27:15 +0000 (02:27 +0000)
dynamic section is found.

binutils/ChangeLog
binutils/readelf.c

index c2cc125be610bf92fd967132215860e6ae4279cb..689bb9c712a2c9999c67d8aee8d34c59f483cc40 100644 (file)
@@ -1,3 +1,9 @@
+2007-10-24  Tristan Gingold  <gingold@adacore.com>
+           Alan Modra  <amodra@bigpond.net.au>
+
+       * readelf.c (process_program_headers): Use dynamic segment unless
+       dynamic section is found.
+
 2007-10-16  Bob Wilson  <bob.wilson@acm.org>
 
        * doc/binutils.texi (objcopy, strip): Replace hyphens with em-dashes.
index e550f6fba7f1264756bf5bb96ab98ae285ec56cc..5ea766dac651be0d3987eb082e2a2dbb2698ffad 100644 (file)
@@ -3530,6 +3530,11 @@ process_program_headers (FILE *file)
          if (dynamic_addr)
            error (_("more than one dynamic segment\n"));
 
+         /* By default, assume that the .dynamic section is the first
+            section in the DYNAMIC segment.  */
+         dynamic_addr = segment->p_offset;
+         dynamic_size = segment->p_filesz;
+
          /* Try to locate the .dynamic section. If there is
             a section header table, we can easily locate it.  */
          if (section_headers != NULL)
@@ -3544,23 +3549,21 @@ process_program_headers (FILE *file)
                }
 
              if (sec->sh_type == SHT_NOBITS)
-               break;
+               {
+                 dynamic_size = 0;
+                 break;
+               }
 
              dynamic_addr = sec->sh_offset;
              dynamic_size = sec->sh_size;
 
              if (dynamic_addr < segment->p_offset
                  || dynamic_addr > segment->p_offset + segment->p_filesz)
-               warn (_("the .dynamic section is not contained within the dynamic segment\n"));
+               warn (_("the .dynamic section is not contained"
+                       " within the dynamic segment\n"));
              else if (dynamic_addr > segment->p_offset)
-               warn (_("the .dynamic section is not the first section in the dynamic segment.\n"));
-           }
-         else
-           {
-             /* Otherwise, we can only assume that the .dynamic
-                section is the first section in the DYNAMIC segment.  */
-             dynamic_addr = segment->p_offset;
-             dynamic_size = segment->p_filesz;
+               warn (_("the .dynamic section is not the first section"
+                       " in the dynamic segment.\n"));
            }
          break;