* lexsup.c: Rename --add-needed to --copy-dt-needed-entries.

* ldlang.h (struct lang_input_statement_struct): Rename add_needed
        to add_DT_NEEDED_for_dynamic.  Rename as_needed to
        add_DT_NEEDED_for_regular.
        * ldlang.c: Likewise.
        * ldlang.h: Likewise.
        * ldlang.c: Use the new variable names.
        * ldgram.y: Likewise.
        * emultempl/elf32.em: Likewise.
        * ld.texinfo: Document the renamed option.  Also mention its
        affect on the resolution of dynamic symbols.
        * NEWS: Mention the changed option name.
This commit is contained in:
Nick Clifton
2009-11-05 15:35:50 +00:00
parent 3cbc5de02a
commit ddbb8a31d5
10 changed files with 119 additions and 66 deletions

View File

@ -1,3 +1,18 @@
2009-11-05 Nick Clifton <nickc@redhat.com>
* lexsup.c: Rename --add-needed to --copy-dt-needed-entries.
* ldlang.h (struct lang_input_statement_struct): Rename add_needed
to add_DT_NEEDED_for_dynamic. Rename as_needed to
add_DT_NEEDED_for_regular.
* ldlang.c: Likewise.
* ldlang.h: Likewise.
* ldlang.c: Use the new variable names.
* ldgram.y: Likewise.
* emultempl/elf32.em: Likewise.
* ld.texinfo: Document the renamed option. Also mention its
affect on the resolution of dynamic symbols.
* NEWS: Mention the changed option name.
2009-11-04 Kai Tietz <kai.tietz@onevision.com> 2009-11-04 Kai Tietz <kai.tietz@onevision.com>
* emulparams/arm_epoc_pe.sh: Remove ENTRY. * emulparams/arm_epoc_pe.sh: Remove ENTRY.

View File

@ -1,5 +1,8 @@
-*- text -*- -*- text -*-
* --add-needed renamed to --copy-dt-needed-entries in order to avoid confusion
with --as-needed option.
* Extend .def file syntax by '== <ID>' for imports and exports. This allows * Extend .def file syntax by '== <ID>' for imports and exports. This allows
to alias the import/export table name written in PE image. to alias the import/export table name written in PE image.

View File

