aboutsummaryrefslogtreecommitdiff
path: root/lib/Object/WindowsResource.cpp
AgeCommit message (Collapse)Author
2018-01-09[Support] Add WritableMemoryBuffer::getNewMemBufferPavel Labath
Summary: The idea is that it would replace (non-Writable)MemoryBuffer::getNewMemBuffer, which is quite useless unless you const_cast its contents to write to it (which all (both) callers of this function were doing). This patch also fixes one of the usages in COFFWriter. After fixing the other usage in clang, I plan to delete the old function. Reviewers: dblaikie, Bigcheese Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D41540 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322094 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-18Fix buffer overrun in WindowsResourceCOFFWriter::writeSymbolTable()Bob Haarman
Summary: We were using sprintf(..., "$R06X", <some uint32_t>) to create strings that are expected to be exactly length 8, but this results in longer strings if the uint32_t is greater than 0xffffff. This change modifies the behavior as follows: - Uses the loop counter instead of the data offset. This gives us sequential symbol names, avoiding collisions as much as possible. - Masks the value to 0xffffff to avoid generating names longer than 8 bytes. - Uses formatv instead of sprintf. Fixes PR35581. Reviewers: ruiu, zturner Reviewed By: ruiu Subscribers: hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D41270 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321030 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-13Remove redundant includes from lib/Object.Michael Zolotukhin
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320625 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-10[llvm-cvtres] Add support for ARM64Martin Storsjo
Also change some default cases into llvm_unreachable in WindowsResourceCOFFWriter, to make it easier to find if they are triggerd from within e.g. lld, which supported ARM64 earlier than llvm-cvtres did. Differential Revision: https://reviews.llvm.org/D39892 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317942 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-01Fix warnings discovered by rL317076. [-Wunused-private-field]NAKAMURA Takumi
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317091 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-24Fix bug 34051 by handling empty .res files gracefully.Eric Beckmann
Summary: Previously, llvm-cvtres crashes on .res files which are empty except for the null header. This allows the library to simply pass over them. Subscribers: llvm-commits, hiraditya Differential Revision: https://reviews.llvm.org/D37044 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311625 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-08Revert "Revert "Revert "Revert "Switch external cvtres.exe for llvm's own ↵Eric Beckmann
resource library."""" This reverts commit 147f45ff24456aea59575fa4ac16c8fa554df46a. Revert "Revert "Revert "Revert "Replace trivial use of external rc.exe by writing our own .res file."""" This reverts commit 61a90a67ed54a1f0dfeab457b65abffa129569e4. The patches were intially reverted because they were causing a failure on CrWinClangLLD. Unfortunately, this was done haphazardly and didn't compile, so the revert was reverted again quickly to fix this. One that was done, the revert of the revert was itself reverted. This allowed me to finally fix the actual bug in r307452. This patch re-enables the code path that had originally been causing the bug, now that it (should) be fixed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307460 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-07Add name offset flags, for parity with cvtres.exe.Eric Beckmann
Summary: The original cvtres.exe sets the high bit when an identifier offset points to a string. Even though this is not mentioned in the spec, and in fact does not seem to cause errors with most cases, for some reason this causes a failure in Chromium where the new resource file is not verified as a new version. This patch sets this high bit flag, and also adds a test case to check that the output of our library is always identical to original cvtres. Reviewers: zturner, ruiu Subscribers: llvm-commits, hiraditya Differential Revision: https://reviews.llvm.org/D35099 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307452 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-05Revert "Revert "Revert "Switch external cvtres.exe for llvm's own resource ↵Eric Beckmann
library.""" This reverts commit ae21ee0b6cacbc1efaf4d42502e71da2f0eb45c3. The initial revert was done in order to prevent ongoing errors on chromium bots such as CrWinClangLLD. However, this was done haphazardly and I didn't realize there were test and compilation failures, so this revert was reverted. Now that those have been fixed, we can revert the revert of the revert. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307227 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-05Revert "Revert "Revert "Replace trivial use of external rc.exe by writing ↵Eric Beckmann
our own .res file.""" This reverts commit 5fecbbbe5049665d86834cf69d8f75db4f392308. The initial revert was done in order to prevent ongoing errors on chromium bots such as CrWinClangLLD. However, this was done haphazardly and I didn't realize there were test and compilation failures, so this revert was reverted. Now that those have been fixed, we can revert the revert of the revert. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307226 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-05Revert "Revert "Replace trivial use of external rc.exe by writing our own ↵Eric Beckmann
.res file."" This reverts commit 8c8dce3b8f15d6ebaefc35ce88f15a85c8cdbd6e. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307191 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-05Revert "Revert "Switch external cvtres.exe for llvm's own resource library.""Eric Beckmann
This reverts commit 165e578e47f1cd38191120aad23a9020fb5476dd. Forgot to run tests on this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307190 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-05Revert "Switch external cvtres.exe for llvm's own resource library."Eric Beckmann
This reverts commit 600d52c278e123dd08bee24c1f00932b55add8de. This patch still seems to break CrWinClangLLD, reverting until I can find root problem. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307189 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-05Revert "Replace trivial use of external rc.exe by writing our own .res file."Eric Beckmann
This patch still seems to break CrWinClangLLD, reverting this once more until I can discover root problem. This reverts commit 3dbbc8ce43be50ffde2b1c655c6d3a25796fe78b. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307188 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-01Revert "Revert "Replace trivial use of external rc.exe by writing our own ↵Eric Beckmann
.res file."" Summary: This reverts commit 51931072a7c9a52540baf76fc30ef391d2529a2f. This revert was originally done because the integrations of the new WindowsResource library into LLD was causing error in chromium, due to bugs in how resource sections were handled. These bugs were fixed, meaning that the features may be reintegrated. Subscribers: hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D34922 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306941 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-30Fix bug in symbol generation for resource COFFEric Beckmann
Symbols in the resource COFF file should be for .rsrc$02, where the actual resource data is, not .rsrc$01, which contains the directory tree. Differential Revision: https://reviews.llvm.org/D34832 Patch by Joe Ranieri. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306853 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-29Revert "Replace trivial use of external rc.exe by writing our own .res file."Eric Beckmann
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306618 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-26Replace trivial use of external rc.exe by writing our own .res file.Eric Beckmann
This patch removes the dependency on the external rc.exe tool by writing a simple .res file using our own library. In this patch I also added an explicit definition for the .res file magic. Furthermore, I added a unittest for embeded manifests and fixed a bug exposed by the test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306311 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-19Have writeCOFFWriter return Expected<unique_ptr>.Eric Beckmann
Summary: Have writeCOFFWriter return Expected<unique_ptr> instead of requiring being passed an uninitialized unique_ptr. Reviewers: zturner, ruiu Subscribers: hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D34307 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305730 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-16Clean up some things in the WindowsResource changes.Eric Beckmann
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305596 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-16[Object] Remove redundant std::move.Benjamin Kramer
Found by -Wpessimizing-move. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305595 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-16Switch external cvtres.exe for llvm's own resource library.Eric Beckmann
In this patch, I flip the switch in DriverUtils from using the external cvtres.exe tool to using the Windows Resource library in llvm. I also fixed a bug where .rsrc sections were marked as discardable memory and therefore were placed in the wrong order in the final PE. Furthermore, I modified WindowsResource to write the coff directly to a memory buffer instead of to file, also had it use the machine types already declared in COFF.h instead creating my own enum. Finally, I flipped the switch to allow all unit tests that had previously run only on windows due to a winres dependency to run cross-platform. Reviewers: zturner, ruiu Subscribers: llvm-commits, hiraditya Differential Revision: https://reviews.llvm.org/D34265 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305592 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-13Use reference to iterate through string table instead of copying.Eric Beckmann
Summary: just a quick patch Subscribers: ruiu, llvm-commits, hiraditya Differential Revision: https://reviews.llvm.org/D34171 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305324 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-13Fix a bug introduced in r305092 on big-endian systems.Eric Beckmann
Summary: We were writing the length of the string based on system-endianness, and not universally little-endian. This fixes that. Reviewers: zturner Subscribers: hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D34159 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305322 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-13Fix alignment complaint.Eric Beckmann
Summary: Apparently we need to write using a void* pointer on some architectures, or else alignment error is caused. Subscribers: hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D34166 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305320 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-13Improve error messages in order to help with fixing a big-endian bug.Eric Beckmann
Summary: Added output to stderr so that we can actually see what is happening when the test fails on big endian. Reviewers: zturner Subscribers: llvm-commits, hiraditya Differential Revision: https://reviews.llvm.org/D34155 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305314 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-13Revert "Revert "Fix alignment bug in COFF emission.""Eric Beckmann
This revert was done so that my other patch to add test framework could land separately. Now the revert can be reverted and this patch can reland. This reverts commit 18b3c75b2b0d32601fb60a06b9672c33d6f0dff9. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305259 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-13Update the test framework for llvm-cvtres to be more comprehensive.Eric Beckmann
Summary: Added test cases for multiple machine types, file merging, multiple languages, and more resource types. Also fixed new bugs these tests exposed. Subscribers: javed.absar, llvm-commits, hiraditya Differential Revision: https://reviews.llvm.org/D34047 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305258 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-13Revert "Fix alignment bug in COFF emission."Eric Beckmann
I accidentally combined this patch with one for adding more tests, they should be separated. This reverts commit 3da218a523be78df32e637d3446ecf97c9ea0465. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305257 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-13Fix alignment bug in COFF emission.Eric Beckmann
Summary: Fix alignment issue in D34020, by aligning all sections to 8 bytes. Reviewers: zturner Subscribers: hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D34072 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305256 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-10Fix a ubsan failure introduced by r305092Vedant Kumar
lib/Object/WindowsResource.cpp:578:3: runtime error: store to misaligned address 0x7fa09aedebbe for type 'unsigned int', which requires 4 byte alignment 0x7fa09aedebbe: note: pointer points here 00 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ^ git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305149 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-09Implement COFF emission for parsed Windows Resource ( .res) files.Eric Beckmann
Summary: Add the WindowsResourceCOFFWriter class for producing the final COFF after all parsing is done. Reviewers: hiraditya!, zturner, ruiu Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D34020 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305092 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-07Move Object format code to lib/BinaryFormat.Zachary Turner
This creates a new library called BinaryFormat that has all of the headers from llvm/Support containing structure and layout definitions for various types of binary formats like dwarf, coff, elf, etc as well as the code for identifying a file from its magic. Differential Revision: https://reviews.llvm.org/D33843 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304864 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-30Fix bug on Big-Endian system, due to reference to vector out of scope.Eric Beckmann
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304255 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-30This patch should fix various clang warnings and a use of to_stringEric Beckmann
which isn't support before c++11. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304252 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-30[Object] Remove unused field + constructor.Benjamin Kramer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304233 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-30[Object] Fix pessimizing move.Benjamin Kramer
Returning the Error by value triggers copy elision, the move is more expensive. Clang rightfully warns about it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304232 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-30Adding parsing ability for .res file.Eric Beckmann
Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D33566 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304225 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-20Fix -Wunneeded-internal-declaration by removing constant arrays only used in ↵David Blaikie
sizeof expressions, in favor of constants containing the size directly git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303483 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-20Add functionality to cvtres to parse all entries in res file.Eric Beckmann
Summary: Added the new modules in the Object/ folder. Updated the llvm-cvtres interface as well, and added additional tests. Subscribers: llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D33180 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303480 91177308-0d34-0410-b5e6-96231b3b80d8