* som.c (som_begin_writing): Account for alignment needs of
authorJeff Law <law@redhat.com>
Sat, 19 Mar 1994 15:08:12 +0000 (15:08 +0000)
committerJeff Law <law@redhat.com>
Sat, 19 Mar 1994 15:08:12 +0000 (15:08 +0000)
        subspaces too when writing executables.  Never request a negative
        bss size.  Fixes some problems with demand paged executables,
        still having problems with pure executables and shared executables.

bfd/ChangeLog
bfd/som.c

index b8ea8a804653adb8f12d7a67275f32884d647bc6..4f1fcfc603bb32fd96ec7febdb6a2a41961de8d5 100644 (file)
@@ -1,3 +1,10 @@
+Sat Mar 19 07:06:59 1994  Jeffrey A. Law  (law@snake.cs.utah.edu)
+
+       * som.c (som_begin_writing): Account for alignment needs of
+       subspaces too when writing executables.  Never request a negative
+       bss size.  Fixes some problems with demand paged executables,
+       still having problems with pure executables and shared executables.
+
 Fri Mar 18 19:12:47 1994  Jim Kingdon  (kingdon@lioth.cygnus.com)
 
        * trad-core.c (trad_unix_core_file_p): Call bfd_zmalloc not
index c3bef323ef1597b1327326d56b05926e05f26742..f17e064899c2c88c55d5db90281260f339cf7627 100644 (file)
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -3001,6 +3001,27 @@ som_begin_writing (abfd)
              /* Only do this for the first subspace within each space.  */
              first_subspace = 0;
            }
+         else if (abfd->flags & EXEC_P)
+           {
+             /* Have to keep proper alignments for the subspaces
+                in executables too!  */
+             if (subsection->flags & SEC_CODE)
+               {
+                 unsigned tmp = exec_header.exec_tsize;
+
+                 tmp = SOM_ALIGN (tmp, 1 << subsection->alignment_power);
+                 current_offset += (tmp - exec_header.exec_tsize);
+                 exec_header.exec_tsize = tmp;
+               }
+             else
+               {
+                 unsigned tmp = exec_header.exec_dsize;
+
+                 tmp = SOM_ALIGN (tmp, 1 << subsection->alignment_power);
+                 current_offset += (tmp - exec_header.exec_dsize);
+                 exec_header.exec_dsize = tmp;
+               }
+           }
 
          subsection->target_index = total_subspaces++;
          /* This is real data to be loaded from the file.  */
@@ -3127,6 +3148,8 @@ som_begin_writing (abfd)
       tmp = exec_header.exec_dsize;
       tmp = SOM_ALIGN (tmp, PA_PAGESIZE);
       exec_header.exec_bsize -= (tmp - exec_header.exec_dsize);
+      if (exec_header.exec_bsize < 0)
+       exec_header.exec_bsize = 0;
       exec_header.exec_dsize = tmp;
 
       bfd_seek (abfd, obj_som_file_hdr (abfd)->aux_header_location, SEEK_SET);