Only pad the tesxt section if the data section is going to follow it.
authorNick Clifton <nickc@redhat.com>
Wed, 13 Jun 2001 07:58:05 +0000 (07:58 +0000)
committerNick Clifton <nickc@redhat.com>
Wed, 13 Jun 2001 07:58:05 +0000 (07:58 +0000)
bfd/ChangeLog
bfd/aoutx.h

index eea5f48826fa0bb11d217f2a7bb6d26bc98591a9..c2f627792f3a7a9a6e15aa03497ded47b4e43eb8 100644 (file)
@@ -1,3 +1,8 @@
+2001-06-13  Nick Clifton  <nickc@cambridge.redhat.com>
+
+       * aoutx.h (adjust_z_magic): Only pad the tesxt section if the data
+       section is going to follow it.
+
 2001-06-12  Catherine Moore  <clm@redhat.com>
 
         * elflink.h (elf_gc_propagate_vtable_entries): Replace FILE_ALIGN
index 93b939a415edb922957a35809fefaf5d1b69ae14..6119564e237e5197a62a498fe53aeca3a5e10974 100644 (file)
@@ -1006,10 +1006,14 @@ adjust_z_magic (abfd, execp)
     }
   if (abdp && abdp->zmagic_mapped_contiguous)
     {
-      text_pad = (obj_datasec(abfd)->vma
-                 - obj_textsec(abfd)->vma
-                 - obj_textsec(abfd)->_raw_size);
-      obj_textsec(abfd)->_raw_size += text_pad;
+      asection * text = obj_textsec (abfd);
+      asection * data = obj_datasec (abfd);
+
+      text_pad = data->vma - (text->vma + text->_raw_size);
+      /* Only pad the text section if the data
+        section is going to be placed after it.  */
+      if (text_pad > 0)
+       text->_raw_size += text_pad;
     }
   obj_datasec(abfd)->filepos = (obj_textsec(abfd)->filepos
                                + obj_textsec(abfd)->_raw_size);