X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gold%2Fcopy-relocs.cc;h=4931aa06b659c1694d929a21433a951b2240322e;hb=62672b10bbd1c0797eb8ff2fd71b30360d6c373e;hp=345c0c64cebec43cc374abfd97d29ed4a7027996;hpb=f5c870d25d59bc1e6fcb6a836b6bd1981788982c;p=deliverable%2Fbinutils-gdb.git diff --git a/gold/copy-relocs.cc b/gold/copy-relocs.cc index 345c0c64ce..4931aa06b6 100644 --- a/gold/copy-relocs.cc +++ b/gold/copy-relocs.cc @@ -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 . // This file is part of gold. @@ -60,7 +60,7 @@ Copy_relocs::copy_reloc( Sized_symbol* sym, Sized_relobj* object, unsigned int shndx, - Output_section *output_section, + Output_section* output_section, const Reloc& rel, Output_data_reloc* reloc_section) { @@ -125,20 +125,32 @@ Copy_relocs::emit_copy_reloc( bool is_ordinary; unsigned int shndx = sym->shndx(&is_ordinary); gold_assert(is_ordinary); - typename elfcpp::Elf_types::Elf_WXword addralign = - sym->object()->section_addralign(shndx); + typename elfcpp::Elf_types::Elf_WXword addralign; + + { + // Lock the object so we can read from it. This is only called + // single-threaded from scan_relocs, so it is OK to lock. + // Unfortunately we have no way to pass in a Task token. + const Task* dummy_task = reinterpret_cast(-1); + Object* obj = sym->object(); + Task_lock_obj tl(dummy_task, obj); + addralign = obj->section_addralign(shndx); + } typename Sized_symbol::Value_type value = sym->value(); 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_, false); + this->dynbss_, ORDER_BSS, false); } Output_data_space* dynbss = this->dynbss_;