Store a Symbol for EntrySym.

This makes it impossible to forget to call repl on the SymbolBody.

llvm-svn: 266432
This commit is contained in:
Rafael Espindola 2016-04-15 14:41:56 +00:00
parent 917fc9d7cb
commit 38c67a27fe
5 changed files with 10 additions and 7 deletions

View File

@ -20,7 +20,7 @@ namespace lld {
namespace elf {
class InputFile;
class SymbolBody;
struct Symbol;
enum ELFKind {
ELFNoneKind,
@ -37,7 +37,7 @@ enum class BuildIdKind { None, Fnv1, Md5, Sha1 };
// and such fields have the same name as the corresponding options.
// Most fields are initialized by the driver.
struct Configuration {
SymbolBody *EntrySym = nullptr;
Symbol *EntrySym = nullptr;
InputFile *FirstElf = nullptr;
llvm::StringRef DynamicLinker;
llvm::StringRef Entry;

View File

@ -428,7 +428,7 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) {
// Set either EntryAddr (if S is a number) or EntrySym (otherwise).
StringRef S = Config->Entry;
if (S.getAsInteger(0, Config->EntryAddr))
Config->EntrySym = Symtab.addUndefined(S);
Config->EntrySym = Symtab.addUndefined(S)->getSymbol();
}
for (std::unique_ptr<InputFile> &F : Files)

View File

@ -18,6 +18,8 @@
namespace lld {
namespace elf {
class SymbolBody;
template <class ELFT> class ICF;
template <class ELFT> class DefinedRegular;
template <class ELFT> class ObjectFile;

View File

@ -99,12 +99,13 @@ template <class ELFT> void elf::markLive(SymbolTable<ELFT> *Symtab) {
auto MarkSymbol = [&](SymbolBody *Sym) {
if (Sym)
if (auto *D = dyn_cast<DefinedRegular<ELFT>>(&Sym->repl()))
if (auto *D = dyn_cast<DefinedRegular<ELFT>>(Sym))
Enqueue(D->Section);
};
// Add GC root symbols.
MarkSymbol(Config->EntrySym);
if (Config->EntrySym)
MarkSymbol(Config->EntrySym->Body);
MarkSymbol(Symtab->find(Config->Init));
MarkSymbol(Symtab->find(Config->Fini));
for (StringRef S : Config->Undefined)

View File

@ -1634,8 +1634,8 @@ static uint32_t getMipsEFlags() {
}
template <class ELFT> static typename ELFT::uint getEntryAddr() {
if (SymbolBody *B = Config->EntrySym)
return B->repl().getVA<ELFT>();
if (Symbol *S = Config->EntrySym)
return S->Body->getVA<ELFT>();
if (Config->EntryAddr != uint64_t(-1))
return Config->EntryAddr;
return 0;