aboutsummaryrefslogtreecommitdiff
path: root/bfd/som.c
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>1994-03-19 15:08:12 +0000
committerJeff Law <law@redhat.com>1994-03-19 15:08:12 +0000
commit00806436cdfc323bfa857e5266e01142ff911eae (patch)
treebe6943265f2c724dbe90d48134de71832f0f9d69 /bfd/som.c
parent157669175157e845aa1fa2bf52f5be07ed497005 (diff)
downloadgdb-00806436cdfc323bfa857e5266e01142ff911eae.zip
gdb-00806436cdfc323bfa857e5266e01142ff911eae.tar.gz
gdb-00806436cdfc323bfa857e5266e01142ff911eae.tar.bz2
* 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.
Diffstat (limited to 'bfd/som.c')
-rw-r--r--bfd/som.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/bfd/som.c b/bfd/som.c
index c3bef32..f17e064 100644
--- 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);