diff options
author | Fangrui Song <maskray@google.com> | 2020-06-03 06:37:39 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2020-06-03 06:37:39 -0700 |
commit | 37a141bfed4dd3c33d77c15dfde00e4b4f5b24c7 (patch) | |
tree | 05fc3a047c219a7e59357a758472a566e926a570 /ld/ldlang.c | |
parent | 433953ffa1a59531a5537327a4e3ce24565e609c (diff) | |
download | gdb-37a141bfed4dd3c33d77c15dfde00e4b4f5b24c7.zip gdb-37a141bfed4dd3c33d77c15dfde00e4b4f5b24c7.tar.gz gdb-37a141bfed4dd3c33d77c15dfde00e4b4f5b24c7.tar.bz2 |
ld: Add --export-dynamic-symbol and --export-dynamic-symbol-list
--export-dynamic-symbol-list is like a dynamic list, but without
the symbolic property for unspecified symbols.
When creating an executable, --export-dynamic-symbol-list is treated
like --dynamic-list.
When creating a shared library, it is treated like --dynamic-list if
-Bsymbolic or --dynamic-list are used, otherwise, it is ignored, so
that references to matched symbols will not be bound to the definitions
within the shared library.
PR ld/25910
* NEWS: Mention --export-dynamic-symbol[-list].
* ld.texi: Document --export-dynamic-symbol[-list].
* ldgram.y: Pass current_dynamic_list_p to
lang_append_dynamic_list.
* ldlang.c (current_dynamic_list_p): New.
(ang_append_dynamic_list): Updated to take a pointer to
struct bfd_elf_dynamic_list * argument instead of using
link_info.dynamic_list.
(lang_append_dynamic_list_cpp_typeinfo): Pass
&link_info.dynamic_list to ang_append_dynamic_list.
(lang_append_dynamic_list_cpp_new): Likewise.
* ldlang.h (current_dynamic_list_p): New.
(lang_append_dynamic_list): Add a pointer to
struct bfd_elf_dynamic_list * argument.
* ldlex.h (option_values): Add OPTION_EXPORT_DYNAMIC_SYMBOL and
OPTION_EXPORT_DYNAMIC_SYMBOL_LIST.
* lexsup.c (ld_options): Add entries for
OPTION_EXPORT_DYNAMIC_SYMBOL and
OPTION_EXPORT_DYNAMIC_SYMBOL_LIST.
(parse_args): Handle --export-dynamic-symbol and
--export-dynamic-symbol-list.
* testsuite/ld-dynamic/export-dynamic-symbol-1.d: New.
* testsuite/ld-dynamic/export-dynamic-symbol-2.d: New.
* testsuite/ld-dynamic/export-dynamic-symbol-glob.d: New.
* testsuite/ld-dynamic/export-dynamic-symbol-list-1.d: New.
* testsuite/ld-dynamic/export-dynamic-symbol-list-2.d: New.
* testsuite/ld-dynamic/export-dynamic-symbol-list-glob.d: New.
* testsuite/ld-dynamic/export-dynamic-symbol.exp: New.
* testsuite/ld-dynamic/export-dynamic-symbol.s: New.
* testsuite/ld-dynamic/foo-bar.list: New.
* testsuite/ld-dynamic/foo.list: New.
* testsuite/ld-dynamic/foo.s: New.
* testsuite/ld-dynamic/fstar.list: New.
* testsuite/ld-elf/dlempty.list: New.
* testsuite/ld-elf/shared.exp: Add tests for
--export-dynamic-symbol and --export-dynamic-symbol-list.
Diffstat (limited to 'ld/ldlang.c')
-rw-r--r-- | ld/ldlang.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c index 3d653d4..14a6a57 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -118,6 +118,7 @@ lang_statement_list_type file_chain = { NULL, NULL }; lang_statement_union). */ lang_statement_list_type input_file_chain; static const char *current_input_file; +struct bfd_elf_dynamic_list **current_dynamic_list_p; struct bfd_sym_chain entry_symbol = { NULL, NULL }; const char *entry_section = ".text"; struct lang_input_statement_flags input_flags; @@ -9324,15 +9325,16 @@ lang_add_unique (const char *name) /* Append the list of dynamic symbols to the existing one. */ void -lang_append_dynamic_list (struct bfd_elf_version_expr *dynamic) +lang_append_dynamic_list (struct bfd_elf_dynamic_list **list_p, + struct bfd_elf_version_expr *dynamic) { - if (link_info.dynamic_list) + if (*list_p) { struct bfd_elf_version_expr *tail; for (tail = dynamic; tail->next != NULL; tail = tail->next) ; - tail->next = link_info.dynamic_list->head.list; - link_info.dynamic_list->head.list = dynamic; + tail->next = (*list_p)->head.list; + (*list_p)->head.list = dynamic; } else { @@ -9341,7 +9343,7 @@ lang_append_dynamic_list (struct bfd_elf_version_expr *dynamic) d = (struct bfd_elf_dynamic_list *) xcalloc (1, sizeof *d); d->head.list = dynamic; d->match = lang_vers_match; - link_info.dynamic_list = d; + *list_p = d; } } @@ -9363,7 +9365,7 @@ lang_append_dynamic_list_cpp_typeinfo (void) dynamic = lang_new_vers_pattern (dynamic, symbols [i], "C++", FALSE); - lang_append_dynamic_list (dynamic); + lang_append_dynamic_list (&link_info.dynamic_list, dynamic); } /* Append the list of C++ operator new and delete dynamic symbols to the @@ -9384,7 +9386,7 @@ lang_append_dynamic_list_cpp_new (void) dynamic = lang_new_vers_pattern (dynamic, symbols [i], "C++", FALSE); - lang_append_dynamic_list (dynamic); + lang_append_dynamic_list (&link_info.dynamic_list, dynamic); } /* Scan a space and/or comma separated string of features. */ |