This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

PATCH for elfcode.h



My last change to elfcode.h assumed that asect->reloc_count was valid.
That turns out not to be true for dynamic sections.  This patch, which
I took the liberty of checking in, avoids depending on that value.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

1999-06-12  Mark Mitchell  <mark@codesourcery.com>

	* elfcode.h (elf_slurp_reloc_table_from_section): Don't assume
	asect->reloc_count is valid.

Index: elfcode.h
===================================================================
RCS file: /cvs/binutils/binutils/bfd/elfcode.h,v
retrieving revision 1.3
diff -u -p -r1.3 elfcode.h
--- elfcode.h	1999/06/02 18:16:48	1.3
+++ elfcode.h	1999/06/13 00:52:40
@@ -1335,16 +1335,22 @@ elf_slurp_reloc_table (abfd, asect, symb
     }
   else
     {
+      /* Note that ASECT->RELOC_COUNT tends not to be accurate in this
+	 case because relocations against this section may use the
+	 dynamic symbol table, and in that case bfd_section_from_shdr
+	 in elf.c does not update the RELOC_COUNT.  */
       if (asect->_raw_size == 0)
 	return true;
 
       rel_hdr = &d->this_hdr;
       reloc_count = rel_hdr->sh_size / rel_hdr->sh_entsize;
       rel_hdr2 = NULL;
+      reloc_count2 = 0;
     }
 
-  relents = (arelent *) bfd_alloc (abfd, 
-				   asect->reloc_count * sizeof (arelent));
+  relents = ((arelent *) 
+	     bfd_alloc (abfd, 
+			(reloc_count + reloc_count2) * sizeof (arelent)));
   if (relents == NULL)
     return false;
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]