[committed] MIPS/LD/testsuite: Correct dynamic links with VR4100, VR4300 and VR5000

Message ID alpine.DEB.2.00.1801301814450.4074@tp.orcam.me.uk
State New
Headers show
Series
  • [committed] MIPS/LD/testsuite: Correct dynamic links with VR4100, VR4300 and VR5000
Related show

Commit Message

Maciej W. Rozycki Jan. 31, 2018, 2:50 p.m.
Correct LD test suite failures with VR4100, VR4300 and VR5000 bare metal 
MIPS/ELF targets which do not default to linking with shared libraries, 
which leads to link failures like:

.../ld/ld-new: cannot find -lcomm-data
FAIL: Common symbol override test

or:

.../ld/ld-new: attempted static link of dynamic object `tmpdir/pr14170.so'
FAIL: PR ld/14170

removing:

FAIL: Build pr22471b.so
FAIL: Build pr22471
FAIL: Build pr22649-2b.so
FAIL: Build pr22649-2d.so
FAIL: Build pr22150
FAIL: PR ld/14170
FAIL: --gc-sections with __gxx_personality

test failures.

	ld/
	* testsuite/ld-elf/comm-data.exp: Pass `-call_shared' to links 
	involving a shared library for `mips*vr4100*-*-elf*', 
	`mips*vr4300*-*-elf*' and `mips*vr5000*-*-elf*' targets.
	* testsuite/ld-elf/provide-hidden.exp: Likewise.
	* testsuite/ld-elf/shared.exp: Likewise.
	* testsuite/ld-gc/gc.exp: Likewise.
	* testsuite/ld-mips-elf/comm-data.exp: Likewise.
---
Hi,

 Like with <https://sourceware.org/ml/binutils/2018-01/msg00425.html> 
