This is the mail archive of the binutils@sources.redhat.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]
Other format: [Raw text]

RFA: readelf relocations, part


The easier part; some bugs in RELA handling for .debug_info.  Speaks for
itself, really.

 - A .rela.debug_info section of size 0 would cause display_debug_info to
return without processing .debug_info.  I have a GCC/binutils combination
which produces this in object files, for some reason.  We should be
tolerant.
 - Offsets into the .debug_abbrev section, which is unmapped, will be
against symbol 0.  Allow that.
 - Ignore the value already in the offset if we find a relocation; this is
RELA.

OK?

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

2002-10-04  Daniel Jacobowitz  <drow@mvista.com>

	* readelf.c (display_debug_inf): Ignore empty .rela.debug_info
	sections.  Allow relocations against the absolute symbol.  Don't
	use the value in compunit.cu_abbrev_offset if we found a RELA
	relocation.

Index: readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.175
diff -u -p -r1.175 readelf.c
--- readelf.c	1 Oct 2002 03:27:56 -0000	1.175
+++ readelf.c	4 Oct 2002 14:17:54 -0000
@@ -7978,7 +7978,8 @@ display_debug_info (section, start, file
 	  Elf_Internal_Sym *sym;
 
 	  if (relsec->sh_type != SHT_RELA
-	      || SECTION_HEADER (relsec->sh_info) != section)
+	      || SECTION_HEADER (relsec->sh_info) != section
+	      || relsec->sh_size == 0)
 	    continue;
 
 	  if (!slurp_rela_relocs (file, relsec->sh_offset, relsec->sh_size,
@@ -7999,7 +8000,8 @@ display_debug_info (section, start, file
 		{
 		  sym = symtab + ELF32_R_SYM (rp->r_info);
 
-		  if (ELF32_ST_TYPE (sym->st_info) != STT_SECTION)
+		  if (ELF32_R_SYM (rp->r_info) != 0
+		      && ELF32_ST_TYPE (sym->st_info) != STT_SECTION)
 		    {
 		      warn (_("Skipping unexpected symbol type %u\n"),
 			    ELF32_ST_TYPE (sym->st_info));
@@ -8010,7 +8012,8 @@ display_debug_info (section, start, file
 		{
 		  sym = symtab + ELF64_R_SYM (rp->r_info);
 
-		  if (ELF64_ST_TYPE (sym->st_info) != STT_SECTION)
+		  if (ELF64_R_SYM (rp->r_info) != 0
+		      && ELF64_ST_TYPE (sym->st_info) != STT_SECTION)
 		    {
 		      warn (_("Skipping unexpected symbol type %u\n"),
 			    ELF64_ST_TYPE (sym->st_info));
@@ -8018,7 +8021,7 @@ display_debug_info (section, start, file
 		    }
 		}
 
-	      compunit.cu_abbrev_offset += rp->r_addend;
+	      compunit.cu_abbrev_offset = rp->r_addend;
 	      break;
 	    }
 


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