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

Michael Spencer via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 8 14:41:03 PDT 2015


On Tue, Sep 8, 2015 at 2:18 PM, Rui Ueyama <ruiu at google.com> wrote:
> It's probably better to store a pointer to an undefined symbol for "_start"
> to Config object and get its symbol resolution result just by looking at the
> undefined objects repl(), instead of looking up the name more than once.
> That's what we do in COFF.

Undefined references currently require an ELFT, which we can't get
until we read the first input file.

I'll look into changing it so we can generate an undefined symbol at the start.

- Michael Spencer

>
> On Wed, Sep 9, 2015 at 6:11 AM, Michael J. Spencer via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
>>
>> Author: mspencer
>> Date: Tue Sep  8 16:11:25 2015
>> New Revision: 247073
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=247073&view=rev
>> Log:
>> [lld][elf2] Fix hard coded entry address.
>>
>> Modified:
>>     lld/trunk/ELF/Writer.cpp
>>     lld/trunk/test/elf2/basic.s
>>     lld/trunk/test/elf2/basic32.s
>>
>> Modified: lld/trunk/ELF/Writer.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=247073&r1=247072&r2=247073&view=diff
>>
>> ==============================================================================
>> --- lld/trunk/ELF/Writer.cpp (original)
>> +++ lld/trunk/ELF/Writer.cpp Tue Sep  8 16:11:25 2015
>> @@ -576,7 +576,11 @@ template <class ELFT> void Writer<ELFT>:
>>    auto &FirstObj = cast<ObjectFile<ELFT>>(*Symtab.getFirstELF());
>>    EHdr->e_machine = FirstObj.getEMachine();
>>    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_shoff = SectionHeaderOff;
>>    EHdr->e_ehsize = sizeof(Elf_Ehdr_Impl<ELFT>);
>>
>> Modified: lld/trunk/test/elf2/basic.s
>> URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic.s?rev=247073&r1=247072&r2=247073&view=diff
>>
>> ==============================================================================
>> --- lld/trunk/test/elf2/basic.s (original)
>> +++ lld/trunk/test/elf2/basic.s Tue Sep  8 16:11:25 2015
>> @@ -23,7 +23,7 @@ _start:
>>  # CHECK-NEXT:   Type: Executable (0x2)
>>  # CHECK-NEXT:   Machine: EM_X86_64 (0x3E)
>>  # CHECK-NEXT:   Version: 1
>> -# CHECK-NEXT:   Entry: 0x401000
>> +# CHECK-NEXT:   Entry: 0x1000
>>  # CHECK-NEXT:   ProgramHeaderOffset: 0x40
>>  # CHECK-NEXT:   SectionHeaderOffset: 0x1070
>>  # CHECK-NEXT:   Flags [ (0x0)
>>
>> Modified: lld/trunk/test/elf2/basic32.s
>> URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic32.s?rev=247073&r1=247072&r2=247073&view=diff
>>
>> ==============================================================================
>> --- lld/trunk/test/elf2/basic32.s (original)
>> +++ lld/trunk/test/elf2/basic32.s Tue Sep  8 16:11:25 2015
>> @@ -23,7 +23,7 @@ _start:
>>  # CHECK-NEXT:   Type: Executable (0x2)
>>  # CHECK-NEXT:   Machine: EM_386 (0x3)
>>  # CHECK-NEXT:   Version: 1
>> -# CHECK-NEXT:   Entry: 0x401000
>> +# CHECK-NEXT:   Entry: 0x1000
>>  # CHECK-NEXT:   ProgramHeaderOffset: 0x34
>>  # CHECK-NEXT:   SectionHeaderOffset: 0x1058
>>  # CHECK-NEXT:   Flags [ (0x0)
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>


More information about the llvm-commits mailing list