(commit 86b24e15c45b ("MIPS/LD/testsuite: Correct comm-data.exp test 
ABI/emul/endian arrangement")) some remain due to a handling peculiarity 
with the IRIX format variation, e.g.:

regexp_diff match failure
regexp "^ +0x0*76540000 00000000 00000000 00000000 00000000 .*$"
line   "  0x76540000 00000308 00000000 00000000 00000000 ................"
FAIL: Common symbol override test

Similarly <https://sourceware.org/ml/binutils/2018-01/msg00442.html> 
(commit af667f2218ec ("MIPS/LD/testsuite: Correct PR ld/22649 test case 
failures")) and the issue with `_procedure_table_size', e.g.:

.../ld/ld-new: tmpdir/libpr20828.so: protected symbol `_procedure_table_size' isn't defined
.../ld/ld-new: final link failed: Bad value

And finally what looks like a linker script problem:

.../ld/ld-new: tmpdir/provide-hidden-s.so: The first section in the PT_DYNAMIC segment is not the .dynamic section
.../ld/ld-new: final link failed: Bad value

 All these are independent problems however and I have now committed this 
fix.

  Maciej
---
 ld/testsuite/ld-elf/comm-data.exp      |    6 ++++++
 ld/testsuite/ld-elf/provide-hidden.exp |   14 ++++++++++----
 ld/testsuite/ld-elf/shared.exp         |   19 ++++++++++++++-----
 ld/testsuite/ld-gc/gc.exp              |   10 +++++++++-
 ld/testsuite/ld-mips-elf/comm-data.exp |    3 ++-
 5 files changed, 41 insertions(+), 11 deletions(-)

binutils-mips-ld-test-vrxxxx-call-shared.diff

Comments

H.J. Lu March 14, 2018, 11:06 a.m. | #1
On Wed, Jan 31, 2018 at 6:50 AM, Maciej W. Rozycki <macro@mips.com> wrote:
> Correct LD test suite failures with VR4100, VR4300 and VR5000 bare metal

> MIPS/ELF targets which do not default to linking with shared libraries,

> which leads to link failures like:

>

> .../ld/ld-new: cannot find -lcomm-data

> FAIL: Common symbol override test

>

> or:

>

> .../ld/ld-new: attempted static link of dynamic object `tmpdir/pr14170.so'

> FAIL: PR ld/14170

>

> removing:

>

> FAIL: Build pr22471b.so

> FAIL: Build pr22471

> FAIL: Build pr22649-2b.so

> FAIL: Build pr22649-2d.so

> FAIL: Build pr22150

> FAIL: PR ld/14170

> FAIL: --gc-sections with __gxx_personality

>

> test failures.

>

>         ld/

>         * testsuite/ld-elf/comm-data.exp: Pass `-call_shared' to links

>         involving a shared library for `mips*vr4100*-*-elf*',

>         `mips*vr4300*-*-elf*' and `mips*vr5000*-*-elf*' targets.

>         * testsuite/ld-elf/provide-hidden.exp: Likewise.

>         * testsuite/ld-elf/shared.exp: Likewise.

>         * testsuite/ld-gc/gc.exp: Likewise.

>         * testsuite/ld-mips-elf/comm-data.exp: Likewise.

> ---

> Hi,

>

>  Like with <https://sourceware.org/ml/binutils/2018-01/msg00425.html>

> (commit 86b24e15c45b ("MIPS/LD/testsuite: Correct comm-data.exp test

> ABI/emul/endian arrangement")) some remain due to a handling peculiarity

> with the IRIX format variation, e.g.:

>

> regexp_diff match failure

> regexp "^ +0x0*76540000 00000000 00000000 00000000 00000000 .*$"

> line   "  0x76540000 00000308 00000000 00000000 00000000 ................"

> FAIL: Common symbol override test

>

> Similarly <https://sourceware.org/ml/binutils/2018-01/msg00442.html>

> (commit af667f2218ec ("MIPS/LD/testsuite: Correct PR ld/22649 test case

> failures")) and the issue with `_procedure_table_size', e.g.:

>

> .../ld/ld-new: tmpdir/libpr20828.so: protected symbol `_procedure_table_size' isn't defined

> .../ld/ld-new: final link failed: Bad value

>

> And finally what looks like a linker script problem:

>

> .../ld/ld-new: tmpdir/provide-hidden-s.so: The first section in the PT_DYNAMIC segment is not the .dynamic section

> .../ld/ld-new: final link failed: Bad value

>

>  All these are independent problems however and I have now committed this

> fix.

>

>   Maciej

> ---

>  ld/testsuite/ld-elf/comm-data.exp      |    6 ++++++

>  ld/testsuite/ld-elf/provide-hidden.exp |   14 ++++++++++----

>  ld/testsuite/ld-elf/shared.exp         |   19 ++++++++++++++-----

>  ld/testsuite/ld-gc/gc.exp              |   10 +++++++++-

>  ld/testsuite/ld-mips-elf/comm-data.exp |    3 ++-

>  5 files changed, 41 insertions(+), 11 deletions(-)

>


> Index: binutils/ld/testsuite/ld-gc/gc.exp

> ===================================================================

> --- binutils.orig/ld/testsuite/ld-gc/gc.exp     2018-01-31 14:15:45.871840273 +0000

> +++ binutils/ld/testsuite/ld-gc/gc.exp  2018-01-31 14:16:12.850499318 +0000

> @@ -116,11 +116,18 @@ if { [is_elf_format] && [check_shared_li

>      if { [istarget tic6x-*] } then {

>         set gasopt "-mpic -mpid=near"

>      }

> +    # These targets do not default to linking with shared libraries.

> +    set old_ldflags $LDFLAGS

> +    if { [istarget "mips*vr4100*-*-elf*"] \

> +        || [istarget "mips*vr4300*-*-elf*"] \

> +        || [istarget "mips*vr5000*-*-elf*"] } {

> +       append LDFLAGS " -call_shared"

> +    }

>      if {![ld_assemble_flags $as $gasopt $srcdir/$subdir/libpersonality.s tmpdir/libpersonality.o]

>         || ![ld_link $ld tmpdir/libpersonality.so "-shared tmpdir/libpersonality.o"] } then {

>         fail libpersonality

>      } else {

> -       run_dump_test "personality"

> +       run_dump_test "personality" [list [list ld $LFLAGS]]


   ^^^^^^^^^ Typo.  This should be $LDFLAGS.

I will check in a fix:

diff --git a/ld/testsuite/ld-gc/gc.exp b/ld/testsuite/ld-gc/gc.exp
index a95d2d4900..efdddd7452 100644
--- a/ld/testsuite/ld-gc/gc.exp
+++ b/ld/testsuite/ld-gc/gc.exp
@@ -127,7 +127,7 @@ if { [is_elf_format] && [check_shared_lib_support] } then {
   || ![ld_link $ld tmpdir/libpersonality.so "-shared
tmpdir/libpersonality.o"] } then {
   fail libpersonality
     } else {
-  run_dump_test "personality" [list [list ld $LFLAGS]]
+  run_dump_test "personality" [list [list ld $LDFLAGS]]
     }
     run_dump_test "pr18223"
     if {![ld_assemble_flags $as $gasopt $srcdir/$subdir/pr20022a.s
tmpdir/pr20022a.o]

>      }

>      run_dump_test "pr18223"

>      if {![ld_assemble_flags $as $gasopt $srcdir/$subdir/pr20022a.s tmpdir/pr20022a.o]

> @@ -129,6 +136,7 @@ if { [is_elf_format] && [check_shared_li

>      } else {

>         run_dump_test "pr20022"

>      }

> +    set LDFLAGS $old_ldflags

>  }

>

>  if { [is_remote host] || [which $CC] != 0 } {



-- 
H.J.

Patch

Index: binutils/ld/testsuite/ld-elf/comm-data.exp
===================================================================
--- binutils.orig/ld/testsuite/ld-elf/comm-data.exp	2018-01-31 14:15:45.833496998 +0000
+++ binutils/ld/testsuite/ld-elf/comm-data.exp	2018-01-31 14:16:12.810095170 +0000
@@ -41,6 +41,12 @@  set LFLAGS ""
 if [istarget "tic6x-*-*"] {
     append LFLAGS " -melf32_tic6x_le"
 }
+# These targets do not default to linking with shared libraries.
+if { [istarget "mips*vr4100*-*-elf*"] \
+     || [istarget "mips*vr4300*-*-elf*"] \
+     || [istarget "mips*vr5000*-*-elf*"] } {
+    append LFLAGS " -call_shared"
+}
 
 set testname "Common symbol override test"
 
Index: binutils/ld/testsuite/ld-elf/provide-hidden.exp
===================================================================
--- binutils.orig/ld/testsuite/ld-elf/provide-hidden.exp	2018-01-31 14:15:45.846577320 +0000
+++ binutils/ld/testsuite/ld-elf/provide-hidden.exp	2018-01-31 14:16:12.820172949 +0000
@@ -35,6 +35,12 @@  set AFLAGS_PIC ""
 if [istarget "tic6x-*-*"] {
     append AFLAGS_PIC " -mpic -mpid=near"
 }
+# These targets do not default to linking with shared libraries.
+if { [istarget "mips*vr4100*-*-elf*"] \
+     || [istarget "mips*vr4300*-*-elf*"] \
+     || [istarget "mips*vr5000*-*-elf*"] } {
+    append LFLAGS " -call_shared"
+}
 
 set testname "PROVIDE_HIDDEN test"
 
@@ -77,7 +83,7 @@  run_ld_link_tests [list \
 	"provide-hidden-3"] \
     [list \
 	"$testname 4" \
-	"-T provide-hidden-1.ld" "tmpdir/provide-hidden-s.so" \
+	"$LFLAGS -T provide-hidden-1.ld" "tmpdir/provide-hidden-s.so" \
 	"" \
 	[list provide-hidden-3.s] \
 	[list "readelf -s provide-hidden-dynsec.nd"] \
@@ -93,7 +99,7 @@  run_ld_link_tests [list \
 	"provide-hidden-5"] \
     [list \
 	"$testname 6" \
-	"-T provide-hidden-1.ld" "tmpdir/provide-hidden-s.so" \
+	"$LFLAGS -T provide-hidden-1.ld" "tmpdir/provide-hidden-s.so" \
 	"" \
 	[list provide-hidden-4.s] \
 	[list \
@@ -129,7 +135,7 @@  run_ld_link_tests [list \
 	"provide-hidden-9"] \
     [list \
 	"$testname 10" \
-	"-T provide-hidden-2.ld" "tmpdir/provide-hidden-s.so" \
+	"$LFLAGS -T provide-hidden-2.ld" "tmpdir/provide-hidden-s.so" \
 	"" \
 	[list provide-hidden-3.s] \
 	[list "readelf -s provide-hidden-dynabs.nd"] \
@@ -145,7 +151,7 @@  run_ld_link_tests [list \
 	"provide-hidden-11"] \
     [list \
 	"$testname 12" \
-	"-T provide-hidden-2.ld" "tmpdir/provide-hidden-s.so" \
+	"$LFLAGS -T provide-hidden-2.ld" "tmpdir/provide-hidden-s.so" \
 	"" \
 	[list provide-hidden-4.s] \
 	[list \
Index: binutils/ld/testsuite/ld-elf/shared.exp
===================================================================
--- binutils.orig/ld/testsuite/ld-elf/shared.exp	2018-01-31 14:15:49.464940117 +0000
+++ binutils/ld/testsuite/ld-elf/shared.exp	2018-01-31 14:37:15.004509966 +0000
@@ -57,6 +57,12 @@  set hpux ""
 if [istarget "*-*-hpux*"] {
     set hpux "--defsym HPUX=1"
 }
+# These targets do not default to linking with shared libraries.
+if { [istarget "mips*vr4100*-*-elf*"] \
+     || [istarget "mips*vr4300*-*-elf*"] \
+     || [istarget "mips*vr5000*-*-elf*"] } {
+    append LFLAGS " -call_shared"
+}
 
 if [is_underscore_target] {
     set ASFLAGS "$ASFLAGS --defsym UNDERSCORE=1"
@@ -332,7 +338,8 @@  run_ld_link_tests {
 # bfin does not currently support copy relocs.
 run_ld_link_tests [list \
     [list "PR ld/14170" \
-	"--no-dynamic-linker tmpdir/pr14170a.o tmpdir/pr14170.so" "" $hpux \
+	"$LFLAGS --no-dynamic-linker tmpdir/pr14170a.o tmpdir/pr14170.so" "" \
+	$hpux \
 	 {pr14170c.s} { } "pr14170" ] \
 ] "bfin-*-*"
 
@@ -361,7 +368,7 @@  run_ld_link_tests {
     {"Build shared library for broken linker scrip test"
 	"-shared --hash-style=sysv" "" "" "note-3.s" {} "note-3.so" }
     {"Link using broken linker script"
-	"--script note-3.t tmpdir/note-3.so" "" "" ""
+	"$LFLAGS --script note-3.t tmpdir/note-3.so" "" "" ""
 	{ { ld "note-3.l" } }
 	"a.out" }
 }
@@ -382,7 +389,9 @@  run_ld_link_tests {
 # bfin does not currently support copy relocs.
 run_ld_link_tests {
     {"pr17068 link --as-needed lib in group"
-	"--as-needed --no-dynamic-linker" "--start-group tmpdir/pr17068a.a tmpdir/pr17068.so tmpdir/pr17068b.a --end-group" ""
+	"$LFLAGS --as-needed --no-dynamic-linker"
+	"--start-group tmpdir/pr17068a.a tmpdir/pr17068.so tmpdir/pr17068b.a\
+	 --end-group" ""
 	{start.s pr17068.s} {} "pr17068"}
 } "bfin-*-*"
 
@@ -419,7 +428,7 @@  setup_xfail "hppa*64*-*-hpux*"
 run_ld_link_tests [list \
     [list \
 	"pr20995" \
-	"" "tmpdir/pr20995.so" "$AFLAGS_NONPIC" \
+	"$LFLAGS" "tmpdir/pr20995.so" "$AFLAGS_NONPIC" \
 	{pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995"]]
 
 # xfail on arm*-*-eabi* is particularly because of no support of GNU_RELRO.
@@ -429,7 +438,7 @@  setup_xfail "hppa*64*-*-hpux*"
 run_ld_link_tests [list \
     [list \
 	"pr20995-2" \
-	"" "tmpdir/pr20995-2.so" "$AFLAGS_NONPIC" \
+	"$LFLAGS" "tmpdir/pr20995-2.so" "$AFLAGS_NONPIC" \
 	{pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995-2"]]
 
 setup_xfail "tic6x-*-*"
Index: binutils/ld/testsuite/ld-gc/gc.exp
===================================================================
--- binutils.orig/ld/testsuite/ld-gc/gc.exp	2018-01-31 14:15:45.871840273 +0000
+++ binutils/ld/testsuite/ld-gc/gc.exp	2018-01-31 14:16:12.850499318 +0000
@@ -116,11 +116,18 @@  if { [is_elf_format] && [check_shared_li
     if { [istarget tic6x-*] } then {
 	set gasopt "-mpic -mpid=near"
     }
+    # These targets do not default to linking with shared libraries.
+    set old_ldflags $LDFLAGS
+    if { [istarget "mips*vr4100*-*-elf*"] \
+	 || [istarget "mips*vr4300*-*-elf*"] \
+	 || [istarget "mips*vr5000*-*-elf*"] } {
+	append LDFLAGS " -call_shared"
+    }
     if {![ld_assemble_flags $as $gasopt $srcdir/$subdir/libpersonality.s tmpdir/libpersonality.o]
 	|| ![ld_link $ld tmpdir/libpersonality.so "-shared tmpdir/libpersonality.o"] } then {
 	fail libpersonality
     } else {
-	run_dump_test "personality"
+	run_dump_test "personality" [list [list ld $LFLAGS]]
     }
     run_dump_test "pr18223"
     if {![ld_assemble_flags $as $gasopt $srcdir/$subdir/pr20022a.s tmpdir/pr20022a.o]
@@ -129,6 +136,7 @@  if { [is_elf_format] && [check_shared_li
     } else {
 	run_dump_test "pr20022"
     }
+    set LDFLAGS $old_ldflags
 }
 
 if { [is_remote host] || [which $CC] != 0 } {
Index: binutils/ld/testsuite/ld-mips-elf/comm-data.exp
===================================================================
--- binutils.orig/ld/testsuite/ld-mips-elf/comm-data.exp	2018-01-31 14:15:45.887025109 +0000
+++ binutils/ld/testsuite/ld-mips-elf/comm-data.exp	2018-01-31 14:38:49.598148871 +0000
@@ -136,7 +136,8 @@  proc mips_comm_data_test { abi flag emul
     run_ld_link_tests [list \
 	[list \
 	    "$testname" \
-	    "$LDFLAGS $ZFLAG -T ../ld-elf/comm-data2.ld -Ltmpdir -lmips-$abi-$reloc-comm-data" "" \
+	    "$LDFLAGS -call_shared $ZFLAG -T ../ld-elf/comm-data2.ld -Ltmpdir\
+	     -lmips-$abi-$reloc-comm-data" "" \
 	    "$AFLAGS -call_nonpic" \
 	    { ../ld-elf/comm-data2.s } \
 	    { \