[PATCH] D63837: [LLD] [COFF] Fix .rsrc sections with differing permissions
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 27 13:56:54 PDT 2019
mstorsjo updated this revision to Diff 206928.
mstorsjo marked an inline comment as done.
mstorsjo added a comment.
Added the comment Rui requested. I also renamed the obj file from .obj to .o, as it is created with windres, not cvtres.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63837/new/
https://reviews.llvm.org/D63837
Files:
COFF/Writer.cpp
test/COFF/Inputs/id.res.o
test/COFF/resource-objs.test
Index: test/COFF/resource-objs.test
===================================================================
--- /dev/null
+++ test/COFF/resource-objs.test
@@ -0,0 +1,5 @@
+# RUN: lld-link /out:%t.exe /dll /noentry %S/Inputs/id.res.o
+# RUN: llvm-readobj -file-headers %t.exe | FileCheck %s
+
+CHECK: ResourceTableRVA: 0x1000
+CHECK: ResourceTableSize: 0x80
Index: COFF/Writer.cpp
===================================================================
--- COFF/Writer.cpp
+++ COFF/Writer.cpp
@@ -219,6 +219,7 @@
void sortExceptionTable();
void sortCRTSectionChunks(std::vector<Chunk *> &Chunks);
void addSyntheticIdata();
+ void fixPartialSectionChars(StringRef Name, uint32_t Chars);
bool fixGnuImportChunks();
PartialSection *createPartialSection(StringRef Name, uint32_t OutChars);
PartialSection *findPartialSection(StringRef Name, uint32_t OutChars);
@@ -652,6 +653,24 @@
});
}
+// Change the characteristics of existing PartialSections that belong to the
+// section Name to Chars.
+void Writer::fixPartialSectionChars(StringRef Name, uint32_t Chars) {
+ for (auto It : PartialSections) {
+ PartialSection *PSec = It.second;
+ StringRef CurName = PSec->Name;
+ if (!CurName.consume_front(Name) ||
+ (!CurName.empty() && !CurName.startswith("$")))
+ continue;
+ if (PSec->Characteristics == Chars)
+ continue;
+ PartialSection *DestSec = createPartialSection(PSec->Name, Chars);
+ DestSec->Chunks.insert(DestSec->Chunks.end(), PSec->Chunks.begin(),
+ PSec->Chunks.end());
+ PSec->Chunks.clear();
+ }
+}
+
// Sort concrete section chunks from GNU import libraries.
//
// GNU binutils doesn't use short import files, but instead produces import
@@ -667,17 +686,7 @@
// Make sure all .idata$* section chunks are mapped as RDATA in order to
// be sorted into the same sections as our own synthesized .idata chunks.
- for (auto It : PartialSections) {
- PartialSection *PSec = It.second;
- if (!PSec->Name.startswith(".idata"))
- continue;
- if (PSec->Characteristics == RDATA)
- continue;
- PartialSection *RDataSec = createPartialSection(PSec->Name, RDATA);
- RDataSec->Chunks.insert(RDataSec->Chunks.end(), PSec->Chunks.begin(),
- PSec->Chunks.end());
- PSec->Chunks.clear();
- }
+ fixPartialSectionChars(".idata", RDATA);
bool HasIdata = false;
// Sort all .idata$* chunks, grouping chunks from the same library,
@@ -808,6 +817,7 @@
PSec->Chunks.push_back(C);
}
+ fixPartialSectionChars(".rsrc", DATA | R);
// Even in non MinGW cases, we might need to link against GNU import
// libraries.
bool HasIdata = fixGnuImportChunks();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63837.206928.patch
Type: text/x-patch
Size: 2712 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190627/78dce5b8/attachment.bin>
More information about the llvm-commits
mailing list