/* Interfaces for libdw.
Copyright (C) 2002, 2004, 2005, 2006 Red Hat, Inc.
This file is part of Red Hat elfutils.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
Red Hat elfutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by the
/* Internal interfaces for libelf.
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006 Red Hat, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005 Red Hat, Inc.
This file is part of Red Hat elfutils.
Contributed by Ulrich Drepper <drepper@redhat.com>, 1998.
/* We often have to update a flag iff a value changed. Make this
- convenient. */
-#define update_if_changed(var, exp, flag) \
+ convenient. None of the parameters must have a side effect. */
+#ifdef __GNUC__
+# define update_if_changed(var, exp, flag) \
do { \
__typeof__ (var) *_var = &(var); \
__typeof__ (exp) _exp = (exp); \
(flag) |= ELF_F_DIRTY; \
} \
} while (0)
+#else
+# define update_if_changed(var, exp, flag) \
+ do { \
+ if ((var) != (exp)) \
+ { \
+ (var) = (exp); \
+ (flag) |= ELF_F_DIRTY; \
+ } \
+ } while (0)
+#endif
#endif /* libelfP.h */
-2006-05-28 Ulrich Drepper <drepper@redhat.com>
-
- * addr2line.c (print_dwarf_function): Use unsigned type for lineno
- and colno.
+2006-05-31 Ulrich Drepper <drepper@redhat.com>
+
+ * ld.c: Recognize --as-needed and --no-as-needed options.
+ * ld.h (struct usedfile): Add as_needed field.
+ (struct ld_state): Likewise.
+ * ldgeneric.c (ld_handle_filename_list): Copy as_needed flag from
+ the list.
+ * ldscript.y (filename_id_list): Split to correctly parse all
+ combinations.
+ (mark_as_needed): Fix loop.
2006-05-27 Ulrich Drepper <drepper@redhat.com>
&attr_mem), &val) == 0)
{
const char *file = dwarf_filesrc (files, val, NULL, NULL);
- unsigned int lineno = 0;
- unsigned int colno = 0;
+ int lineno = 0, colno = 0;
if (dwarf_formudata (dwarf_attr (&scopes[i],
DW_AT_call_line,
&attr_mem), &val) == 0)
ARGP_no_gc_sections,
ARGP_no_undefined,
ARGP_conserve,
+ ARGP_as_needed,
+ ARGP_no_as_needed,
#if YYDEBUG
ARGP_yydebug,
#endif
N_("Add/suppress addition indentifying link-editor to .comment section"),
0 },
+ { "as-needed", ARGP_as_needed, NULL, 0,
+ N_("Only set DT_NEEDED for following dynamic libs if actually used"), 0 },
+ { "no-as-needed", ARGP_no_as_needed, NULL, 0,
+ N_("Always set DT_NEEDED for following dynamic libs"), 0 },
+
#if YYDEBUG
{ "yydebug", ARGP_yydebug, NULL, 0,
N_("Select to get parser debug information"), 0 },
case 'O':
case ARGP_whole_archive:
case ARGP_no_whole_archive:
+ case ARGP_as_needed:
+ case ARGP_no_as_needed:
case 'L':
case '(':
case ')':
ld_state.extract_rule = defaultextract;
break;
+ case ARGP_as_needed:
+ ld_state.as_needed = true;
+ break;
+ case ARGP_no_as_needed:
+ ld_state.as_needed = false;
+ break;
+
case ARGP_static:
case ARGP_dynamic:
/* Enable/disable use for DSOs. */
newfile->soname = newfile->fname = newfile->rfname = fname;
newfile->file_type = type;
newfile->extract_rule = ld_state.extract_rule;
+ newfile->as_needed = ld_state.as_needed;
newfile->lazyload = ld_state.lazyload;
newfile->status = not_opened;
-/* Copyright (C) 2001, 2002, 2003, 2005 Red Hat, Inc.
+/* Copyright (C) 2001, 2002, 2003, 2005, 2006 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2001.
used in a reference. */
bool used;
+ /* True when file should be added to DT_NEEDED list only when
+ directly referenced. */
+ bool as_needed;
+
/* If nonzero this is the archive sequence number which can be used to
determine whether back refernces from -( -) or GROUP statements
have to be followed. */
/* If true static linking is requested. */
bool statically;
+ /* If true, add DT_NEEDED entries for following files if they are
+ needed. */
+ bool as_needed;
+
/* How to extract elements from archives. */
enum extract_rule extract_rule;
-/* Copyright (C) 2001, 2002, 2003, 2004, 2005 Red Hat, Inc.
+/* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2001.
curp = runp->real = ld_new_inputfile (runp->name, relocatable_file_type);
/* Set flags for group handling. */
- runp->real->group_start = runp->group_start;
- runp->real->group_end = runp->group_end;
+ curp->group_start = runp->group_start;
+ curp->group_end = runp->group_end;
+
+ /* Set as-needed flag from the file, not the command line. */
+ curp->as_needed = runp->as_needed;
/* Read the file and everything else which comes up, including
handling groups. */
%{
/* Parser for linker scripts.
- Copyright (C) 2001, 2002, 2003, 2004, 2005 Red Hat, Inc.
+ Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2001.
%type <output_rule> outputsections
%type <assignment> assignment
%type <filename_list> filename_id_list
+%type <filename_list> filename_id_listelem
%type <version> versionlist
%type <version> version
%type <version> version_stmt_list
{ $$ = new_expr (exp_pagesize); }
;
-filename_id_list: kGROUP '(' filename_id_list ')'
+filename_id_list: filename_id_list comma_opt filename_id_listelem
+ {
+ $3->next = $1->next;
+ $$ = $1->next = $3;
+ }
+ | filename_id_listelem
+ { $$ = $1; }
+ ;
+
+comma_opt: ','
+ |
+ ;
+
+filename_id_listelem: kGROUP '(' filename_id_list ')'
{
/* First little optimization. If there is only one
file in the group don't do anything. */
}
| kAS_NEEDED '(' filename_id_list ')'
{ $$ = mark_as_needed ($3); }
- | filename_id_list comma_opt filename_id
- {
- struct filename_list *newp = new_filename_listelem ($3);
- newp->next = $1->next;
- $$ = $1->next = newp;
- }
| filename_id
{ $$ = new_filename_listelem ($1); }
;
-comma_opt: ','
- |
- ;
versionlist: versionlist version
{
mark_as_needed (struct filename_list *listp)
{
struct filename_list *runp = listp;
- while (runp != NULL)
+ do
{
runp->as_needed = true;
runp = runp->next;
}
+ while (runp != listp);
return listp;
}