diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-07-13 19:26:06 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-07-13 19:26:06 +0000 |
commit | 267829774358b5aebd3e726ae318813bd48129bb (patch) | |
tree | 5a8904da0d9716ea10b69258f5d50e0b1ee2ec2c /ELF/LinkerScript.h | |
parent | 0317860f00ca8e821989c92c8a6cc461fd5f2009 (diff) | |
download | src-267829774358b5aebd3e726ae318813bd48129bb.tar.gz src-267829774358b5aebd3e726ae318813bd48129bb.zip |
Vendor import of lld trunk r307894:vendor/lld/lld-trunk-r307894
Notes
Notes:
svn path=/vendor/lld/dist/; revision=320965
svn path=/vendor/lld/lld-trunk-r307894/; revision=320966; tag=vendor/lld/lld-trunk-r307894
Diffstat (limited to 'ELF/LinkerScript.h')
-rw-r--r-- | ELF/LinkerScript.h | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/ELF/LinkerScript.h b/ELF/LinkerScript.h index f8a34a1e97dd..dd5a7d797f60 100644 --- a/ELF/LinkerScript.h +++ b/ELF/LinkerScript.h @@ -110,7 +110,6 @@ struct MemoryRegion { std::string Name; uint64_t Origin; uint64_t Length; - uint64_t Offset; uint32_t Flags; uint32_t NegFlags; }; @@ -140,6 +139,10 @@ struct OutputSectionCommand : BaseCommand { template <class ELFT> void writeTo(uint8_t *Buf); template <class ELFT> void maybeCompress(); uint32_t getFiller(); + + void sort(std::function<int(InputSectionBase *S)> Order); + void sortInitFini(); + void sortCtorsDtors(); }; // This struct represents one section match pattern in SECTIONS() command. @@ -222,6 +225,17 @@ struct ScriptConfiguration { }; class LinkerScript final { + // Temporary state used in processCommands() and assignAddresses() + // that must be reinitialized for each call to the above functions, and must + // not be used outside of the scope of a call to the above functions. + struct AddressState { + uint64_t ThreadBssOffset = 0; + OutputSection *OutSec = nullptr; + MemoryRegion *MemRegion = nullptr; + llvm::DenseMap<const MemoryRegion *, uint64_t> MemRegionOffset; + std::function<uint64_t()> LMAOffset; + AddressState(const ScriptConfiguration &Opt); + }; llvm::DenseMap<OutputSection *, OutputSectionCommand *> SecToCommand; llvm::DenseMap<StringRef, OutputSectionCommand *> NameToOutputSectionCommand; @@ -234,7 +248,7 @@ class LinkerScript final { std::vector<InputSectionBase *> createInputSectionList(OutputSectionCommand &Cmd); - std::vector<size_t> getPhdrIndices(OutputSection *Sec); + std::vector<size_t> getPhdrIndices(OutputSectionCommand *Cmd); size_t getPhdrIndex(const Twine &Loc, StringRef PhdrName); MemoryRegion *findMemoryRegion(OutputSectionCommand *Cmd); @@ -244,14 +258,10 @@ class LinkerScript final { void output(InputSection *Sec); void process(BaseCommand &Base); + AddressState *CurAddressState = nullptr; OutputSection *Aether; uint64_t Dot; - uint64_t ThreadBssOffset = 0; - - std::function<uint64_t()> LMAOffset; - OutputSection *CurOutSec = nullptr; - MemoryRegion *CurMemRegion = nullptr; public: bool ErrorOnMissingSection = false; @@ -276,13 +286,11 @@ public: std::vector<PhdrEntry> createPhdrs(); bool ignoreInterpSection(); - bool hasLMA(OutputSection *Sec); bool shouldKeep(InputSectionBase *S); void assignOffsets(OutputSectionCommand *Cmd); - void createOrphanCommands(); void processNonSectionCommands(); - void assignAddresses(std::vector<PhdrEntry> &Phdrs); - + void assignAddresses(); + void allocateHeaders(std::vector<PhdrEntry> &Phdrs); void addSymbol(SymbolAssignment *Cmd); void processCommands(OutputSectionFactory &Factory); |