mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-30 17:21:10 +00:00
[COFF] Store Chunk RVAs and section offsets as uint32_t
Saves 8 bytes on SectionChunk, one of the most commonly allocated data structures. llvm-svn: 360188
This commit is contained in:
parent
3bdb81c26d
commit
34e9c41164
@ -53,7 +53,7 @@ SectionChunk::SectionChunk(ObjFile *F, const coff_section *H)
|
||||
// SectionChunk is one of the most frequently allocated classes, so it is
|
||||
// important to keep it as compact as possible. As of this writing, the number
|
||||
// below is the size of this class on x64 platforms.
|
||||
static_assert(sizeof(SectionChunk) <= 120, "SectionChunk grew unexpectedly");
|
||||
static_assert(sizeof(SectionChunk) <= 112, "SectionChunk grew unexpectedly");
|
||||
|
||||
static void add16(uint8_t *P, int16_t V) { write16le(P, read16le(P) + V); }
|
||||
static void add32(uint8_t *P, int32_t V) { write32le(P, read32le(P) + V); }
|
||||
|
@ -67,9 +67,14 @@ public:
|
||||
// getSize().
|
||||
virtual void finalizeContents() {}
|
||||
|
||||
// The writer sets and uses the addresses.
|
||||
uint64_t getRVA() const { return RVA; }
|
||||
void setRVA(uint64_t V) { RVA = V; }
|
||||
// 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.
|
||||
uint32_t getRVA() const { return RVA; }
|
||||
void setRVA(uint64_t V) {
|
||||
RVA = (uint32_t)V;
|
||||
assert(RVA == V && "RVA truncated");
|
||||
}
|
||||
|
||||
// Returns true if this has non-zero data. BSS chunks return
|
||||
// false. If false is returned, the space occupied by this chunk
|
||||
@ -114,14 +119,15 @@ public:
|
||||
|
||||
protected:
|
||||
// The RVA of this chunk in the output. The writer sets a value.
|
||||
uint64_t RVA = 0;
|
||||
|
||||
// The output section for this chunk.
|
||||
OutputSection *Out = nullptr;
|
||||
uint32_t RVA = 0;
|
||||
|
||||
public:
|
||||
// The offset from beginning of the output section. The writer sets a value.
|
||||
uint64_t OutputSectionOff = 0;
|
||||
uint32_t OutputSectionOff = 0;
|
||||
|
||||
protected:
|
||||
// The output section for this chunk.
|
||||
OutputSection *Out = nullptr;
|
||||
};
|
||||
|
||||
// A chunk corresponding a section of an input file.
|
||||
|
Loading…
Reference in New Issue
Block a user