This is the mail archive of the binutils@sourceware.org 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]

d30v bandaids


D30V support in binutils is weird.  It looks to me like it was written
for REL (or copied from another REL target) and blindly changed to
RELA without making needed changes to gas and BFD.  For instance, D30V
gas always creates relocs with addends of zero and BFD pulls addends
out of the section contents.  The target may as well be REL.

This patch teaches readelf about the weirdness, and stops D30V gas
munging dwarf debug info.

binutils/
	* readelf.c (apply_relocations): D30V is really REL.
gas/
	* config/tc-d30v.c (d30v_cons_align): Don't align constants
	in debug sections.

Index: binutils/readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.509
diff -u -p -r1.509 readelf.c
--- binutils/readelf.c	23 Jul 2010 14:52:48 -0000	1.509
+++ binutils/readelf.c	2 Aug 2010 07:37:18 -0000
@@ -9657,13 +9657,17 @@ apply_relocations (void * file,
 	  addend = 0;
 	  if (is_rela)
 	    addend += rp->r_addend;
-	  /* R_XTENSA_32 and R_PJ_DATA_DIR32 are partial_inplace.  */
+	  /* R_XTENSA_32, R_PJ_DATA_DIR32 and R_D30V_32_NORMAL are
+	     partial_inplace.  */
 	  if (!is_rela
 	      || (elf_header.e_machine == EM_XTENSA
 		  && reloc_type == 1)
 	      || ((elf_header.e_machine == EM_PJ
 		   || elf_header.e_machine == EM_PJ_OLD)
-		  && reloc_type == 1))
+		  && reloc_type == 1)
+	      || ((elf_header.e_machine == EM_D30V
+		   || elf_header.e_machine == EM_CYGNUS_D30V)
+		  && reloc_type == 12))
 	    addend += byte_get (rloc, reloc_size);
 
 	  if (is_32bit_pcrel_reloc (reloc_type)
Index: gas/config/tc-d30v.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-d30v.c,v
retrieving revision 1.40
diff -u -p -r1.40 tc-d30v.c
--- gas/config/tc-d30v.c	28 Jun 2010 14:06:57 -0000	1.40
+++ gas/config/tc-d30v.c	2 Aug 2010 07:37:29 -0000
@@ -1884,6 +1884,10 @@ d30v_cons_align (int size)
 {
   int log_size;
 
+  /* Don't specially align anything in debug sections.  */
+  if ((now_seg->flags & SEC_ALLOC) == 0)
+    return;
+
   log_size = 0;
   while ((size >>= 1) != 0)
     ++log_size;

-- 
Alan Modra
Australia Development Lab, IBM


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