* aoutx.h (final_link): Write a zero in first word of
	stringtab if no symbols rather than corrupting last byte
	of text/data.
This commit is contained in:
Alan Modra 2007-08-01 07:43:36 +00:00
parent a0ac008e3e
commit f6e688f76b
2 changed files with 14 additions and 10 deletions

View file

@ -1,3 +1,10 @@
2007-08-01 Alan Modra <amodra@bigpond.net.au>
PR4694
* aoutx.h (final_link): Write a zero in first word of
stringtab if no symbols rather than corrupting last byte
of text/data.
2007-07-31 Jakub Jelinek <jakub@redhat.com> 2007-07-31 Jakub Jelinek <jakub@redhat.com>
* elf.c (get_program_header_size): Adjacent loadable .note* * elf.c (get_program_header_size): Adjacent loadable .note*

View file

@ -5557,22 +5557,19 @@ NAME (aout, final_link) (bfd *abfd,
exec_hdr (abfd)->a_drsize / obj_reloc_entry_size (abfd); exec_hdr (abfd)->a_drsize / obj_reloc_entry_size (abfd);
/* Write out the string table, unless there are no symbols. */ /* 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 (abfd->symcount > 0)
{ {
if (bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET) != 0 if (!emit_stringtab (abfd, aout_info.strtab))
|| ! emit_stringtab (abfd, aout_info.strtab))
goto error_return; goto error_return;
} }
else if (obj_textsec (abfd)->reloc_count == 0 else
&& obj_datasec (abfd)->reloc_count == 0)
{ {
bfd_byte b; bfd_byte b[BYTES_IN_WORD];
file_ptr pos;
b = 0; memset (b, 0, BYTES_IN_WORD);
pos = obj_datasec (abfd)->filepos + exec_hdr (abfd)->a_data - 1; if (bfd_bwrite (b, (bfd_size_type) BYTES_IN_WORD, abfd) != BYTES_IN_WORD)
if (bfd_seek (abfd, pos, SEEK_SET) != 0
|| bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1)
goto error_return; goto error_return;
} }