Automatic date update in version.in
[deliverable/binutils-gdb.git] / bfd / merge.c
index 11be669c2c38057c546698cf18731c41b3c1efa3..0c6f7a10d3d8c67946e26be3880d1f2e1c75e531 100644 (file)
@@ -1,5 +1,5 @@
 /* SEC_MERGE support.
-   Copyright (C) 2001-2019 Free Software Foundation, Inc.
+   Copyright (C) 2001-2020 Free Software Foundation, Inc.
    Written by Jakub Jelinek <jakub@redhat.com>.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -292,8 +292,9 @@ sec_merge_emit (bfd *abfd, struct sec_merge_hash_entry *entry,
   asection *sec = secinfo->sec;
   char *pad = NULL;
   bfd_size_type off = 0;
-  int alignment_power = sec->output_section->alignment_power;
-  bfd_size_type pad_len;
+  unsigned int opb = bfd_octets_per_byte (abfd, sec);
+  int alignment_power = sec->output_section->alignment_power * opb;
+  bfd_size_type pad_len;  /* Octets.  */
 
   /* FIXME: If alignment_power is 0 then really we should scan the
      entry list for the largest required alignment and use that.  */
@@ -364,9 +365,11 @@ _bfd_add_merge_section (bfd *abfd, void **psinfo, asection *sec,
 {
   struct sec_merge_info *sinfo;
   struct sec_merge_sec_info *secinfo;
-  unsigned int align;
+  unsigned int alignment_power;  /* Octets.  */
+  unsigned int align;            /* Octets.  */
   bfd_size_type amt;
   bfd_byte *contents;
+  unsigned int opb = bfd_octets_per_byte (abfd, sec);
 
   if ((abfd->flags & DYNAMIC) != 0
       || (sec->flags & SEC_MERGE) == 0)
@@ -389,10 +392,11 @@ _bfd_add_merge_section (bfd *abfd, void **psinfo, asection *sec,
 #ifndef CHAR_BIT
 #define CHAR_BIT 8
 #endif
-  if (sec->alignment_power >= sizeof (align) * CHAR_BIT)
+  alignment_power = sec->alignment_power * opb;
+  if (alignment_power >= sizeof (align) * CHAR_BIT)
     return TRUE;
 
-  align = 1u << sec->alignment_power;
+  align = 1u << alignment_power;
   if ((sec->entsize < align
        && ((sec->entsize & (sec->entsize - 1))
           || !(sec->flags & SEC_STRINGS)))
@@ -549,7 +553,7 @@ record_section (struct sec_merge_info *sinfo,
 
   return TRUE;
 
-error_return:
+ error_return:
   for (secinfo = sinfo->chain; secinfo; secinfo = secinfo->next)
     *secinfo->psecinfo = NULL;
   return FALSE;
@@ -739,7 +743,7 @@ _bfd_merge_sections (bfd *abfd,
   for (sinfo = (struct sec_merge_info *) xsinfo; sinfo; sinfo = sinfo->next)
     {
       struct sec_merge_sec_info *secinfo;
-      bfd_size_type align;
+      bfd_size_type align;  /* Bytes.  */
 
       if (! sinfo->chain)
        continue;
@@ -764,8 +768,10 @@ _bfd_merge_sections (bfd *abfd,
              return FALSE;
            if (align)
              {
+               unsigned int opb = bfd_octets_per_byte (abfd, secinfo->sec);
+
                align = (bfd_size_type) 1 << secinfo->sec->alignment_power;
-               if ((secinfo->sec->size & (align - 1)) != 0)
+               if (((secinfo->sec->size / opb) & (align - 1)) != 0)
                  align = 0;
              }
          }
@@ -782,7 +788,7 @@ _bfd_merge_sections (bfd *abfd,
       else
        {
          struct sec_merge_hash_entry *e;
-         bfd_size_type size = 0;
+         bfd_size_type size = 0;  /* Octets.  */
 
          /* Things are much simpler for non-strings.
             Just assign them slots in the section.  */
This page took 0.028211 seconds and 4 git commands to generate.