This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
RFA: Don't crash when closing a relocatable file opened both_direction
- From: Daniel Jacobowitz <drow at false dot org>
- To: binutils at sourceware dot org
- Date: Wed, 8 Jun 2005 17:52:26 -0400
- Subject: RFA: Don't crash when closing a relocatable file opened both_direction
sec->orelocation is set in final_link. So if we've opened an input file and
want to write it out again, we shouldn't do anything with it. This shows up
as a crash in gdb -write.
OK?
--
Daniel Jacobowitz
CodeSourcery, LLC
2005-06-08 Daniel Jacobowitz <dan@codesourcery.com>
* elfcode.h (elf_write_relocs): Do nothing if there are no
relocations.
Index: elfcode.h
===================================================================
RCS file: /cvs/src/src/bfd/elfcode.h,v
retrieving revision 1.70
diff -u -p -r1.70 elfcode.h
--- elfcode.h 31 May 2005 19:32:29 -0000 1.70
+++ elfcode.h 8 Jun 2005 21:50:35 -0000
@@ -875,6 +875,12 @@ elf_write_relocs (bfd *abfd, asection *s
if (sec->reloc_count == 0)
return;
+ /* If we have opened an existing file for update, reloc_count may be
+ set even though we are not linking. In that case we have nothing
+ to do. */
+ if (sec->orelocation == NULL)
+ return;
+
rela_hdr = &elf_section_data (sec)->rel_hdr;
rela_hdr->sh_size = rela_hdr->sh_entsize * sec->reloc_count;