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]

[PATCH] - fix offsets in DWARF when linking relocatable (-r)


Hi folks,

We noticed that when linking together object files with DWARF debug
info in relocatable mode resulting DWARF debug info is not correct
because relocations are used to describe offsets in other sections.
And since RELA is used for PPC that offsetes are kept in relocation 
itself not in actual debug section. That patch fix that. It updates
offsets in debug sections as well. It's safe: they will be 
overwritten at final link time. But that makes possible to debug
relocatable files as well as finally linked


------- ChangesLog ------------------------------------------------

2000-08-18  Igor Shevlyakov  <igor@windriver.com>

	* elf32-ppc.c (ppc_elf_relocate_section): Update offset
	values (from addend field) in .debug* sections.

------- diff ------------------------------------------------------

Index: elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.15
diff -c -3 -p -r1.15 elf32-ppc.c
*** elf32-ppc.c	2000/07/20 03:21:59	1.15
--- elf32-ppc.c	2000/08/18 14:50:48
*************** ppc_elf_relocate_section (output_bfd, in
*** 2941,2946 ****
--- 2941,2947 ----
        asection *sec			= (asection *)0;
        struct elf_link_hash_entry *h	= (struct elf_link_hash_entry *)0;
        const char *sym_name		= (const char *)0;
+       int update_data                   = 0;
        reloc_howto_type *howto;
        unsigned long r_symndx;
        bfd_vma relocation;
*************** ppc_elf_relocate_section (output_bfd, in
*** 2972,2978 ****
  	      if ((unsigned)ELF_ST_TYPE (sym->st_info) == STT_SECTION)
  		{
  		  sec = local_sections[r_symndx];
! 		  addend = rel->r_addend += sec->output_offset + sym->st_value;
  		}
  	    }
  
--- 2973,2988 ----
  	      if ((unsigned)ELF_ST_TYPE (sym->st_info) == STT_SECTION)
  		{
  		  sec = local_sections[r_symndx];
! 		  rel->r_addend += sec->output_offset + sym->st_value;
! 		  /* It safe to put real offset into .debug* sections
! 		     since it will be overwritten at final link. But
! 		     DWARF debug info will be correct even when
! 		     linking is relocatable.
! 		  */
! 		  if ((input_section->flags & SEC_DEBUGGING) == 0)
! 		    addend = rel->r_addend;
! 		  else
! 		    update_data = 1;
  		}
  	    }
  
*************** ppc_elf_relocate_section (output_bfd, in
*** 2984,2990 ****
  		   (long)offset,
  		   (long)addend);
  #endif
! 	  continue;
  	}
  
        /* This is a final link.  */
--- 2994,3001 ----
  		   (long)offset,
  		   (long)addend);
  #endif
! 	  if (!update_data)
! 	    continue;
  	}
  
        /* This is a final link.  */

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