summaryrefslogtreecommitdiff
path: root/include/llvm/Object/WindowsResource.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/Object/WindowsResource.h')
-rw-r--r--include/llvm/Object/WindowsResource.h57
1 files changed, 41 insertions, 16 deletions
diff --git a/include/llvm/Object/WindowsResource.h b/include/llvm/Object/WindowsResource.h
index 4839013c8228c..3d32409fd4aca 100644
--- a/include/llvm/Object/WindowsResource.h
+++ b/include/llvm/Object/WindowsResource.h
@@ -30,7 +30,6 @@
#define LLVM_INCLUDE_LLVM_OBJECT_RESFILE_H
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/STLExtras.h"
#include "llvm/BinaryFormat/COFF.h"
#include "llvm/Object/Binary.h"
#include "llvm/Object/Error.h"
@@ -44,14 +43,47 @@
#include <map>
namespace llvm {
-
-class FileOutputBuffer;
-
namespace object {
class WindowsResource;
-enum class Machine { UNKNOWN, ARM, X64, X86 };
+const size_t WIN_RES_MAGIC_SIZE = 16;
+const size_t WIN_RES_NULL_ENTRY_SIZE = 16;
+const uint32_t WIN_RES_HEADER_ALIGNMENT = 4;
+const uint32_t WIN_RES_DATA_ALIGNMENT = 4;
+const uint16_t WIN_RES_PURE_MOVEABLE = 0x0030;
+
+struct WinResHeaderPrefix {
+ support::ulittle32_t DataSize;
+ support::ulittle32_t HeaderSize;
+};
+
+// Type and Name may each either be an integer ID or a string. This struct is
+// only used in the case where they are both IDs.
+struct WinResIDs {
+ uint16_t TypeFlag;
+ support::ulittle16_t TypeID;
+ uint16_t NameFlag;
+ support::ulittle16_t NameID;
+
+ void setType(uint16_t ID) {
+ TypeFlag = 0xffff;
+ TypeID = ID;
+ }
+
+ void setName(uint16_t ID) {
+ NameFlag = 0xffff;
+ NameID = ID;
+ }
+};
+
+struct WinResHeaderSuffix {
+ support::ulittle32_t DataVersion;
+ support::ulittle16_t MemoryFlags;
+ support::ulittle16_t Language;
+ support::ulittle32_t Version;
+ support::ulittle32_t Characteristics;
+};
class ResourceEntryRef {
public:
@@ -76,14 +108,6 @@ private:
Error loadNext();
- struct HeaderSuffix {
- support::ulittle32_t DataVersion;
- support::ulittle16_t MemoryFlags;
- support::ulittle16_t Language;
- support::ulittle32_t Version;
- support::ulittle32_t Characteristics;
- };
-
BinaryStreamReader Reader;
bool IsStringType;
ArrayRef<UTF16> Type;
@@ -91,7 +115,7 @@ private:
bool IsStringName;
ArrayRef<UTF16> Name;
uint16_t NameID;
- const HeaderSuffix *Suffix = nullptr;
+ const WinResHeaderSuffix *Suffix = nullptr;
ArrayRef<uint8_t> Data;
const WindowsResource *OwningRes = nullptr;
};
@@ -185,8 +209,9 @@ private:
std::vector<std::vector<UTF16>> StringTable;
};
-Error writeWindowsResourceCOFF(StringRef OutputFile, Machine MachineType,
- const WindowsResourceParser &Parser);
+Expected<std::unique_ptr<MemoryBuffer>>
+writeWindowsResourceCOFF(llvm::COFF::MachineTypes MachineType,
+ const WindowsResourceParser &Parser);
} // namespace object
} // namespace llvm