Simplify -e <number> option handling.
This patch is to parse the entry symbol name lazily. llvm-svn: 288882
This commit is contained in:
parent
67ec0eb531
commit
a1407c4fdf
|
@ -148,7 +148,6 @@ struct Configuration {
|
||||||
ELFKind EKind = ELFNoneKind;
|
ELFKind EKind = ELFNoneKind;
|
||||||
uint16_t DefaultSymbolVersion = llvm::ELF::VER_NDX_GLOBAL;
|
uint16_t DefaultSymbolVersion = llvm::ELF::VER_NDX_GLOBAL;
|
||||||
uint16_t EMachine = llvm::ELF::EM_NONE;
|
uint16_t EMachine = llvm::ELF::EM_NONE;
|
||||||
uint64_t EntryAddr = 0;
|
|
||||||
uint64_t ErrorLimit = 20;
|
uint64_t ErrorLimit = 20;
|
||||||
uint64_t ImageBase;
|
uint64_t ImageBase;
|
||||||
uint64_t MaxPageSize;
|
uint64_t MaxPageSize;
|
||||||
|
|
|
@ -780,18 +780,10 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) {
|
||||||
for (InputFile *F : Files)
|
for (InputFile *F : Files)
|
||||||
Symtab.addFile(F);
|
Symtab.addFile(F);
|
||||||
|
|
||||||
// Add the start symbol.
|
// Add the start symbol. Note that AMDGPU binaries have no entries.
|
||||||
// It initializes either Config->Entry or Config->EntryAddr.
|
if (Config->Entry.empty() && !Config->Relocatable &&
|
||||||
// Note that AMDGPU binaries have no entries.
|
Config->EMachine != EM_AMDGPU)
|
||||||
if (!Config->Entry.empty()) {
|
|
||||||
// It is either "-e <addr>" or "-e <symbol>".
|
|
||||||
if (!Config->Entry.getAsInteger(0, Config->EntryAddr))
|
|
||||||
Config->Entry = "";
|
|
||||||
} else if (!Config->Relocatable && Config->EMachine != EM_AMDGPU) {
|
|
||||||
// -e was not specified. Use the default start symbol name
|
|
||||||
// if it is resolvable.
|
|
||||||
Config->Entry = (Config->EMachine == EM_MIPS) ? "__start" : "_start";
|
Config->Entry = (Config->EMachine == EM_MIPS) ? "__start" : "_start";
|
||||||
}
|
|
||||||
|
|
||||||
// If an object file defining the entry symbol is in an archive file,
|
// If an object file defining the entry symbol is in an archive file,
|
||||||
// extract the file now.
|
// extract the file now.
|
||||||
|
|
|
@ -1402,11 +1402,13 @@ template <class ELFT> void Writer<ELFT>::setPhdrs() {
|
||||||
// 4. the address of the first byte of the .text section, if present;
|
// 4. the address of the first byte of the .text section, if present;
|
||||||
// 5. the address 0.
|
// 5. the address 0.
|
||||||
template <class ELFT> typename ELFT::uint Writer<ELFT>::getEntryAddr() {
|
template <class ELFT> typename ELFT::uint Writer<ELFT>::getEntryAddr() {
|
||||||
// Case 1, 2 or 3
|
// Case 1, 2 or 3. As a special case, if the symbol is actually
|
||||||
if (Config->Entry.empty())
|
// a number, we'll use that number as an address.
|
||||||
return Config->EntryAddr;
|
|
||||||
if (SymbolBody *B = Symtab<ELFT>::X->find(Config->Entry))
|
if (SymbolBody *B = Symtab<ELFT>::X->find(Config->Entry))
|
||||||
return B->getVA<ELFT>();
|
return B->getVA<ELFT>();
|
||||||
|
uint64_t Addr;
|
||||||
|
if (!Config->Entry.getAsInteger(0, Addr))
|
||||||
|
return Addr;
|
||||||
|
|
||||||
// Case 4
|
// Case 4
|
||||||
if (OutputSectionBase *Sec = findSection(".text")) {
|
if (OutputSectionBase *Sec = findSection(".text")) {
|
||||||
|
|
Loading…
Reference in New Issue