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]
Other format: [Raw text]

RFA: Un-bork arm-linux dynamic linking


I am too fiddly for my own good.  When I fixed static linking for Richard
last week, I snuck in a cleanup.  The cleanup turns out to be wrong.
R_ARM_ABS32 relocs against a symbol shouldn't force creation of a PLT, but
they -should- increment its PLT refcount; otherwise, if the symbol turns out
to be a function, we'll forget to create the PLT slot, and crash.

At least I got a new testcase.  OK?

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

2004-01-22  Daniel Jacobowitz  <drow@mvista.com>

	* elf32-arm.h (elf32_arm_check_relocs): Revert part of 2004-01-13
	change.

2004-01-22  Daniel Jacobowitz  <drow@mvista.com>

	* ld-arm/arm-app-abs32.s, ld-arm/arm-app-abs32.r,
	ld-arm/arm-app-abs32.d: New files.
	* ld-arm/arm-elf.exp: Add arm-app-abs32 testcase.

Index: bfd/elf32-arm.h
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/bfd/elf32-arm.h,v
retrieving revision 1.119
diff -u -p -r1.119 elf32-arm.h
--- bfd/elf32-arm.h	13 Jan 2004 21:09:34 -0000	1.119
+++ bfd/elf32-arm.h	22 Jan 2004 15:53:03 -0000
@@ -2945,10 +2945,11 @@ elf32_arm_check_relocs (abfd, info, sec,
 		   symbol local.  */
 		if (ELF32_R_TYPE (rel->r_info) == R_ARM_PC24
 		    || ELF32_R_TYPE (rel->r_info) == R_ARM_PLT32)
-		  {
-		    h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
-		    h->plt.refcount += 1;
-		  }
+		  h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
+
+		/* If we create a PLT entry, this relocation will reference
+		   it, even if it's an ABS32 relocation.  */
+		h->plt.refcount += 1;
 	      }
 
 	    /* If we are creating a shared library, and this is a reloc
Index: ld/testsuite/ld-arm/arm-app-abs32.d
===================================================================
RCS file: ld/testsuite/ld-arm/arm-app-abs32.d
diff -N ld/testsuite/ld-arm/arm-app-abs32.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-arm/arm-app-abs32.d	22 Jan 2004 15:52:06 -0000
@@ -0,0 +1,29 @@
+
+tmpdir/arm-app-abs32:     file format elf32-littlearm
+architecture: arm, flags 0x00000112:
+EXEC_P, HAS_SYMS, D_PAGED
+start address .*
+
+Disassembly of section .plt:
+
+.* <.plt>:
+    .*:	e52de004 	str	lr, \[sp, #-4\]!
+    .*:	e59fe004 	ldr	lr, \[pc, #4\]	; .* <.plt\+0x10>
+    .*:	e08fe00e 	add	lr, pc, lr
+    .*:	e5bef008 	ldr	pc, \[lr, #8\]!
+    .*:	000080b4 	streqh	r8, \[r0\], -r4
+    .*:	e28fc6.* 	add	ip, pc, #.*	; .*
+    .*:	e28cca.* 	add	ip, ip, #.*	; .*
+    .*:	e5bcf.* 	ldr	pc, \[ip, #.*\]!
+Disassembly of section .text:
+
+.* <_start>:
+    .*:	e1a0c00d 	mov	ip, sp
+    .*:	e92dd800 	stmdb	sp!, {fp, ip, lr, pc}
+    .*:	e59f0004 	ldr	r0, \[pc, #4\]	; .* <.text\+0x14>
+    .*:	e89d6800 	ldmia	sp, {fp, sp, lr}
+    .*:	e12fff1e 	bx	lr
+    .*:	.* 	.*
+
+.* <app_func2>:
+    .*:	e12fff1e 	bx	lr
Index: ld/testsuite/ld-arm/arm-app-abs32.r
===================================================================
RCS file: ld/testsuite/ld-arm/arm-app-abs32.r
diff -N ld/testsuite/ld-arm/arm-app-abs32.r
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-arm/arm-app-abs32.r	22 Jan 2004 15:47:12 -0000
@@ -0,0 +1,8 @@
+
+tmpdir/arm-app-abs32:     file format elf32-littlearm
+
+DYNAMIC RELOCATION RECORDS
+OFFSET   TYPE              VALUE 
+.* R_ARM_JUMP_SLOT   lib_func1
+
+
Index: ld/testsuite/ld-arm/arm-app-abs32.s
===================================================================
RCS file: ld/testsuite/ld-arm/arm-app-abs32.s
diff -N ld/testsuite/ld-arm/arm-app-abs32.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-arm/arm-app-abs32.s	22 Jan 2004 15:42:15 -0000
@@ -0,0 +1,16 @@
+	.text
+	.globl _start
+_start:
+	mov	ip, sp
+	stmdb	sp!, {r11, ip, lr, pc}
+	ldr	a1, .Lval
+	ldmia	sp, {r11, sp, lr}
+	bx	lr
+
+.Lval:
+	.long	lib_func1
+
+	.globl app_func2
+app_func2:
+	bx	lr
+
Index: ld/testsuite/ld-arm/arm-elf.exp
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/ld/testsuite/ld-arm/arm-elf.exp,v
retrieving revision 1.2
diff -u -p -r1.2 arm-elf.exp
--- ld/testsuite/ld-arm/arm-elf.exp	13 Jan 2004 21:09:18 -0000	1.2
+++ ld/testsuite/ld-arm/arm-elf.exp	22 Jan 2004 15:37:20 -0000
@@ -44,6 +44,9 @@ set armelftests {
     {"Simple static application" "" "" {arm-static-app.s}
      {{objdump -fdw arm-static-app.d} {objdump -rw arm-static-app.r}}
      "arm-static-app"}
+    {"Non-pcrel function reference" "tmpdir/arm-lib.so" "" {arm-app-abs32.s}
+     {{objdump -fdw arm-app-abs32.d} {objdump -Rw arm-app-abs32.r}}
+     "arm-app-abs32"}
 }
 
 run_ld_link_tests $armelftests


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