summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/COFF/Chunks.cpp2
-rw-r--r--lld/COFF/Chunks.h22
2 files changed, 15 insertions, 9 deletions
diff --git a/lld/COFF/Chunks.cpp b/lld/COFF/Chunks.cpp
index d2007ea760d..166912497a6 100644
--- a/lld/COFF/Chunks.cpp
+++ b/lld/COFF/Chunks.cpp
@@ -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); }
diff --git a/lld/COFF/Chunks.h b/lld/COFF/Chunks.h
index f3ea5401c45..223141bfc92 100644
--- a/lld/COFF/Chunks.h
+++ b/lld/COFF/Chunks.h
@@ -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.
OpenPOWER on IntegriCloud