PR 273
authorDave Anglin <dave.anglin@nrc.ca>
Wed, 28 Jul 2004 22:23:53 +0000 (22:23 +0000)
committerDave Anglin <dave.anglin@nrc.ca>
Wed, 28 Jul 2004 22:23:53 +0000 (22:23 +0000)
* som.c (setup_sections): Improve estimation of space sizes in
relocatable objects.

bfd/ChangeLog
bfd/som.c

index beac39c2a3373c2ae0607d88a516908eb8e0d9b3..ef719fc301353dd84ebdd6b877ca26c4f9c4dade 100644 (file)
@@ -1,3 +1,10 @@
+2004-07-28  Nick Clifton  <nickc@redhat.com>
+           John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
+
+       PR 273
+       * som.c (setup_sections): Improve estimation of space sizes in
+       relocatable objects.
+
 2004-07-27  Jason Thorpe  <thorpej@wasabisystems.com>
        * config.bfd (hppa*-*-netbsd*): Set targ_defvec to
        bfd_elf32_hppa_nbsd_vec.  Add bfd_elf32_hppa_linux_vec
index 4b40f1bf12a28e3a3371c343e21f7fc189dea296..c35b344f1d0a5aa448815cb8ca02fe579303588b 100644 (file)
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -1913,6 +1913,7 @@ setup_sections (abfd, file_hdr, current_offset)
       struct som_subspace_dictionary_record subspace, save_subspace;
       unsigned int subspace_index;
       asection *space_asect;
+      bfd_size_type space_size = 0;
       char *newname;
 
       /* Read the space dictionary element.  */
@@ -2104,6 +2105,9 @@ setup_sections (abfd, file_hdr, current_offset)
          subspace_asect->alignment_power = exact_log2 (subspace.alignment);
          if (subspace_asect->alignment_power == (unsigned) -1)
            goto error_return;
+
+         /* Keep track of the accumulated sizes of the sections.  */
+         space_size += subspace.subspace_length;
        }
 
       /* This can happen for a .o which defines symbols in otherwise
@@ -2111,11 +2115,25 @@ setup_sections (abfd, file_hdr, current_offset)
       if (!save_subspace.file_loc_init_value)
        space_asect->size = 0;
       else
-       /* Setup the size for the space section based upon the info in the
-          last subspace of the space.  */
-       space_asect->size = (save_subspace.subspace_start
-                            - space_asect->vma
-                            + save_subspace.subspace_length);
+       {
+         if (file_hdr->a_magic != RELOC_MAGIC)
+           {
+             /* Setup the size for the space section based upon the info
+                in the last subspace of the space.  */
+             space_asect->size = (save_subspace.subspace_start
+                                  - space_asect->vma
+                                  + save_subspace.subspace_length);
+           }
+         else
+           {
+             /* The subspace_start field is not initialised in relocatable
+                only objects, so it cannot be used for length calculations.
+                Instead we use the space_size value which we have been
+                accumulating.  This isn't an accurate estimate since it
+                ignores alignment and ordering issues.  */
+             space_asect->size = space_size;
+           }
+       }
     }
   /* Now that we've read in all the subspace records, we need to assign
      a target index to each subspace.  */
This page took 0.029046 seconds and 4 git commands to generate.