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]

ARM long branch stub: pic


Hello,

There is a bug when computing the target of a long branch stub in PIC mode (it jumps 4 bytes too far). I propose the attached patch.

Note that the current PIC stub is not correct (it uses a target address rather than an offset), I will send a separate patch for this later.

A Thumb mapping symbol was also missing in the short v4t thumb->arm stub, but this had no impact on the testsuite.

Validated on arm-none-eabi and arm-linux-gnueabi.

Christophe.
2009-02-04  Christophe Lyon  <christophe.lyon@st.com>

	bfd/
	* elf32-arm.c (arm_build_one_stub): Fix relocation target for pic
	stub. Catch default case error.
	(arm_map_one_stub): Add missing Thumb mapping symbol.

	testsuite/
	* ld-arm/farcall-arm-arm-pic-veneer.d,
	ld-arm/farcall-arm-thumb-blx-pic-veneer.d,
	ld-arm/farcall-arm-thumb-pic-veneer.d,
	ld-arm/farcall-thumb-arm-blx-pic-veneer.d,
	ld-arm/farcall-thumb-thumb-blx-pic-veneer.d: Fix expected stub
	target.
Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.171
diff -u -p -r1.171 elf32-arm.c
--- bfd/elf32-arm.c	18 Feb 2009 12:45:38 -0000	1.171
+++ bfd/elf32-arm.c	18 Feb 2009 15:09:05 -0000
@@ -3208,9 +3208,10 @@ arm_build_one_stub (struct bfd_hash_entr
 	 start of the stub.  */
       _bfd_final_link_relocate (elf32_arm_howto_from_type (R_ARM_REL32),
 				stub_bfd, stub_sec, stub_sec->contents,
-				stub_entry->stub_offset + 8, sym_value, 0);
+				stub_entry->stub_offset + 8, sym_value, -4);
       break;
     default:
+      BFD_FAIL();
       break;
     }
 
@@ -11704,6 +11705,8 @@ arm_map_one_stub (struct bfd_hash_entry 
     case arm_stub_short_branch_v4t_thumb_arm:
       if (!elf32_arm_output_stub_sym (osi, stub_name, addr | 1, 8))
 	return FALSE;
+      if (!elf32_arm_output_map_sym (osi, ARM_MAP_THUMB, addr))
+	return FALSE;
       if (!elf32_arm_output_map_sym (osi, ARM_MAP_ARM, addr + 4))
 	return FALSE;
       break;
Index: ld/testsuite/ld-arm/farcall-arm-arm-pic-veneer.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-arm/farcall-arm-arm-pic-veneer.d,v
retrieving revision 1.2
diff -u -p -r1.2 farcall-arm-arm-pic-veneer.d
--- ld/testsuite/ld-arm/farcall-arm-arm-pic-veneer.d	25 Jun 2008 14:28:48 -0000	1.2
+++ ld/testsuite/ld-arm/farcall-arm-arm-pic-veneer.d	18 Feb 2009 15:09:11 -0000
@@ -5,7 +5,7 @@ Disassembly of section .text:
 00001000 <__bar_veneer>:
     1000:	e59fc000 	ldr	ip, \[pc, #0\]	; 1008 <__bar_veneer\+0x8>
     1004:	e08ff00c 	add	pc, pc, ip
-    1008:	02000018 	.word	0x02000018
+    1008:	02000014 	.word	0x02000014
     100c:	00000000 	.word	0x00000000
 
 00001010 <_start>:
Index: ld/testsuite/ld-arm/farcall-arm-thumb-blx-pic-veneer.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-arm/farcall-arm-thumb-blx-pic-veneer.d,v
retrieving revision 1.2
diff -u -p -r1.2 farcall-arm-thumb-blx-pic-veneer.d
--- ld/testsuite/ld-arm/farcall-arm-thumb-blx-pic-veneer.d	25 Jun 2008 14:28:48 -0000	1.2
+++ ld/testsuite/ld-arm/farcall-arm-thumb-blx-pic-veneer.d	18 Feb 2009 15:09:11 -0000
@@ -5,7 +5,7 @@ Disassembly of section .text:
 00001000 <__bar_from_arm>:
     1000:	e59fc000 	ldr	ip, \[pc, #0\]	; 1008 <__bar_from_arm\+0x8>
     1004:	e08ff00c 	add	pc, pc, ip
-    1008:	0200000d 	.word	0x0200000d
+    1008:	02000009 	.word	0x02000009
     100c:	00000000 	.word	0x00000000
 
 00001010 <_start>:
Index: ld/testsuite/ld-arm/farcall-arm-thumb-pic-veneer.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-arm/farcall-arm-thumb-pic-veneer.d,v
retrieving revision 1.2
diff -u -p -r1.2 farcall-arm-thumb-pic-veneer.d
--- ld/testsuite/ld-arm/farcall-arm-thumb-pic-veneer.d	25 Jun 2008 14:28:48 -0000	1.2
+++ ld/testsuite/ld-arm/farcall-arm-thumb-pic-veneer.d	18 Feb 2009 15:09:11 -0000
@@ -5,7 +5,7 @@ Disassembly of section .text:
 00001000 <__bar_from_arm>:
     1000:	e59fc000 	ldr	ip, \[pc, #0\]	; 1008 <__bar_from_arm\+0x8>
     1004:	e08ff00c 	add	pc, pc, ip
-    1008:	0200000d 	.word	0x0200000d
+    1008:	02000009 	.word	0x02000009
     100c:	00000000 	.word	0x00000000
 
 00001010 <_start>:
Index: ld/testsuite/ld-arm/farcall-thumb-arm-blx-pic-veneer.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-arm/farcall-thumb-arm-blx-pic-veneer.d,v
retrieving revision 1.3
diff -u -p -r1.3 farcall-thumb-arm-blx-pic-veneer.d
--- ld/testsuite/ld-arm/farcall-thumb-arm-blx-pic-veneer.d	25 Jun 2008 14:28:48 -0000	1.3
+++ ld/testsuite/ld-arm/farcall-thumb-arm-blx-pic-veneer.d	18 Feb 2009 15:09:11 -0000
@@ -5,7 +5,7 @@ Disassembly of section .text:
 00001000 <__bar_from_thumb>:
     1000:	e59fc000 	ldr	ip, \[pc, #0\]	; 1008 <__bar_from_thumb\+0x8>
     1004:	e08ff00c 	add	pc, pc, ip
-    1008:	0200000c 	.word	0x0200000c
+    1008:	02000008 	.word	0x02000008
     100c:	00000000 	.word	0x00000000
 
 00001010 <_start>:
Index: ld/testsuite/ld-arm/farcall-thumb-thumb-blx-pic-veneer.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-arm/farcall-thumb-thumb-blx-pic-veneer.d,v
retrieving revision 1.2
diff -u -p -r1.2 farcall-thumb-thumb-blx-pic-veneer.d
--- ld/testsuite/ld-arm/farcall-thumb-thumb-blx-pic-veneer.d	25 Jun 2008 14:28:48 -0000	1.2
+++ ld/testsuite/ld-arm/farcall-thumb-thumb-blx-pic-veneer.d	18 Feb 2009 15:09:11 -0000
@@ -5,7 +5,7 @@ Disassembly of section .text:
 00001000 <__bar_veneer>:
     1000:	e59fc000 	ldr	ip, \[pc, #0\]	; 1008 <__bar_veneer\+0x8>
     1004:	e08ff00c 	add	pc, pc, ip
-    1008:	0200000d 	.word	0x0200000d
+    1008:	02000009 	.word	0x02000009
     100c:	00000000 	.word	0x00000000
 
 00001010 <_start>:

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