mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-02 18:58:15 +00:00
[COFF] Remove finalizeContents virtual method from Chunk, NFC
This only needs to be done for MergeChunks, so just do that in a separate pass in the Writer. This is one small step towards eliminating the vtable in Chunk. llvm-svn: 361573
This commit is contained in:
parent
ae02e89448
commit
11c141eb68
@ -873,14 +873,15 @@ void MergeChunk::addSection(SectionChunk *C) {
|
||||
}
|
||||
|
||||
void MergeChunk::finalizeContents() {
|
||||
if (!Finalized) {
|
||||
for (SectionChunk *C : Sections)
|
||||
if (C->Live)
|
||||
Builder.add(toStringRef(C->getContents()));
|
||||
Builder.finalize();
|
||||
Finalized = true;
|
||||
}
|
||||
assert(!Finalized && "should only finalize once");
|
||||
for (SectionChunk *C : Sections)
|
||||
if (C->Live)
|
||||
Builder.add(toStringRef(C->getContents()));
|
||||
Builder.finalize();
|
||||
Finalized = true;
|
||||
}
|
||||
|
||||
void MergeChunk::assignSubsectionRVAs() {
|
||||
for (SectionChunk *C : Sections) {
|
||||
if (!C->Live)
|
||||
continue;
|
||||
|
@ -78,10 +78,6 @@ public:
|
||||
// before calling this function.
|
||||
virtual void writeTo(uint8_t *Buf) const {}
|
||||
|
||||
// Called by the writer after an RVA is assigned, but before calling
|
||||
// getSize().
|
||||
virtual void finalizeContents() {}
|
||||
|
||||
// The writer sets and uses the addresses. In practice, PE images cannot be
|
||||
// larger than 2GB. Chunks are always laid as part of the image, so Chunk RVAs
|
||||
// can be stored with 32 bits.
|
||||
@ -320,7 +316,8 @@ class MergeChunk : public Chunk {
|
||||
public:
|
||||
MergeChunk(uint32_t Alignment);
|
||||
static void addSection(SectionChunk *C);
|
||||
void finalizeContents() override;
|
||||
void finalizeContents();
|
||||
void assignSubsectionRVAs();
|
||||
|
||||
uint32_t getOutputCharacteristics() const override;
|
||||
StringRef getSectionName() const override { return ".rdata"; }
|
||||
|
@ -865,9 +865,12 @@ void Writer::createSections() {
|
||||
}
|
||||
|
||||
void Writer::createMiscChunks() {
|
||||
for (MergeChunk *P : MergeChunk::Instances)
|
||||
if (P)
|
||||
for (MergeChunk *P : MergeChunk::Instances) {
|
||||
if (P) {
|
||||
P->finalizeContents();
|
||||
RdataSec->addChunk(P);
|
||||
}
|
||||
}
|
||||
|
||||
// Create thunks for locally-dllimported symbols.
|
||||
if (!Symtab->LocalImportChunks.empty()) {
|
||||
@ -1162,7 +1165,6 @@ void Writer::assignAddresses() {
|
||||
VirtualSize += Padding;
|
||||
VirtualSize = alignTo(VirtualSize, C->getAlignment());
|
||||
C->setRVA(RVA + VirtualSize);
|
||||
C->finalizeContents();
|
||||
VirtualSize += C->getSize();
|
||||
if (C->hasData())
|
||||
RawSize = alignTo(VirtualSize, SectorSize);
|
||||
@ -1177,6 +1179,11 @@ void Writer::assignAddresses() {
|
||||
FileSize += alignTo(RawSize, SectorSize);
|
||||
}
|
||||
SizeOfImage = alignTo(RVA, PageSize);
|
||||
|
||||
// Assign addresses to sections in MergeChunks.
|
||||
for (MergeChunk *MC : MergeChunk::Instances)
|
||||
if (MC)
|
||||
MC->assignSubsectionRVAs();
|
||||
}
|
||||
|
||||
template <typename PEHeaderTy> void Writer::writeHeader() {
|
||||
|
Loading…
Reference in New Issue
Block a user