[PATCH] MIPS/BFD: Handle linker garbage collection with n64 relocs

Hans-Peter Nilsson hans-peter.nilsson@axis.com
Mon May 7 05:46:00 GMT 2012


> From: "Maciej W. Rozycki" <macro@linux-mips.org>
> Date: Mon, 7 May 2012 05:28:31 +0200

>  I have applied this change now, thanks.

Outdated patch or lack of testing?  Your
RELOC_AGAINST_DISCARDED_SECTION macro assumes there's a variable
"i" it can use, which is probably true for only one target...
All others broke, as below.

/tmp/hpautotest-binutils/bsrc/src/bfd/elf32-arm.c: In function 'elf32_arm_relocate_section':
/tmp/hpautotest-binutils/bsrc/src/bfd/elf32-arm.c:10485: error: 'i' undeclared (first use in this function)
/tmp/hpautotest-binutils/bsrc/src/bfd/elf32-arm.c:10485: error: (Each undeclared identifier is reported only once
/tmp/hpautotest-binutils/bsrc/src/bfd/elf32-arm.c:10485: error: for each function it appears in.)
make[4]: *** [elf32-arm.lo] Error 1
make[4]: Leaving directory `/tmp/hpautotest-binutils/arm-unknown-eabi/bfd'

It seems there's some cleanup to do in the elfxx-mips.c use, as
its passed index (i) is always 0 (either wrong or confusing) and
the call is needlessly wrapped in do ... while (0).

Obvious fix (ok, "i_" is a nonobvious paint, meh) committed
after testing cris-elf, mipsisa32r2el-linux and arm-eabi.

bfd:
	* elf-bfd.h (RELOC_AGAINST_DISCARDED_SECTION): Declare and use
	local variable i_ instead of assuming and using a variable i.

Index: elf-bfd.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.336
diff -p -u -r1.336 elf-bfd.h
--- elf-bfd.h	7 May 2012 03:27:48 -0000	1.336
+++ elf-bfd.h	7 May 2012 05:42:55 -0000
@@ -2411,6 +2411,7 @@ extern asection _bfd_elf_large_com_secti
 					rel, count, relend,		\
 					howto, index, contents)		\
   {									\
+    int i_;								\
     _bfd_clear_contents (howto, input_bfd, input_section,		\
 			 contents + rel[index].r_offset);		\
 									\
@@ -2440,10 +2441,10 @@ extern asection _bfd_elf_large_com_secti
 	  }								\
       }									\
 									\
-    for (i = 0; i < count; i++)						\
+    for (i_ = 0; i_ < count; i_++)					\
       {									\
-	rel[i].r_info = 0;						\
-	rel[i].r_addend = 0;						\
+	rel[i_].r_info = 0;						\
+	rel[i_].r_addend = 0;						\
       }									\
     rel += count - 1;							\
     continue;								\

brgds, H-P



More information about the Binutils mailing list