diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2020-03-13 07:34:56 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2020-03-13 07:39:06 -0700 |
commit | 74e10d1742f1b8312359c59a2af06c9e661252b3 (patch) | |
tree | 7627e27f43e85e6906a483b754ff43a93047f5c8 /ld/testsuite | |
parent | 2d61316c32a9fa3e14786c3312d9ca87c9298db5 (diff) | |
download | gdb-74e10d1742f1b8312359c59a2af06c9e661252b3.zip gdb-74e10d1742f1b8312359c59a2af06c9e661252b3.tar.gz gdb-74e10d1742f1b8312359c59a2af06c9e661252b3.tar.bz2 |
x86: Check static link of dynamic objects
On Linux/x86, when -static is passed to gcc, gcc passes it to linker
before all input files suitable for creating static executable. X86
linker will report error for dynamic input objects if -static is passed
at command-line before all input files without --dynamic-linker unless
--no-dynamic-linker is used.
bfd/
PR ld/24920
* elf-linker-x86.h (elf_linker_x86_params): Add
static_before_all_inputs and has_dynamic_linker.
* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Report
dynamic input objects if -static is passed at command-line
before all input files without --dynamic-linker unless
--no-dynamic-linker is used.
ld/
PR ld/24920
* emulparams/elf32_x86_64.sh: Use static.sh.
* emulparams/elf_i386.sh: Likewise.
* emulparams/elf_x86_64.sh: Likewise.
* emulparams/static.sh: New file.
* emultempl/elf-x86.em: Include "ldlex.h".
* testsuite/ld-elf/pr24920.err: New file.
* testsuite/ld-elf/linux-x86.exp: Run ld/24920 tests.
Diffstat (limited to 'ld/testsuite')
-rw-r--r-- | ld/testsuite/ld-elf/linux-x86.exp | 33 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr24920.err | 1 |
2 files changed, 30 insertions, 4 deletions
diff --git a/ld/testsuite/ld-elf/linux-x86.exp b/ld/testsuite/ld-elf/linux-x86.exp index d304fb1..63a321b 100644 --- a/ld/testsuite/ld-elf/linux-x86.exp +++ b/ld/testsuite/ld-elf/linux-x86.exp @@ -19,11 +19,36 @@ # MA 02110-1301, USA. # +# Linux/x86 tests. +if { ![istarget "i?86-*-linux*"] \ + && ![istarget "x86_64-*-linux*"] \ + && ![istarget "amd64-*-linux*"] } { + return +} + +run_ld_link_tests [list \ + [list \ + "Build pr24920.so" \ + "-shared" \ + "" \ + "" \ + {dummy.s} \ + {} \ + "pr24920.so" \ + ] \ + [list \ + "Build pr24920" \ + "-static " \ + "-Bdynamic tmpdir/pr24920.so" \ + "" \ + {start.s} \ + {{ld pr24920.err}} \ + "pr24920" \ + ] \ +] + # Test very simple native Linux/x86 programs with linux-x86.S. -if { ![isnative] || ![check_compiler_available] \ - || (![istarget "i?86-*-linux*"] \ - && ![istarget "x86_64-*-linux*"] \ - && ![istarget "amd64-*-linux*"]) } { +if { ![isnative] || ![check_compiler_available] } { return } diff --git a/ld/testsuite/ld-elf/pr24920.err b/ld/testsuite/ld-elf/pr24920.err new file mode 100644 index 0000000..8f5cab9 --- /dev/null +++ b/ld/testsuite/ld-elf/pr24920.err @@ -0,0 +1 @@ +.*: attempted static link of dynamic object `tmpdir/pr24920.so' |