Skip to content

Commit 2cfddda

Browse files
authored
[LLD][COFF] Simplify creation of .edata chunks (NFC) (#123651)
Since commit dadc6f2, only the constructor of the `EdataContents` class is used. Replace it with a function and skip the call when using a custom `.edata` section.
1 parent fb974e8 commit 2cfddda

File tree

3 files changed

+7
-18
lines changed

3 files changed

+7
-18
lines changed

lld/COFF/DLL.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ Chunk *DelayLoadContents::newThunkChunk(DefinedImportData *s,
920920
}
921921
}
922922

923-
EdataContents::EdataContents(COFFLinkerContext &ctx) : ctx(ctx) {
923+
void createEdataChunks(COFFLinkerContext &ctx, std::vector<Chunk *> &chunks) {
924924
unsigned baseOrdinal = 1 << 16, maxOrdinal = 0;
925925
for (Export &e : ctx.config.exports) {
926926
baseOrdinal = std::min(baseOrdinal, (unsigned)e.ordinal);

lld/COFF/DLL.h

+2-14
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,8 @@ class DelayLoadContents {
7777
COFFLinkerContext &ctx;
7878
};
7979

80-
// Windows-specific.
81-
// EdataContents creates all chunks for the DLL export table.
82-
class EdataContents {
83-
public:
84-
EdataContents(COFFLinkerContext &ctx);
85-
std::vector<Chunk *> chunks;
86-
87-
uint64_t getRVA() { return chunks[0]->getRVA(); }
88-
uint64_t getSize() {
89-
return chunks.back()->getRVA() + chunks.back()->getSize() - getRVA();
90-
}
91-
92-
COFFLinkerContext &ctx;
93-
};
80+
// Create all chunks for the DLL export table.
81+
void createEdataChunks(COFFLinkerContext &ctx, std::vector<Chunk *> &chunks);
9482

9583
} // namespace lld::coff
9684

lld/COFF/Writer.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ struct ChunkRange {
204204
class Writer {
205205
public:
206206
Writer(COFFLinkerContext &c)
207-
: buffer(c.e.outputBuffer), delayIdata(c), edata(c), ctx(c) {}
207+
: buffer(c.e.outputBuffer), delayIdata(c), ctx(c) {}
208208
void run();
209209

210210
private:
@@ -293,7 +293,6 @@ class Writer {
293293
Chunk *iatStart = nullptr;
294294
uint64_t iatSize = 0;
295295
DelayLoadContents delayIdata;
296-
EdataContents edata;
297296
bool setNoSEHCharacteristic = false;
298297
uint32_t tlsAlignment = 0;
299298

@@ -1335,7 +1334,9 @@ void Writer::createExportTable() {
13351334
if (ctx.config.hadExplicitExports)
13361335
Warn(ctx) << "literal .edata sections override exports";
13371336
} else if (!ctx.config.exports.empty()) {
1338-
for (Chunk *c : edata.chunks)
1337+
std::vector<Chunk *> edataChunks;
1338+
createEdataChunks(ctx, edataChunks);
1339+
for (Chunk *c : edataChunks)
13391340
edataSec->addChunk(c);
13401341
}
13411342
if (!edataSec->chunks.empty()) {

0 commit comments

Comments
 (0)