aboutsummaryrefslogtreecommitdiff
path: root/gas/write.c
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@cygnus>1993-07-19 20:05:16 +0000
committerKen Raeburn <raeburn@cygnus>1993-07-19 20:05:16 +0000
commit8d6c34a108d95fa9432d099f63472b8c0f8e33c4 (patch)
treec561e4084d51eeb2056bfa15b2709ba7e00809d2 /gas/write.c
parent4380166dfa7c9580ecd581b7496dfc0b5277a4c8 (diff)
downloadgdb-8d6c34a108d95fa9432d099f63472b8c0f8e33c4.zip
gdb-8d6c34a108d95fa9432d099f63472b8c0f8e33c4.tar.gz
gdb-8d6c34a108d95fa9432d099f63472b8c0f8e33c4.tar.bz2
(write_relocs): New function, split off from write_contents. Use memset
instead of bzero. (write_object_file): Apply write_relocs to each section before applying write_contents.
Diffstat (limited to 'gas/write.c')
-rw-r--r--gas/write.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/gas/write.c b/gas/write.c
index ca7c625..8a480f1 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -476,7 +476,7 @@ adjust_reloc_syms (abfd, sec, xxx)
}
static void
-write_contents (abfd, sec, xxx)
+write_relocs (abfd, sec, xxx)
bfd *abfd;
asection *sec;
char *xxx;
@@ -503,7 +503,7 @@ write_contents (abfd, sec, xxx)
/* Set up reloc information as well. */
relocs = (arelent **) bfd_alloc_by_size_t (stdoutput,
n * sizeof (arelent *));
- bzero ((char*)relocs, n * sizeof (arelent*));
+ memset ((char*)relocs, 0, n * sizeof (arelent*));
i = 0;
for (fixp = seginfo->fix_root; fixp != (fixS *) NULL; fixp = fixp->fx_next)
@@ -527,6 +527,7 @@ write_contents (abfd, sec, xxx)
continue;
}
data = fixp->fx_frag->fr_literal + fixp->fx_where;
+ /* @@ Assumes max size of reloc is 4. */
if (fixp->fx_where + 4
> fixp->fx_frag->fr_fix + fixp->fx_frag->fr_offset)
abort ();
@@ -613,14 +614,30 @@ write_contents (abfd, sec, xxx)
}
}
#endif
+}
- /* Force calculations (size, vma) to get done. */
- bfd_set_section_contents (stdoutput, sec, "", 0, (addressT) 0);
+static void
+write_contents (abfd, sec, xxx)
+ bfd *abfd;
+ asection *sec;
+ char *xxx;
+{
+ segment_info_type *seginfo = seg_info (sec);
+ unsigned long offset = 0;
+ fragS *frags;
+ int i, n;
+ arelent **relocs;
+ fixS *fixp;
/* Write out the frags. */
if (! (bfd_get_section_flags (abfd, sec) & SEC_HAS_CONTENTS))
return;
+#if 0 /* Who cares? Let the first call, below, do it. */
+ /* Force calculations (size, vma) to get done. */
+ bfd_set_section_contents (stdoutput, sec, "", 0, (addressT) 0);
+#endif
+
for (frags = seginfo->frchainP->frch_root;
frags;
frags = frags->fr_next)
@@ -1281,6 +1298,8 @@ write_object_file ()
/* Now that all the sizes are known, and contents correct, we can
start writing the file. */
+ bfd_map_over_sections (stdoutput, write_relocs, (char *) 0);
+
bfd_map_over_sections (stdoutput, write_contents, (char *) 0);
output_file_close (out_file_name);