* merge.c (sec_merge_emit): Do not zero pad sections that do not
authorNick Clifton <nickc@redhat.com>
Fri, 20 Aug 2010 14:41:48 +0000 (14:41 +0000)
committerNick Clifton <nickc@redhat.com>
Fri, 20 Aug 2010 14:41:48 +0000 (14:41 +0000)
        have an alignment.

bfd/ChangeLog
bfd/merge.c

index cfe91d979bfa760cc0305d2498e1f47623810b1c..9a52165d796a2e2ea8140edb253a5c13e35c066e 100644 (file)
@@ -1,3 +1,8 @@
+2010-08-20  Nick Clifton  <nickc@redhat.com>
+
+       * merge.c (sec_merge_emit): Do not zero pad sections that do not
+       have an alignment.
+
 2010-08-18  Pedro Alves  <pedro@codesourcery.com>
 
        PR corefile/8210
index 7aa088ff94734a50eb070351849507b567498f38..180af267a219bcaf970e19f0d421f4a75b398899 100644 (file)
@@ -307,6 +307,9 @@ sec_merge_emit (bfd *abfd, struct sec_merge_hash_entry *entry)
       len = -off & (entry->alignment - 1);
       if (len != 0)
        {
+         /* We should never have an entry with an alignment
+            greater than the section's alignment.  */
+         BFD_ASSERT (len <= (bfd_size_type) (1 << alignment_power));
          if (bfd_bwrite (pad, len, abfd) != len)
            goto err;
          off += len;
@@ -324,6 +327,7 @@ sec_merge_emit (bfd *abfd, struct sec_merge_hash_entry *entry)
   /* Trailing alignment needed?  */
   off = sec->size - off;
   if (off != 0
+      && alignment_power
       && bfd_bwrite (pad, off, abfd) != off)
     goto err;