Browse Source
--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.binutils-2_35-branch
committed by
H.J. Lu
22 changed files with 341 additions and 9 deletions
@ -0,0 +1,9 @@ |
|||
#name: --export-dynamic-symbol foo archive |
|||
#source: export-dynamic-symbol.s |
|||
#ld: -pie --export-dynamic-symbol foo tmpdir/libpr25910.a |
|||
#nm: -n |
|||
|
|||
#failif |
|||
#... |
|||
[0-9a-f]+ T +foo |
|||
#... |
|||
@ -0,0 +1,9 @@ |
|||
#name: -u --export-dynamic-symbol foo archive |
|||
#source: export-dynamic-symbol.s |
|||
#ld: -pie -u foo --export-dynamic-symbol foo --export-dynamic-symbol=bar tmpdir/libpr25910.a |
|||
#nm: -D |
|||
|
|||
#... |
|||
[0-9a-f]+ T +bar |
|||
[0-9a-f]+ T +foo |
|||
#... |
|||
@ -0,0 +1,8 @@ |
|||
#name: -u --export-dynamic-symbol "f*" archive |
|||
#source: export-dynamic-symbol.s |
|||
#ld: -pie -u foo --export-dynamic-symbol "f*" tmpdir/libpr25910.a |
|||
#nm: -D |
|||
|
|||
#... |
|||
[0-9a-f]+ T +foo |
|||
#... |
|||
@ -0,0 +1,9 @@ |
|||
#name: --export-dynamic-symbol-list foo archive |
|||
#source: export-dynamic-symbol.s |
|||
#ld: -pie --export-dynamic-symbol-list foo.list tmpdir/libpr25910.a |
|||
#nm: -n |
|||
|
|||
#failif |
|||
#... |
|||
[0-9a-f]+ T +foo |
|||
#... |
|||
@ -0,0 +1,9 @@ |
|||
#name: -u --export-dynamic-symbol-list foo bar archive |
|||
#source: export-dynamic-symbol.s |
|||
#ld: -pie -u foo --export-dynamic-symbol-list foo-bar.list tmpdir/libpr25910.a |
|||
#nm: -D |
|||
|
|||
#... |
|||
[0-9a-f]+ T +bar |
|||
[0-9a-f]+ T +foo |
|||
#... |
|||
@ -0,0 +1,8 @@ |
|||
#name: -u --export-dynamic-symbol-list fstar archive |
|||
#source: export-dynamic-symbol.s |
|||
#ld: -pie -u foo --export-dynamic-symbol-list fstar.list tmpdir/libpr25910.a |
|||
#nm: -D |
|||
|
|||
#... |
|||
[0-9a-f]+ T +foo |
|||
#... |
|||
@ -0,0 +1,70 @@ |
|||
# Expect script for ld --export-dynamic-symbol tests |
|||
# Copyright (C) 2020 Free Software Foundation, Inc. |
|||
# |
|||
# This file is part of the GNU Binutils. |
|||
# |
|||
# This program is free software; you can redistribute it and/or modify |
|||
# it under the terms of the GNU General Public License as published by |
|||
# the Free Software Foundation; either version 3 of the License, or |
|||
# (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU General Public License |
|||
# along with this program; if not, write to the Free Software |
|||
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
|||
# MA 02110-1301, USA. |
|||
# |
|||
|
|||
if ![is_elf_format] { |
|||
return |
|||
} |
|||
|
|||
# Skip targets where -shared is not supported |
|||
|
|||
if ![check_shared_lib_support] { |
|||
return |
|||
} |
|||
|
|||
set old_ASFLAGS $ASFLAGS |
|||
|
|||
# These targets require extra GAS options when building code for shared |
|||
# libraries. |
|||
if [istarget "nds32*-*"] { |
|||
append ASFLAGS " -mpic" |
|||
} |
|||
if [istarget "tic6x-*-*"] { |
|||
append ASFLAGS " -mpic -mpid=near" |
|||
} |
|||
if [istarget "sparc*-*-*"] { |
|||
append ASFLAGS " -K PIC -Av9" |
|||
} |
|||
|
|||
set old_LDFLAGS $LDFLAGS |
|||
|
|||
# These targets require a non-default emulation for successful shared |
|||
# library/executable builds. |
|||
if [istarget "tic6x-*-*"] { |
|||
append LDFLAGS " -melf32_tic6x_le" |
|||
} |
|||
|
|||
set build_tests { |
|||
{"Build libpr25910.a" |
|||
"" "" "" |
|||
{foo.s} {} "libpr25910.a"} |
|||
} |
|||
|
|||
run_ld_link_tests $build_tests |
|||
|
|||
set test_list [lsort [glob -nocomplain $srcdir/$subdir/export-dynamic-symbol-*.d]] |
|||
foreach test_file $test_list { |
|||
set test_name [file rootname $test_file] |
|||
verbose $test_name |
|||
run_dump_test $test_name |
|||
} |
|||
|
|||
set ASFLAGS $old_ASFLAGS |
|||
set LDFLAGS $old_LDFLAGS |
|||
@ -0,0 +1,17 @@ |
|||
.text |
|||
.global start /* Used by SH targets. */ |
|||
start: |
|||
.global _start |
|||
_start: |
|||
.global __start |
|||
__start: |
|||
.global main /* Used by HPPA targets. */ |
|||
main: |
|||
.globl _main /* Used by LynxOS targets. */ |
|||
_main: |
|||
.word 0 |
|||
|
|||
.section .text.1, "ax" |
|||
.global bar |
|||
bar: |
|||
.word 0 |
|||
@ -0,0 +1 @@ |
|||
{ foo; bar; }; |
|||
@ -0,0 +1 @@ |
|||
{ foo; }; |
|||
@ -0,0 +1,4 @@ |
|||
.text |
|||
.globl foo |
|||
foo: |
|||
.byte 0 |
|||
@ -0,0 +1 @@ |
|||
{ f*; }; |
|||
@ -0,0 +1,3 @@ |
|||
{ |
|||
empty; |
|||
}; |
|||
Loading…
Reference in new issue