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/emulparams | |
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/emulparams')
-rw-r--r-- | ld/emulparams/elf32_x86_64.sh | 1 | ||||
-rw-r--r-- | ld/emulparams/elf_i386.sh | 1 | ||||
-rw-r--r-- | ld/emulparams/elf_x86_64.sh | 1 | ||||
-rw-r--r-- | ld/emulparams/static.sh | 12 |
4 files changed, 15 insertions, 0 deletions
diff --git a/ld/emulparams/elf32_x86_64.sh b/ld/emulparams/elf32_x86_64.sh index 249553a..1f672c6 100644 --- a/ld/emulparams/elf32_x86_64.sh +++ b/ld/emulparams/elf32_x86_64.sh @@ -4,6 +4,7 @@ source_sh ${srcdir}/emulparams/dynamic_undefined_weak.sh source_sh ${srcdir}/emulparams/reloc_overflow.sh source_sh ${srcdir}/emulparams/call_nop.sh source_sh ${srcdir}/emulparams/cet.sh +source_sh ${srcdir}/emulparams/static.sh SCRIPT_NAME=elf ELFSIZE=32 OUTPUT_FORMAT="elf32-x86-64" diff --git a/ld/emulparams/elf_i386.sh b/ld/emulparams/elf_i386.sh index 645707d..c98d5e6 100644 --- a/ld/emulparams/elf_i386.sh +++ b/ld/emulparams/elf_i386.sh @@ -3,6 +3,7 @@ source_sh ${srcdir}/emulparams/extern_protected_data.sh source_sh ${srcdir}/emulparams/dynamic_undefined_weak.sh source_sh ${srcdir}/emulparams/call_nop.sh source_sh ${srcdir}/emulparams/cet.sh +source_sh ${srcdir}/emulparams/static.sh SCRIPT_NAME=elf OUTPUT_FORMAT="elf32-i386" NO_RELA_RELOCS=yes diff --git a/ld/emulparams/elf_x86_64.sh b/ld/emulparams/elf_x86_64.sh index 2b34941..be98082 100644 --- a/ld/emulparams/elf_x86_64.sh +++ b/ld/emulparams/elf_x86_64.sh @@ -4,6 +4,7 @@ source_sh ${srcdir}/emulparams/dynamic_undefined_weak.sh source_sh ${srcdir}/emulparams/reloc_overflow.sh source_sh ${srcdir}/emulparams/call_nop.sh source_sh ${srcdir}/emulparams/cet.sh +source_sh ${srcdir}/emulparams/static.sh SCRIPT_NAME=elf ELFSIZE=64 OUTPUT_FORMAT="elf64-x86-64" diff --git a/ld/emulparams/static.sh b/ld/emulparams/static.sh new file mode 100644 index 0000000..410839b --- /dev/null +++ b/ld/emulparams/static.sh @@ -0,0 +1,12 @@ +PARSE_AND_LIST_ARGS_CASES="$PARSE_AND_LIST_ARGS_CASES + case OPTION_DYNAMIC_LINKER: + params.has_dynamic_linker = TRUE; + return FALSE; + + case OPTION_NON_SHARED: + /* Check if -static is passed at command-line before all input + files. */ + if (!lang_has_input_file) + params.static_before_all_inputs = TRUE; + return FALSE; +" |