summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/WindowsResource.cpp
diff options
context:
space:
mode:
authorEric Beckmann <ecbeckmann@google.com>2017-06-29 00:17:26 +0000
committerEric Beckmann <ecbeckmann@google.com>2017-06-29 00:17:26 +0000
commitd40dd64ff09af6f9dab68943492322015b61b24f (patch)
tree95c987439a28ee209a4708644698df6b2712a67f /llvm/lib/Object/WindowsResource.cpp
parent798a19ab8e3a065d5d1be38094288b228a0c039c (diff)
downloadbcm5719-llvm-d40dd64ff09af6f9dab68943492322015b61b24f.tar.gz
bcm5719-llvm-d40dd64ff09af6f9dab68943492322015b61b24f.zip
Revert "Replace trivial use of external rc.exe by writing our own .res file."
This reverts commit d4c7e9fc63c10dbab0c30186ef8575474a704496. This is done in order to address the failure of CrWinClangLLD etc. bots. These throw an error of "side-by-side configuration is incorrect" during compilation, which sounds suspiciously related to these manifest changes. Revert "Switch external cvtres.exe for llvm's own resource library." This reverts commit 71fe8ef283a9dab9a3f21432c98466cbc23990d1. llvm-svn: 306618
Diffstat (limited to 'llvm/lib/Object/WindowsResource.cpp')
-rw-r--r--llvm/lib/Object/WindowsResource.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/llvm/lib/Object/WindowsResource.cpp b/llvm/lib/Object/WindowsResource.cpp
index ff9b9ca35eb..35d5dd4ac47 100644
--- a/llvm/lib/Object/WindowsResource.cpp
+++ b/llvm/lib/Object/WindowsResource.cpp
@@ -36,19 +36,23 @@ const uint32_t MIN_HEADER_SIZE = 7 * sizeof(uint32_t) + 2 * sizeof(uint16_t);
// 8-byte because it makes everyone happy.
const uint32_t SECTION_ALIGNMENT = sizeof(uint64_t);
+static const size_t ResourceMagicSize = 16;
+
+static const size_t NullEntrySize = 16;
+
uint32_t WindowsResourceParser::TreeNode::StringCount = 0;
uint32_t WindowsResourceParser::TreeNode::DataCount = 0;
WindowsResource::WindowsResource(MemoryBufferRef Source)
: Binary(Binary::ID_WinRes, Source) {
- size_t LeadingSize = WIN_RES_MAGIC_SIZE + WIN_RES_NULL_ENTRY_SIZE;
+ size_t LeadingSize = ResourceMagicSize + NullEntrySize;
BBS = BinaryByteStream(Data.getBuffer().drop_front(LeadingSize),
support::little);
}
Expected<std::unique_ptr<WindowsResource>>
WindowsResource::createWindowsResource(MemoryBufferRef Source) {
- if (Source.getBufferSize() < WIN_RES_MAGIC_SIZE + WIN_RES_NULL_ENTRY_SIZE)
+ if (Source.getBufferSize() < ResourceMagicSize + NullEntrySize)
return make_error<GenericBinaryError>(
"File too small to be a resource file",
object_error::invalid_file_type);
@@ -101,10 +105,12 @@ static Error readStringOrId(BinaryStreamReader &Reader, uint16_t &ID,
}
Error ResourceEntryRef::loadNext() {
- const WinResHeaderPrefix *Prefix;
- RETURN_IF_ERROR(Reader.readObject(Prefix));
+ uint32_t DataSize;
+ RETURN_IF_ERROR(Reader.readInteger(DataSize));
+ uint32_t HeaderSize;
+ RETURN_IF_ERROR(Reader.readInteger(HeaderSize));
- if (Prefix->HeaderSize < MIN_HEADER_SIZE)
+ if (HeaderSize < MIN_HEADER_SIZE)
return make_error<GenericBinaryError>("Header size is too small.",
object_error::parse_failed);
@@ -112,13 +118,13 @@ Error ResourceEntryRef::loadNext() {
RETURN_IF_ERROR(readStringOrId(Reader, NameID, Name, IsStringName));
- RETURN_IF_ERROR(Reader.padToAlignment(WIN_RES_HEADER_ALIGNMENT));
+ RETURN_IF_ERROR(Reader.padToAlignment(sizeof(uint32_t)));
RETURN_IF_ERROR(Reader.readObject(Suffix));
- RETURN_IF_ERROR(Reader.readArray(Data, Prefix->DataSize));
+ RETURN_IF_ERROR(Reader.readArray(Data, DataSize));
- RETURN_IF_ERROR(Reader.padToAlignment(WIN_RES_DATA_ALIGNMENT));
+ RETURN_IF_ERROR(Reader.padToAlignment(sizeof(uint32_t)));
return Error::success();
}
@@ -319,6 +325,7 @@ private:
void writeDirectoryTree();
void writeDirectoryStringTable();
void writeFirstSectionRelocations();
+
std::unique_ptr<MemoryBuffer> OutputBuffer;
char *BufferStart;
uint64_t CurrentOffset = 0;
@@ -462,6 +469,8 @@ void WindowsResourceCOFFWriter::writeFirstSectionHeader() {
SectionOneHeader->PointerToLinenumbers = 0;
SectionOneHeader->NumberOfRelocations = Data.size();
SectionOneHeader->NumberOfLinenumbers = 0;
+ SectionOneHeader->Characteristics = COFF::IMAGE_SCN_ALIGN_1BYTES;
+ SectionOneHeader->Characteristics += COFF::IMAGE_SCN_CNT_INITIALIZED_DATA;
SectionOneHeader->Characteristics += COFF::IMAGE_SCN_CNT_INITIALIZED_DATA;
SectionOneHeader->Characteristics += COFF::IMAGE_SCN_MEM_READ;
}
OpenPOWER on IntegriCloud