summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Object/COFF.h3
-rw-r--r--llvm/lib/Object/WindowsResource.cpp4
2 files changed, 5 insertions, 2 deletions
diff --git a/llvm/include/llvm/Object/COFF.h b/llvm/include/llvm/Object/COFF.h
index 78e0b5f6ed3..89c1ba6be35 100644
--- a/llvm/include/llvm/Object/COFF.h
+++ b/llvm/include/llvm/Object/COFF.h
@@ -698,6 +698,9 @@ struct coff_resource_dir_entry {
uint32_t getNameOffset() const {
return maskTrailingOnes<uint32_t>(31) & NameOffset;
}
+ // Even though the PE/COFF spec doesn't mention this, the high bit of a name
+ // offset is set.
+ void setNameOffset(uint32_t Offset) { NameOffset = Offset | (1 << 31); }
} Identifier;
union {
support::ulittle32_t DataEntryOffset;
diff --git a/llvm/lib/Object/WindowsResource.cpp b/llvm/lib/Object/WindowsResource.cpp
index b0cd6c8ebda..be767a154f9 100644
--- a/llvm/lib/Object/WindowsResource.cpp
+++ b/llvm/lib/Object/WindowsResource.cpp
@@ -616,8 +616,8 @@ void WindowsResourceCOFFWriter::writeDirectoryTree() {
for (auto const &Child : StringChildren) {
auto *Entry = reinterpret_cast<coff_resource_dir_entry *>(BufferStart +
CurrentOffset);
- Entry->Identifier.NameOffset =
- StringTableOffsets[Child.second->getStringIndex()];
+ Entry->Identifier.setNameOffset(
+ StringTableOffsets[Child.second->getStringIndex()]);
if (Child.second->checkIsDataNode()) {
Entry->Offset.DataEntryOffset = NextLevelOffset;
NextLevelOffset += sizeof(coff_resource_data_entry);
OpenPOWER on IntegriCloud