From: Daniel Jacobowitz Date: Tue, 17 May 2005 19:44:55 +0000 (+0000) Subject: * elf.c (_bfd_elf_write_object_contents): Check for non-NULL X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=26ae6d5ed03b3e749598b33ffd0aaefbaf9a6d7d;p=binutils-gdb.git * elf.c (_bfd_elf_write_object_contents): Check for non-NULL elf_shstrtab. * format.c (bfd_check_format_matches): Set output_has_begun for both_direction. * section.c (bfd_set_section_contents): Use bfd_write_p. Remove special case for both_direction. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index c6ecec74e71..ed035b7c29e 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,12 @@ +2005-05-17 Daniel Jacobowitz + + * elf.c (_bfd_elf_write_object_contents): Check for non-NULL + elf_shstrtab. + * format.c (bfd_check_format_matches): Set output_has_begun + for both_direction. + * section.c (bfd_set_section_contents): Use bfd_write_p. Remove + special case for both_direction. + 2005-05-17 Nick Clifton * elf.c (group_signature): Check for a group section which is diff --git a/bfd/elf.c b/bfd/elf.c index 5a97580d14d..3ef04d4e2cc 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -4950,8 +4950,9 @@ _bfd_elf_write_object_contents (bfd *abfd) } /* Write out the section header names. */ - if (bfd_seek (abfd, elf_tdata (abfd)->shstrtab_hdr.sh_offset, SEEK_SET) != 0 - || ! _bfd_elf_strtab_emit (abfd, elf_shstrtab (abfd))) + if (elf_shstrtab (abfd) != NULL + && (bfd_seek (abfd, elf_tdata (abfd)->shstrtab_hdr.sh_offset, SEEK_SET) != 0 + || ! _bfd_elf_strtab_emit (abfd, elf_shstrtab (abfd)))) return FALSE; if (bed->elf_backend_final_write_processing) diff --git a/bfd/format.c b/bfd/format.c index 3a36210cf0e..4ccca2a3aa7 100644 --- a/bfd/format.c +++ b/bfd/format.c @@ -173,6 +173,14 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching) if (matching) free (matching_vector); + /* If the file was opened for update, then `output_has_begun' + some time ago when the file was created. Do not recompute + sections sizes or alignments in _bfd_set_section_contents. + We can not set this flag until after checking the format, + because it will interfere with creation of BFD sections. */ + if (abfd->direction == both_direction) + abfd->output_has_begun = TRUE; + return TRUE; /* File position has moved, BTW. */ } @@ -319,6 +327,14 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching) if (matching) free (matching_vector); + /* If the file was opened for update, then `output_has_begun' + some time ago when the file was created. Do not recompute + sections sizes or alignments in _bfd_set_section_contents. + We can not set this flag until after checking the format, + because it will interfere with creation of BFD sections. */ + if (abfd->direction == both_direction) + abfd->output_has_begun = TRUE; + return TRUE; /* File position has moved, BTW. */ } diff --git a/bfd/section.c b/bfd/section.c index 4e46a5db330..75acad7752b 100644 --- a/bfd/section.c +++ b/bfd/section.c @@ -1346,22 +1346,10 @@ bfd_set_section_contents (bfd *abfd, return FALSE; } - switch (abfd->direction) + if (!bfd_write_p (abfd)) { - case read_direction: - case no_direction: bfd_set_error (bfd_error_invalid_operation); return FALSE; - - case write_direction: - break; - - case both_direction: - /* File is opened for update. `output_has_begun' some time ago when - the file was created. Do not recompute sections sizes or alignments - in _bfd_set_section_content. */ - abfd->output_has_begun = TRUE; - break; } /* Record a copy of the data in memory if desired. */