2010-03-22 Doug Kwan <dougkwan@google.com>
[binutils-gdb.git] / gold / copy-relocs.cc
index 6ef72d3ed38677ca903142989e4ba28c5cd6ee4b..1ff7ffebd69aa2e65c970300761be702aa02d0ef 100644 (file)
@@ -1,6 +1,6 @@
 // copy-relocs.cc -- handle COPY relocations for gold.
 
-// Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
@@ -132,13 +132,17 @@ Copy_relocs<sh_type, size, big_endian>::emit_copy_reloc(
   while ((value & (addralign - 1)) != 0)
     addralign >>= 1;
 
+  // Mark the dynamic object as needed for the --as-needed option.
+  sym->object()->set_is_needed();
+
   if (this->dynbss_ == NULL)
     {
       this->dynbss_ = new Output_data_space(addralign, "** dynbss");
       layout->add_output_section_data(".bss",
                                      elfcpp::SHT_NOBITS,
                                      elfcpp::SHF_ALLOC | elfcpp::SHF_WRITE,
-                                     this->dynbss_);
+                                     this->dynbss_, false, false, false,
+                                     false);
     }
 
   Output_data_space* dynbss = this->dynbss_;