diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2016-02-23 08:05:57 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2016-02-23 08:34:31 -0800 |
commit | ebd4795d75eefa19ce686f5360e3dd277243df1e (patch) | |
tree | 227c5f9ed84ac2ff106ec458435ec26bc19acac5 | |
parent | 749468cb2ffd47271ae74631469532a74d913fb0 (diff) | |
download | binutils-gdb-users/hjl/pr19704.tar.gz |
Add dynamic_undefined_weak.shusers/hjl/pr19704
-rw-r--r-- | bfd/elf-bfd.h | 4 | ||||
-rw-r--r-- | bfd/elf32-i386.c | 1 | ||||
-rw-r--r-- | bfd/elf64-x86-64.c | 1 | ||||
-rw-r--r-- | bfd/elfxx-target.h | 6 | ||||
-rw-r--r-- | include/bfdlink.h | 4 | ||||
-rw-r--r-- | ld/Makefile.am | 1 | ||||
-rw-r--r-- | ld/Makefile.in | 1 | ||||
-rw-r--r-- | ld/emulparams/dynamic_undefined_weak.sh | 12 | ||||
-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_i386_be.sh | 1 | ||||
-rw-r--r-- | ld/emulparams/elf_i386_chaos.sh | 1 | ||||
-rw-r--r-- | ld/emulparams/elf_i386_ldso.sh | 1 | ||||
-rw-r--r-- | ld/emulparams/elf_i386_vxworks.sh | 1 | ||||
-rw-r--r-- | ld/emulparams/elf_iamcu.sh | 1 | ||||
-rw-r--r-- | ld/emulparams/elf_k1om.sh | 1 | ||||
-rw-r--r-- | ld/emulparams/elf_l1om.sh | 1 | ||||
-rw-r--r-- | ld/emulparams/elf_x86_64.sh | 1 | ||||
-rw-r--r-- | ld/emulparams/extern_protected_data.sh | 8 |
19 files changed, 45 insertions, 3 deletions
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index e8a4dd51f7a..54d2fbdf5b1 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -1434,6 +1434,10 @@ struct elf_backend_data /* Address of protected data defined in the shared library may be external, i.e., due to copy relocation. */ unsigned extern_protected_data : 1; + + /* Undefined weak symbol in the executable is dynamic, i.e, requires + dynamic relocation. */ + unsigned dynamic_undefined_weak : 1; }; /* Information about reloc sections associated with a bfd_elf_section_data diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index a8951d8d586..59ddfe2b675 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -5768,6 +5768,7 @@ elf_i386_add_symbol_hook (bfd * abfd, #define elf_backend_got_header_size 12 #define elf_backend_plt_alignment 4 #define elf_backend_extern_protected_data 1 +#define elf_backend_dynamic_undefined_weak 0 /* Support RELA for objdump of prelink objects. */ #define elf_info_to_howto elf_i386_info_to_howto_rel diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 8fb2232f90a..274cf489a40 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -6360,6 +6360,7 @@ static const struct bfd_elf_special_section #define elf_backend_rela_normal 1 #define elf_backend_plt_alignment 4 #define elf_backend_extern_protected_data 1 +#define elf_backend_dynamic_undefined_weak 0 #define elf_info_to_howto elf_x86_64_info_to_howto diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h index b3227ed3c52..f35d5d07b4a 100644 --- a/bfd/elfxx-target.h +++ b/bfd/elfxx-target.h @@ -120,6 +120,9 @@ #ifndef elf_backend_extern_protected_data #define elf_backend_extern_protected_data 0 #endif +#ifndef elf_backend_dynamic_undefined_weak +#define elf_backend_dynamic_undefined_weak 1 +#endif #ifndef elf_backend_stack_align #define elf_backend_stack_align 16 #endif @@ -824,7 +827,8 @@ static struct elf_backend_data elfNN_bed = elf_backend_want_p_paddr_set_to_zero, elf_backend_default_execstack, elf_backend_caches_rawsize, - elf_backend_extern_protected_data + elf_backend_extern_protected_data, + elf_backend_dynamic_undefined_weak }; /* Forward declaration for use when initialising alternative_target field. */ diff --git a/include/bfdlink.h b/include/bfdlink.h index 9b849aa761e..860811c2a78 100644 --- a/include/bfdlink.h +++ b/include/bfdlink.h @@ -542,6 +542,10 @@ struct bfd_link_info backend to decide. */ int extern_protected_data; + /* > 0 to treat undefined weak symbol in the executable as dynamic, + requiring dynamic relocation. */ + int dynamic_undefined_weak; + /* Non-zero if auto-import thunks for DATA items in pei386 DLLs should be generated/linked against. Set to 1 if this feature is explicitly requested by the user, -1 if enabled by default. */ diff --git a/ld/Makefile.am b/ld/Makefile.am index 7339298fa99..4a8c0b6e875 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 8803e22c7fa..45388d7bacf 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 diff --git a/ld/emulparams/dynamic_undefined_weak.sh b/ld/emulparams/dynamic_undefined_weak.sh new file mode 100644 index 00000000000..c6d99052a04 --- /dev/null +++ b/ld/emulparams/dynamic_undefined_weak.sh @@ -0,0 +1,12 @@ +PARSE_AND_LIST_OPTIONS_DYNAMIC_UNDEFINED_WEAK=' + fprintf (file, _("\ + -z dynamic-undefined-weak Treat undefined weak symbol as dynamic\n")); +' + +PARSE_AND_LIST_ARGS_CASE_Z_DYNAMIC_UNDEFINED_WEAK=' + else if (strcmp (optarg, "dynamic-undefined-weak") == 0) + link_info.dynamic_undefined_weak = TRUE; +' + +PARSE_AND_LIST_OPTIONS="$PARSE_AND_LIST_OPTIONS $PARSE_AND_LIST_OPTIONS_DYNAMIC_UNDEFINED_WEAK" +PARSE_AND_LIST_ARGS_CASE_Z="$PARSE_AND_LIST_ARGS_CASE_Z $PARSE_AND_LIST_ARGS_CASE_Z_DYNAMIC_UNDEFINED_WEAK" diff --git a/ld/emulparams/elf32_x86_64.sh b/ld/emulparams/elf32_x86_64.sh index 0a035483923..1b285c559a1 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 7dceea9a2dd..3451bb2b1ea 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 40ed8c6608b..70db4432395 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 33757bfd9e1..aa36cb51c2d 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 f7805819b9b..1328520c57c 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 cb289e6307d..aaea8c48743 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 5fae6515ea3..863027b57b4 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 289274daca6..494efcc6c90 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 17fa8e2579c..b1158791f46 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 5d31da1ba1b..0159a6ca44c 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 fd4bd3b3c82..65c68adb0b2 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" |