diff options
-rw-r--r-- | lld/ELF/Chunks.h | 1 | ||||
-rw-r--r-- | lld/ELF/Writer.cpp | 48 | ||||
-rw-r--r-- | lld/ELF/Writer.h | 1 |
3 files changed, 24 insertions, 26 deletions
diff --git a/lld/ELF/Chunks.h b/lld/ELF/Chunks.h index db205dbdf81..286fa20b331 100644 --- a/lld/ELF/Chunks.h +++ b/lld/ELF/Chunks.h @@ -18,7 +18,6 @@ namespace elf2 { class Defined; template <class ELFT> class ObjectFile; -class OutputSection; // A Chunk represents a chunk of data that will occupy space in the // output (if the resolver chose that). It may or may not be backed by diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 67b967b1276..9a60153b78e 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -25,6 +25,30 @@ using namespace lld::elf2; static const int PageSize = 4096; namespace { +// OutputSection represents a section in an output file. It's a +// container of chunks. OutputSection and Chunk are 1:N relationship. +// Chunks cannot belong to more than one OutputSections. The writer +// creates multiple OutputSections and assign them unique, +// non-overlapping file offsets and VAs. +class OutputSection { +public: + OutputSection(StringRef Name) : Name(Name), Header({}) {} + void setVA(uint64_t); + void setFileOffset(uint64_t); + template <class ELFT> void addSectionChunk(SectionChunk<ELFT> *C); + std::vector<Chunk *> &getChunks() { return Chunks; } + template <class ELFT> + void writeHeaderTo(llvm::object::Elf_Shdr_Impl<ELFT> *SHdr); + + // Returns the size of the section in the output file. + uint64_t getSize() { return Header.sh_size; } + +private: + StringRef Name; + llvm::ELF::Elf64_Shdr Header; + std::vector<Chunk *> Chunks; +}; + // The writer writes a SymbolTable result to a file. template <class ELFT> class Writer { public: @@ -55,30 +79,6 @@ private: namespace lld { namespace elf2 { -// OutputSection represents a section in an output file. It's a -// container of chunks. OutputSection and Chunk are 1:N relationship. -// Chunks cannot belong to more than one OutputSections. The writer -// creates multiple OutputSections and assign them unique, -// non-overlapping file offsets and VAs. -class OutputSection { -public: - OutputSection(StringRef Name) : Name(Name), Header({}) {} - void setVA(uint64_t); - void setFileOffset(uint64_t); - template <class ELFT> void addSectionChunk(SectionChunk<ELFT> *C); - std::vector<Chunk *> &getChunks() { return Chunks; } - template <class ELFT> - void writeHeaderTo(llvm::object::Elf_Shdr_Impl<ELFT> *SHdr); - - // Returns the size of the section in the output file. - uint64_t getSize() { return Header.sh_size; } - -private: - StringRef Name; - llvm::ELF::Elf64_Shdr Header; - std::vector<Chunk *> Chunks; -}; - template <class ELFT> void writeResult(SymbolTable *Symtab) { Writer<ELFT>(Symtab).run(); } diff --git a/lld/ELF/Writer.h b/lld/ELF/Writer.h index b54251ef995..9f2f9f80ebf 100644 --- a/lld/ELF/Writer.h +++ b/lld/ELF/Writer.h @@ -13,7 +13,6 @@ namespace lld { namespace elf2 { -class OutputSection; class SymbolTable; template <class ELFT> |