Line 1... |
Line 1... |
// target-reloc.h -- target specific relocation support -*- C++ -*-
|
// target-reloc.h -- target specific relocation support -*- C++ -*-
|
|
|
// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
|
// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
|
// Written by Ian Lance Taylor <iant@google.com>.
|
// Written by Ian Lance Taylor <iant@google.com>.
|
|
|
// This file is part of gold.
|
// This file is part of gold.
|
|
|
// This program is free software; you can redistribute it and/or modify
|
// This program is free software; you can redistribute it and/or modify
|
Line 167... |
Line 167... |
}
|
}
|
gold_error(_("%s symbol '%s' is not defined locally"),
|
gold_error(_("%s symbol '%s' is not defined locally"),
|
v, sym->name());
|
v, sym->name());
|
}
|
}
|
|
|
|
// Return true if we are should issue an error saying that SYM is an
|
|
// undefined symbol. This is called if there is a relocation against
|
|
// SYM.
|
|
|
|
inline bool
|
|
issue_undefined_symbol_error(const Symbol* sym)
|
|
{
|
|
// We only report global symbols.
|
|
if (sym == NULL)
|
|
return false;
|
|
|
|
// We only report undefined symbols.
|
|
if (!sym->is_undefined() && !sym->is_placeholder())
|
|
return false;
|
|
|
|
// We don't report weak symbols.
|
|
if (sym->binding() == elfcpp::STB_WEAK)
|
|
return false;
|
|
|
|
// We don't report symbols defined in discarded sections.
|
|
if (sym->is_defined_in_discarded_section())
|
|
return false;
|
|
|
|
// If the target defines this symbol, don't report it here.
|
|
if (parameters->target().is_defined_by_abi(sym))
|
|
return false;
|
|
|
|
// See if we've been told to ignore whether this symbol is
|
|
// undefined.
|
|
const char* const u = parameters->options().unresolved_symbols();
|
|
if (u != NULL)
|
|
{
|
|
if (strcmp(u, "ignore-all") == 0)
|
|
return false;
|
|
if (strcmp(u, "report-all") == 0)
|
|
return true;
|
|
if (strcmp(u, "ignore-in-object-files") == 0 && !sym->in_dyn())
|
|
return false;
|
|
if (strcmp(u, "ignore-in-shared-libs") == 0 && !sym->in_reg())
|
|
return false;
|
|
}
|
|
|
|
// When creating a shared library, only report unresolved symbols if
|
|
// -z defs was used.
|
|
if (parameters->options().shared() && !parameters->options().defs())
|
|
return false;
|
|
|
|
// Otherwise issue a warning.
|
|
return true;
|
|
}
|
|
|
// This function implements the generic part of relocation processing.
|
// This function implements the generic part of relocation processing.
|
// The template parameter Relocate must be a class type which provides
|
// The template parameter Relocate must be a class type which provides
|
// a single function, relocate(), which implements the machine
|
// a single function, relocate(), which implements the machine
|
// specific part of a relocation.
|
// specific part of a relocation.
|
|
|
Line 342... |
Line 393... |
_("reloc has bad offset %zu"),
|
_("reloc has bad offset %zu"),
|
static_cast<size_t>(offset));
|
static_cast<size_t>(offset));
|
continue;
|
continue;
|
}
|
}
|
|
|
if (sym != NULL
|
if (issue_undefined_symbol_error(sym))
|
&& (sym->is_undefined() || sym->is_placeholder())
|
|
&& sym->binding() != elfcpp::STB_WEAK
|
|
&& !is_defined_in_discarded_section
|
|
&& !target->is_defined_by_abi(sym)
|
|
&& (!parameters->options().shared() // -shared
|
|
|| parameters->options().defs())) // -z defs
|
|
gold_undefined_symbol_at_location(sym, relinfo, i, offset);
|
gold_undefined_symbol_at_location(sym, relinfo, i, offset);
|
else if (sym != NULL
|
else if (sym != NULL
|
&& sym->visibility() != elfcpp::STV_DEFAULT
|
&& sym->visibility() != elfcpp::STV_DEFAULT
|
&& (sym->is_undefined() || sym->is_from_dynobj()))
|
&& (sym->is_undefined() || sym->is_from_dynobj()))
|
visibility_error(sym);
|
visibility_error(sym);
|