diff options
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 11 | ||||
-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 | ||||
-rw-r--r-- | ld/emultempl/elf-x86.em | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/linux-x86.exp | 33 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr24920.err | 1 |
8 files changed, 57 insertions, 4 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 8ac66fc2e58..74d2f1b41fe 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,14 @@ +2020-03-13 H.J. Lu <hongjiu.lu@intel.com> + + 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. + 2020-03-13 Christian Eggers <ceggers@gmx.de> * ldexp.c (fold_name): Return SIZEOF_HEADERS in bytes. diff --git a/ld/emulparams/elf32_x86_64.sh b/ld/emulparams/elf32_x86_64.sh index 249553aaac1..1f672c6e426 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 645707ddbdb..c98d5e6600e 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 2b34941986e..be98082982f 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 00000000000..410839b8a56 --- /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; +" diff --git a/ld/emultempl/elf-x86.em b/ld/emultempl/elf-x86.em index 8de44916991..e18caffbb26 100644 --- a/ld/emultempl/elf-x86.em +++ b/ld/emultempl/elf-x86.em @@ -22,6 +22,7 @@ # fragment <<EOF +#include "ldlex.h" #include "elf-linker-x86.h" static struct elf_linker_x86_params params; diff --git a/ld/testsuite/ld-elf/linux-x86.exp b/ld/testsuite/ld-elf/linux-x86.exp index d304fb14427..63a321b9668 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 00000000000..8f5cab91679 --- /dev/null +++ b/ld/testsuite/ld-elf/pr24920.err @@ -0,0 +1 @@ +.*: attempted static link of dynamic object `tmpdir/pr24920.so' |