diff options
Diffstat (limited to 'ld')
90 files changed, 1457 insertions, 8 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 1037198..0318956 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,102 @@ +2016-02-26 H.J. Lu <hongjiu.lu@intel.com> + + PR ld/19636 + PR ld/19704 + PR ld/19719 + * Makefile.am (ELF_X86_DEPS): Add dynamic_undefined_weak.sh. + * Makefile.in: Regenerated. + * NEWS: Mention -z nodynamic-undefined-weak. + * ld.texinfo: Document -z nodynamic-undefined-weak. + * ldmain.c (main): Initialize dynamic_undefined_weak to -1. + * emulparams/dynamic_undefined_weak.sh: New file. + * emulparams/elf32_x86_64.sh: Source dynamic_undefined_weak.sh. + * emulparams/elf_i386.sh: Likewise. + * emulparams/elf_i386_be.sh: Likewise. + * emulparams/elf_i386_chaos.sh: Likewise. + * emulparams/elf_i386_ldso.sh: Likewise. + * emulparams/elf_i386_vxworks.sh: Likewise. + * emulparams/elf_iamcu.sh: Likewise. + * emulparams/elf_k1om.sh: Likewise. + * emulparams/elf_l1om.sh: Likewise. + * emulparams/elf_x86_64.sh: Likewise. + * emulparams/extern_protected_data.sh (PARSE_AND_LIST_OPTIONS): + Append. + (PARSE_AND_LIST_ARGS_CASE_Z): Likewise. + * testsuite/ld-elf/pr19719a.c: New file. + * testsuite/ld-elf/pr19719b.c: Likewise. + * testsuite/ld-elf/pr19719c.c: Likewise. + * testsuite/ld-elf/pr19719d.c: Likewise. + * testsuite/ld-i386/pr19636-1.s: Likewise. + * testsuite/ld-i386/pr19636-1a.d: Likewise. + * testsuite/ld-i386/pr19636-1b.d: Likewise. + * testsuite/ld-i386/pr19636-1c.d: Likewise. + * testsuite/ld-i386/pr19636-1d-nacl.d: Likewise. + * testsuite/ld-i386/pr19636-1d.d: Likewise. + * testsuite/ld-i386/pr19636-1e.d: Likewise. + * testsuite/ld-i386/pr19636-1f.d: Likewise. + * testsuite/ld-i386/pr19636-1g.d: Likewise. + * testsuite/ld-i386/pr19636-1h.d: Likewise. + * testsuite/ld-i386/pr19636-1i.d: Likewise. + * testsuite/ld-i386/pr19636-2.s: Likewise. + * testsuite/ld-i386/pr19636-2a.d: Likewise. + * testsuite/ld-i386/pr19636-2b.d: Likewise. + * testsuite/ld-i386/pr19636-2c-nacl.d: Likewise. + * testsuite/ld-i386/pr19636-2c.d: Likewise. + * testsuite/ld-i386/pr19636-2d-nacl.d: Likewise. + * testsuite/ld-i386/pr19636-2d.d: Likewise. + * testsuite/ld-i386/pr19636-2e-nacl.d: Likewise. + * testsuite/ld-i386/pr19636-2e.d: Likewise. + * testsuite/ld-i386/pr19636-3.s: Likewise. + * testsuite/ld-i386/pr19636-3a.d: Likewise. + * testsuite/ld-i386/pr19636-3b.d: Likewise. + * testsuite/ld-i386/pr19636-3c.d: Likewise. + * testsuite/ld-i386/pr19636-3d.d: Likewise. + * testsuite/ld-i386/pr19636-3e.d: Likewise. + * testsuite/ld-i386/pr19636-3f.d: Likewise. + * testsuite/ld-i386/pr19636-3g.d: Likewise. + * testsuite/ld-i386/pr19636-4.s: Likewise. + * testsuite/ld-i386/pr19636-4a.d: Likewise. + * testsuite/ld-i386/pr19636-4b.d: Likewise. + * testsuite/ld-i386/pr19636-4c.d: Likewise. + * testsuite/ld-i386/pr19636-4d.d: Likewise. + * testsuite/ld-i386/pr19704.out: Likewise. + * testsuite/ld-i386/pr19704a.c: Likewise. + * testsuite/ld-i386/pr19704b.c: Likewise. + * testsuite/ld-x86-64/pr19636-1.s: Likewise. + * testsuite/ld-x86-64/pr19636-1a.d: Likewise. + * testsuite/ld-x86-64/pr19636-1b.d: Likewise. + * testsuite/ld-x86-64/pr19636-1c.d: Likewise. + * testsuite/ld-x86-64/pr19636-1d.d: Likewise. + * testsuite/ld-x86-64/pr19636-1e.d: Likewise. + * testsuite/ld-x86-64/pr19636-1f.d: Likewise. + * testsuite/ld-x86-64/pr19636-1g.d: Likewise. + * testsuite/ld-x86-64/pr19636-2.s: Likewise. + * testsuite/ld-x86-64/pr19636-2a.d: Likewise. + * testsuite/ld-x86-64/pr19636-2b.d: Likewise. + * testsuite/ld-x86-64/pr19636-2c.d: Likewise. + * testsuite/ld-x86-64/pr19636-2d-nacl.d: Likewise. + * testsuite/ld-x86-64/pr19636-2d.d: Likewise. + * testsuite/ld-x86-64/pr19636-2e.d: Likewise. + * testsuite/ld-x86-64/pr19636-2f.d: Likewise. + * testsuite/ld-x86-64/pr19636-2g.d: Likewise. + * testsuite/ld-x86-64/pr19636-2h.d: Likewise. + * testsuite/ld-x86-64/pr19636-2i.d: Likewise. + * testsuite/ld-x86-64/pr19636-3.s: Likewise. + * testsuite/ld-x86-64/pr19636-3a.d: Likewise. + * testsuite/ld-x86-64/pr19636-3b.d: Likewise. + * testsuite/ld-x86-64/pr19636-3c.d: Likewise. + * testsuite/ld-x86-64/pr19636-3d.d: Likewise. + * testsuite/ld-x86-64/pr19704.out: Likewise. + * testsuite/ld-x86-64/pr19704a.c: Likewise. + * testsuite/ld-x86-64/pr19704b.c: Likewise. + * testsuite/ld-elf/shared.exp (mix_pic_and_non_pic): New. + Run mix_pic_and_non_pic. + * testsuite/ld-i386/i386.exp (undefined_weak): New. + Run undefined_weak and PR ld/19636 tests. + * testsuite/ld-x86-64/x86-64.exp: Likewise. + * testsuite/ld-x86-64/pr13082-3b.d: Updated. + * testsuite/ld-x86-64/pr13082-4b.d: Likewise. + 2016-02-25 Nick Clifton <nickc@redhat.com> * ld.h (struct ld_config_type): Remove specified_data_size field. diff --git a/ld/Makefile.am b/ld/Makefile.am index 7339298..4a8c0b6 100644 --- a/ld/Makefile.am +++ b/ld/Makefile.am @@ -671,6 +671,7 @@ ELF_DEPS = $(srcdir)/emultempl/elf32.em $(srcdir)/emultempl/elf-generic.em $(src ELF_GEN_DEPS = $(srcdir)/emultempl/generic.em $(srcdir)/emultempl/elf-generic.em $(srcdir)/emultempl/genelf.em $(srcdir)/scripttempl/DWARF.sc ELF_X86_DEPS = $(ELF_DEPS) $(srcdir)/emulparams/plt_unwind.sh \ $(srcdir)/emulparams/extern_protected_data.sh \ + $(srcdir)/emulparams/dynamic_undefined_weak.sh \ $(srcdir)/emulparams/call_nop.sh @TDIRS@ diff --git a/ld/Makefile.in b/ld/Makefile.in index 8803e22..45388d7 100644 --- a/ld/Makefile.in +++ b/ld/Makefile.in @@ -887,6 +887,7 @@ ELF_DEPS = $(srcdir)/emultempl/elf32.em $(srcdir)/emultempl/elf-generic.em $(src ELF_GEN_DEPS = $(srcdir)/emultempl/generic.em $(srcdir)/emultempl/elf-generic.em $(srcdir)/emultempl/genelf.em $(srcdir)/scripttempl/DWARF.sc ELF_X86_DEPS = $(ELF_DEPS) $(srcdir)/emulparams/plt_unwind.sh \ $(srcdir)/emulparams/extern_protected_data.sh \ + $(srcdir)/emulparams/dynamic_undefined_weak.sh \ $(srcdir)/emulparams/call_nop.sh @@ -1,5 +1,8 @@ -*- text -*- +* Support for -z nodynamic-undefined-weak in the x86 ELF linker, which + avoids dynamic relocations against undefined weak symbols in executable. + Changes in 2.26: * Add --fix-stm32l4xx-629360 to the ARM linker to enable a link-time diff --git a/ld/emulparams/dynamic_undefined_weak.sh b/ld/emulparams/dynamic_undefined_weak.sh new file mode 100644 index 0000000..82d88d6 --- /dev/null +++ b/ld/emulparams/dynamic_undefined_weak.sh @@ -0,0 +1,12 @@ +PARSE_AND_LIST_OPTIONS_NODYNAMIC_UNDEFINED_WEAK=' + fprintf (file, _("\ + -z nodynamic-undefined-weak Do not treat undefined weak symbol as dynamic\n")); +' + +PARSE_AND_LIST_ARGS_CASE_Z_NODYNAMIC_UNDEFINED_WEAK=' + else if (strcmp (optarg, "nodynamic-undefined-weak") == 0) + link_info.dynamic_undefined_weak = FALSE; +' + +PARSE_AND_LIST_OPTIONS="$PARSE_AND_LIST_OPTIONS $PARSE_AND_LIST_OPTIONS_NODYNAMIC_UNDEFINED_WEAK" +PARSE_AND_LIST_ARGS_CASE_Z="$PARSE_AND_LIST_ARGS_CASE_Z $PARSE_AND_LIST_ARGS_CASE_Z_NODYNAMIC_UNDEFINED_WEAK" diff --git a/ld/emulparams/elf32_x86_64.sh b/ld/emulparams/elf32_x86_64.sh index 0a03548..1b285c5 100644 --- a/ld/emulparams/elf32_x86_64.sh +++ b/ld/emulparams/elf32_x86_64.sh @@ -1,5 +1,6 @@ . ${srcdir}/emulparams/plt_unwind.sh . ${srcdir}/emulparams/extern_protected_data.sh +. ${srcdir}/emulparams/dynamic_undefined_weak.sh . ${srcdir}/emulparams/call_nop.sh SCRIPT_NAME=elf ELFSIZE=32 diff --git a/ld/emulparams/elf_i386.sh b/ld/emulparams/elf_i386.sh index 7dceea9..3451bb2 100644 --- a/ld/emulparams/elf_i386.sh +++ b/ld/emulparams/elf_i386.sh @@ -1,5 +1,6 @@ . ${srcdir}/emulparams/plt_unwind.sh . ${srcdir}/emulparams/extern_protected_data.sh +. ${srcdir}/emulparams/dynamic_undefined_weak.sh . ${srcdir}/emulparams/call_nop.sh SCRIPT_NAME=elf OUTPUT_FORMAT="elf32-i386" diff --git a/ld/emulparams/elf_i386_be.sh b/ld/emulparams/elf_i386_be.sh index 40ed8c6..70db443 100644 --- a/ld/emulparams/elf_i386_be.sh +++ b/ld/emulparams/elf_i386_be.sh @@ -1,4 +1,5 @@ . ${srcdir}/emulparams/extern_protected_data.sh +. ${srcdir}/emulparams/dynamic_undefined_weak.sh . ${srcdir}/emulparams/call_nop.sh SCRIPT_NAME=elf OUTPUT_FORMAT="elf32-i386" diff --git a/ld/emulparams/elf_i386_chaos.sh b/ld/emulparams/elf_i386_chaos.sh index 33757bf..aa36cb5 100644 --- a/ld/emulparams/elf_i386_chaos.sh +++ b/ld/emulparams/elf_i386_chaos.sh @@ -1,5 +1,6 @@ . ${srcdir}/emulparams/plt_unwind.sh . ${srcdir}/emulparams/extern_protected_data.sh +. ${srcdir}/emulparams/dynamic_undefined_weak.sh . ${srcdir}/emulparams/call_nop.sh SCRIPT_NAME=elf_chaos OUTPUT_FORMAT="elf32-i386" diff --git a/ld/emulparams/elf_i386_ldso.sh b/ld/emulparams/elf_i386_ldso.sh index f780581..1328520 100644 --- a/ld/emulparams/elf_i386_ldso.sh +++ b/ld/emulparams/elf_i386_ldso.sh @@ -1,5 +1,6 @@ . ${srcdir}/emulparams/plt_unwind.sh . ${srcdir}/emulparams/extern_protected_data.sh +. ${srcdir}/emulparams/dynamic_undefined_weak.sh . ${srcdir}/emulparams/call_nop.sh SCRIPT_NAME=elf OUTPUT_FORMAT="elf32-i386" diff --git a/ld/emulparams/elf_i386_vxworks.sh b/ld/emulparams/elf_i386_vxworks.sh index cb289e6..aaea8c4 100644 --- a/ld/emulparams/elf_i386_vxworks.sh +++ b/ld/emulparams/elf_i386_vxworks.sh @@ -12,4 +12,5 @@ GENERATE_PIE_SCRIPT=yes NO_SMALL_DATA=yes . ${srcdir}/emulparams/vxworks.sh . ${srcdir}/emulparams/extern_protected_data.sh +. ${srcdir}/emulparams/dynamic_undefined_weak.sh . ${srcdir}/emulparams/call_nop.sh diff --git a/ld/emulparams/elf_iamcu.sh b/ld/emulparams/elf_iamcu.sh index 5fae651..863027b 100644 --- a/ld/emulparams/elf_iamcu.sh +++ b/ld/emulparams/elf_iamcu.sh @@ -1,5 +1,6 @@ . ${srcdir}/emulparams/plt_unwind.sh . ${srcdir}/emulparams/extern_protected_data.sh +. ${srcdir}/emulparams/dynamic_undefined_weak.sh . ${srcdir}/emulparams/call_nop.sh SCRIPT_NAME=elf OUTPUT_FORMAT="elf32-iamcu" diff --git a/ld/emulparams/elf_k1om.sh b/ld/emulparams/elf_k1om.sh index 289274d..494efcc 100644 --- a/ld/emulparams/elf_k1om.sh +++ b/ld/emulparams/elf_k1om.sh @@ -1,5 +1,6 @@ . ${srcdir}/emulparams/plt_unwind.sh . ${srcdir}/emulparams/extern_protected_data.sh +. ${srcdir}/emulparams/dynamic_undefined_weak.sh . ${srcdir}/emulparams/call_nop.sh SCRIPT_NAME=elf ELFSIZE=64 diff --git a/ld/emulparams/elf_l1om.sh b/ld/emulparams/elf_l1om.sh index 17fa8e2..b115879 100644 --- a/ld/emulparams/elf_l1om.sh +++ b/ld/emulparams/elf_l1om.sh @@ -1,5 +1,6 @@ . ${srcdir}/emulparams/plt_unwind.sh . ${srcdir}/emulparams/extern_protected_data.sh +. ${srcdir}/emulparams/dynamic_undefined_weak.sh . ${srcdir}/emulparams/call_nop.sh SCRIPT_NAME=elf ELFSIZE=64 diff --git a/ld/emulparams/elf_x86_64.sh b/ld/emulparams/elf_x86_64.sh index 5d31da1..0159a6c 100644 --- a/ld/emulparams/elf_x86_64.sh +++ b/ld/emulparams/elf_x86_64.sh @@ -1,5 +1,6 @@ . ${srcdir}/emulparams/plt_unwind.sh . ${srcdir}/emulparams/extern_protected_data.sh +. ${srcdir}/emulparams/dynamic_undefined_weak.sh . ${srcdir}/emulparams/call_nop.sh SCRIPT_NAME=elf ELFSIZE=64 diff --git a/ld/emulparams/extern_protected_data.sh b/ld/emulparams/extern_protected_data.sh index fd4bd3b..65c68ad 100644 --- a/ld/emulparams/extern_protected_data.sh +++ b/ld/emulparams/extern_protected_data.sh @@ -1,9 +1,13 @@ -PARSE_AND_LIST_OPTIONS=' +PARSE_AND_LIST_OPTIONS_NOEXTEN_PROTECTED_DATA=' fprintf (file, _("\ -z noextern-protected-data Do not treat protected data symbol as external\n")); ' -PARSE_AND_LIST_ARGS_CASE_Z=' +PARSE_AND_LIST_ARGS_CASE_Z_NOEXTEN_PROTECTED_DATA=' else if (strcmp (optarg, "noextern-protected-data") == 0) link_info.extern_protected_data = FALSE; ' + + +PARSE_AND_LIST_OPTIONS="$PARSE_AND_LIST_OPTIONS $PARSE_AND_LIST_OPTIONS_NOEXTEN_PROTECTED_DATA" +PARSE_AND_LIST_ARGS_CASE_Z="$PARSE_AND_LIST_ARGS_CASE_Z $PARSE_AND_LIST_ARGS_CASE_Z_NOEXTEN_PROTECTED_DATA" diff --git a/ld/ld.texinfo b/ld/ld.texinfo index 723e5e8..ee462c5 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -1199,6 +1199,12 @@ generated by compiler. Updates on protected data symbols by another module aren't visible to the resulting shared library. Supported for i386 and x86-64. +@item nodynamic-undefined-weak +Don't treat undefined weak symbols as dynamic when building executable. +This option overrides linker backend default. It can be used to avoid +dynamic relocations against undefined weak symbols in executable. +Supported for i386 and x86-64. + @item call-nop=prefix-addr @itemx call-nop=prefix-nop @itemx call-nop=suffix-nop diff --git a/ld/ldmain.c b/ld/ldmain.c index 7425da0..21133ab 100644 --- a/ld/ldmain.c +++ b/ld/ldmain.c @@ -278,6 +278,7 @@ main (int argc, char **argv) link_info.fini_function = "_fini"; link_info.relax_pass = 1; link_info.extern_protected_data = -1; + link_info.dynamic_undefined_weak = -1; link_info.pei386_auto_import = -1; link_info.spare_dynamic_tags = 5; link_info.path_separator = ':'; diff --git a/ld/testsuite/ld-elf/pr19719a.c b/ld/testsuite/ld-elf/pr19719a.c new file mode 100644 index 0000000..72249a5 --- /dev/null +++ b/ld/testsuite/ld-elf/pr19719a.c @@ -0,0 +1,12 @@ +#include <stdio.h> + +extern int foo (void); +extern int bar (void); + +int +main (void) +{ + if (foo () == bar ()) + printf ("PASS\n"); + return 0; +} diff --git a/ld/testsuite/ld-elf/pr19719b.c b/ld/testsuite/ld-elf/pr19719b.c new file mode 100644 index 0000000..6ef6268 --- /dev/null +++ b/ld/testsuite/ld-elf/pr19719b.c @@ -0,0 +1,8 @@ +extern int __attribute__ ((weak)) fun (void); +int +foo (void) +{ + if (&fun != 0) + return fun (); + return 0; +} diff --git a/ld/testsuite/ld-elf/pr19719c.c b/ld/testsuite/ld-elf/pr19719c.c new file mode 100644 index 0000000..5c877d9 --- /dev/null +++ b/ld/testsuite/ld-elf/pr19719c.c @@ -0,0 +1,8 @@ +extern int __attribute__ ((weak)) fun (void); +int +bar (void) +{ + if (&fun != 0) + return fun (); + return 0; +} diff --git a/ld/testsuite/ld-elf/pr19719d.c b/ld/testsuite/ld-elf/pr19719d.c new file mode 100644 index 0000000..231eeef --- /dev/null +++ b/ld/testsuite/ld-elf/pr19719d.c @@ -0,0 +1,5 @@ +int +fun (void) +{ + return 20; +} diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp index a864430..e615f55 100644 --- a/ld/testsuite/ld-elf/shared.exp +++ b/ld/testsuite/ld-elf/shared.exp @@ -582,3 +582,63 @@ if { [istarget *-*-linux*] ] \ ] } + +proc mix_pic_and_non_pic {cflags ldflags} { + set testname "Mixing PIC and non-PIC" + if { ![ string match "" $cflags$ldflags] } { + set testname "$testname ($cflags $ldflags)" + } + + run_cc_link_tests [list \ + [list \ + "Build libpr19719a.so" \ + "-shared -Wl,-soname,libpr19719.so" \ + "-fPIC" \ + { pr19719d.c } \ + {} \ + "libpr19719a.so" \ + ] \ + [list \ + "Build libpr19719b.so" \ + "-shared -Wl,-soname,libpr19719.so" \ + "-fPIC" \ + { dummy.c } \ + {} \ + "libpr19719b.so" \ + ] \ + [list \ + "Build pr19073b.o" \ + "-r -nostdlib" \ + "-fPIC" \ + { pr19719b.c } \ + {} \ + "libpr19719b.o" \ + ] \ + ] + + exec cp tmpdir/libpr19719b.so tmpdir/libpr19719.so + + run_ld_link_exec_tests [] [list \ + [list \ + "Run pr19719" \ + "$ldflags tmpdir/libpr19719b.o tmpdir/libpr19719.so -R tmpdir" \ + "" \ + { pr19719a.c pr19719c.c } \ + "pr19719" \ + "pass.out" \ + "$cflags" \ + ] \ + ] + + exec cp tmpdir/libpr19719a.so tmpdir/libpr19719.so + + set exec_output [run_host_cmd tmpdir/pr19719 ""] + if {![string match "PASS" $exec_output]} { + fail $testname + } else { + pass $testname + } +} + +mix_pic_and_non_pic "" "" +mix_pic_and_non_pic "-fPIE" "-pie" diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp index 1a79694..ab8f017 100644 --- a/ld/testsuite/ld-i386/i386.exp +++ b/ld/testsuite/ld-i386/i386.exp @@ -320,6 +320,35 @@ run_dump_test "load5b" run_dump_test "load6" run_dump_test "pr19175" run_dump_test "pr19615" +run_dump_test "pr19636-1a" +run_dump_test "pr19636-1b" +run_dump_test "pr19636-1c" +run_dump_test "pr19636-1d" +run_dump_test "pr19636-1d-nacl" +run_dump_test "pr19636-1e" +run_dump_test "pr19636-1f" +run_dump_test "pr19636-1g" +run_dump_test "pr19636-1h" +run_dump_test "pr19636-1i" +run_dump_test "pr19636-2a" +run_dump_test "pr19636-2b" +run_dump_test "pr19636-2c" +run_dump_test "pr19636-2c-nacl" +run_dump_test "pr19636-2d" +run_dump_test "pr19636-2d-nacl" +run_dump_test "pr19636-2e" +run_dump_test "pr19636-2e-nacl" +run_dump_test "pr19636-3a" +run_dump_test "pr19636-3b" +run_dump_test "pr19636-3c" +run_dump_test "pr19636-3d" +run_dump_test "pr19636-3e" +run_dump_test "pr19636-3f" +run_dump_test "pr19636-3g" +run_dump_test "pr19636-4a" +run_dump_test "pr19636-4b" +run_dump_test "pr19636-4c" +run_dump_test "pr19636-4d" if { !([istarget "i?86-*-linux*"] || [istarget "i?86-*-gnu*"] @@ -339,6 +368,62 @@ run_dump_test "pr17935-2" run_dump_test "pr18801" run_dump_test "pr18815" +proc undefined_weak {cflags ldflags} { + set testname "Undefined weak symbol" + if { ![ string match "" $cflags$ldflags] } { + set testname "$testname ($cflags $ldflags)" + } + + if { [ regexp "\-fPIE" $cflags] + && ![ regexp "\-z nodynamic-undefined-weak" $ldflags] } { + set weak_symbol "Weak defined" + } else { + set weak_symbol "Weak undefined" + } + + run_cc_link_tests [list \ + [list \ + "Build libpr19704a.so" \ + "-shared -Wl,-soname,libpr19704.so" \ + "" \ + { dummy.s } \ + {} \ + "libpr19704a.so" \ + ] \ + [list \ + "Build libpr19704b.so" \ + "-shared -Wl,-soname,libpr19704.so" \ + "-fPIC" \ + { pr19704b.c } \ + {} \ + "libpr19704b.so" \ + ] \ + ] + + exec cp tmpdir/libpr19704a.so tmpdir/libpr19704.so + + run_ld_link_exec_tests [] [list \ + [list \ + "Run pr19704" \ + "$ldflags tmpdir/libpr19704.so -R tmpdir" \ + "" \ + { pr19704a.c } \ + "pr19704" \ + "pr19704.out" \ + "$cflags" \ + ] \ + ] + + exec cp tmpdir/libpr19704b.so tmpdir/libpr19704.so + + set exec_output [run_host_cmd tmpdir/pr19704 ""] + if {![string match $weak_symbol $exec_output]} { + fail $testname + } else { + pass $testname + } +} + # Add $PLT_CFLAGS if PLT is expected. global PLT_CFLAGS @@ -636,6 +721,12 @@ if { [isnative] "got1.out" \ ] \ ] + + undefined_weak "" "" + undefined_weak "-fPIE" "" + undefined_weak "-fPIE" "-pie" + undefined_weak "-fPIE" "-z nodynamic-undefined-weak" + undefined_weak "-fPIE" "-pie -z nodynamic-undefined-weak" } if { !([istarget "i?86-*-linux*"] diff --git a/ld/testsuite/ld-i386/pr19636-1.s b/ld/testsuite/ld-i386/pr19636-1.s new file mode 100644 index 0000000..b2bc4df --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-1.s @@ -0,0 +1,9 @@ + .text + .weak func1 + .weak func2 + .weak func3 + .globl _start +_start: + cmp func1@GOT(%eax), %eax + jmp *func2@GOT(%eax) + call func3@PLT diff --git a/ld/testsuite/ld-i386/pr19636-1a.d b/ld/testsuite/ld-i386/pr19636-1a.d new file mode 100644 index 0000000..47b946f --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-1a.d @@ -0,0 +1,16 @@ +#source: pr19636-1.s +#as: --32 -mrelax-relocations=no +#ld: -pie -m elf_i386 --no-dynamic-linker +#readelf : -r --wide -x .got -x .got.plt --dyn-syms + +There are no relocations in this file. + +Symbol table '\.dynsym' contains 1 entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name + +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND + + +Hex dump of section '.got': + 0x[0-9a-f]+ [0 ]+\.+ + +Hex dump of section '.got.plt': + 0x[0-9a-f]+ +[0-9a-f]+ +[0 ]+ .\.+ diff --git a/ld/testsuite/ld-i386/pr19636-1b.d b/ld/testsuite/ld-i386/pr19636-1b.d new file mode 100644 index 0000000..bc67f9d --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-1b.d @@ -0,0 +1,19 @@ +#source: pr19636-1.s +#as: --32 -mrelax-relocations=no +#ld: -pie -E -m elf_i386 --no-dynamic-linker +#readelf : -r --wide -x .got -x .got.plt --dyn-syms + +There are no relocations in this file. + +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name + +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND + +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +_start +#... + +Hex dump of section '.got': + 0x[0-9a-f]+ [0 ]+\.+ + +Hex dump of section '.got.plt': + 0x[0-9a-f]+ +[0-9a-f]+ +[0 ]+ .\.+ diff --git a/ld/testsuite/ld-i386/pr19636-1c.d b/ld/testsuite/ld-i386/pr19636-1c.d new file mode 100644 index 0000000..9aebbb1 --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-1c.d @@ -0,0 +1,9 @@ +#source: pr19636-1.s +#as: --32 -mrelax-relocations=no +#ld: -pie -E -m elf_i386 --no-dynamic-linker +#readelf : --wide --dyn-syms + +#failif +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +WEAK +DEFAULT +UND +func[0-9]? +#... diff --git a/ld/testsuite/ld-i386/pr19636-1d-nacl.d b/ld/testsuite/ld-i386/pr19636-1d-nacl.d new file mode 100644 index 0000000..fef5eea --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-1d-nacl.d @@ -0,0 +1,124 @@ +#source: pr19636-1.s +#as: --32 -mrelax-relocations=no +#ld: -pie -m elf_i386 --no-dynamic-linker +#objdump: -dw +#target: i?86-*-nacl* x86_64-*-nacl* + +.*: +file format .* + + +Disassembly of section .plt: + +0+ <.plt>: +[ ]*[a-f0-9]+: ff 73 04 pushl 0x4\(%ebx\) +[ ]*[a-f0-9]+: 8b 4b 08 mov 0x8\(%ebx\),%ecx +[ ]*[a-f0-9]+: 83 e1 e0 and \$0xffffffe0,%ecx +[ ]*[a-f0-9]+: ff e1 jmp \*%ecx +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 8b 8b 0c 00 00 00 mov 0xc\(%ebx\),%ecx +[ ]*[a-f0-9]+: 83 e1 e0 and \$0xffffffe0,%ecx +[ ]*[a-f0-9]+: ff e1 jmp \*%ecx +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 68 00 00 00 00 push \$0x0 +[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 6a <_start-0x16> +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop + +Disassembly of section .text: + +0+80 <_start>: +[ ]*[a-f0-9]+: 3b 80 f8 ff ff ff cmp -0x8\(%eax\),%eax +[ ]*[a-f0-9]+: ff a0 fc ff ff ff jmp \*-0x4\(%eax\) +[ ]*[a-f0-9]+: e8 af ff ff ff call 40 <_start-0x40> diff --git a/ld/testsuite/ld-i386/pr19636-1d.d b/ld/testsuite/ld-i386/pr19636-1d.d new file mode 100644 index 0000000..16e316c --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-1d.d @@ -0,0 +1,26 @@ +#source: pr19636-1.s +#as: --32 -mrelax-relocations=no +#ld: -pie -m elf_i386 --no-dynamic-linker +#objdump: -dw +#notarget: i?86-*-nacl* x86_64-*-nacl* + +.*: +file format .* + + +Disassembly of section .plt: + +0+c0 <.plt>: +[ ]*[a-f0-9]+: ff b3 04 00 00 00 pushl 0x4\(%ebx\) +[ ]*[a-f0-9]+: ff a3 08 00 00 00 jmp \*0x8\(%ebx\) +[ ]*[a-f0-9]+: 00 00 add %al,\(%eax\) +[ ]*[a-f0-9]+: 00 00 add %al,\(%eax\) +[ ]*[a-f0-9]+: ff a3 0c 00 00 00 jmp \*0xc\(%ebx\) +[ ]*[a-f0-9]+: 68 00 00 00 00 push \$0x0 +[ ]*[a-f0-9]+: e9 00 00 00 00 jmp [a-f0-9]+ <.*> + +Disassembly of section .text: + +0+e0 <_start>: +[ ]*[a-f0-9]+: 3b 80 f8 ff ff ff cmp -0x8\(%eax\),%eax +[ ]*[a-f0-9]+: ff a0 fc ff ff ff jmp \*-0x4\(%eax\) +[ ]*[a-f0-9]+: e8 df ff ff ff call d0 <_start-0x10> diff --git a/ld/testsuite/ld-i386/pr19636-1e.d b/ld/testsuite/ld-i386/pr19636-1e.d new file mode 100644 index 0000000..25a5b64 --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-1e.d @@ -0,0 +1,19 @@ +#source: pr19636-1.s +#as: --32 -mrelax-relocations=no +#ld: -shared -m elf_i386 --no-dynamic-linker +#readelf : -r --wide --dyn-syms + +Relocation section '\.rel\.dyn' at offset [0x0-9a-f]+ contains 2 entries: + +Offset +Info +Type +Sym. Value +Symbol's Name +[0-9a-f]+ +[0-9a-f]+ +R_386_GLOB_DAT +0+ +func1 +[0-9a-f]+ +[0-9a-f]+ +R_386_GLOB_DAT +0+ +func2 + +Relocation section '\.rel\.plt' at offset 0x[0-9a-f]+ contains 1 entries: + +Offset +Info +Type +Sym. Value +Symbol's Name +[0-9a-f]+ +[0-9a-f]+ +R_386_JUMP_SLOT +0+ +func3 + +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +WEAK +DEFAULT +UND +func[0-9]? +#pass diff --git a/ld/testsuite/ld-i386/pr19636-1f.d b/ld/testsuite/ld-i386/pr19636-1f.d new file mode 100644 index 0000000..0bf7595 --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-1f.d @@ -0,0 +1,19 @@ +#source: pr19636-1.s +#as: --32 -mrelax-relocations=no +#ld: -shared -Bsymbolic -m elf_i386 --no-dynamic-linker +#readelf : -r --wide --dyn-syms + +Relocation section '\.rel\.dyn' at offset [0x0-9a-f]+ contains 2 entries: + +Offset +Info +Type +Sym. Value +Symbol's Name +[0-9a-f]+ +[0-9a-f]+ +R_386_GLOB_DAT +0+ +func1 +[0-9a-f]+ +[0-9a-f]+ +R_386_GLOB_DAT +0+ +func2 + +Relocation section '\.rel\.plt' at offset 0x[0-9a-f]+ contains 1 entries: + +Offset +Info +Type +Sym. Value +Symbol's Name +[0-9a-f]+ +[0-9a-f]+ +R_386_JUMP_SLOT +0+ +func3 + +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +WEAK +DEFAULT +UND +func[0-9]? +#pass diff --git a/ld/testsuite/ld-i386/pr19636-1g.d b/ld/testsuite/ld-i386/pr19636-1g.d new file mode 100644 index 0000000..1b3233f --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-1g.d @@ -0,0 +1,12 @@ +#source: pr19636-1.s +#as: --32 -mrelax-relocations=no +#ld: -m elf_i386 --no-dynamic-linker +#readelf : -r --wide -x .got -x .got.plt --dyn-syms + +There are no relocations in this file. + +Hex dump of section '.got': + 0x[0-9a-f]+ [0 ]+\.+ + +Hex dump of section '.got.plt': + 0x[0-9a-f]+ [0 ]+\.+ diff --git a/ld/testsuite/ld-i386/pr19636-1h.d b/ld/testsuite/ld-i386/pr19636-1h.d new file mode 100644 index 0000000..f9c4837 --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-1h.d @@ -0,0 +1,19 @@ +#source: pr19636-1.s +#as: --32 -mrelax-relocations=no +#ld: -E -m elf_i386 --no-dynamic-linker +#readelf : -r --wide -x .got -x .got.plt --dyn-syms + +There are no relocations in this file. + +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name + +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND + +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +_start +#... + +Hex dump of section '.got': + 0x[0-9a-f]+ [0 ]+\.+ + +Hex dump of section '.got.plt': + 0x[0-9a-f]+ +[0-9a-f]+ +[0 ]+ .\.+ diff --git a/ld/testsuite/ld-i386/pr19636-1i.d b/ld/testsuite/ld-i386/pr19636-1i.d new file mode 100644 index 0000000..f67e39b --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-1i.d @@ -0,0 +1,9 @@ +#source: pr19636-1.s +#as: --32 -mrelax-relocations=no +#ld: -E -m elf_i386 --no-dynamic-linker +#readelf : --wide --dyn-syms + +#failif +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +WEAK +DEFAULT +UND +func[0-9]? +#... diff --git a/ld/testsuite/ld-i386/pr19636-2.s b/ld/testsuite/ld-i386/pr19636-2.s new file mode 100644 index 0000000..e8e7c9f --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-2.s @@ -0,0 +1,9 @@ + .text + .weak func + .globl _start +_start: + cmp func@GOT(%eax), %eax + jmp *func@GOT(%eax) + call func@PLT + cmp $func, %eax + call func diff --git a/ld/testsuite/ld-i386/pr19636-2a.d b/ld/testsuite/ld-i386/pr19636-2a.d new file mode 100644 index 0000000..fbed7e7 --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-2a.d @@ -0,0 +1,19 @@ +#source: pr19636-2.s +#as: --32 -mrelax-relocations=no +#ld: -pie -m elf_i386 +#readelf : -r --wide -x .got -x .got.plt --dyn-syms + +Relocation section '\.rel\.dyn' at offset [0x0-9a-f]+ contains 1 entries: + +Offset +Info +Type +Sym. Value +Symbol's Name +[0-9a-f]+ +[0-9a-f]+ +R_386_PC32 +0+ +func + +Symbol table '\.dynsym' contains 2 entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name + +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND + + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +WEAK +DEFAULT +UND +func + +Hex dump of section '.got': + 0x[0-9a-f]+ [0 ]+\.+ + +Hex dump of section '.got.plt': + 0x[0-9a-f]+ +[0-9a-f]+ +[0 ]+ .\.+ diff --git a/ld/testsuite/ld-i386/pr19636-2b.d b/ld/testsuite/ld-i386/pr19636-2b.d new file mode 100644 index 0000000..9a0a263 --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-2b.d @@ -0,0 +1,22 @@ +#source: pr19636-2.s +#as: --32 -mrelax-relocations=no +#ld: -pie -E -m elf_i386 +#readelf : -r --wide -x .got -x .got.plt --dyn-syms + +Relocation section '\.rel\.dyn' at offset [0x0-9a-f]+ contains 1 entries: + +Offset +Info +Type +Sym. Value +Symbol's Name +[0-9a-f]+ +[0-9a-f]+ +R_386_PC32 +0+ +func + +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +_start +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +WEAK +DEFAULT +UND +func +#... + +Hex dump of section '.got': + 0x[0-9a-f]+ [0 ]+\.+ + +Hex dump of section '.got.plt': + 0x[0-9a-f]+ +[0-9a-f]+ +[0 ]+ .\.+ diff --git a/ld/testsuite/ld-i386/pr19636-2c-nacl.d b/ld/testsuite/ld-i386/pr19636-2c-nacl.d new file mode 100644 index 0000000..7543e0e --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-2c-nacl.d @@ -0,0 +1,126 @@ +#source: pr19636-2.s +#as: --32 -mrelax-relocations=no +#ld: -pie -m elf_i386 +#objdump: -dw +#target: i?86-*-nacl* x86_64-*-nacl* + +.*: +file format .* + + +Disassembly of section .plt: + +0+ <.plt>: +[ ]*[a-f0-9]+: ff 73 04 pushl 0x4\(%ebx\) +[ ]*[a-f0-9]+: 8b 4b 08 mov 0x8\(%ebx\),%ecx +[ ]*[a-f0-9]+: 83 e1 e0 and \$0xffffffe0,%ecx +[ ]*[a-f0-9]+: ff e1 jmp \*%ecx +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 8b 8b 0c 00 00 00 mov 0xc\(%ebx\),%ecx +[ ]*[a-f0-9]+: 83 e1 e0 and \$0xffffffe0,%ecx +[ ]*[a-f0-9]+: ff e1 jmp \*%ecx +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 68 00 00 00 00 push \$0x0 +[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 6a <_start-0x16> +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop +[ ]*[a-f0-9]+: 90 nop + +Disassembly of section .text: + +0+80 <_start>: +[ ]*[a-f0-9]+: 3b 80 fc ff ff ff cmp -0x4\(%eax\),%eax +[ ]*[a-f0-9]+: ff a0 fc ff ff ff jmp \*-0x4\(%eax\) +[ ]*[a-f0-9]+: e8 af ff ff ff call 40 <_start-0x40> +[ ]*[a-f0-9]+: 3d 00 00 00 00 cmp \$0x0,%eax +[ ]*[a-f0-9]+: e8 fc ff ff ff call 97 <_start\+0x17> diff --git a/ld/testsuite/ld-i386/pr19636-2c.d b/ld/testsuite/ld-i386/pr19636-2c.d new file mode 100644 index 0000000..98b53aa --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-2c.d @@ -0,0 +1,28 @@ +#source: pr19636-2.s +#as: --32 -mrelax-relocations=no +#ld: -pie -m elf_i386 +#objdump: -dw +#notarget: i?86-*-nacl* x86_64-*-nacl* + +.*: +file format .* + + +Disassembly of section .plt: + +0+130 <.plt>: +[ ]*[a-f0-9]+: ff b3 04 00 00 00 pushl 0x4\(%ebx\) +[ ]*[a-f0-9]+: ff a3 08 00 00 00 jmp \*0x8\(%ebx\) +[ ]*[a-f0-9]+: 00 00 add %al,\(%eax\) +[ ]*[a-f0-9]+: 00 00 add %al,\(%eax\) +[ ]*[a-f0-9]+: ff a3 0c 00 00 00 jmp \*0xc\(%ebx\) +[ ]*[a-f0-9]+: 68 00 00 00 00 push \$0x0 +[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 150 <_start> + +Disassembly of section .text: + +0+150 <_start>: +[ ]*[a-f0-9]+: 3b 80 fc ff ff ff cmp -0x4\(%eax\),%eax +[ ]*[a-f0-9]+: ff a0 fc ff ff ff jmp \*-0x4\(%eax\) +[ ]*[a-f0-9]+: e8 df ff ff ff call 140 <_start-0x10> +[ ]*[a-f0-9]+: 3d 00 00 00 00 cmp \$0x0,%eax +[ ]*[a-f0-9]+: e8 fc ff ff ff call 167 <_start\+0x17> diff --git a/ld/testsuite/ld-i386/pr19636-2d-nacl.d b/ld/testsuite/ld-i386/pr19636-2d-nacl.d new file mode 100644 index 0000000..99c491f --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-2d-nacl.d @@ -0,0 +1,21 @@ +#source: pr19636-2.s +#as: --32 -mrelax-relocations=no +#ld: -shared -m elf_i386 +#readelf : -r --wide --dyn-syms +#target: i?86-*-nacl* x86_64-*-nacl* + +Relocation section '\.rel\.dyn' at offset [0x0-9a-f]+ contains 3 entries: + +Offset +Info +Type +Sym. Value +Symbol's Name +[0-9a-f]+ +[0-9a-f]+ +R_386_32 +0+ +func +[0-9a-f]+ +[0-9a-f]+ +R_386_PC32 +0+ +func +[0-9a-f]+ +[0-9a-f]+ +R_386_GLOB_DAT +0+ +func + +Relocation section '\.rel\.plt' at offset [0x0-9a-f]+ contains 1 entries: + +Offset +Info +Type +Sym. Value +Symbol's Name +[0-9a-f]+ +[0-9a-f]+ +R_386_JUMP_SLOT +0+ +func + +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +WEAK +DEFAULT +UND +func +#pass diff --git a/ld/testsuite/ld-i386/pr19636-2d.d b/ld/testsuite/ld-i386/pr19636-2d.d new file mode 100644 index 0000000..28eaa04 --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-2d.d @@ -0,0 +1,17 @@ +#source: pr19636-2.s +#as: --32 -mrelax-relocations=no +#ld: -shared -m elf_i386 +#readelf : -r --wide --dyn-syms +#notarget: i?86-*-nacl* x86_64-*-nacl* + +Relocation section '\.rel\.dyn' at offset [0x0-9a-f]+ contains 3 entries: + +Offset +Info +Type +Sym. Value +Symbol's Name +[0-9a-f]+ +[0-9a-f]+ +R_386_32 +0+ +func +[0-9a-f]+ +[0-9a-f]+ +R_386_PC32 +0+ +func +[0-9a-f]+ +[0-9a-f]+ +R_386_GLOB_DAT +0+ +func + +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +WEAK +DEFAULT +UND +func +#pass diff --git a/ld/testsuite/ld-i386/pr19636-2e-nacl.d b/ld/testsuite/ld-i386/pr19636-2e-nacl.d new file mode 100644 index 0000000..f791128 --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-2e-nacl.d @@ -0,0 +1,21 @@ +#source: pr19636-2.s +#as: --32 -mrelax-relocations=no +#ld: -shared -Bsymbolic -m elf_i386 +#readelf : -r --wide --dyn-syms +#target: i?86-*-nacl* x86_64-*-nacl* + +Relocation section '\.rel\.dyn' at offset [0x0-9a-f]+ contains 3 entries: + +Offset +Info +Type +Sym. Value +Symbol's Name +[0-9a-f]+ +[0-9a-f]+ +R_386_32 +0+ +func +[0-9a-f]+ +[0-9a-f]+ +R_386_PC32 +0+ +func +[0-9a-f]+ +[0-9a-f]+ +R_386_GLOB_DAT +0+ +func + +Relocation section '\.rel\.plt' at offset [0x0-9a-f]+ contains 1 entries: + +Offset +Info +Type +Sym. Value +Symbol's Name +[0-9a-f]+ +[0-9a-f]+ +R_386_JUMP_SLOT +0+ +func + +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +WEAK +DEFAULT +UND +func +#pass diff --git a/ld/testsuite/ld-i386/pr19636-2e.d b/ld/testsuite/ld-i386/pr19636-2e.d new file mode 100644 index 0000000..148e306 --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-2e.d @@ -0,0 +1,17 @@ +#source: pr19636-2.s +#as: --32 -mrelax-relocations=no +#ld: -shared -Bsymbolic -m elf_i386 +#readelf : -r --wide --dyn-syms +#notarget: i?86-*-nacl* x86_64-*-nacl* + +Relocation section '\.rel\.dyn' at offset [0x0-9a-f]+ contains 3 entries: + +Offset +Info +Type +Sym. Value +Symbol's Name +[0-9a-f]+ +[0-9a-f]+ +R_386_32 +0+ +func +[0-9a-f]+ +[0-9a-f]+ +R_386_PC32 +0+ +func +[0-9a-f]+ +[0-9a-f]+ +R_386_GLOB_DAT +0+ +func + +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +WEAK +DEFAULT +UND +func +#pass diff --git a/ld/testsuite/ld-i386/pr19636-3.s b/ld/testsuite/ld-i386/pr19636-3.s new file mode 100644 index 0000000..9bd7e4a --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-3.s @@ -0,0 +1,5 @@ + .text + .weak func + .globl _start +_start: + .dc.a func diff --git a/ld/testsuite/ld-i386/pr19636-3a.d b/ld/testsuite/ld-i386/pr19636-3a.d new file mode 100644 index 0000000..078896e --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-3a.d @@ -0,0 +1,10 @@ +#source: pr19636-3.s +#as: --32 +#ld: -pie -m elf_i386 +#readelf : -r --dyn-syms --wide + +There are no relocations in this file. + +Symbol table '\.dynsym' contains 1 entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name + +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND + diff --git a/ld/testsuite/ld-i386/pr19636-3b.d b/ld/testsuite/ld-i386/pr19636-3b.d new file mode 100644 index 0000000..e8f9138 --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-3b.d @@ -0,0 +1,6 @@ +#source: pr19636-3.s +#as: --32 +#ld: -pie -E -m elf_i386 +#readelf : -r --wide + +There are no relocations in this file. diff --git a/ld/testsuite/ld-i386/pr19636-3c.d b/ld/testsuite/ld-i386/pr19636-3c.d new file mode 100644 index 0000000..701b131 --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-3c.d @@ -0,0 +1,9 @@ +#source: pr19636-3.s +#as: --32 +#ld: -pie -E -m elf_i386 +#readelf : --dyn-syms --wide + +#failif +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +WEAK +DEFAULT +UND +func +#... diff --git a/ld/testsuite/ld-i386/pr19636-3d.d b/ld/testsuite/ld-i386/pr19636-3d.d new file mode 100644 index 0000000..12ff6b8 --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-3d.d @@ -0,0 +1,14 @@ +#source: pr19636-3.s +#as: --32 +#ld: -shared -m elf_i386 +#readelf : -r --wide --dyn-syms + +Relocation section '\.rela?\..*' at offset 0x[0-9a-f]+ contains [0-9]+ entries: +#... +[0-9a-f]+[ \t]+[0-9a-f]+[ \t]+R_.*[ \t]+[0-9a-f]+[ \t]+func.* +#... +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +WEAK +DEFAULT +UND +func +#... diff --git a/ld/testsuite/ld-i386/pr19636-3e.d b/ld/testsuite/ld-i386/pr19636-3e.d new file mode 100644 index 0000000..a0f3344 --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-3e.d @@ -0,0 +1,14 @@ +#source: pr19636-3.s +#as: --32 +#ld: -shared -Bsymbolic -m elf_i386 +#readelf : -r --wide --dyn-syms + +Relocation section '\.rela?\..*' at offset 0x[0-9a-f]+ contains [0-9]+ entries: +#... +[0-9a-f]+[ \t]+[0-9a-f]+[ \t]+R_.*[ \t]+[0-9a-f]+[ \t]+func.* +#... +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +WEAK +DEFAULT +UND +func +#... diff --git a/ld/testsuite/ld-i386/pr19636-3f.d b/ld/testsuite/ld-i386/pr19636-3f.d new file mode 100644 index 0000000..858850b --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-3f.d @@ -0,0 +1,6 @@ +#source: pr19636-3.s +#as: --32 +#ld: -E -m elf_i386 +#readelf : -r --wide + +There are no relocations in this file. diff --git a/ld/testsuite/ld-i386/pr19636-3g.d b/ld/testsuite/ld-i386/pr19636-3g.d new file mode 100644 index 0000000..1b0d668 --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-3g.d @@ -0,0 +1,9 @@ +#source: pr19636-3.s +#as: --32 +#ld: -E -m elf_i386 +#readelf : --dyn-syms --wide + +#failif +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +WEAK +DEFAULT +UND +func +#... diff --git a/ld/testsuite/ld-i386/pr19636-4.s b/ld/testsuite/ld-i386/pr19636-4.s new file mode 100644 index 0000000..6c981f5 --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-4.s @@ -0,0 +1,14 @@ + .text + .type start,"function" + .global start +start: + .type _start,"function" + .global _start +_start: + .type __start,"function" + .global __start +__start: + .type main,"function" + .global main +main: + .long 0 diff --git a/ld/testsuite/ld-i386/pr19636-4a.d b/ld/testsuite/ld-i386/pr19636-4a.d new file mode 100644 index 0000000..8cdbc1c --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-4a.d @@ -0,0 +1,8 @@ +#source: pr19636-4.s +#as: --32 +#ld: -pie --defsym foobar=0x100 -m elf_i386 +#readelf : --dyn-syms --wide + +Symbol table '\.dynsym' contains 1 entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name + +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND + diff --git a/ld/testsuite/ld-i386/pr19636-4b.d b/ld/testsuite/ld-i386/pr19636-4b.d new file mode 100644 index 0000000..7ac3629 --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-4b.d @@ -0,0 +1,10 @@ +#source: pr19636-4.s +#as: --32 +#ld: -pie -E --defsym foobar=0x100 -m elf_i386 +#readelf : --dyn-syms --wide + +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name +#... + +[0-9]+: +0+100 +0 +NOTYPE +GLOBAL +DEFAULT +ABS +foobar +#pass diff --git a/ld/testsuite/ld-i386/pr19636-4c.d b/ld/testsuite/ld-i386/pr19636-4c.d new file mode 100644 index 0000000..a3891c4 --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-4c.d @@ -0,0 +1,10 @@ +#source: pr19636-4.s +#as: --32 +#ld: -shared -Bsymbolic --defsym foobar=0x100 -m elf_i386 +#readelf : --dyn-syms --wide + +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name +#... + +[0-9]+: +0+100 +0 +NOTYPE +GLOBAL +DEFAULT +ABS +foobar +#pass diff --git a/ld/testsuite/ld-i386/pr19636-4d.d b/ld/testsuite/ld-i386/pr19636-4d.d new file mode 100644 index 0000000..a9487f0 --- /dev/null +++ b/ld/testsuite/ld-i386/pr19636-4d.d @@ -0,0 +1,10 @@ +#source: pr19636-4.s +#as: --32 +#ld: -E --defsym foobar=0x100 -m elf_i386 +#readelf : --dyn-syms --wide + +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name +#... + +[0-9]+: +0+100 +0 +NOTYPE +GLOBAL +DEFAULT +ABS +foobar +#pass diff --git a/ld/testsuite/ld-i386/pr19704.out b/ld/testsuite/ld-i386/pr19704.out new file mode 100644 index 0000000..3506f46 --- /dev/null +++ b/ld/testsuite/ld-i386/pr19704.out @@ -0,0 +1 @@ +Weak undefined diff --git a/ld/testsuite/ld-i386/pr19704a.c b/ld/testsuite/ld-i386/pr19704a.c new file mode 100644 index 0000000..aa52e00 --- /dev/null +++ b/ld/testsuite/ld-i386/pr19704a.c @@ -0,0 +1,13 @@ +#include <stdio.h> + +extern int __attribute__ ((weak)) fun (void); + +int +main (void) +{ + if (&fun != 0) + fun (); + else + printf ("Weak undefined\n"); + return 0; +} diff --git a/ld/testsuite/ld-i386/pr19704b.c b/ld/testsuite/ld-i386/pr19704b.c new file mode 100644 index 0000000..1d688e1 --- /dev/null +++ b/ld/testsuite/ld-i386/pr19704b.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +void +fun (void) +{ + printf ("Weak defined\n"); +} diff --git a/ld/testsuite/ld-x86-64/pr13082-3b.d b/ld/testsuite/ld-x86-64/pr13082-3b.d index 12efaf0..766dd74 100644 --- a/ld/testsuite/ld-x86-64/pr13082-3b.d +++ b/ld/testsuite/ld-x86-64/pr13082-3b.d @@ -4,6 +4,4 @@ #ld: -pie -melf32_x86_64 #readelf: -r --wide -Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entries: - Offset Info Type Sym. Value Symbol's Name \+ Addend -[0-9a-f]+ +[0-9a-f]+ +R_X86_64_32 +[0-9a-f]+ +func \+ 0 +There are no relocations in this file. diff --git a/ld/testsuite/ld-x86-64/pr13082-4b.d b/ld/testsuite/ld-x86-64/pr13082-4b.d index cb4d90a..6d4a35b 100644 --- a/ld/testsuite/ld-x86-64/pr13082-4b.d +++ b/ld/testsuite/ld-x86-64/pr13082-4b.d @@ -4,6 +4,4 @@ #ld: -pie -melf32_x86_64 #readelf: -r --wide -Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entries: - Offset Info Type Sym. Value Symbol's Name \+ Addend -[0-9a-f]+ +[0-9a-f]+ +R_X86_64_64 +[0-9a-f]+ +func \+ 1 +There are no relocations in this file. diff --git a/ld/testsuite/ld-x86-64/pr19636-1.s b/ld/testsuite/ld-x86-64/pr19636-1.s new file mode 100644 index 0000000..9bd7e4a --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-1.s @@ -0,0 +1,5 @@ + .text + .weak func + .globl _start +_start: + .dc.a func diff --git a/ld/testsuite/ld-x86-64/pr19636-1a.d b/ld/testsuite/ld-x86-64/pr19636-1a.d new file mode 100644 index 0000000..5cdfcb9 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-1a.d @@ -0,0 +1,10 @@ +#source: pr19636-1.s +#as: --64 +#ld: -pie -m elf_x86_64 +#readelf : -r --dyn-syms --wide + +There are no relocations in this file. + +Symbol table '\.dynsym' contains 1 entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name + +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND + diff --git a/ld/testsuite/ld-x86-64/pr19636-1b.d b/ld/testsuite/ld-x86-64/pr19636-1b.d new file mode 100644 index 0000000..e68e399 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-1b.d @@ -0,0 +1,6 @@ +#source: pr19636-1.s +#as: --64 +#ld: -pie -E -m elf_x86_64 +#readelf : -r --wide + +There are no relocations in this file. diff --git a/ld/testsuite/ld-x86-64/pr19636-1c.d b/ld/testsuite/ld-x86-64/pr19636-1c.d new file mode 100644 index 0000000..5262a51 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-1c.d @@ -0,0 +1,9 @@ +#source: pr19636-1.s +#as: --64 +#ld: -pie -E -m elf_x86_64 +#readelf : --dyn-syms --wide + +#failif +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +WEAK +DEFAULT +UND +func +#... diff --git a/ld/testsuite/ld-x86-64/pr19636-1d.d b/ld/testsuite/ld-x86-64/pr19636-1d.d new file mode 100644 index 0000000..00da41e --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-1d.d @@ -0,0 +1,14 @@ +#source: pr19636-1.s +#as: --64 +#ld: -shared -m elf_x86_64 +#readelf : -r --wide --dyn-syms + +Relocation section '\.rela?\..*' at offset 0x[0-9a-f]+ contains [0-9]+ entries: +#... +[0-9a-f]+[ \t]+[0-9a-f]+[ \t]+R_.*[ \t]+[0-9a-f]+[ \t]+func.* +#... +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +WEAK +DEFAULT +UND +func +#... diff --git a/ld/testsuite/ld-x86-64/pr19636-1e.d b/ld/testsuite/ld-x86-64/pr19636-1e.d new file mode 100644 index 0000000..ea369b2 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-1e.d @@ -0,0 +1,14 @@ +#source: pr19636-1.s +#as: --64 +#ld: -shared -Bsymbolic -m elf_x86_64 +#readelf : -r --wide --dyn-syms + +Relocation section '\.rela?\..*' at offset 0x[0-9a-f]+ contains [0-9]+ entries: +#... +[0-9a-f]+[ \t]+[0-9a-f]+[ \t]+R_.*[ \t]+[0-9a-f]+[ \t]+func.* +#... +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +WEAK +DEFAULT +UND +func +#... diff --git a/ld/testsuite/ld-x86-64/pr19636-1f.d b/ld/testsuite/ld-x86-64/pr19636-1f.d new file mode 100644 index 0000000..4fc721a --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-1f.d @@ -0,0 +1,6 @@ +#source: pr19636-1.s +#as: --64 +#ld: -E -m elf_x86_64 +#readelf : -r --wide + +There are no relocations in this file. diff --git a/ld/testsuite/ld-x86-64/pr19636-1g.d b/ld/testsuite/ld-x86-64/pr19636-1g.d new file mode 100644 index 0000000..7cd52a5 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-1g.d @@ -0,0 +1,9 @@ +#source: pr19636-1.s +#as: --64 +#ld: -E -m elf_x86_64 +#readelf : --dyn-syms --wide + +#failif +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +WEAK +DEFAULT +UND +func +#... diff --git a/ld/testsuite/ld-x86-64/pr19636-2.s b/ld/testsuite/ld-x86-64/pr19636-2.s new file mode 100644 index 0000000..8814ecd --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-2.s @@ -0,0 +1,9 @@ + .text + .weak func1 + .weak func2 + .weak func3 + .globl _start +_start: + cmp func1@GOTPCREL(%rip),%rax + jmp *func2@GOTPCREL(%rip) + call func3@PLT diff --git a/ld/testsuite/ld-x86-64/pr19636-2a.d b/ld/testsuite/ld-x86-64/pr19636-2a.d new file mode 100644 index 0000000..1efb87e --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-2a.d @@ -0,0 +1,17 @@ +#source: pr19636-2.s +#as: --64 -mrelax-relocations=no +#ld: -pie -m elf_x86_64 --no-dynamic-linker +#readelf : -r --wide -x .got -x .got.plt --dyn-syms + +There are no relocations in this file. + +Symbol table '\.dynsym' contains 1 entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name + +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND + + +Hex dump of section '.got': + 0x[0-9a-f]+ [0 ]+\.+ + +Hex dump of section '.got.plt': + 0x[0-9a-f]+ +[0-9a-f]+ +[0 ]+ .+ + 0x[0-9a-f]+ [0 ]+\.+ diff --git a/ld/testsuite/ld-x86-64/pr19636-2b.d b/ld/testsuite/ld-x86-64/pr19636-2b.d new file mode 100644 index 0000000..7e3b6ff --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-2b.d @@ -0,0 +1,20 @@ +#source: pr19636-2.s +#as: --64 -mrelax-relocations=no +#ld: -pie -E -m elf_x86_64 --no-dynamic-linker +#readelf : -r --wide -x .got -x .got.plt --dyn-syms + +There are no relocations in this file. + +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name + +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND + +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +_start +#... + +Hex dump of section '.got': + 0x[0-9a-f]+ [0 ]+\.+ + +Hex dump of section '.got.plt': + 0x[0-9a-f]+ +[0-9a-f]+ +[0 ]+ .+ + 0x[0-9a-f]+ [0 ]+\.+ diff --git a/ld/testsuite/ld-x86-64/pr19636-2c.d b/ld/testsuite/ld-x86-64/pr19636-2c.d new file mode 100644 index 0000000..4659da7 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-2c.d @@ -0,0 +1,9 @@ +#source: pr19636-2.s +#as: --64 -mrelax-relocations=no +#ld: -pie -E -m elf_x86_64 --no-dynamic-linker +#readelf : --wide --dyn-syms + +#failif +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +WEAK +DEFAULT +UND +func[0-9]? +#... diff --git a/ld/testsuite/ld-x86-64/pr19636-2d-nacl.d b/ld/testsuite/ld-x86-64/pr19636-2d-nacl.d new file mode 100644 index 0000000..67851a6 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-2d-nacl.d @@ -0,0 +1,37 @@ +#source: pr19636-2.s +#as: --64 -mrelax-relocations=no +#ld: -pie -m elf_x86_64 --no-dynamic-linker +#objdump: -dw +#target: x86_64-*-nacl* + +.*: +file format .* + + +Disassembly of section .plt: + +0+ <.plt>: +[ ]*[a-f0-9]+: ff 35 42 02 01 10 pushq 0x10010242\(%rip\) # 10010248 <_GLOBAL_OFFSET_TABLE_\+0x8> +[ ]*[a-f0-9]+: 4c 8b 1d 43 02 01 10 mov 0x10010243\(%rip\),%r11 # 10010250 <_GLOBAL_OFFSET_TABLE_\+0x10> +[ ]*[a-f0-9]+: 41 83 e3 e0 and \$0xffffffe0,%r11d +[ ]*[a-f0-9]+: 4d 01 fb add %r15,%r11 +[ ]*[a-f0-9]+: 41 ff e3 jmpq \*%r11 +[ ]*[a-f0-9]+: 66 0f 1f 84 00 00 00 00 00 nopw 0x0\(%rax,%rax,1\) +[ ]*[a-f0-9]+: 66 66 66 66 66 66 2e 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 data16 nopw %cs:0x0\(%rax,%rax,1\) +[ ]*[a-f0-9]+: 66 66 66 66 66 66 2e 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 data16 nopw %cs:0x0\(%rax,%rax,1\) +[ ]*[a-f0-9]+: 66 90 xchg %ax,%ax +[ ]*[a-f0-9]+: 4c 8b 1d 11 02 01 10 mov 0x10010211\(%rip\),%r11 # 10010258 <_GLOBAL_OFFSET_TABLE_\+0x18> +[ ]*[a-f0-9]+: 41 83 e3 e0 and \$0xffffffe0,%r11d +[ ]*[a-f0-9]+: 4d 01 fb add %r15,%r11 +[ ]*[a-f0-9]+: 41 ff e3 jmpq \*%r11 +[ ]*[a-f0-9]+: 66 66 66 66 66 66 2e 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 data16 nopw %cs:0x0\(%rax,%rax,1\) +[ ]*[a-f0-9]+: 68 00 00 00 00 pushq \$0x0 +[ ]*[a-f0-9]+: e9 00 00 00 00 jmpq 6a <_start-0x16> +[ ]*[a-f0-9]+: 66 66 66 66 66 66 2e 0f 1f 84 00 00 00 00 00 data16 data16 data16 data16 data16 nopw %cs:0x0\(%rax,%rax,1\) +[ ]*[a-f0-9]+: 0f 1f 80 00 00 00 00 nopl 0x0\(%rax\) + +Disassembly of section .text: + +0+80 <_start>: +[ ]*[a-f0-9]+: 48 3b 05 a9 01 01 10 cmp 0x100101a9\(%rip\),%rax # 10010230 <_DYNAMIC\+0xe0> +[ ]*[a-f0-9]+: ff 25 ab 01 01 10 jmpq \*0x100101ab\(%rip\) # 10010238 <_DYNAMIC\+0xe8> +[ ]*[a-f0-9]+: e8 ae ff ff ff callq 40 <_start-0x40> diff --git a/ld/testsuite/ld-x86-64/pr19636-2d.d b/ld/testsuite/ld-x86-64/pr19636-2d.d new file mode 100644 index 0000000..ff25ec1 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-2d.d @@ -0,0 +1,25 @@ +#source: pr19636-2.s +#as: --64 -mrelax-relocations=no +#ld: -pie -m elf_x86_64 --no-dynamic-linker +#objdump: -dw +#notarget: x86_64-*-nacl* + +.*: +file format .* + + +Disassembly of section .plt: + +0+120 <.plt>: +[ ]*[a-f0-9]+: ff 35 2a 01 20 00 pushq 0x20012a\(%rip\) # 200250 <_GLOBAL_OFFSET_TABLE_\+0x8> +[ ]*[a-f0-9]+: ff 25 2c 01 20 00 jmpq \*0x20012c\(%rip\) # 200258 <_GLOBAL_OFFSET_TABLE_\+0x10> +[ ]*[a-f0-9]+: 0f 1f 40 00 nopl 0x0\(%rax\) +[ ]*[a-f0-9]+: ff 25 2a 01 20 00 jmpq \*0x20012a\(%rip\) # 200260 <_GLOBAL_OFFSET_TABLE_\+0x18> +[ ]*[a-f0-9]+: 68 00 00 00 00 pushq \$0x0+ +[ ]*[a-f0-9]+: e9 00 00 00 00 jmpq [a-f0-9]+ <.*> + +Disassembly of section .text: + +0+140 <_start>: +[ ]*[a-f0-9]+: 48 3b 05 f1 00 20 00 cmp 0x2000f1\(%rip\),%rax # 200238 <_DYNAMIC\+0xe0> +[ ]*[a-f0-9]+: ff 25 f3 00 20 00 jmpq \*0x2000f3\(%rip\) # 200240 <_DYNAMIC\+0xe8> +[ ]*[a-f0-9]+: e8 de ff ff ff callq 130 <_start-0x10> diff --git a/ld/testsuite/ld-x86-64/pr19636-2e.d b/ld/testsuite/ld-x86-64/pr19636-2e.d new file mode 100644 index 0000000..3689d75 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-2e.d @@ -0,0 +1,19 @@ +#source: pr19636-2.s +#as: --64 -mrelax-relocations=no +#ld: -shared -m elf_x86_64 --no-dynamic-linker +#readelf : -r --wide --dyn-syms + +Relocation section '\.rela\.dyn' at offset [0x0-9a-f]+ contains 2 entries: + +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend +[0-9a-f]+ +[0-9a-f]+ +R_X86_64_GLOB_DAT +0+ +func1 \+ 0 +[0-9a-f]+ +[0-9a-f]+ +R_X86_64_GLOB_DAT +0+ +func2 \+ 0 + +Relocation section '\.rela\.plt' at offset 0x[0-9a-f]+ contains 1 entries: + +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend +[0-9a-f]+ +[0-9a-f]+ +R_X86_64_JUMP_SLOT +0+ +func3 \+ 0 + +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +WEAK +DEFAULT +UND +func[0-9]? +#pass diff --git a/ld/testsuite/ld-x86-64/pr19636-2f.d b/ld/testsuite/ld-x86-64/pr19636-2f.d new file mode 100644 index 0000000..605fa24 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-2f.d @@ -0,0 +1,19 @@ +#source: pr19636-2.s +#as: --64 -mrelax-relocations=no +#ld: -shared -Bsymbolic -m elf_x86_64 --no-dynamic-linker +#readelf : -r --wide --dyn-syms + +Relocation section '\.rela\.dyn' at offset [0x0-9a-f]+ contains 2 entries: + +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend +[0-9a-f]+ +[0-9a-f]+ +R_X86_64_GLOB_DAT +0+ +func1 \+ 0 +[0-9a-f]+ +[0-9a-f]+ +R_X86_64_GLOB_DAT +0+ +func2 \+ 0 + +Relocation section '\.rela\.plt' at offset 0x[0-9a-f]+ contains 1 entries: + +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend +[0-9a-f]+ +[0-9a-f]+ +R_X86_64_JUMP_SLOT +0+ +func3 \+ 0 + +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +WEAK +DEFAULT +UND +func[0-9]? +#pass diff --git a/ld/testsuite/ld-x86-64/pr19636-2g.d b/ld/testsuite/ld-x86-64/pr19636-2g.d new file mode 100644 index 0000000..f4553d8 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-2g.d @@ -0,0 +1,13 @@ +#source: pr19636-2.s +#as: --64 -mrelax-relocations=no +#ld: -m elf_x86_64 --no-dynamic-linker +#readelf : -r --wide -x .got -x .got.plt --dyn-syms + +There are no relocations in this file. + +Hex dump of section '.got': + 0x[0-9a-f]+ [0 ]+\.+ + +Hex dump of section '.got.plt': + 0x[0-9a-f]+ [0 ]+\.+ + 0x[0-9a-f]+ [0 ]+\.+ diff --git a/ld/testsuite/ld-x86-64/pr19636-2h.d b/ld/testsuite/ld-x86-64/pr19636-2h.d new file mode 100644 index 0000000..4353fbc --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-2h.d @@ -0,0 +1,20 @@ +#source: pr19636-2.s +#as: --64 -mrelax-relocations=no +#ld: -E -m elf_x86_64 --no-dynamic-linker +#readelf : -r --wide -x .got -x .got.plt --dyn-syms + +There are no relocations in this file. + +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name + +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND + +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +_start +#... + +Hex dump of section '.got': + 0x[0-9a-f]+ [0 ]+\.+ + +Hex dump of section '.got.plt': + 0x[0-9a-f]+ +[0-9a-f]+ +[0 ]+ .+ + 0x[0-9a-f]+ [0 ]+\.+ diff --git a/ld/testsuite/ld-x86-64/pr19636-2i.d b/ld/testsuite/ld-x86-64/pr19636-2i.d new file mode 100644 index 0000000..7a4003a --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-2i.d @@ -0,0 +1,9 @@ +#source: pr19636-2.s +#as: --64 -mrelax-relocations=no +#ld: -E -m elf_x86_64 --no-dynamic-linker +#readelf : --wide --dyn-syms + +#failif +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +WEAK +DEFAULT +UND +func[0-9]? +#... diff --git a/ld/testsuite/ld-x86-64/pr19636-3.s b/ld/testsuite/ld-x86-64/pr19636-3.s new file mode 100644 index 0000000..6c981f5 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-3.s @@ -0,0 +1,14 @@ + .text + .type start,"function" + .global start +start: + .type _start,"function" + .global _start +_start: + .type __start,"function" + .global __start +__start: + .type main,"function" + .global main +main: + .long 0 diff --git a/ld/testsuite/ld-x86-64/pr19636-3a.d b/ld/testsuite/ld-x86-64/pr19636-3a.d new file mode 100644 index 0000000..af01939 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-3a.d @@ -0,0 +1,8 @@ +#source: pr19636-3.s +#as: --64 +#ld: -pie --defsym foobar=0x100 -m elf_x86_64 +#readelf : --dyn-syms --wide + +Symbol table '\.dynsym' contains 1 entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name + +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND + diff --git a/ld/testsuite/ld-x86-64/pr19636-3b.d b/ld/testsuite/ld-x86-64/pr19636-3b.d new file mode 100644 index 0000000..be8c4f6 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-3b.d @@ -0,0 +1,10 @@ +#source: pr19636-3.s +#as: --64 +#ld: -pie -E --defsym foobar=0x100 -m elf_x86_64 +#readelf : --dyn-syms --wide + +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name +#... + +[0-9]+: +0+100 +0 +NOTYPE +GLOBAL +DEFAULT +ABS +foobar +#pass diff --git a/ld/testsuite/ld-x86-64/pr19636-3c.d b/ld/testsuite/ld-x86-64/pr19636-3c.d new file mode 100644 index 0000000..02b6464 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-3c.d @@ -0,0 +1,10 @@ +#source: pr19636-3.s +#as: --64 +#ld: -shared -Bsymbolic --defsym foobar=0x100 -m elf_x86_64 +#readelf : --dyn-syms --wide + +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name +#... + +[0-9]+: +0+100 +0 +NOTYPE +GLOBAL +DEFAULT +ABS +foobar +#pass diff --git a/ld/testsuite/ld-x86-64/pr19636-3d.d b/ld/testsuite/ld-x86-64/pr19636-3d.d new file mode 100644 index 0000000..3d9a6d7 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19636-3d.d @@ -0,0 +1,10 @@ +#source: pr19636-3.s +#as: --64 +#ld: -E --defsym foobar=0x100 -m elf_x86_64 +#readelf : --dyn-syms --wide + +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name +#... + +[0-9]+: +0+100 +0 +NOTYPE +GLOBAL +DEFAULT +ABS +foobar +#pass diff --git a/ld/testsuite/ld-x86-64/pr19704.out b/ld/testsuite/ld-x86-64/pr19704.out new file mode 100644 index 0000000..3506f46 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19704.out @@ -0,0 +1 @@ +Weak undefined diff --git a/ld/testsuite/ld-x86-64/pr19704a.c b/ld/testsuite/ld-x86-64/pr19704a.c new file mode 100644 index 0000000..aa52e00 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19704a.c @@ -0,0 +1,13 @@ +#include <stdio.h> + +extern int __attribute__ ((weak)) fun (void); + +int +main (void) +{ + if (&fun != 0) + fun (); + else + printf ("Weak undefined\n"); + return 0; +} diff --git a/ld/testsuite/ld-x86-64/pr19704b.c b/ld/testsuite/ld-x86-64/pr19704b.c new file mode 100644 index 0000000..1d688e1 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr19704b.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +void +fun (void) +{ + printf ("Weak defined\n"); +} diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index 7248377..214b08b 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -355,6 +355,82 @@ run_dump_test "pr19162" run_dump_test "pr19175" run_dump_test "pr18591" run_dump_test "pr19615" +run_dump_test "pr19636-1a" +run_dump_test "pr19636-1b" +run_dump_test "pr19636-1c" +run_dump_test "pr19636-1d" +run_dump_test "pr19636-1e" +run_dump_test "pr19636-1f" +run_dump_test "pr19636-1g" +run_dump_test "pr19636-2a" +run_dump_test "pr19636-2b" +run_dump_test "pr19636-2c" +run_dump_test "pr19636-2d" +run_dump_test "pr19636-2d-nacl" +run_dump_test "pr19636-2e" +run_dump_test "pr19636-2f" +run_dump_test "pr19636-2g" +run_dump_test "pr19636-2h" +run_dump_test "pr19636-2i" +run_dump_test "pr19636-3a" +run_dump_test "pr19636-3b" +run_dump_test "pr19636-3c" + +proc undefined_weak {cflags ldflags} { + set testname "Undefined weak symbol" + if { ![ string match "" $cflags$ldflags] } { + set testname "$testname ($cflags $ldflags)" + } + + if { [ regexp "\-fPIE" $cflags] + && ![ regexp "\-z nodynamic-undefined-weak" $ldflags] } { + set weak_symbol "Weak defined" + } else { + set weak_symbol "Weak undefined" + } + + run_cc_link_tests [list \ + [list \ + "Build libpr19704a.so" \ + "-shared -Wl,-soname,libpr19704.so" \ + "" \ + { dummy.s } \ + {} \ + "libpr19704a.so" \ + ] \ + [list \ + "Build libpr19704b.so" \ + "-shared -Wl,-soname,libpr19704.so" \ + "-fPIC" \ + { pr19704b.c } \ + {} \ + "libpr19704b.so" \ + ] \ + ] + + exec cp tmpdir/libpr19704a.so tmpdir/libpr19704.so + + run_ld_link_exec_tests [] [list \ + [list \ + "Run pr19704" \ + "$ldflags tmpdir/libpr19704.so -R tmpdir" \ + "" \ + { pr19704a.c } \ + "pr19704" \ + "pr19704.out" \ + "$cflags" \ + ] \ + ] + + exec cp tmpdir/libpr19704b.so tmpdir/libpr19704.so + + set exec_output [run_host_cmd tmpdir/pr19704 ""] + if {![string match $weak_symbol $exec_output]} { + fail $testname + } else { + pass $testname + } +} # Add $PLT_CFLAGS if PLT is expected. global PLT_CFLAGS @@ -686,6 +762,12 @@ if { [isnative] && [which $CC] != 0 } { ] \ ] } + + undefined_weak "" "" + undefined_weak "-fPIE" "" + undefined_weak "-fPIE" "-pie" + undefined_weak "-fPIE" "-z nodynamic-undefined-weak" + undefined_weak "-fPIE" "-pie -z nodynamic-undefined-weak" } if { ![istarget "x86_64-*-linux*"]} { |