[lld] r251158 - ELF2: Factor out getEntryAddr from writeHeader. NFC.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 23 15:44:37 PDT 2015
Author: ruiu
Date: Fri Oct 23 17:44:37 2015
New Revision: 251158
URL: http://llvm.org/viewvc/llvm-project?rev=251158&view=rev
Log:
ELF2: Factor out getEntryAddr from writeHeader. NFC.
Modified:
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=251158&r1=251157&r2=251158&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri Oct 23 17:44:37 2015
@@ -67,6 +67,7 @@ private:
return !Symtab.getSharedFiles().empty() || Config->Shared;
}
uintX_t getVAStart() const { return Config->Shared ? 0 : Target->getVAStart(); }
+ uintX_t getEntryAddr() const;
int getPhdrsNum() const;
std::unique_ptr<llvm::FileOutputBuffer> Buffer;
@@ -723,12 +724,7 @@ template <class ELFT> void Writer<ELFT>:
EHdr->e_type = Config->Shared ? ET_DYN : ET_EXEC;
EHdr->e_machine = FirstObj.getEMachine();
EHdr->e_version = EV_CURRENT;
- if (Config->EntrySym) {
- if (auto *E = dyn_cast<ELFSymbolBody<ELFT>>(Config->EntrySym->repl()))
- EHdr->e_entry = getSymVA<ELFT>(*E);
- } else if (Config->EntryAddr != uint64_t(-1)) {
- EHdr->e_entry = Config->EntryAddr;
- }
+ EHdr->e_entry = getEntryAddr();
EHdr->e_phoff = sizeof(Elf_Ehdr);
EHdr->e_shoff = SectionHeaderOff;
EHdr->e_ehsize = sizeof(Elf_Ehdr);
@@ -772,6 +768,18 @@ template <class ELFT> void Writer<ELFT>:
}
template <class ELFT>
+typename ELFFile<ELFT>::uintX_t Writer<ELFT>::getEntryAddr() const {
+ if (Config->EntrySym) {
+ if (auto *E = dyn_cast<ELFSymbolBody<ELFT>>(Config->EntrySym->repl()))
+ return getSymVA<ELFT>(*E);
+ return 0;
+ }
+ if (Config->EntryAddr != uint64_t(-1))
+ return Config->EntryAddr;
+ return 0;
+}
+
+template <class ELFT>
void Writer<ELFT>::setPhdr(Elf_Phdr *PH, uint32_t Type, uint32_t Flags,
uintX_t FileOff, uintX_t VA, uintX_t Size,
uintX_t Align) {
More information about the llvm-commits
mailing list