aboutsummaryrefslogtreecommitdiff
path: root/bfd/aoutx.h
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2007-08-01 07:43:36 +0000
committerAlan Modra <amodra@gmail.com>2007-08-01 07:43:36 +0000
commitf6e688f76be9d0327cabd52f5f75478abaace764 (patch)
treee7bdd580eb22cbf259b0590a74215882787866b9 /bfd/aoutx.h
parenta0ac008e3e98e660e7c82d7ec595e04542fea683 (diff)
downloadgdb-f6e688f76be9d0327cabd52f5f75478abaace764.zip
gdb-f6e688f76be9d0327cabd52f5f75478abaace764.tar.gz
gdb-f6e688f76be9d0327cabd52f5f75478abaace764.tar.bz2
PR4694
* aoutx.h (final_link): Write a zero in first word of stringtab if no symbols rather than corrupting last byte of text/data.
Diffstat (limited to 'bfd/aoutx.h')
-rw-r--r--bfd/aoutx.h17
1 files changed, 7 insertions, 10 deletions
diff --git a/bfd/aoutx.h b/bfd/aoutx.h
index af7d45b..2b5507e 100644
--- a/bfd/aoutx.h
+++ b/bfd/aoutx.h
@@ -5557,22 +5557,19 @@ NAME (aout, final_link) (bfd *abfd,
exec_hdr (abfd)->a_drsize / obj_reloc_entry_size (abfd);
/* Write out the string table, unless there are no symbols. */
+ if (bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET) != 0)
+ goto error_return;
if (abfd->symcount > 0)
{
- if (bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET) != 0
- || ! emit_stringtab (abfd, aout_info.strtab))
+ if (!emit_stringtab (abfd, aout_info.strtab))
goto error_return;
}
- else if (obj_textsec (abfd)->reloc_count == 0
- && obj_datasec (abfd)->reloc_count == 0)
+ else
{
- bfd_byte b;
- file_ptr pos;
+ bfd_byte b[BYTES_IN_WORD];
- b = 0;
- pos = obj_datasec (abfd)->filepos + exec_hdr (abfd)->a_data - 1;
- if (bfd_seek (abfd, pos, SEEK_SET) != 0
- || bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1)
+ memset (b, 0, BYTES_IN_WORD);
+ if (bfd_bwrite (b, (bfd_size_type) BYTES_IN_WORD, abfd) != BYTES_IN_WORD)
goto error_return;
}