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]

Fix placement of ARM veneers in data sections


In the attached testcase, LD puts a far call veneer in .after, which
is not marked SEC_CODE.  This and .text end up in the same output
section, so this is not an obviously fatal problem - but the linker
script mimics libgloss's handling of .fini_array.  A veneer is not a
helpful function pointer.

It makes sense to limit the attachments to code sections, so that's
what I've done in this patch.  Tested on arm-none-eabi, checked in.

-- 
Daniel Jacobowitz
CodeSourcery

2009-12-09  Daniel Jacobowitz  <dan@codesourcery.com>

	* elf32-arm.c (elf32_arm_next_input_section): Skip sections without
	SEC_CODE.

2009-12-09  Daniel Jacobowitz  <dan@codesourcery.com>

	* ld-arm/arm-elf.exp (armeabitests): Add farcall-data.
	* ld-arm/farcall-data.d, ld-arm/farcall-data.s: New.
	* lib/ld-lib.exp (run_ld_link_tests, run_cc_link_tests): Correct
	regular expression for archives.

Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.215
diff -u -p -r1.215 elf32-arm.c
--- bfd/elf32-arm.c	17 Nov 2009 16:31:48 -0000	1.215
+++ bfd/elf32-arm.c	9 Dec 2009 21:33:05 -0000
@@ -3785,7 +3785,7 @@ elf32_arm_next_input_section (struct bfd
     {
       asection **list = htab->input_list + isec->output_section->index;
 
-      if (*list != bfd_abs_section_ptr)
+      if (*list != bfd_abs_section_ptr && (isec->flags & SEC_CODE) != 0)
 	{
 	  /* Steal the link_sec pointer for our list.  */
 #define PREV_SEC(sec) (htab->stub_group[(sec)->id].link_sec)
Index: ld/testsuite/ld-arm/arm-elf.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-arm/arm-elf.exp,v
retrieving revision 1.64
diff -u -p -r1.64 arm-elf.exp
--- ld/testsuite/ld-arm/arm-elf.exp	23 Nov 2009 14:41:33 -0000	1.64
+++ ld/testsuite/ld-arm/arm-elf.exp	9 Dec 2009 21:33:06 -0000
@@ -422,6 +422,9 @@ set armeabitests {
      {{objdump -fdw farcall-mixed-lib.d}}
      "farcall-mixed-lib.so"}
 
+    {"Long branch with mixed text and data" "-T arm.ld" "" {farcall-data.s}
+     {{objdump -dr farcall-data.d}}
+     "farcall-data"}
 }
 
 run_ld_link_tests $armeabitests
Index: ld/testsuite/ld-arm/farcall-data.d
===================================================================
RCS file: ld/testsuite/ld-arm/farcall-data.d
diff -N ld/testsuite/ld-arm/farcall-data.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-arm/farcall-data.d	9 Dec 2009 21:33:06 -0000
@@ -0,0 +1,19 @@
+.*:     file format .*
+
+Disassembly of section .text:
+
+00008000 <_start>:
+    8000:	ea000000 	b	8008 <__far_veneer>
+    8004:	00000000 	andeq	r0, r0, r0
+
+00008008 <__far_veneer>:
+    8008:	e51ff004 	ldr	pc, \[pc, #-4\]	; 800c <__far_veneer\+0x4>
+    800c:	12340000 	\.word	0x12340000
+
+00008010 <after>:
+    8010:	11111111 	\.word	0x11111111
+
+Disassembly of section \.far:
+
+12340000 <far>:
+12340000:	e12fff1e 	bx	lr
Index: ld/testsuite/ld-arm/farcall-data.s
===================================================================
RCS file: ld/testsuite/ld-arm/farcall-data.s
diff -N ld/testsuite/ld-arm/farcall-data.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-arm/farcall-data.s	9 Dec 2009 21:33:06 -0000
@@ -0,0 +1,14 @@
+	.syntax unified
+	.text
+	.global _start
+	.type _start, %function
+_start:
+    b far
+
+.section .after
+after:
+	.word 0x11111111
+
+	.section .far, "ax"
+	.type far, %function
+far:	bx lr
Index: ld/testsuite/lib/ld-lib.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/lib/ld-lib.exp,v
retrieving revision 1.67
diff -u -p -r1.67 ld-lib.exp
--- ld/testsuite/lib/ld-lib.exp	1 Oct 2009 23:29:28 -0000	1.67
+++ ld/testsuite/lib/ld-lib.exp	9 Dec 2009 21:33:06 -0000
@@ -1227,7 +1227,7 @@ proc run_ld_link_tests { ldtests } {
 	    continue
 	}
 
-	if { [regexp ".*a$" $binfile] } {
+	if { [regexp ".*\\.a$" $binfile] } {
 	    if { ![ar_simple_create $ar $ld_options $binfile "$objfiles"] } {
 		fail $testname
 		set failed 1
@@ -1538,7 +1538,7 @@ proc run_cc_link_tests { ldtests } {
 	    set cc_cmd $CC
 	}
 
-	if { [regexp ".*a$" $binfile] } {
+	if { [regexp ".*\\.a$" $binfile] } {
 	    if { ![ar_simple_create $ar $ldflags $binfile "$objfiles"] } {
 		fail $testname
 		set failed 1


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