[lld] r228377 - [ELF] Speedup creating program headers.
Rui Ueyama
ruiu at google.com
Thu Feb 5 20:44:40 PST 2015
On Thu, Feb 5, 2015 at 8:15 PM, Shankar Easwaran <shankare at codeaurora.org>
wrote:
> Author: shankare
> Date: Thu Feb 5 22:15:04 2015
> New Revision: 228377
>
> URL: http://llvm.org/viewvc/llvm-project?rev=228377&view=rev
> Log:
> [ELF] Speedup creating program headers.
>
> After the total number of program headers are determined, virtual addresses
> and file offsets need not be reassigned for sections whose virtual
> addresses and
> fileoffsets remained the same.
>
> This doesnot change any functionality.
>
> Modified:
> lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h?rev=228377&r1=228376&r2=228377&view=diff
>
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h Thu Feb 5 22:15:04 2015
> @@ -755,7 +755,7 @@ DefaultLayout<ELFT>::assignVirtualAddres
>
> std::sort(_segments.begin(), _segments.end(),
> Segment<ELFT>::compareSegments);
>
> - uint64_t virtualAddress = _context.getBaseAddress();
> + uint64_t baseAddress = _context.getBaseAddress();
>
> // HACK: This is a super dirty hack. The elf header and program header
> are
> // not part of a section, but we need them to be loaded at the base
> address
> @@ -774,6 +774,7 @@ DefaultLayout<ELFT>::assignVirtualAddres
> firstLoadSegment->prepend(_elfHeader);
> bool newSegmentHeaderAdded = true;
> bool virtualAddressAssigned = false;
> + bool fileOffsetAssigned = false;
> while (true) {
> for (auto si : _segments) {
> si->finalize();
> @@ -783,8 +784,8 @@ DefaultLayout<ELFT>::assignVirtualAddres
> }
> if (!newSegmentHeaderAdded && virtualAddressAssigned)
> break;
> - virtualAddressAssigned = true;
> - uint64_t address = virtualAddress;
> + uint64_t address = baseAddress;
> + ;
>
Stray ';' here.
> // start assigning virtual addresses
> for (auto &si : _segments) {
> if ((si->segmentType() != llvm::ELF::PT_LOAD) &&
> @@ -794,18 +795,27 @@ DefaultLayout<ELFT>::assignVirtualAddres
> if (si->segmentType() == llvm::ELF::PT_NULL) {
> si->assignVirtualAddress(0 /*non loadable*/);
> } else {
> + if (virtualAddressAssigned && (address != baseAddress) &&
> + (address == si->virtualAddr()))
> + break;
> si->assignVirtualAddress(address);
> }
> address = si->virtualAddr() + si->memSize();
> }
> - uint64_t fileoffset = 0;
> + uint64_t baseFileOffset = 0;
> + uint64_t fileoffset = baseFileOffset;
> for (auto &si : _segments) {
> if ((si->segmentType() != llvm::ELF::PT_LOAD) &&
> (si->segmentType() != llvm::ELF::PT_NULL))
> continue;
> + if (fileOffsetAssigned && (fileoffset != baseFileOffset) &&
> + (fileoffset == si->fileOffset()))
> + break;
> si->assignFileOffsets(fileoffset);
> fileoffset = si->fileOffset() + si->fileSize();
> }
> + virtualAddressAssigned = true;
> + fileOffsetAssigned = true;
> _programHeader->resetProgramHeaders();
> }
> Section<ELFT> *section;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150205/4e3c38bd/attachment.html>
More information about the llvm-commits
mailing list