Attached is a patch that updates elf2flt support for microblaze:

 * Handling for new reloc type R_MICROBLAZE_32_PCREL_LO (we can just ignore it)
 * remove workarounds for old microblaze linker bugs, fixed in 2.16
 * Tweak configure{.in} to indicate that MicroBlaze needs the
--disable-emit-relocs switch

signed-off-by: John Williams <john.willi...@petalogix.com>

 configure    |    2 +-
 configure.in |    2 +-
 elf2flt.c    |   28 +++++-----------------------
 3 files changed, 7 insertions(+), 25 deletions(-)
? microblaze-elf2flt-update.patch
Index: configure
===================================================================
RCS file: /var/cvs/elf2flt/configure,v
retrieving revision 1.17
diff -u -r1.17 configure
--- configure	7 May 2009 23:09:35 -0000	1.17
+++ configure	17 May 2009 03:10:00 -0000
@@ -1355,7 +1355,7 @@
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --disable-got-check - disable check for GOT (needed on H8)
- --disable-emit-relocs - don't use the --emit-relocs (-q) linker option
+ --disable-emit-relocs - don't use the --emit-relocs (-q) linker option (needed on MicroBlaze)
   --enable-emit-ctor-dtor manually create ctor/dtor list
 
 Optional Packages:
Index: configure.in
===================================================================
RCS file: /var/cvs/elf2flt/configure.in,v
retrieving revision 1.16
diff -u -r1.16 configure.in
--- configure.in	7 May 2009 06:14:27 -0000	1.16
+++ configure.in	17 May 2009 03:10:00 -0000
@@ -50,7 +50,7 @@
 )
 
 AC_ARG_ENABLE(emit_relocs,
-	[ --disable-emit-relocs - don't use the --emit-relocs (-q) linker option ],
+	[ --disable-emit-relocs - don't use the --emit-relocs (-q) linker option (needed on MicroBlaze)],
 	[ emit_relocs=$enableval ],
 	[ emit_relocs=yes ]
 )
Index: elf2flt.c
===================================================================
RCS file: /var/cvs/elf2flt/elf2flt.c,v
retrieving revision 1.57
diff -u -r1.57 elf2flt.c
--- elf2flt.c	7 May 2009 06:23:02 -0000	1.57
+++ elf2flt.c	17 May 2009 03:10:01 -0000
@@ -522,6 +522,7 @@
 			{
 			case R_MICROBLAZE_NONE:
 			case R_MICROBLAZE_64_NONE:
+			case R_MICROBLAZE_32_PCREL_LO:
 				continue;
 			}
 #endif /* TARGET_microblaze */
@@ -979,15 +980,11 @@
 		   the relocation symbol. */
 				{
 					unsigned char *p = r_mem;
-					uint32_t offset;
 					pflags=0x80000000;
 
 					/* work out the relocation */
 					sym_vma = bfd_section_vma(abs_bfd, sym_section);
-					/* grab any offset from the text */
-					offset = (p[2]<<24) + (p[3] << 16) + (p[6] << 8) + (p[7]);
-					/* Update the address */
-					sym_addr += offset + sym_vma + q->addend;
+					sym_addr += sym_vma + q->addend;
 					/* Write relocated pointer back */
 					p[2] = (sym_addr >> 24) & 0xff;
 					p[3] = (sym_addr >> 16) & 0xff;
@@ -1019,36 +1016,21 @@
 				case R_MICROBLAZE_32:
 				{	
 					unsigned char *p = r_mem;
-					unsigned long offset;
 
-					/* grab any offset from the text */
-					offset = (p[0]<<24) + (p[1] << 16) + (p[2] << 8) + (p[3]);
 					sym_vma = bfd_section_vma(abs_bfd, sym_section);
-					/* This is a horrible kludge.  For some
-					   reason, *sometimes* the offset is in
-					   both addend and the code.  Detect
-					   it, and cancel the effect.  Otherwise
-					   the offset gets added twice - ouch.
-					   There should be a better test
-					   for this condition, based on the
-					   BFD data structures */
-					if(offset==q->addend)
-						offset=0;
-
-					sym_addr += offset + sym_vma + q->addend;
+					sym_addr += sym_vma + q->addend;
 					relocation_needed = 1;
 					break;
 				}
 				case R_MICROBLAZE_64_PCREL:
 					sym_vma = 0;
-					//sym_addr = (*(q->sym_ptr_ptr))->value;
 					sym_addr += sym_vma + q->addend;
 					sym_addr -= (q->address + 4);
 					sym_addr = htonl(sym_addr);
 					/* insert 16 MSB */
-					* ((unsigned short *) (r_mem+2)) |= (sym_addr) & 0xFFFF;
+					* ((unsigned short *) (r_mem+2)) = (sym_addr) & 0xFFFF;
 					/* then 16 LSB */
-					* ((unsigned short *) (r_mem+6)) |= (sym_addr >> 16) & 0xFFFF;
+					* ((unsigned short *) (r_mem+6)) = (sym_addr >> 16) & 0xFFFF;
 					/* We've done all the work, so continue
 					   to next reloc instead of break */
 					continue;
_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to