]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Don't pass -fPIC to gdb_compile_shlib
authorTom de Vries <tdevries@suse.de>
Mon, 14 Dec 2020 17:16:40 +0000 (18:16 +0100)
committerTom de Vries <tdevries@suse.de>
Mon, 14 Dec 2020 17:16:40 +0000 (18:16 +0100)
When running test-case gdb.base/info-shared.exp, I see in gdb.log:
...
Executing on host: \
  gcc ... -fPIC -fpic -c -o info-shared-solib1.c.o info-shared-solib1.c
...

The -fPIC comes from the test-case:
...
if { [gdb_compile_shlib $srcfile_lib1 $binfile_lib1 \
         [list additional_flags=-fPIC]] != "" } {
...
but the -fpic, which overrides the -fPIC comes from gdb_compile_shlib.

The proc gdb_compile_shlib adds the -fpic or similar dependent on platform
and compiler.  However, in some cases it doesn't add anything, which is
probably why all those test-case pass -fPIC.

Fix this by removing -fPIC from all the calls to gdb_compile_shlib, and
ensuring that gdb_compile_shlib takes care of adding it, if required.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-14  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (gdb_compile_shlib): Make sure it's not necessary to
pass -fPIC.
* gdb.ada/catch_ex_std.exp: Don't pass -fPIC to gdb_compile_shlib.
* gdb.base/break-probes.exp: Same.
* gdb.base/ctxobj.exp: Same.
* gdb.base/dso2dso.exp: Same.
* gdb.base/global-var-nested-by-dso.exp: Same.
* gdb.base/info-shared.exp: Same.
* gdb.base/jit-reader-simple.exp: Same.
* gdb.base/print-file-var.exp: Same.
* gdb.base/skip-solib.exp: Same.
* gdb.btrace/dlopen.exp: Same.

12 files changed:
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.ada/catch_ex_std.exp
gdb/testsuite/gdb.base/break-probes.exp
gdb/testsuite/gdb.base/ctxobj.exp
gdb/testsuite/gdb.base/dso2dso.exp
gdb/testsuite/gdb.base/global-var-nested-by-dso.exp
gdb/testsuite/gdb.base/info-shared.exp
gdb/testsuite/gdb.base/jit-reader-simple.exp
gdb/testsuite/gdb.base/print-file-var.exp
gdb/testsuite/gdb.base/skip-solib.exp
gdb/testsuite/gdb.btrace/dlopen.exp
gdb/testsuite/lib/gdb.exp

index 500d4445098cda4b91cf4299b54d9852725d4c14..1c522e83193ed4fcf4264b6c35f03b38d35288c6 100644 (file)
@@ -1,3 +1,18 @@
+2020-12-14  Tom de Vries  <tdevries@suse.de>
+
+       * lib/gdb.exp (gdb_compile_shlib): Make sure it's not necessary to
+       pass -fPIC.
+       * gdb.ada/catch_ex_std.exp: Don't pass -fPIC to gdb_compile_shlib.
+       * gdb.base/break-probes.exp: Same.
+       * gdb.base/ctxobj.exp: Same.
+       * gdb.base/dso2dso.exp: Same.
+       * gdb.base/global-var-nested-by-dso.exp: Same.
+       * gdb.base/info-shared.exp: Same.
+       * gdb.base/jit-reader-simple.exp: Same.
+       * gdb.base/print-file-var.exp: Same.
+       * gdb.base/skip-solib.exp: Same.
+       * gdb.btrace/dlopen.exp: Same.
+
 2020-12-14  Tom de Vries  <tdevries@suse.de>
 
        PR testsuite/26963
index c5a0a93559437d03b272c510478749dfedec95d7..d49cbab93df9127706431ff1c4e36795eeda7095 100644 (file)
@@ -29,8 +29,7 @@ set sofile [standard_output_file libsome_package.so]
 set outdir [file dirname $binfile]
 
 # Create the shared library.
-if {[gdb_compile_shlib $srcfile2 $sofile \
-        {ada debug additional_flags=-fPIC}] != ""} {
+if {[gdb_compile_shlib $srcfile2 $sofile {ada debug}] != ""} {
     return -1
 }
 
index 08513ddbb216cabb6e4af704d196a8e6115f632a..96ef93d9f569c6d6332a6079e66f816879a8fdfc 100644 (file)
@@ -30,8 +30,7 @@ if { [istarget "*bsd*"] } {
 }
 set probes_bp "dl_main"
 
-if { [gdb_compile_shlib $srcfile_lib $binfile_lib \
-         [list additional_flags=-fPIC]] != "" } {
+if { [gdb_compile_shlib $srcfile_lib $binfile_lib {}] != "" } {
     untested "failed to compile shared library"
     return -1
 }
index b8931bafb433a9beb6a655d784df1ca4a31e5ef0..faf209cc0da37fa4f2ee4c9fdcbde99e23f77daa 100644 (file)
@@ -33,10 +33,10 @@ set libsrc [list "${srcdir}/${subdir}/ctxobj-v.c" \
 set libobj1 [standard_output_file libctxobj1.so]
 set libobj2 [standard_output_file libctxobj2.so]
 
-set libobj1_opts { debug additional_flags=-fPIC
+set libobj1_opts { debug
                    additional_flags=-DVERSION=104
                    additional_flags=-DGET_VERSION=get_version_1 }
-set libobj2_opts { debug additional_flags=-fPIC
+set libobj2_opts { debug
                    additional_flags=-DVERSION=203
                    additional_flags=-DGET_VERSION=get_version_2 }
 
index 7d8ea7057c712e861ae526a6b7665b62be514961..4c0b27955d0ef33bc932780dca3b40ca40c08e23 100644 (file)
@@ -40,13 +40,13 @@ set srcfile_libdso1 $srcdir/$subdir/$libdso1.c
 set binfile_libdso1 [standard_output_file $libdso1.so]
 
 if { [gdb_compile_shlib $srcfile_libdso2 $binfile_libdso2 \
-       [list debug additional_flags=-fPIC]] != "" } {
+       [list debug]] != "" } {
   untested "failed to compile shared library 2"
   return -1
 }
 
 if { [gdb_compile_shlib $srcfile_libdso1 $binfile_libdso1 \
-       [list debug additional_flags=-fPIC]] != "" } {
+       [list debug]] != "" } {
   untested "failed to compile shared library 1"
   return -1
 }
index f88c5d094f913430e4c01b4e8b7a113e2c0615c7..c2775950155a4aa05df3fc3a39cb9ac91df1aaa2 100644 (file)
@@ -28,13 +28,13 @@ set srcfile_lib2 $srcdir/$subdir/$lib2name.c
 set binfile_lib2 [standard_output_file $lib2name.so]
 
 if { [gdb_compile_shlib $srcfile_lib1 $binfile_lib1 \
-       [list debug additional_flags=-fPIC]] != "" } {
+       [list debug]] != "" } {
   untested "failed to compile shared library 1"
   return -1
 }
 
 if { [gdb_compile_shlib $srcfile_lib2 $binfile_lib2 \
-       [list debug additional_flags=-fPIC]] != "" } {
+       [list debug]] != "" } {
   untested "failed to compile shared library 2"
   return -1
 }
index 9a54100f8a6046c65265388f3bbab3baea0903cd..7b8ce5b11e71ac81f088567a7a8c84c3b9ce0317 100644 (file)
@@ -29,14 +29,12 @@ set srcfile_lib2 $srcdir/$subdir/$lib2name.c
 set binfile_lib2 [standard_output_file $lib2name.so]
 set define2 -DSHLIB2_NAME=\"$binfile_lib2\"
 
-if { [gdb_compile_shlib $srcfile_lib1 $binfile_lib1 \
-         [list additional_flags=-fPIC]] != "" } {
+if { [gdb_compile_shlib $srcfile_lib1 $binfile_lib1 {}] != "" } {
     untested "failed to compile shared library 1"
     return -1
 }
 
-if { [gdb_compile_shlib $srcfile_lib2 $binfile_lib2 \
-         [list additional_flags=-fPIC]] != "" } {
+if { [gdb_compile_shlib $srcfile_lib2 $binfile_lib2 {}] != "" } {
     untested "failed to compile shared library 2"
     return -1
 }
index a8f33c6d7a8137ce64e7aab4a4df782a114c0975..99c4dcf7325c1986ccd963aca110ee9ae0b46e8f 100644 (file)
@@ -56,7 +56,7 @@ proc build_shared_jit {{options ""}} {
     global testfile
     global srcfile_lib binfile_lib binfile_lib2
 
-    lappend options "debug additional_flags=-fPIC"
+    lappend options "debug"
     if { [gdb_compile_shlib $srcfile_lib $binfile_lib $options] != "" } {
        return -1
     }
index 62e5f230ebeafc02e31d4ad4828103f09784849c..219bedcde4360534bb14658653a8bc71b230791e 100644 (file)
@@ -42,7 +42,7 @@ proc test {hidden dlopen version_id_main lang} {
     set libobj1 [standard_output_file ${lib1}$suffix.so]
     set libobj2 [standard_output_file ${lib2}$suffix.so]
 
-    set lib_opts { debug additional_flags=-fPIC $lang }
+    set lib_opts { debug $lang }
     lappend lib_opts "additional_flags=-DHIDDEN=$hidden"
 
     if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib1}.c \
index 528410a0d53404f8a2372e852a6bc22a385b9683..8ecba70aa05ca5b83e0b05728190880cb3a9ff88 100644 (file)
@@ -39,7 +39,7 @@ set binfile_lib [standard_output_file ${libname}.so]
 # the main program.
 #
 
-if {[gdb_compile_shlib ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} [list debug additional_flags=-fPIC -Wl,-soname,${libname}.so]] != ""} {
+if {[gdb_compile_shlib ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} [list debug -Wl,-soname,${libname}.so]] != ""} {
     return -1
 }
 
index fc910a933a63984217a0e1225fef5971260ae133..6839b0f4f43954b7632f2c11c116bb00f2183843 100644 (file)
@@ -31,8 +31,7 @@ set basename_lib dlopen-dso
 set srcfile_lib $srcdir/$subdir/$basename_lib.c
 set binfile_lib [standard_output_file $basename_lib.so]
 
-if { [gdb_compile_shlib $srcfile_lib $binfile_lib \
-         [list additional_flags=-fPIC]] != "" } {
+if { [gdb_compile_shlib $srcfile_lib $binfile_lib {}] != "" } {
     untested "failed to prepare shlib"
     return -1
 }
index 46728bb936df904635f092556cbdcdc7b968d16b..94bdf1ac856fc49981f8a276f1d4522b75cdd9f3 100644 (file)
@@ -4304,17 +4304,21 @@ proc gdb_compile_shlib {sources dest options} {
             lappend obj_options "additional_flags=-qpic"
         }
        "clang-*" {
-           if { !([istarget "*-*-cygwin*"]
-                  || [istarget "*-*-mingw*"]) } {
+           if { [istarget "*-*-cygwin*"]
+                || [istarget "*-*-mingw*"] } {
+               lappend obj_options "additional_flags=-fPIC"
+           } else {
                lappend obj_options "additional_flags=-fpic"
            }
        }
         "gcc-*" {
-            if { !([istarget "powerpc*-*-aix*"]
+            if { [istarget "powerpc*-*-aix*"]
                    || [istarget "rs6000*-*-aix*"]
                    || [istarget "*-*-cygwin*"]
                    || [istarget "*-*-mingw*"]
-                   || [istarget "*-*-pe*"]) } {
+                   || [istarget "*-*-pe*"] } {
+                lappend obj_options "additional_flags=-fPIC"
+           } else {
                 lappend obj_options "additional_flags=-fpic"
             }
         }
@@ -4323,6 +4327,7 @@ proc gdb_compile_shlib {sources dest options} {
         }
         default {
            # don't know what the compiler is...
+           lappend obj_options "additional_flags=-fPIC"
         }
     }