Skip to content

Commit 8ba2bb1

Browse files
authored
Merge pull request #194 from CodaFi/refine-binary-type
Remove minidump support
2 parents 2d18d9e + a8c2c0c commit 8ba2bb1

File tree

3 files changed

+40
-41
lines changed

3 files changed

+40
-41
lines changed

Sources/LLVM/ObjectFile.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ public class BinaryFile {
3232
case coffImportFile
3333
/// LLVM IR.
3434
case ir
35-
/// A Windows Minidump file.
36-
case minidump
3735
/// A Windows resource file.
3836
case winRes
3937
/// A COFF file.
@@ -63,7 +61,6 @@ public class BinaryFile {
6361
case LLVMBinaryTypeMachOUniversalBinary: self = .machOUniversalBinary
6462
case LLVMBinaryTypeCOFFImportFile: self = .coff
6563
case LLVMBinaryTypeIR: self = .ir
66-
case LLVMBinaryTypeMinidump: self = .minidump
6764
case LLVMBinaryTypeWinRes: self = .winRes
6865
case LLVMBinaryTypeCOFF: self = .coff
6966
case LLVMBinaryTypeELF32L: self = .elf32L

Sources/llvmshims/include/shim.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ typedef enum {
2525
LLVMBinaryTypeCOFFImportFile,
2626
// LLVM IR
2727
LLVMBinaryTypeIR,
28-
LLVMBinaryTypeMinidump,
2928

3029
// Windows resource (.res) file.
3130
LLVMBinaryTypeWinRes,

Sources/llvmshims/src/shim.cpp

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ extern "C" {
3030
LLVMBinaryTypeCOFFImportFile,
3131
// LLVM IR
3232
LLVMBinaryTypeIR,
33-
LLVMBinaryTypeMinidump,
3433

3534
// Windows resource (.res) file.
3635
LLVMBinaryTypeWinRes,
@@ -108,42 +107,46 @@ wrap(const symbol_iterator *SI) {
108107
}
109108

110109
LLVMBinaryType LLVMBinaryGetType(LLVMBinaryRef BR) {
111-
switch (unwrap(BR)->getType()) {
112-
case 0: //ID_Archive:
113-
return LLVMBinaryTypeArchive;
114-
case 1: //ID_MachOUniversalBinary:
115-
return LLVMBinaryTypeMachOUniversalBinary;
116-
case 2: //ID_COFFImportFile:
117-
return LLVMBinaryTypeCOFFImportFile;
118-
case 3: //ID_IR:
119-
return LLVMBinaryTypeIR;
120-
case 4: //ID_Minidump:
121-
return LLVMBinaryTypeMinidump;
122-
case 5: //ID_WinRes:
123-
return LLVMBinaryTypeWinRes;
124-
case 7: //ID_COFF:
125-
return LLVMBinaryTypeCOFF;
126-
case 8: //ID_ELF32L:
127-
return LLVMBinaryTypeELF32L;
128-
case 9: //ID_ELF32B:
129-
return LLVMBinaryTypeELF32B;
130-
case 10: //ID_ELF64L:
131-
return LLVMBinaryTypeELF64L;
132-
case 11: //ID_ELF64B:
133-
return LLVMBinaryTypeELF64B;
134-
case 12: //ID_MachO32L:
135-
return LLVMBinaryTypeMachO32L;
136-
case 13: //ID_MachO32B:
137-
return LLVMBinaryTypeMachO32B;
138-
case 14: //ID_MachO64L:
139-
return LLVMBinaryTypeMachO64L;
140-
case 15: //ID_MachO64B:
141-
return LLVMBinaryTypeMachO64B;
142-
case 16: //ID_Wasm:
143-
return LLVMBinaryTypeWasm;
144-
default:
145-
llvm_unreachable("Unknown binary kind!");
146-
}
110+
class BinaryTypeMapper : public Binary {
111+
public:
112+
static LLVMBinaryType mapBinaryTypeToLLVMBinaryType(unsigned Kind) {
113+
switch (Kind) {
114+
case ID_Archive:
115+
return LLVMBinaryTypeArchive;
116+
case ID_MachOUniversalBinary:
117+
return LLVMBinaryTypeMachOUniversalBinary;
118+
case ID_COFFImportFile:
119+
return LLVMBinaryTypeCOFFImportFile;
120+
case ID_IR:
121+
return LLVMBinaryTypeIR;
122+
case ID_WinRes:
123+
return LLVMBinaryTypeWinRes;
124+
case ID_COFF:
125+
return LLVMBinaryTypeCOFF;
126+
case ID_ELF32L:
127+
return LLVMBinaryTypeELF32L;
128+
case ID_ELF32B:
129+
return LLVMBinaryTypeELF32B;
130+
case ID_ELF64L:
131+
return LLVMBinaryTypeELF64L;
132+
case ID_ELF64B:
133+
return LLVMBinaryTypeELF64B;
134+
case ID_MachO32L:
135+
return LLVMBinaryTypeMachO32L;
136+
case ID_MachO32B:
137+
return LLVMBinaryTypeMachO32B;
138+
case ID_MachO64L:
139+
return LLVMBinaryTypeMachO64L;
140+
case ID_MachO64B:
141+
return LLVMBinaryTypeMachO64B;
142+
case ID_Wasm:
143+
return LLVMBinaryTypeWasm;
144+
default:
145+
llvm_unreachable("Unknown binary kind!");
146+
}
147+
}
148+
};
149+
return BinaryTypeMapper::mapBinaryTypeToLLVMBinaryType(unwrap(BR)->getType());
147150
}
148151

149152
LLVMBinaryRef LLVMCreateBinary(LLVMMemoryBufferRef MemBuf, LLVMContextRef Context, char **ErrorMessage) {

0 commit comments

Comments
 (0)