+2009-09-30 Doug Kwan <dougkwan@google.com>
+
+ * arm.cc (Target_arm::may_need_copy_reloc): Check for THUMB function
+ symbol and call Symbol::may_need_copy_reloc to determine if
+ a copy reloc is needed.
+ * copy-relocs.cc (Copy_relocs::need_copy_reloc): Return false if -z
+ nocopyreloc is given in command line.
+ (Copy_relocs::emit_copy_reloc): Assert that -z nocopyreloc is not
+ given in command line.
+ * i386.cc (Target_i386::may_need_copy_reloc): Remove.
+ (Target_i386::Scan::global): Use Symbol::may_need_copy_reloc instead
+ of the removed Target_i386::may_need_copy_reloc.
+ * options.h (copyreloc): New option with default value false.
+ * powerpc.cc (Target_powerpc::may_need_copy_reloc): Remove.
+ (Target_powerpc::Scan::global): Use Symbol::may_need_copy_reloc
+ instead of the removed Target_powerpc::may_need_copy_reloc.
+ * sparc.cc (Target_powerpc::may_need_copy_reloc): Remove.
+ (Target_sparc::Scan::global): Use Symbol::may_need_copy_reloc
+ instead of the removed Target_sparc::may_need_copy_reloc.
+ * symtab.h (Symbol::may_need_copy_reloc): New method definition.
+ * x86_64.cc (Target_powerpc::may_need_copy_reloc): Remove.
+ (Target_x86_64::Scan::global): Use Symbol::may_need_copy_reloc
+ instead of the removed Target_x86_64::may_need_copy_reloc.
+
2009-09-30 Ian Lance Taylor <iant@google.com>
* object.h (class Object): Remove target_ field, and target,
bool
may_need_copy_reloc(Symbol* gsym)
{
- return (!parameters->options().shared()
- && gsym->is_from_dynobj()
- && gsym->type() != elfcpp::STT_FUNC
- && gsym->type() != elfcpp::STT_ARM_TFUNC);
+ return (gsym->type() != elfcpp::STT_ARM_TFUNC
+ && gsym->may_need_copy_reloc());
}
// Add a potential copy relocation.
Sized_relobj<size, big_endian>* object,
unsigned int shndx) const
{
- // FIXME: Handle -z nocopyrelocs.
+ if (!parameters->options().copyreloc())
+ return false;
if (sym->symsize() == 0)
return false;
Sized_symbol<size>* sym,
Output_data_reloc<sh_type, true, size, big_endian>* reloc_section)
{
+ // We should not be here if -z nocopyreloc is given.
+ gold_assert(parameters->options().copyreloc());
+
typename elfcpp::Elf_types<size>::Elf_WXword symsize = sym->symsize();
// There is no defined way to determine the required alignment of
Reloc_section*
rel_dyn_section(Layout*);
- // Return true if the symbol may need a COPY relocation.
- // References from an executable object to non-function symbols
- // defined in a dynamic object may need a COPY relocation.
- bool
- may_need_copy_reloc(Symbol* gsym)
- {
- return (!parameters->options().shared()
- && gsym->is_from_dynobj()
- && gsym->type() != elfcpp::STT_FUNC);
- }
-
// Add a potential copy relocation.
void
copy_reloc(Symbol_table* symtab, Layout* layout,
// Make a dynamic relocation if necessary.
if (gsym->needs_dynamic_reloc(Symbol::ABSOLUTE_REF))
{
- if (target->may_need_copy_reloc(gsym))
+ if (gsym->may_need_copy_reloc())
{
target->copy_reloc(symtab, layout, object,
data_shndx, output_section, gsym, reloc);
flags |= Symbol::FUNCTION_CALL;
if (gsym->needs_dynamic_reloc(flags))
{
- if (target->may_need_copy_reloc(gsym))
+ if (gsym->may_need_copy_reloc())
{
target->copy_reloc(symtab, layout, object,
data_shndx, output_section, gsym, reloc);
NULL);
DEFINE_uint64(max_page_size, options::DASH_Z, '\0', 0,
N_("Set maximum page size to SIZE"), N_("SIZE"));
+ DEFINE_bool(copyreloc, options::DASH_Z, '\0', true,
+ NULL,
+ N_("Do not create copy relocs"));
DEFINE_bool(nodefaultlib, options::DASH_Z, '\0', false,
N_("Mark object not to use default search paths"),
NULL);
Reloc_section*
rela_dyn_section(Layout*);
- // Return true if the symbol may need a COPY relocation.
- // References from an executable object to non-function symbols
- // defined in a dynamic object may need a COPY relocation.
- bool
- may_need_copy_reloc(Symbol* gsym)
- {
- return (!parameters->options().shared()
- && gsym->is_from_dynobj()
- && gsym->type() != elfcpp::STT_FUNC);
- }
-
// Copy a relocation against a global symbol.
void
copy_reloc(Symbol_table* symtab, Layout* layout,
// Make a dynamic relocation if necessary.
if (gsym->needs_dynamic_reloc(Symbol::ABSOLUTE_REF))
{
- if (target->may_need_copy_reloc(gsym))
+ if (gsym->may_need_copy_reloc())
{
target->copy_reloc(symtab, layout, object,
data_shndx, output_section, gsym, reloc);
flags |= Symbol::FUNCTION_CALL;
if (gsym->needs_dynamic_reloc(flags))
{
- if (target->may_need_copy_reloc(gsym))
+ if (gsym->may_need_copy_reloc())
{
target->copy_reloc(symtab, layout, object,
data_shndx, output_section, gsym,
Reloc_section*
rela_dyn_section(Layout*);
- // Return true if the symbol may need a COPY relocation.
- // References from an executable object to non-function symbols
- // defined in a dynamic object may need a COPY relocation.
- bool
- may_need_copy_reloc(Symbol* gsym)
- {
- return (!parameters->options().shared()
- && gsym->is_from_dynobj()
- && gsym->type() != elfcpp::STT_FUNC);
- }
-
// Copy a relocation against a global symbol.
void
copy_reloc(Symbol_table* symtab, Layout* layout,
flags |= Symbol::FUNCTION_CALL;
if (gsym->needs_dynamic_reloc(flags))
{
- if (target->may_need_copy_reloc(gsym))
+ if (gsym->may_need_copy_reloc())
{
target->copy_reloc(symtab, layout, object,
data_shndx, output_section, gsym,
// Make a dynamic relocation if necessary.
if (gsym->needs_dynamic_reloc(Symbol::ABSOLUTE_REF))
{
- if (target->may_need_copy_reloc(gsym))
+ if (gsym->may_need_copy_reloc())
{
target->copy_reloc(symtab, layout, object,
data_shndx, output_section, gsym, reloc);
set_is_forced_local()
{ this->is_forced_local_ = true; }
+ // Return true if this may need a COPY relocation.
+ // References from an executable object to non-function symbols
+ // defined in a dynamic object may need a COPY relocation.
+ bool
+ may_need_copy_reloc() const
+ {
+ return (!parameters->options().shared()
+ && parameters->options().copyreloc()
+ && this->is_from_dynobj()
+ && this->type() != elfcpp::STT_FUNC);
+ }
+
protected:
// Instances of this class should always be created at a specific
// size.
Reloc_section*
rela_dyn_section(Layout*);
- // Return true if the symbol may need a COPY relocation.
- // References from an executable object to non-function symbols
- // defined in a dynamic object may need a COPY relocation.
- bool
- may_need_copy_reloc(Symbol* gsym)
- {
- return (!parameters->options().shared()
- && gsym->is_from_dynobj()
- && gsym->type() != elfcpp::STT_FUNC);
- }
-
// Add a potential copy relocation.
void
copy_reloc(Symbol_table* symtab, Layout* layout,
// Make a dynamic relocation if necessary.
if (gsym->needs_dynamic_reloc(Symbol::ABSOLUTE_REF))
{
- if (target->may_need_copy_reloc(gsym))
+ if (gsym->may_need_copy_reloc())
{
target->copy_reloc(symtab, layout, object,
data_shndx, output_section, gsym, reloc);
flags |= Symbol::FUNCTION_CALL;
if (gsym->needs_dynamic_reloc(flags))
{
- if (target->may_need_copy_reloc(gsym))
+ if (gsym->may_need_copy_reloc())
{
target->copy_reloc(symtab, layout, object,
data_shndx, output_section, gsym, reloc);