This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
empty relocation tables
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: binutils at sources dot redhat dot com
- Date: Tue, 19 Nov 2002 16:49:32 +0000
- Subject: empty relocation tables
- Organization: Codesourcery LLC
Hi,
this patch fixes a problem encountered by a WindRiver customer. A section
with no relocations caused a segfault. Fixed thusly. Ok?
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2002-11-19 Nathan Sidwell <nathan@codesourcery.com>
* elflink.h (elf_link_output_relocs): Do nothing if input section
size is zero.
Index: elflink.h
===================================================================
RCS file: /cvs/src/src/bfd/elflink.h,v
retrieving revision 1.193
diff -c -3 -p -r1.193 elflink.h
*** elflink.h 4 Nov 2002 13:20:56 -0000 1.193
--- elflink.h 19 Nov 2002 15:07:48 -0000
*************** elf_bfd_final_link (abfd, info)
*** 5063,5068 ****
--- 5063,5074 ----
if ((sec->flags & SEC_RELOC) != 0)
{
size_t ext_size;
+ if (!input_rel_hdr->sh_size)
+ /* There are no relocations. We can't let this just fall through
+ though, as INTERNAL_RELOCS could be zero, and we fail to set
+ OUTPUT_REL_HDR too. */
+ return;
+
ext_size = elf_section_data (sec)->rel_hdr.sh_size;
if (ext_size > max_external_reloc_size)