Skip to content

Commit 7d469e4

Browse files
committed
[LLD][COFF] Simplify creation of .edata chunks (NFC)
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 a16adaf commit 7d469e4

File tree

3 files changed

+7
-18
lines changed

3 files changed

+7
-18
lines changed

lld/COFF/DLL.cpp

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 14 deletions
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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ struct ChunkRange {
210210
class Writer {
211211
public:
212212
Writer(COFFLinkerContext &c)
213-
: buffer(c.e.outputBuffer), delayIdata(c), edata(c), ctx(c) {}
213+
: buffer(c.e.outputBuffer), delayIdata(c), ctx(c) {}
214214
void run();
215215

216216
private:
@@ -298,7 +298,6 @@ class Writer {
298298
Chunk *iatStart = nullptr;
299299
uint64_t iatSize = 0;
300300
DelayLoadContents delayIdata;
301-
EdataContents edata;
302301
bool setNoSEHCharacteristic = false;
303302
uint32_t tlsAlignment = 0;
304303

@@ -1325,7 +1324,9 @@ void Writer::createExportTable() {
13251324
if (ctx.config.hadExplicitExports)
13261325
Warn(ctx) << "literal .edata sections override exports";
13271326
} else if (!ctx.config.exports.empty()) {
1328-
for (Chunk *c : edata.chunks)
1327+
std::vector<Chunk *> edataChunks;
1328+
createEdataChunks(ctx, edataChunks);
1329+
for (Chunk *c : edataChunks)
13291330
edataSec->addChunk(c);
13301331
}
13311332
if (!edataSec->chunks.empty()) {

0 commit comments

Comments
 (0)