This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[patch 8/9] Nios II port, ld testsuite fixes
- From: Sandra Loosemore <sandra at codesourcery dot com>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Thu, 24 Jan 2013 13:20:49 -0700
- Subject: [patch 8/9] Nios II port, ld testsuite fixes
This patch fixes some testsuite failures and errors I encountered while
working on the Nios II port. A couple notes:
The Nios II ABI only supports the relocations for PIC on Linux targets,
and the ELF compiler gives an error with -fPIC. I believe MIPS ELF and
possibly some other bare-metal targets don't support shared libraries or
PIC, either.
Besides the two problems with lto.exp that I've fixed in this patch,
there are still some spurious errors remaining there -- e.g., it assumes
that the default linker script provides a hosted environment (printf),
which isn't the case for our Nios II ELF configuration -- but maybe
someone who better understands what is being tested there can suggest
better ways to fix those problems.
-Sandra
2013-01-24 Sandra Loosemore <sandra@codesourcery.com>
ld/testsuite/
* ld-elf/indirect.exp: Skip on targets that don't support
-shared -fPIC.
* ld-elfcomm/elfcomm.exp: Build with -G0 for nios2.
* ld-plugin/lto.exp: Skip shared library tests on targets that
don't support them. Skip execution tests on non-native targets.
Index: ld/testsuite/ld-elf/indirect.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-elf/indirect.exp,v
retrieving revision 1.2
diff -u -p -r1.2 indirect.exp
--- ld/testsuite/ld-elf/indirect.exp 14 Dec 2012 11:58:59 -0000 1.2
+++ ld/testsuite/ld-elf/indirect.exp 22 Jan 2013 18:36:37 -0000
@@ -37,6 +37,11 @@ if { [which $CC] == 0 } {
return
}
+# Some bare-metal targets don't support shared libs or PIC.
+if { ![run_host_cmd_yesno $CC "-shared -fPIC $srcdir/$subdir/dummy.c -o tmpdir/t.so"] } {
+ return
+}
+
proc check_link_message { cmd string testname } {
send_log "$cmd\n"
verbose "$cmd"
Index: ld/testsuite/ld-elfcomm/elfcomm.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-elfcomm/elfcomm.exp,v
retrieving revision 1.23
diff -u -p -r1.23 elfcomm.exp
--- ld/testsuite/ld-elfcomm/elfcomm.exp 31 Dec 2010 22:29:19 -0000 1.23
+++ ld/testsuite/ld-elfcomm/elfcomm.exp 22 Jan 2013 18:36:38 -0000
@@ -181,6 +181,10 @@ proc assembler_generates_commons {} {
return 1
}
+if [istarget nios2*-*-*] {
+ set CFLAGS "$CFLAGS -G0"
+}
+
# Explicitly use "-fcommon" so that even if $CFLAGS includes
# "-fno-common", these tests are compiled as expected.
if { ![ld_compile "$CC $CFLAGS -fcommon" $srcdir/$subdir/common1a.c tmpdir/common1a.o]
Index: ld/testsuite/ld-plugin/lto.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-plugin/lto.exp,v
retrieving revision 1.2
diff -u -p -r1.2 lto.exp
--- ld/testsuite/ld-plugin/lto.exp 16 Jan 2013 08:14:35 -0000 1.2
+++ ld/testsuite/ld-plugin/lto.exp 23 Jan 2013 19:24:12 -0000
@@ -265,7 +265,9 @@ set lto_run_elf_tests {
run_cc_link_tests $lto_link_tests
-if { [is_elf_format] } {
+# Restrict these to ELF targets that support shared libs and PIC.
+if { [is_elf_format]
+ && [run_host_cmd_yesno $CC "-shared -fPIC $srcdir/$subdir/dummy.c -o tmpdir/t.so"] } {
run_cc_link_tests $lto_link_elf_tests
}
@@ -295,6 +297,11 @@ remote_exec host "mv" "tmpdir/dump tmpdi
run_cc_link_tests $lto_link_symbol_tests
+# The following tests require running the executable generated by ld.
+if ![isnative] {
+ return
+}
+
run_ld_link_exec_tests [] $lto_run_tests
if { [is_elf_format] } {