@ -110,7 +110,7 @@ fi
if test x"$LDEMUL_RECOGNIZED_FILE" != xgld"${EMULATION_NAME}"_load_symbols; then if test x"$LDEMUL_RECOGNIZED_FILE" != xgld"${EMULATION_NAME}"_load_symbols; then
fragment <<EOF fragment <<EOF
/* Handle as_needed DT_NEEDED. */ /* Handle the generation of DT_NEEDED tags. */
static bfd_boolean static bfd_boolean
gld${EMULATION_NAME}_load_symbols (lang_input_statement_type *entry) gld${EMULATION_NAME}_load_symbols (lang_input_statement_type *entry)
@ -120,13 +120,13 @@ gld${EMULATION_NAME}_load_symbols (lang_input_statement_type *entry)
/* Tell the ELF linker that we don't want the output file to have a /* Tell the ELF linker that we don't want the output file to have a
DT_NEEDED entry for this file, unless it is used to resolve DT_NEEDED entry for this file, unless it is used to resolve
references in a regular object. */ references in a regular object. */
if (entry->as_needed) if (entry->add_DT_NEEDED_for_regular)
link_class = DYN_AS_NEEDED; link_class = DYN_AS_NEEDED;
/* Tell the ELF linker that we don't want the output file to have a /* Tell the ELF linker that we don't want the output file to have a
DT_NEEDED entry for any dynamic library in DT_NEEDED tags from DT_NEEDED entry for any dynamic library in DT_NEEDED tags from
this file at all. */ this file at all. */
if (!entry->add_needed) if (!entry->add_DT_NEEDED_for_dynamic)
link_class |= DYN_NO_ADD_NEEDED; link_class |= DYN_NO_ADD_NEEDED;
if (entry->just_syms_flag if (entry->just_syms_flag
@ -134,7 +134,7 @@ gld${EMULATION_NAME}_load_symbols (lang_input_statement_type *entry)
einfo (_("%P%F: --just-symbols may not be used on DSO: %B\n"), einfo (_("%P%F: --just-symbols may not be used on DSO: %B\n"),
entry->the_bfd); entry->the_bfd);
if (!link_class if (link_class == 0
|| (bfd_get_file_flags (entry->the_bfd) & DYNAMIC) == 0) || (bfd_get_file_flags (entry->the_bfd) & DYNAMIC) == 0)
return FALSE; return FALSE;

View File

@ -1132,27 +1132,24 @@ restore the old behaviour.
@item --as-needed @item --as-needed
@itemx --no-as-needed @itemx --no-as-needed
This option affects ELF DT_NEEDED tags for dynamic libraries mentioned This option affects ELF DT_NEEDED tags for dynamic libraries mentioned
on the command line after the @option{--as-needed} option. Normally, on the command line after the @option{--as-needed} option. Normally
the linker will add a DT_NEEDED tag for each dynamic library mentioned the linker will add a DT_NEEDED tag for each dynamic library mentioned
on the command line, regardless of whether the library is actually on the command line, regardless of whether the library is actually
needed. @option{--as-needed} causes a DT_NEEDED tag to only be emitted needed or not. @option{--as-needed} causes a DT_NEEDED tag to only be
for a library that satisfies a symbol reference from regular objects emitted for a library that satisfies an undefined symbol reference
which is undefined at the point that the library was linked, or, if from a regular object file or, if the library is not found in the
the library is not found in the DT_NEEDED lists of other libraries DT_NEEDED lists of other libraries linked up to that point, an
linked up to that point, a reference from another dynamic library. undefined symbol reference from another dynamic library.
@option{--no-as-needed} restores the default behaviour. @option{--no-as-needed} restores the default behaviour.
@kindex --add-needed @kindex --add-needed
@kindex --no-add-needed @kindex --no-add-needed
@item --add-needed @item --add-needed
@itemx --no-add-needed @itemx --no-add-needed
This option affects the treatment of dynamic libraries from ELF These two options have been deprecated because of the similarity of
DT_NEEDED tags in dynamic libraries mentioned on the command line after their names to the @option{--as-needed} and @option{--no-as-needed}
the @option{--no-add-needed} option. Normally, the linker will add options. They have been replaced by @option{--copy-dt-needed-entries}
a DT_NEEDED tag for each dynamic library from DT_NEEDED tags. and @option{--no-copy-dt-needed-entries}.
@option{--no-add-needed} causes DT_NEEDED tags will never be emitted
for those libraries from DT_NEEDED tags. @option{--add-needed} restores
the default behaviour.
@kindex -assert @var{keyword} @kindex -assert @var{keyword}
@item -assert @var{keyword} @item -assert @var{keyword}
@ -1253,6 +1250,29 @@ Section overlap is not usually checked for relocatable links. You can
force checking in that case by using the @option{--check-sections} force checking in that case by using the @option{--check-sections}
option. option.
@kindex --copy-dt-needed-entries
@kindex --no-copy-dt-needed-entries
@item --copy-dt-needed-entries
@itemx --no-copy-dt-needed-entries
This option affects the treatment of dynamic libraries referred to
by DT_NEEDED tags @emph{inside} ELF dynamic libraries mentioned on the
command line. Normally the linker will add a DT_NEEDED tag to the
output binary for each library mentioned in a DT_NEEDED tag in an
input dynamic library. With @option{--no-copy-dt-needed-entries}
specified on the command line however any dynamic libraries that
follow it will have their DT_NEEDED entries ignored. The default
behaviour can be restored with @option{--copy-dt-needed-entries}.
This option also has an effect on the resolution of symbols in dynamic
libraries. With the default setting dynamic libraries mentioned on
the command line will be recursively searched, following their
DT_NEEDED tags to other libraries, in order to resolve symbols
required by the output binary. With
@option{--no-copy-dt-needed-entries} specified however the searching
of dynamic libraries that follow it will stop with the dynamic
library itself. No DT_NEEDED links will be traversed to resolve
symbols.
@cindex cross reference table @cindex cross reference table
@kindex --cref @kindex --cref
@item --cref @item --cref

View File

@ -378,17 +378,17 @@ input_list:
{ lang_add_input_file($2,lang_input_file_is_l_enum, { lang_add_input_file($2,lang_input_file_is_l_enum,
(char *)NULL); } (char *)NULL); }
| AS_NEEDED '(' | AS_NEEDED '('
{ $<integer>$ = as_needed; as_needed = TRUE; } { $<integer>$ = add_DT_NEEDED_for_regular; add_DT_NEEDED_for_regular = TRUE; }
input_list ')' input_list ')'
{ as_needed = $<integer>3; } { add_DT_NEEDED_for_regular = $<integer>3; }
| input_list ',' AS_NEEDED '(' | input_list ',' AS_NEEDED '('
{ $<integer>$ = as_needed; as_needed = TRUE; } { $<integer>$ = add_DT_NEEDED_for_regular; add_DT_NEEDED_for_regular = TRUE; }
input_list ')' input_list ')'
{ as_needed = $<integer>5; } { add_DT_NEEDED_for_regular = $<integer>5; }
| input_list AS_NEEDED '(' | input_list AS_NEEDED '('
{ $<integer>$ = as_needed; as_needed = TRUE; } { $<integer>$ = add_DT_NEEDED_for_regular; add_DT_NEEDED_for_regular = TRUE; }
input_list ')' input_list ')'
{ as_needed = $<integer>4; } { add_DT_NEEDED_for_regular = $<integer>4; }
; ;
sections: sections:

View File

@ -1056,8 +1056,8 @@ new_afile (const char *name,
p->next_real_file = NULL; p->next_real_file = NULL;
p->next = NULL; p->next = NULL;
p->dynamic = config.dynamic_link; p->dynamic = config.dynamic_link;
p->add_needed = add_needed; p->add_DT_NEEDED_for_dynamic = add_DT_NEEDED_for_dynamic;
p->as_needed = as_needed; p->add_DT_NEEDED_for_regular = add_DT_NEEDED_for_regular;
p->whole_archive = whole_archive; p->whole_archive = whole_archive;
p->loaded = FALSE; p->loaded = FALSE;
lang_statement_append (&input_file_chain, lang_statement_append (&input_file_chain,
@ -2592,7 +2592,9 @@ load_symbols (lang_input_statement_type *entry,
{ {
bfd_error_type err; bfd_error_type err;
bfd_boolean save_ldlang_sysrooted_script; bfd_boolean save_ldlang_sysrooted_script;
bfd_boolean save_as_needed, save_add_needed, save_whole_archive; bfd_boolean save_add_DT_NEEDED_for_regular;
bfd_boolean save_add_DT_NEEDED_for_dynamic;
bfd_boolean save_whole_archive;
err = bfd_get_error (); err = bfd_get_error ();
@ -2623,10 +2625,10 @@ load_symbols (lang_input_statement_type *entry,
push_stat_ptr (place); push_stat_ptr (place);
save_ldlang_sysrooted_script = ldlang_sysrooted_script; save_ldlang_sysrooted_script = ldlang_sysrooted_script;
ldlang_sysrooted_script = entry->sysrooted; ldlang_sysrooted_script = entry->sysrooted;
save_as_needed = as_needed; save_add_DT_NEEDED_for_regular = add_DT_NEEDED_for_regular;
as_needed = entry->as_needed; add_DT_NEEDED_for_regular = entry->add_DT_NEEDED_for_regular;
save_add_needed = add_needed; save_add_DT_NEEDED_for_dynamic = add_DT_NEEDED_for_dynamic;
add_needed = entry->add_needed; add_DT_NEEDED_for_dynamic = entry->add_DT_NEEDED_for_dynamic;
save_whole_archive = whole_archive; save_whole_archive = whole_archive;
whole_archive = entry->whole_archive; whole_archive = entry->whole_archive;
@ -2639,8 +2641,8 @@ load_symbols (lang_input_statement_type *entry,
ldfile_assumed_script = FALSE; ldfile_assumed_script = FALSE;
ldlang_sysrooted_script = save_ldlang_sysrooted_script; ldlang_sysrooted_script = save_ldlang_sysrooted_script;
as_needed = save_as_needed; add_DT_NEEDED_for_regular = save_add_DT_NEEDED_for_regular;
add_needed = save_add_needed; add_DT_NEEDED_for_dynamic = save_add_DT_NEEDED_for_dynamic;
whole_archive = save_whole_archive; whole_archive = save_whole_archive;
pop_stat_ptr (); pop_stat_ptr ();

View File

@ -270,11 +270,11 @@ typedef struct lang_input_statement_struct
/* Whether DT_NEEDED tags should be added for dynamic libraries in /* Whether DT_NEEDED tags should be added for dynamic libraries in
DT_NEEDED tags from this entry. */ DT_NEEDED tags from this entry. */
unsigned int add_needed : 1; unsigned int add_DT_NEEDED_for_dynamic : 1;
/* Whether this entry should cause a DT_NEEDED tag only when /* Whether this entry should cause a DT_NEEDED tag only when
satisfying references from regular files, or always. */ satisfying references from regular files, or always. */
unsigned int as_needed : 1; unsigned int add_DT_NEEDED_for_regular : 1;
/* Whether to include the entire contents of an archive. */ /* Whether to include the entire contents of an archive. */
unsigned int whole_archive : 1; unsigned int whole_archive : 1;

View File

@ -93,13 +93,14 @@ bfd_boolean version_printed;
/* Nonzero means link in every member of an archive. */ /* Nonzero means link in every member of an archive. */
bfd_boolean whole_archive; bfd_boolean whole_archive;
/* Nonzero means create DT_NEEDED entries only if a dynamic library /* True means only create DT_NEEDED entries for dynamic libraries
actually satisfies some reference in a regular object. */ if they actually satisfy some reference in a regular object. */
bfd_boolean as_needed; bfd_boolean add_DT_NEEDED_for_regular;
/* Nonzero means never create DT_NEEDED entries for dynamic libraries /* True means create DT_NEEDED entries for dynamic libraries that
in DT_NEEDED tags. */ are DT_NEEDED by dynamic libraries specifically mentioned on
bfd_boolean add_needed = TRUE; the command line. */
bfd_boolean add_DT_NEEDED_for_dynamic;
/* TRUE if we should demangle symbol names. */ /* TRUE if we should demangle symbol names. */
bfd_boolean demangling; bfd_boolean demangling;

View File

@ -1,6 +1,6 @@
/* ldmain.h - /* ldmain.h -
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2002, 2003, 2004, Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2002, 2003, 2004,
2005, 2007, 2008 Free Software Foundation, Inc. 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
This file is part of the GNU Binutils. This file is part of the GNU Binutils.
@ -34,8 +34,8 @@ extern bfd_boolean trace_files;
extern bfd_boolean trace_file_tries; extern bfd_boolean trace_file_tries;
extern bfd_boolean version_printed; extern bfd_boolean version_printed;
extern bfd_boolean whole_archive; extern bfd_boolean whole_archive;
extern bfd_boolean as_needed; extern bfd_boolean add_DT_NEEDED_for_regular;
extern bfd_boolean add_needed; extern bfd_boolean add_DT_NEEDED_for_dynamic;
extern bfd_boolean demangling; extern bfd_boolean demangling;
extern int g_switch_value; extern int g_switch_value;
extern const char *output_filename; extern const char *output_filename;

View File

@ -125,10 +125,10 @@ enum option_values
OPTION_SPLIT_BY_RELOC, OPTION_SPLIT_BY_RELOC,
OPTION_SPLIT_BY_FILE , OPTION_SPLIT_BY_FILE ,
OPTION_WHOLE_ARCHIVE, OPTION_WHOLE_ARCHIVE,
OPTION_ADD_NEEDED, OPTION_ADD_DT_NEEDED_FOR_DYNAMIC,
OPTION_NO_ADD_NEEDED, OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC,
OPTION_AS_NEEDED, OPTION_ADD_DT_NEEDED_FOR_REGULAR,
OPTION_NO_AS_NEEDED, OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR,
OPTION_WRAP, OPTION_WRAP,
OPTION_FORCE_EXE_SUFFIX, OPTION_FORCE_EXE_SUFFIX,
OPTION_GC_SECTIONS, OPTION_GC_SECTIONS,
@ -333,19 +333,22 @@ static const struct ld_option ld_options[] =
OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH}, OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH},
'\0', NULL, N_("Reject input files whose architecture is unknown"), '\0', NULL, N_("Reject input files whose architecture is unknown"),
TWO_DASHES }, TWO_DASHES },
{ {"add-needed", no_argument, NULL, OPTION_ADD_NEEDED},
'\0', NULL, N_("Set DT_NEEDED tags for DT_NEEDED entries in\n" /* The next two options are deprecated because of their similarity to
" following dynamic libs"), --as-needed and --no-as-needed. They have been replaced by
TWO_DASHES }, --resolve-implicit-dynamic-symbols and
{ {"no-add-needed", no_argument, NULL, OPTION_NO_ADD_NEEDED}, --no-resolve-implicit-dynamic-symbols. */
'\0', NULL, N_("Do not set DT_NEEDED tags for DT_NEEDED entries\n" { {"add-needed", no_argument, NULL, OPTION_ADD_DT_NEEDED_FOR_DYNAMIC},
" in following dynamic libs"), '\0', NULL, NULL, NO_HELP },
TWO_DASHES }, { {"no-add-needed", no_argument, NULL, OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC},
{ {"as-needed", no_argument, NULL, OPTION_AS_NEEDED}, '\0', NULL, NULL, NO_HELP },
{ {"as-needed", no_argument, NULL, OPTION_ADD_DT_NEEDED_FOR_REGULAR},
'\0', NULL, N_("Only set DT_NEEDED for following dynamic libs if used"), '\0', NULL, N_("Only set DT_NEEDED for following dynamic libs if used"),
TWO_DASHES }, TWO_DASHES },
{ {"no-as-needed", no_argument, NULL, OPTION_NO_AS_NEEDED}, { {"no-as-needed", no_argument, NULL, OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR},
'\0', NULL, N_("Always set DT_NEEDED for following dynamic libs"), '\0', NULL, N_("Always set DT_NEEDED for dynamic libraries mentioned on\n"
" the command line"),
TWO_DASHES }, TWO_DASHES },
{ {"assert", required_argument, NULL, OPTION_ASSERT}, { {"assert", required_argument, NULL, OPTION_ASSERT},
'\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH }, '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH },
@ -373,6 +376,15 @@ static const struct ld_option ld_options[] =
{ {"no-check-sections", no_argument, NULL, OPTION_NO_CHECK_SECTIONS}, { {"no-check-sections", no_argument, NULL, OPTION_NO_CHECK_SECTIONS},
'\0', NULL, N_("Do not check section addresses for overlaps"), '\0', NULL, N_("Do not check section addresses for overlaps"),
TWO_DASHES }, TWO_DASHES },
{ {"copy-dt-needed-entries", no_argument, NULL,
OPTION_ADD_DT_NEEDED_FOR_DYNAMIC},
'\0', NULL, N_("Copy DT_NEEDED links mentioned inside DSOs that follow"),
TWO_DASHES },
{ {"no-copy-dt-needed-entries", no_argument, NULL,
OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC},
'\0', NULL, N_("Do not copy DT_NEEDED links mentioned inside DSOs that follow"),
TWO_DASHES },
{ {"cref", no_argument, NULL, OPTION_CREF}, { {"cref", no_argument, NULL, OPTION_CREF},
'\0', NULL, N_("Output cross reference table"), TWO_DASHES }, '\0', NULL, N_("Output cross reference table"), TWO_DASHES },
{ {"defsym", required_argument, NULL, OPTION_DEFSYM}, { {"defsym", required_argument, NULL, OPTION_DEFSYM},
@ -1379,17 +1391,17 @@ parse_args (unsigned argc, char **argv)
case OPTION_WHOLE_ARCHIVE: case OPTION_WHOLE_ARCHIVE:
whole_archive = TRUE; whole_archive = TRUE;
break; break;
case OPTION_ADD_NEEDED: case OPTION_ADD_DT_NEEDED_FOR_DYNAMIC:
add_needed = TRUE; add_DT_NEEDED_for_dynamic = TRUE;
break; break;
case OPTION_NO_ADD_NEEDED: case OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC:
add_needed = FALSE; add_DT_NEEDED_for_dynamic = FALSE;
break; break;
case OPTION_AS_NEEDED: case OPTION_ADD_DT_NEEDED_FOR_REGULAR:
as_needed = TRUE; add_DT_NEEDED_for_regular = TRUE;
break; break;
case OPTION_NO_AS_NEEDED: case OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR:
as_needed = FALSE; add_DT_NEEDED_for_regular = FALSE;
break; break;
case OPTION_WRAP: case OPTION_WRAP:
add_wrap (optarg); add_wrap (optarg);