forked from OSchip/llvm-project
parent
9ea7fbd1e8
commit
b518f655c3
|
@ -696,29 +696,38 @@ static int64_t computeMipsAddend(const RelTy &Rel, InputSectionBase &Sec,
|
|||
return 0;
|
||||
}
|
||||
|
||||
// Report an undefined symbol if necessary.
|
||||
// Returns true if this function printed out an error message.
|
||||
template <class ELFT>
|
||||
static void reportUndefined(SymbolBody &Sym, InputSectionBase &S,
|
||||
uint64_t Offset) {
|
||||
static bool maybeReportUndefined(SymbolBody &Sym, InputSectionBase &Sec,
|
||||
uint64_t Offset) {
|
||||
if (Config->UnresolvedSymbols == UnresolvedPolicy::IgnoreAll)
|
||||
return;
|
||||
return false;
|
||||
|
||||
if (Sym.isLocal() || !Sym.isUndefined() || Sym.symbol()->isWeak())
|
||||
return false;
|
||||
|
||||
bool CanBeExternal = Sym.symbol()->computeBinding() != STB_LOCAL &&
|
||||
Sym.getVisibility() == STV_DEFAULT;
|
||||
if (Config->UnresolvedSymbols == UnresolvedPolicy::Ignore && CanBeExternal)
|
||||
return;
|
||||
return false;
|
||||
|
||||
std::string Msg =
|
||||
"undefined symbol: " + toString(Sym) + "\n>>> referenced by ";
|
||||
|
||||
std::string Src = S.getSrcMsg<ELFT>(Offset);
|
||||
std::string Src = Sec.getSrcMsg<ELFT>(Offset);
|
||||
if (!Src.empty())
|
||||
Msg += Src + "\n>>> ";
|
||||
Msg += S.getObjMsg<ELFT>(Offset);
|
||||
Msg += Sec.getObjMsg<ELFT>(Offset);
|
||||
|
||||
if (Config->UnresolvedSymbols == UnresolvedPolicy::Warn && CanBeExternal)
|
||||
if ((Config->UnresolvedSymbols == UnresolvedPolicy::Warn && CanBeExternal) ||
|
||||
Config->NoinhibitExec) {
|
||||
warn(Msg);
|
||||
else
|
||||
errorOrWarn(Msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
error(Msg);
|
||||
return true;
|
||||
}
|
||||
|
||||
// MIPS N32 ABI treats series of successive relocations with the same offset
|
||||
|
@ -848,17 +857,9 @@ static void scanRelocs(InputSectionBase &Sec, ArrayRef<RelTy> Rels) {
|
|||
if (Offset == uint64_t(-1))
|
||||
continue;
|
||||
|
||||
// Report undefined symbols. The fact that we report undefined
|
||||
// symbols here means that we report undefined symbols only when
|
||||
// they have relocations pointing to them. We don't care about
|
||||
// undefined symbols that are in dead-stripped sections.
|
||||
if (!Body.isLocal() && Body.isUndefined() && !Body.symbol()->isWeak()) {
|
||||
reportUndefined<ELFT>(Body, Sec, Rel.r_offset);
|
||||
|
||||
// If we report an undefined, and we have an error, go on.
|
||||
if (ErrorCount)
|
||||
continue;
|
||||
}
|
||||
// Skip if the target symbol is an erroneous undefined symbol.
|
||||
if (maybeReportUndefined<ELFT>(Body, Sec, Rel.r_offset))
|
||||
continue;
|
||||
|
||||
RelExpr Expr =
|
||||
Target->getRelExpr(Type, Body, Sec.Data.begin() + Rel.r_offset);
|
||||
|
|
Loading…
Reference in New Issue