Add support for weak undefined symbols.

llvm-svn: 244640
This commit is contained in:
Rafael Espindola 2015-08-11 17:57:05 +00:00
parent 791e9f9c59
commit 76e24ea955
4 changed files with 17 additions and 2 deletions

View File

@ -83,7 +83,8 @@ SymbolBody *elf2::ObjectFile<ELFT>::createSymbolBody(StringRef StringTable,
return new (Alloc) Undefined(Name);
return new (Alloc) DefinedRegular(Name);
case STB_WEAK:
// FIXME: add support for weak undefined
if (Sym->isUndefined())
return new (Alloc) UndefinedWeak(Name);
return new (Alloc) DefinedWeak(Name);
}
}

View File

@ -42,6 +42,7 @@ int SymbolBody::compare(SymbolBody *Other) {
return 0;
case DefinedWeakKind:
case UndefinedKind:
case UndefinedWeakKind:
return 1;
}
llvm_unreachable("unknown symbol kind");

View File

@ -39,7 +39,8 @@ public:
DefinedRegularKind = 0,
DefinedWeakKind = 1,
DefinedLast = 1,
UndefinedKind = 2
UndefinedWeakKind = 2,
UndefinedKind = 3
};
Kind kind() const { return static_cast<Kind>(SymbolKind); }
@ -112,6 +113,15 @@ public:
}
};
class UndefinedWeak : public SymbolBody {
public:
explicit UndefinedWeak(StringRef N) : SymbolBody(UndefinedWeakKind, N) {}
static bool classof(const SymbolBody *S) {
return S->kind() == UndefinedWeakKind;
}
};
} // namespace elf2
} // namespace lld

View File

@ -13,3 +13,6 @@ local:
foo:
.long bar
.weak zed
.long zed