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]

frv-elf linker doesn't handle SEC_MERGE properly


The frv-elf linker fails to take into account merged sections when
applying relocations, so we end up with debug info pointing outside
the debug string section (and probably even worse effects than this).
This patch fixes it.  Ok to install?

Index: bfd/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>, Nick Clifton  <nickc@redhat.com>

	* elf32-frv.c (elf32_frv_relocate_section): Adjust addend of
	relocation pointing to local symbol in merged section.

Index: bfd/elf32-frv.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-frv.c,v
retrieving revision 1.6
diff -u -p -r1.6 elf32-frv.c
--- bfd/elf32-frv.c 25 Jun 2003 06:40:24 -0000 1.6
+++ bfd/elf32-frv.c 26 Aug 2003 19:29:46 -0000
@@ -722,15 +722,27 @@ elf32_frv_relocate_section (output_bfd, 
 
       if (r_symndx < symtab_hdr->sh_info)
 	{
+	  asection *osec;
+
 	  sym = local_syms + r_symndx;
-	  sec = local_sections [r_symndx];
+	  osec = sec = local_sections [r_symndx];
+
+
+	  if ((sec->flags & SEC_MERGE)
+	      && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+	    /* This relocation is relative to a section symbol that is
+	       going to be merged.  Change it so that it is relative
+	       to the merged section symbol.  */
+	    rel->r_addend = _bfd_elf_rel_local_sym (output_bfd, sym, &sec,
+						    rel->r_addend);
+	  
 	  relocation = (sec->output_section->vma
 			+ sec->output_offset
 			+ sym->st_value);
 
 	  name = bfd_elf_string_from_elf_section
 	    (input_bfd, symtab_hdr->sh_link, sym->st_name);
-	  name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name;
+	  name = (name == NULL) ? bfd_section_name (input_bfd, osec) : name;
 	}
       else
 	{
-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer

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