[lld][elf2] Fix hard coded entry address.

llvm-svn: 247073
This commit is contained in:
Michael J. Spencer 2015-09-08 21:11:25 +00:00
parent 0127d80986
commit 8be15899b4
3 changed files with 7 additions and 3 deletions

View File

@ -576,7 +576,11 @@ template <class ELFT> void Writer<ELFT>::writeHeader() {
auto &FirstObj = cast<ObjectFile<ELFT>>(*Symtab.getFirstELF()); auto &FirstObj = cast<ObjectFile<ELFT>>(*Symtab.getFirstELF());
EHdr->e_machine = FirstObj.getEMachine(); EHdr->e_machine = FirstObj.getEMachine();
EHdr->e_version = EV_CURRENT; EHdr->e_version = EV_CURRENT;
EHdr->e_entry = 0x401000;
llvm::DenseMap<StringRef, Symbol *>::const_iterator Entry =
Symtab.getSymbols().find("_start");
EHdr->e_entry = getSymVA(cast<DefinedRegular<ELFT>>(Entry->second->Body));
EHdr->e_phoff = sizeof(Elf_Ehdr_Impl<ELFT>); EHdr->e_phoff = sizeof(Elf_Ehdr_Impl<ELFT>);
EHdr->e_shoff = SectionHeaderOff; EHdr->e_shoff = SectionHeaderOff;
EHdr->e_ehsize = sizeof(Elf_Ehdr_Impl<ELFT>); EHdr->e_ehsize = sizeof(Elf_Ehdr_Impl<ELFT>);

View File

@ -23,7 +23,7 @@ _start:
# CHECK-NEXT: Type: Executable (0x2) # CHECK-NEXT: Type: Executable (0x2)
# CHECK-NEXT: Machine: EM_X86_64 (0x3E) # CHECK-NEXT: Machine: EM_X86_64 (0x3E)
# CHECK-NEXT: Version: 1 # CHECK-NEXT: Version: 1
# CHECK-NEXT: Entry: 0x401000 # CHECK-NEXT: Entry: 0x1000
# CHECK-NEXT: ProgramHeaderOffset: 0x40 # CHECK-NEXT: ProgramHeaderOffset: 0x40
# CHECK-NEXT: SectionHeaderOffset: 0x1070 # CHECK-NEXT: SectionHeaderOffset: 0x1070
# CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: Flags [ (0x0)

View File

@ -23,7 +23,7 @@ _start:
# CHECK-NEXT: Type: Executable (0x2) # CHECK-NEXT: Type: Executable (0x2)
# CHECK-NEXT: Machine: EM_386 (0x3) # CHECK-NEXT: Machine: EM_386 (0x3)
# CHECK-NEXT: Version: 1 # CHECK-NEXT: Version: 1
# CHECK-NEXT: Entry: 0x401000 # CHECK-NEXT: Entry: 0x1000
# CHECK-NEXT: ProgramHeaderOffset: 0x34 # CHECK-NEXT: ProgramHeaderOffset: 0x34
# CHECK-NEXT: SectionHeaderOffset: 0x1058 # CHECK-NEXT: SectionHeaderOffset: 0x1058
# CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: Flags [ (0x0)