aboutsummaryrefslogtreecommitdiff
path: root/gold/layout.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2009-11-05 06:24:39 +0000
committerIan Lance Taylor <ian@airs.com>2009-11-05 06:24:39 +0000
commit594c8e5ede2a93362f335a97389eaadac17ec204 (patch)
treef6fa13b594ad3af2539139a534d3645daefb4fbf /gold/layout.cc
parent946ef19679549c1751ca5c3a963f48c21112e19b (diff)
downloadgdb-594c8e5ede2a93362f335a97389eaadac17ec204.zip
gdb-594c8e5ede2a93362f335a97389eaadac17ec204.tar.gz
gdb-594c8e5ede2a93362f335a97389eaadac17ec204.tar.bz2
PR 10880
* object.h (class Object): Add is_needed and set_is_needed methods. Add is_needed_ field. Make bool fields into bitfields. * symtab.cc (Symbol_table::set_dynsym_indexes): If a symbol is defined in a dynamic object and referenced by a regular object, set is_needed for the dynamic object. * layout.cc (Layout::finish_dynamic_section): Don't add DT_NEEDED if the file is marked with as_needed and it is not needed.
Diffstat (limited to 'gold/layout.cc')
-rw-r--r--gold/layout.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/gold/layout.cc b/gold/layout.cc
index f0a51b4..b44dba6 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -3130,7 +3130,14 @@ Layout::finish_dynamic_section(const Input_objects* input_objects,
p != input_objects->dynobj_end();
++p)
{
- // FIXME: Handle --as-needed.
+ if (!(*p)->is_needed()
+ && (*p)->input_file()->options().as_needed())
+ {
+ // This dynamic object was linked with --as-needed, but it
+ // is not needed.
+ continue;
+ }
+
odyn->add_string(elfcpp::DT_NEEDED, (*p)->soname());
}