From fb35d3d8fae4422243d6803c41b5cb4d2f5e5e2a Mon Sep 17 00:00:00 2001 From: David Daney Date: Fri, 16 Dec 2011 06:18:55 +0000 Subject: [PATCH] 2011-12-15 David Daney Nick Clifton * ld-elfvers/vers.exp (picflag): Set to -fpic for mips*-*-* when using GCC-4.3 or later. (pic): Set to "yes" for mips*-*-linux*. * ld-elfvsb/elfvsb.exp: Don't test non-PIC shared libraried on mips*-*-linux*. (picflag): Set to -fpic for mips*-*-* when using GCC-4.3 or later. * ld-elfweak/elfweak.exp (picflag): Set to -fpic for mips*-*-* when using GCC-4.3 or later. * ld-shared/shared.exp (picflag): Same. * lib/ld-lib.exp (at_least_gcc_version): New proc. --- ld/testsuite/ChangeLog | 14 ++++++++++++++ ld/testsuite/ld-elfvers/vers.exp | 9 ++++++--- ld/testsuite/ld-elfvsb/elfvsb.exp | 7 +++++-- ld/testsuite/ld-elfweak/elfweak.exp | 4 +++- ld/testsuite/ld-shared/shared.exp | 4 +++- ld/testsuite/lib/ld-lib.exp | 25 +++++++++++++++++++++++++ 6 files changed, 56 insertions(+), 7 deletions(-) diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 27f44c2..6dd2e3d 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,17 @@ +2011-12-15 David Daney + Nick Clifton + + * ld-elfvers/vers.exp (picflag): Set to -fpic for mips*-*-* when + using GCC-4.3 or later. + (pic): Set to "yes" for mips*-*-linux*. + * ld-elfvsb/elfvsb.exp: Don't test non-PIC shared libraried on + mips*-*-linux*. + (picflag): Set to -fpic for mips*-*-* when using GCC-4.3 or later. + * ld-elfweak/elfweak.exp (picflag): Set to -fpic for mips*-*-* + when using GCC-4.3 or later. + * ld-shared/shared.exp (picflag): Same. + * lib/ld-lib.exp (at_least_gcc_version): New proc. + 2011-12-10 David Daney * ld-mips-elf/pic-and-nonpic-6-n64.dd: Use correct encoding for diff --git a/ld/testsuite/ld-elfvers/vers.exp b/ld/testsuite/ld-elfvers/vers.exp index d1c2228..b8fefb6 100644 --- a/ld/testsuite/ld-elfvers/vers.exp +++ b/ld/testsuite/ld-elfvers/vers.exp @@ -72,7 +72,9 @@ set SOBJDUMP_FLAGS --syms set shared "--shared --no-undefined-version" set script --version-script -if [istarget mips*-*-*] { +# Old version of GCC for MIPS default to enabling -fpic +# and get confused if it is used on the command line. +if { [istarget mips*-*-*] && ! [at_least_gcc_version 4 3] } then { set picflag "" } else { # Unfortunately, the gcc argument is -fpic and the cc argument is @@ -768,8 +770,9 @@ proc build_exec { test source execname flags solibname verexp versymexp symexp } pass $test } -if [istarget x86_64-*-linux*] { - # x86_64 doesn't like non-pic shared libraries +if { [istarget x86_64-*-linux*] \ + || ( [istarget mips*-*-linux*] && [at_least_gcc_version 4 3] ) } { + # x86_64 and newer MIPS toolchains do not like non-pic shared libraries set pic "yes" } else { set pic "no" diff --git a/ld/testsuite/ld-elfvsb/elfvsb.exp b/ld/testsuite/ld-elfvsb/elfvsb.exp index 3c64783..58bc8f2 100644 --- a/ld/testsuite/ld-elfvsb/elfvsb.exp +++ b/ld/testsuite/ld-elfvsb/elfvsb.exp @@ -249,7 +249,8 @@ proc visibility_run {visibility} { set VSBCFLAG "" }}}}}}}}} - if { [istarget powerpc*-*-linux*] } { + if { [istarget powerpc*-*-linux*] \ + || ( [istarget mips*-*-linux*] && [at_least_gcc_version 4 3] )} { # Testing non-PIC libraries is a waste of effort on any target. # If you don't pass -fpic or -fPIC to gcc, gcc will assume quite # reasonably that you are not compiling for a shared library. @@ -453,7 +454,9 @@ proc visibility_run {visibility} { }} } -if [istarget mips*-*-*] { +# Old version of GCC for MIPS default to enabling -fpic +# and get confused if it is used on the command line. +if { [istarget mips*-*-*] && ! [at_least_gcc_version 4 3] } then { set picflag "" } else { # Unfortunately, the gcc argument is -fpic and the cc argument is diff --git a/ld/testsuite/ld-elfweak/elfweak.exp b/ld/testsuite/ld-elfweak/elfweak.exp index 0cc1299..1b60b89 100644 --- a/ld/testsuite/ld-elfweak/elfweak.exp +++ b/ld/testsuite/ld-elfweak/elfweak.exp @@ -370,7 +370,9 @@ proc build_exec { test execname objs flags dat dynsymexp symexp} { pass $test } -if [istarget mips*-*-*] { +# Old version of GCC for MIPS default to enabling -fpic +# and get confused if it is used on the command line. +if { [istarget mips*-*-*] && ! [at_least_gcc_version 4 3] } then { set picflag "" } else { # Unfortunately, the gcc argument is -fpic and the cc argument is diff --git a/ld/testsuite/ld-shared/shared.exp b/ld/testsuite/ld-shared/shared.exp index 1d25d51..c31ac7d 100644 --- a/ld/testsuite/ld-shared/shared.exp +++ b/ld/testsuite/ld-shared/shared.exp @@ -181,7 +181,9 @@ proc shared_test { progname testname main sh1 sh2 dat args } { pass "$testname" } -if [istarget mips*-*-*] { +# Old version of GCC for MIPS default to enabling -fpic +# and get confused if it is used on the command line. +if { [istarget mips*-*-*] && ! [at_least_gcc_version 4 3] } then { set picflag "" } else { # Unfortunately, the gcc argument is -fpic and the cc argument is diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp index 30098c1..25999e9 100644 --- a/ld/testsuite/lib/ld-lib.exp +++ b/ld/testsuite/lib/ld-lib.exp @@ -27,6 +27,31 @@ proc load_common_lib { name } { load_common_lib binutils-common.exp +# Returns 1 if the gcc for the target is at least version MAJOR.MINOR +# Returns 0 otherwise. +# +proc at_least_gcc_version { major minor } { + + if {![info exists CC]} { + set CC [find_gcc] + } + if { $CC == "" } { + return 0 + } + set state [remote_exec host $CC --version] + set tmp "[lindex $state 1]\n" + # Look for (eg) 4.6.1 in the version output. + regexp " .* (\[1-9\])\\.(\[0-9\])\\.\[0-9\]* .*" "$tmp" fred maj min + verbose "gcc version: $tmp" + verbose "major gcc version is $maj, want at least $major" + if { $maj == $major } then { + verbose "minor gcc version is $min, want at least $minor" + return [expr $min >= $minor ] + } else { + return [expr $maj > $major ] + } +} + # Extract and print the version number of ld. # proc default_ld_version { ld } { -- 2.7.4