forked from OSchip/llvm-project
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:
parent
917fc9d7cb
commit
38c67a27fe
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue