From 49a2394095ba6ca63ba679b8384166999222e867 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Mon, 15 Jul 2013 21:35:15 +0000 Subject: [PATCH] [PECOFF][Writer] Refactoring: Move private methods below public ones. llvm-svn: 186352 --- lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp | 79 ++++++++++++++-------------- 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp b/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp index 62ea7c7..759e76b 100644 --- a/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp +++ b/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp @@ -673,46 +673,6 @@ private: } // end anonymous namespace class ExecutableWriter : public Writer { -private: - /// Apply relocations to the output file buffer. This two pass. In the first - /// pass, we visit all atoms to create a map from atom to its virtual - /// address. In the second pass, we visit all relocation references to fix - /// up addresses in the buffer. - void applyAllRelocations(uint8_t *bufferStart) { - for (auto &cp : _chunks) - if (AtomChunk *chunk = dyn_cast(&*cp)) - chunk->applyRelocations(bufferStart, atomRva); - } - - void addChunk(Chunk *chunk) { - _chunks.push_back(std::unique_ptr(chunk)); - } - - void addSectionChunk(SectionChunk *chunk, - SectionHeaderTableChunk *table) { - _chunks.push_back(std::unique_ptr(chunk)); - table->addSection(chunk); - _numSections++; - - // Compute and set the starting address of sections when loaded in - // memory. They are different from positions on disk because sections need - // to be sector-aligned on disk but page-aligned in memory. - chunk->setVirtualAddress(_imageSizeInMemory); - chunk->buildAtomToVirtualAddr(atomRva); - _imageSizeInMemory = llvm::RoundUpToAlignment( - _imageSizeInMemory + chunk->size(), PAGE_SIZE); - } - - void setImageSizeOnDisk() { - for (auto &chunk : _chunks) { - // Compute and set the offset of the chunk in the output file. - _imageSizeOnDisk = llvm::RoundUpToAlignment(_imageSizeOnDisk, - chunk->align()); - chunk->setFileOffset(_imageSizeOnDisk); - _imageSizeOnDisk += chunk->size(); - } - } - public: explicit ExecutableWriter(const PECOFFTargetInfo &targetInfo) : _PECOFFTargetInfo(targetInfo), _numSections(0), @@ -789,6 +749,45 @@ public: } private: + /// Apply relocations to the output file buffer. This two pass. In the first + /// pass, we visit all atoms to create a map from atom to its virtual + /// address. In the second pass, we visit all relocation references to fix + /// up addresses in the buffer. + void applyAllRelocations(uint8_t *bufferStart) { + for (auto &cp : _chunks) + if (AtomChunk *chunk = dyn_cast(&*cp)) + chunk->applyRelocations(bufferStart, atomRva); + } + + void addChunk(Chunk *chunk) { + _chunks.push_back(std::unique_ptr(chunk)); + } + + void addSectionChunk(SectionChunk *chunk, + SectionHeaderTableChunk *table) { + _chunks.push_back(std::unique_ptr(chunk)); + table->addSection(chunk); + _numSections++; + + // Compute and set the starting address of sections when loaded in + // memory. They are different from positions on disk because sections need + // to be sector-aligned on disk but page-aligned in memory. + chunk->setVirtualAddress(_imageSizeInMemory); + chunk->buildAtomToVirtualAddr(atomRva); + _imageSizeInMemory = llvm::RoundUpToAlignment( + _imageSizeInMemory + chunk->size(), PAGE_SIZE); + } + + void setImageSizeOnDisk() { + for (auto &chunk : _chunks) { + // Compute and set the offset of the chunk in the output file. + _imageSizeOnDisk = llvm::RoundUpToAlignment(_imageSizeOnDisk, + chunk->align()); + chunk->setFileOffset(_imageSizeOnDisk); + _imageSizeOnDisk += chunk->size(); + } + } + std::vector> _chunks; const PECOFFTargetInfo &_PECOFFTargetInfo; uint32_t _numSections; -- 2.7.4