This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[RFA] [ARM] Patch to fix ld-shared/shared.exp and ld-elfvsb/elfvsb.exp failures
- From: Matthew Gretton-Dann <matthew dot gretton-dann at arm dot com>
- To: binutils at sourceware dot org
- Date: Fri, 05 Feb 2010 16:47:11 +0000
- Subject: [RFA] [ARM] Patch to fix ld-shared/shared.exp and ld-elfvsb/elfvsb.exp failures
Hi,
The attached patch fixes failures in ld-elfvsb/elfvsb.exp and
ld-shared/shared.exp for arm*-*-linux* targets.
There are two separate issues here:
1) The section anchors optimization in gcc is changing symbol
pre-emption properties and so causing the tests to fail when compiled
non-PIC. The patch addresses this by passing -fno-section-anchors to
GCC when compiling all tests.
2) When compiling non-PIC for an ARM CPU which has the MOVW instruction
relocations (R_ARM_THM_MOV{W,T}*) may be generated which ld will refuse
to pass into a shared library. The patch addresses this by marking the
non-PIC tests as XFAIL in these cases (this matches the behaviour of
several other targets - including x86_64-*-linux* and
hppa*64*-*-linux*).
I have tested this on Cortex-A8, ARM1136JF-S for
arm-unknown-linux-gnueabi, and StrongARM for arm-linux, and have seen
the following improvements:
Cortex-A8 Pre-Patch Post-Patch
PASS FAIL XFAIL PASS FAIL XFAIL
ld-shared/shared.exp 3 3 0 3 0 3
ld-elfvsb/eldvsb.exp 30 30 0 30 0 30
StrongARM
arm1136jf-s Pre-Patch Post-Patch
PASS FAIL XFAIL PASS FAIL XFAIL
ld-shared/shared.exp 3 3 0 6 0 0
ld-elfvsb/eldvsb.exp 56 4 0 60 0 0
Can someone review the patch, approve and commit please?
Proposed ChangeLog:
2010-02-05 Matthew Gretton-Dann (matthew.gretton-dann@arm.com)
* ld-elfvsb/elfvsb.exp: Fix tests for arm*-*-linux*.
* ld-shared/shared.exp: Likewise.
Thanks,
Matt
--
Matthew Gretton-Dann
Principal Engineer - Tools, PD Software
ARM Limited
Index: ld/testsuite/ld-elfvsb/elfvsb.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-elfvsb/elfvsb.exp,v
retrieving revision 1.32
diff -u -p -r1.32 elfvsb.exp
--- ld/testsuite/ld-elfvsb/elfvsb.exp 2 Sep 2009 07:25:39 -0000 1.32
+++ ld/testsuite/ld-elfvsb/elfvsb.exp 5 Feb 2010 15:54:46 -0000
@@ -60,6 +60,7 @@ if ![isnative] then {return}
set tmpdir tmpdir
set SHCFLAG ""
+set shared_needs_pic "no"
if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
@@ -91,6 +92,27 @@ if { [istarget rs6000*-*-aix*] || [istar
close $file
}
+if [istarget arm*-*-linux*] {
+ # On ARM section anchors can change the symbol pre-emptability for
+ # non-PIC shared libraries, causing these tests to fail. Turn section
+ # anchors off.
+ set SHCFLAG "-fno-section-anchors"
+
+ # On targets that have MOVW the compiler will emit relocations which
+ # the linker doesn't support when compiling -shared without -fpic. The
+ # test to find out whether we want to XFAIL the non-PIC tests requires
+ # a compile - so we pre-calculate it here. We also note that this can
+ # only affect arm*-*-*eabi targets as the old ABI doesn't support v7.
+ if [istarget arm*-*-*eabi] {
+ set file [open $tmpdir/movw-detect.c w]
+ puts $file "void foo(void) { __asm (\"movw r0, #0\"); }"
+ close $file
+ if [run_host_cmd_yesno "$CC" "$CFLAGS -c $tmpdir/movw-detect.c -o $tmpdir/movw-detect.o"] {
+ set shared_needs_pic "yes"
+ }
+ }
+}
+
set support_protected "no"
if [istarget *-*-linux*] {
@@ -201,6 +223,7 @@ proc visibility_run {visibility} {
global picflag
global target_triplet
global support_protected
+ global shared_needs_pic
if [ string match $visibility "hidden" ] {
set VSBCFLAG "-DHIDDEN_TEST"
@@ -273,6 +296,9 @@ proc visibility_run {visibility} {
if { ![istarget hppa*64*-*-linux*] } {
setup_xfail "hppa*-*-linux*"
}
+ if [ string match $shared_needs_pic "yes" ] {
+ setup_xfail "arm*-*-linux*"
+ }
visibility_test $visibility vnp "visibility ($visibility) (non PIC)" mainnp.o sh1np.o sh2np.o elfvsb
@@ -311,6 +337,9 @@ proc visibility_run {visibility} {
if { ![istarget hppa*64*-*-linux*] } {
setup_xfail "hppa*-*-linux*"
}
+ if [ string match $shared_needs_pic "yes" ] {
+ setup_xfail "arm*-*-linux*"
+ }
visibility_test $visibility vnp "visibility ($visibility) (non PIC, load offset)" \
mainnp.o sh1np.o sh2np.o elfvsb \
@@ -377,6 +406,9 @@ proc visibility_run {visibility} {
if { ![istarget hppa*64*-*-linux*] } {
setup_xfail "hppa*-*-linux*"
}
+ if [ string match $shared_needs_pic "yes" ] {
+ setup_xfail "arm*-*-linux*"
+ }
visibility_test $visibility vmpnp "visibility ($visibility) (PIC main, non PIC so)" mainp.o sh1np.o sh2np.o elfvsb
}
Index: ld/testsuite/ld-shared/shared.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-shared/shared.exp,v
retrieving revision 1.23
diff -u -p -r1.23 shared.exp
--- ld/testsuite/ld-shared/shared.exp 2 Sep 2009 07:25:42 -0000 1.23
+++ ld/testsuite/ld-shared/shared.exp 5 Feb 2010 15:54:47 -0000
@@ -66,6 +66,7 @@ if { [istarget *-*-linux*aout*] \
set tmpdir tmpdir
set SHCFLAG ""
+set shared_needs_pic "no"
if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
@@ -97,6 +98,27 @@ if { [istarget rs6000*-*-aix*] || [istar
close $file
}
+if [istarget arm*-*-linux*] {
+ # On ARM section anchors can change the symbol pre-emptability for
+ # non-PIC shared libraries, causing these tests to fail. Turn section
+ # anchors off.
+ set SHCFLAG "-fno-section-anchors"
+
+ # On targets that have MOVW the compiler will emit relocations which
+ # the linker doesn't support when compiling -shared without -fpic. The
+ # test to find out whether we want to XFAIL the non-PIC tests requires
+ # a compile - so we pre-calculate it here. We also note that this can
+ # only affect arm*-*-*eabi targets as the old ABI doesn't support v7.
+ if [istarget arm*-*-*eabi] {
+ set file [open $tmpdir/movw-detect.c w]
+ puts $file "void foo(void) { __asm (\"movw r0, #0\"); }"
+ close $file
+ if [run_host_cmd_yesno "$CC" "$CFLAGS -c $tmpdir/movw-detect.c -o $tmpdir/movw-detect.o"] {
+ set shared_needs_pic "yes"
+ }
+ }
+}
+
# The test procedure.
proc shared_test { progname testname main sh1 sh2 dat args } {
global CC
@@ -212,6 +234,9 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG" $
}
setup_xfail "x86_64-*-linux*"
setup_xfail "s390x-*-linux*"
+ if [ string match $shared_needs_pic "yes" ] {
+ setup_xfail "arm*-*-linux*"
+ }
shared_test shnp "shared (non PIC)" mainnp.o sh1np.o sh2np.o shared
# Test ELF shared library relocations with a non-zero load
@@ -232,6 +257,9 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG" $
}
setup_xfail "x86_64-*-linux*"
setup_xfail "s390x-*-linux*"
+ if [ string match $shared_needs_pic "yes" ] {
+ setup_xfail "arm*-*-linux*"
+ }
shared_test shnp "shared (non PIC, load offset)" \
mainnp.o sh1np.o sh2np.o shared \
"-T $srcdir/$subdir/elf-offset.ld"
@@ -281,6 +309,9 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG $p
}
setup_xfail "x86_64-*-linux*"
setup_xfail "s390x-*-linux*"
+ if [ string match $shared_needs_pic "yes" ] {
+ setup_xfail "arm*-*-linux*"
+ }
shared_test shmpnp "shared (PIC main, non PIC so)" mainp.o sh1np.o sh2np.o shared
}
} else {