[PATCH] D63837: [LLD] [COFF] Fix .rsrc sections with differing permissions
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 28 10:24:28 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL364660: [COFF] Fix .rsrc sections with differing permissions (authored by mstorsjo, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D63837?vs=206928&id=207091#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63837/new/
https://reviews.llvm.org/D63837
Files:
lld/trunk/COFF/Writer.cpp
lld/trunk/test/COFF/Inputs/id.res.o
lld/trunk/test/COFF/resource-objs.test
Index: lld/trunk/test/COFF/resource-objs.test
===================================================================
--- lld/trunk/test/COFF/resource-objs.test
+++ lld/trunk/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: lld/trunk/COFF/Writer.cpp
===================================================================
--- lld/trunk/COFF/Writer.cpp
+++ lld/trunk/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.207091.patch
Type: text/x-patch
Size: 2791 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190628/70c5ccb4/attachment-0001.bin>
More information about the llvm-commits
mailing list