blob: 5da40d04ce0ec4999eb669034b2ccf169d7c9d1d [file] [log] [blame]
Rui Ueyama411c63602015-05-28 19:09:30 +00001//===- InputFiles.cpp -----------------------------------------------------===//
2//
3// The LLVM Linker
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "Chunks.h"
Rui Ueyama8fd9fb92015-06-01 02:58:15 +000011#include "Error.h"
Rui Ueyama411c63602015-05-28 19:09:30 +000012#include "InputFiles.h"
Rui Ueyama67fcd1a02015-08-05 19:51:28 +000013#include "Symbols.h"
Rui Ueyama411c63602015-05-28 19:09:30 +000014#include "llvm/ADT/STLExtras.h"
Peter Collingbourne60c16162015-06-01 20:10:10 +000015#include "llvm/LTO/LTOModule.h"
Rui Ueyama411c63602015-05-28 19:09:30 +000016#include "llvm/Object/COFF.h"
17#include "llvm/Support/COFF.h"
18#include "llvm/Support/Debug.h"
19#include "llvm/Support/Endian.h"
20#include "llvm/Support/raw_ostream.h"
21
Rui Ueyama1c79ce92015-07-08 20:22:50 +000022using namespace llvm::COFF;
Rui Ueyama411c63602015-05-28 19:09:30 +000023using namespace llvm::object;
24using namespace llvm::support::endian;
Rui Ueyama411c63602015-05-28 19:09:30 +000025using llvm::RoundUpToAlignment;
Rui Ueyamaea533cd2015-07-09 19:54:13 +000026using llvm::Triple;
Rui Ueyamacd3f99b2015-07-24 23:51:14 +000027using llvm::support::ulittle32_t;
Rui Ueyama411c63602015-05-28 19:09:30 +000028using llvm::sys::fs::file_magic;
Rui Ueyamaea533cd2015-07-09 19:54:13 +000029using llvm::sys::fs::identify_magic;
Rui Ueyama411c63602015-05-28 19:09:30 +000030
31namespace lld {
32namespace coff {
33
Rui Ueyama65813ed2015-07-02 20:33:48 +000034int InputFile::NextIndex = 0;
35
Rui Ueyama411c63602015-05-28 19:09:30 +000036// Returns the last element of a path, which is supposed to be a filename.
37static StringRef getBasename(StringRef Path) {
Rui Ueyamaea63a282015-06-18 20:16:26 +000038 size_t Pos = Path.find_last_of("\\/");
Rui Ueyama411c63602015-05-28 19:09:30 +000039 if (Pos == StringRef::npos)
40 return Path;
41 return Path.substr(Pos + 1);
42}
43
44// Returns a string in the format of "foo.obj" or "foo.obj(bar.lib)".
45std::string InputFile::getShortName() {
46 if (ParentName == "")
47 return getName().lower();
48 std::string Res = (getBasename(ParentName) + "(" +
49 getBasename(getName()) + ")").str();
50 return StringRef(Res).lower();
51}
52
Rafael Espindolab835ae82015-08-06 14:58:50 +000053void ArchiveFile::parse() {
Rui Ueyamad7c2f582015-05-31 21:04:56 +000054 // Parse a MemoryBufferRef as an archive file.
55 auto ArchiveOrErr = Archive::create(MB);
Rafael Espindolab835ae82015-08-06 14:58:50 +000056 error(ArchiveOrErr, "Failed to parse static library");
Rui Ueyama411c63602015-05-28 19:09:30 +000057 File = std::move(ArchiveOrErr.get());
58
59 // Allocate a buffer for Lazy objects.
Rui Ueyama605e1f62015-06-26 23:51:45 +000060 size_t NumSyms = File->getNumberOfSymbols();
61 size_t BufSize = NumSyms * sizeof(Lazy);
Rui Ueyama411c63602015-05-28 19:09:30 +000062 Lazy *Buf = (Lazy *)Alloc.Allocate(BufSize, llvm::alignOf<Lazy>());
Rui Ueyama8d3010a2015-06-30 19:35:21 +000063 LazySymbols.reserve(NumSyms);
Rui Ueyama411c63602015-05-28 19:09:30 +000064
65 // Read the symbol table to construct Lazy objects.
66 uint32_t I = 0;
67 for (const Archive::Symbol &Sym : File->symbols()) {
Rui Ueyama29792a82015-06-19 21:25:44 +000068 auto *B = new (&Buf[I++]) Lazy(this, Sym);
Rui Ueyama411c63602015-05-28 19:09:30 +000069 // Skip special symbol exists in import library files.
Rui Ueyama29792a82015-06-19 21:25:44 +000070 if (B->getName() != "__NULL_IMPORT_DESCRIPTOR")
Rui Ueyama8d3010a2015-06-30 19:35:21 +000071 LazySymbols.push_back(B);
Rui Ueyama411c63602015-05-28 19:09:30 +000072 }
Rui Ueyama159fb4cd2015-07-14 03:09:59 +000073
74 // Seen is a map from member files to boolean values. Initially
75 // all members are mapped to false, which indicates all these files
76 // are not read yet.
77 for (const Archive::Child &Child : File->children())
Rafael Espindola9f141ef2015-07-14 21:28:07 +000078 Seen[Child.getChildOffset()].clear();
Rui Ueyama411c63602015-05-28 19:09:30 +000079}
80
81// Returns a buffer pointing to a member file containing a given symbol.
Rui Ueyamaadcde532015-07-05 22:50:00 +000082// This function is thread-safe.
Rafael Espindolab835ae82015-08-06 14:58:50 +000083MemoryBufferRef ArchiveFile::getMember(const Archive::Symbol *Sym) {
Rui Ueyama411c63602015-05-28 19:09:30 +000084 auto ItOrErr = Sym->getMember();
Rafael Espindolab835ae82015-08-06 14:58:50 +000085 error(ItOrErr,
86 Twine("Could not get the member for symbol ") + Sym->getName());
Rui Ueyama411c63602015-05-28 19:09:30 +000087 Archive::child_iterator It = ItOrErr.get();
88
89 // Return an empty buffer if we have already returned the same buffer.
Rafael Espindola9f141ef2015-07-14 21:28:07 +000090 if (Seen[It->getChildOffset()].test_and_set())
Rui Ueyama411c63602015-05-28 19:09:30 +000091 return MemoryBufferRef();
Rafael Espindolab835ae82015-08-06 14:58:50 +000092 ErrorOr<MemoryBufferRef> Ret = It->getMemoryBufferRef();
93 error(Ret, Twine("Could not get the buffer for the member defining symbol ") +
94 Sym->getName());
95 return *Ret;
Rui Ueyama411c63602015-05-28 19:09:30 +000096}
97
Rafael Espindolab835ae82015-08-06 14:58:50 +000098void ObjectFile::parse() {
Rui Ueyama411c63602015-05-28 19:09:30 +000099 // Parse a memory buffer as a COFF file.
Rui Ueyamad7c2f582015-05-31 21:04:56 +0000100 auto BinOrErr = createBinary(MB);
Rafael Espindolab835ae82015-08-06 14:58:50 +0000101 error(BinOrErr, "Failed to parse object file");
Rui Ueyama411c63602015-05-28 19:09:30 +0000102 std::unique_ptr<Binary> Bin = std::move(BinOrErr.get());
103
104 if (auto *Obj = dyn_cast<COFFObjectFile>(Bin.get())) {
105 Bin.release();
106 COFFObj.reset(Obj);
107 } else {
Rafael Espindolab835ae82015-08-06 14:58:50 +0000108 error(Twine(getName()) + " is not a COFF file.");
Rui Ueyama411c63602015-05-28 19:09:30 +0000109 }
110
111 // Read section and symbol tables.
Rafael Espindolab835ae82015-08-06 14:58:50 +0000112 initializeChunks();
113 initializeSymbols();
114 initializeSEH();
Rui Ueyama411c63602015-05-28 19:09:30 +0000115}
116
Rafael Espindolab835ae82015-08-06 14:58:50 +0000117void ObjectFile::initializeChunks() {
Rui Ueyama411c63602015-05-28 19:09:30 +0000118 uint32_t NumSections = COFFObj->getNumberOfSections();
119 Chunks.reserve(NumSections);
120 SparseChunks.resize(NumSections + 1);
121 for (uint32_t I = 1; I < NumSections + 1; ++I) {
122 const coff_section *Sec;
123 StringRef Name;
Rafael Espindolab835ae82015-08-06 14:58:50 +0000124 std::error_code EC = COFFObj->getSection(I, Sec);
125 error(EC, Twine("getSection failed: ") + Name);
126 EC = COFFObj->getSectionName(Sec, Name);
127 error(EC, Twine("getSectionName failed: ") + Name);
Rui Ueyamacd3f99b2015-07-24 23:51:14 +0000128 if (Name == ".sxdata") {
129 SXData = Sec;
130 continue;
131 }
Rui Ueyama411c63602015-05-28 19:09:30 +0000132 if (Name == ".drectve") {
133 ArrayRef<uint8_t> Data;
134 COFFObj->getSectionContents(Sec, Data);
Rui Ueyama0569ecf2015-07-04 03:27:46 +0000135 Directives = std::string((const char *)Data.data(), Data.size());
Rui Ueyama411c63602015-05-28 19:09:30 +0000136 continue;
137 }
Rui Ueyama2832ce92015-07-28 01:06:58 +0000138 // Skip non-DWARF debug info. MSVC linker converts the sections into
139 // a PDB file, but we don't support that.
140 if (Name == ".debug" || Name.startswith(".debug$"))
141 continue;
David Majnemer2c345a32015-07-08 16:37:50 +0000142 // We want to preserve DWARF debug sections only when /debug is on.
143 if (!Config->Debug && Name.startswith(".debug"))
Rui Ueyama411c63602015-05-28 19:09:30 +0000144 continue;
145 if (Sec->Characteristics & llvm::COFF::IMAGE_SCN_LNK_REMOVE)
146 continue;
Peter Collingbournebd3a29d2015-06-24 00:12:36 +0000147 auto *C = new (Alloc) SectionChunk(this, Sec);
Rui Ueyama411c63602015-05-28 19:09:30 +0000148 Chunks.push_back(C);
149 SparseChunks[I] = C;
150 }
Rui Ueyama411c63602015-05-28 19:09:30 +0000151}
152
Rafael Espindolab835ae82015-08-06 14:58:50 +0000153void ObjectFile::initializeSymbols() {
Rui Ueyama411c63602015-05-28 19:09:30 +0000154 uint32_t NumSymbols = COFFObj->getNumberOfSymbols();
155 SymbolBodies.reserve(NumSymbols);
156 SparseSymbolBodies.resize(NumSymbols);
Rui Ueyama7171c822015-08-17 23:35:43 +0000157 llvm::SmallVector<Undefined *, 8> WeakAliases;
Rui Ueyama411c63602015-05-28 19:09:30 +0000158 int32_t LastSectionNumber = 0;
159 for (uint32_t I = 0; I < NumSymbols; ++I) {
160 // Get a COFFSymbolRef object.
161 auto SymOrErr = COFFObj->getSymbol(I);
Rafael Espindolab835ae82015-08-06 14:58:50 +0000162 error(SymOrErr, Twine("broken object file: ") + getName());
163
Rui Ueyama411c63602015-05-28 19:09:30 +0000164 COFFSymbolRef Sym = SymOrErr.get();
165
Rui Ueyama411c63602015-05-28 19:09:30 +0000166 const void *AuxP = nullptr;
167 if (Sym.getNumberOfAuxSymbols())
168 AuxP = COFFObj->getSymbol(I + 1)->getRawPtr();
169 bool IsFirst = (LastSectionNumber != Sym.getSectionNumber());
170
Rui Ueyamadae16612015-06-29 22:16:21 +0000171 SymbolBody *Body = nullptr;
172 if (Sym.isUndefined()) {
173 Body = createUndefined(Sym);
174 } else if (Sym.isWeakExternal()) {
175 Body = createWeakExternal(Sym, AuxP);
Rui Ueyama7171c822015-08-17 23:35:43 +0000176 WeakAliases.push_back((Undefined *)Body);
Rui Ueyamadae16612015-06-29 22:16:21 +0000177 } else {
178 Body = createDefined(Sym, AuxP, IsFirst);
179 }
Rui Ueyama411c63602015-05-28 19:09:30 +0000180 if (Body) {
181 SymbolBodies.push_back(Body);
182 SparseSymbolBodies[I] = Body;
183 }
184 I += Sym.getNumberOfAuxSymbols();
185 LastSectionNumber = Sym.getSectionNumber();
186 }
Rui Ueyama7171c822015-08-17 23:35:43 +0000187 for (Undefined *U : WeakAliases)
188 U->WeakAlias = SparseSymbolBodies[(uintptr_t)U->WeakAlias];
Rui Ueyama411c63602015-05-28 19:09:30 +0000189}
190
Rui Ueyamadae16612015-06-29 22:16:21 +0000191Undefined *ObjectFile::createUndefined(COFFSymbolRef Sym) {
Rui Ueyama57fe78d2015-06-08 19:43:59 +0000192 StringRef Name;
Rui Ueyamadae16612015-06-29 22:16:21 +0000193 COFFObj->getSymbolName(Sym, Name);
194 return new (Alloc) Undefined(Name);
195}
196
197Undefined *ObjectFile::createWeakExternal(COFFSymbolRef Sym, const void *AuxP) {
198 StringRef Name;
199 COFFObj->getSymbolName(Sym, Name);
Rui Ueyama48975962015-07-01 22:32:23 +0000200 auto *U = new (Alloc) Undefined(Name);
Rui Ueyamadae16612015-06-29 22:16:21 +0000201 auto *Aux = (const coff_aux_weak_external *)AuxP;
Rui Ueyama7171c822015-08-17 23:35:43 +0000202 U->WeakAlias = (Undefined *)(uintptr_t)Aux->TagIndex;
Rui Ueyama48975962015-07-01 22:32:23 +0000203 return U;
Rui Ueyamadae16612015-06-29 22:16:21 +0000204}
205
206Defined *ObjectFile::createDefined(COFFSymbolRef Sym, const void *AuxP,
207 bool IsFirst) {
208 StringRef Name;
Rui Ueyama411c63602015-05-28 19:09:30 +0000209 if (Sym.isCommon()) {
Rui Ueyamafc510f42015-06-25 19:10:58 +0000210 auto *C = new (Alloc) CommonChunk(Sym);
Rui Ueyama411c63602015-05-28 19:09:30 +0000211 Chunks.push_back(C);
Rui Ueyama68633f12015-06-25 23:22:00 +0000212 return new (Alloc) DefinedCommon(this, Sym, C);
Rui Ueyama411c63602015-05-28 19:09:30 +0000213 }
Rui Ueyama57fe78d2015-06-08 19:43:59 +0000214 if (Sym.isAbsolute()) {
215 COFFObj->getSymbolName(Sym, Name);
216 // Skip special symbols.
Rui Ueyamacd3f99b2015-07-24 23:51:14 +0000217 if (Name == "@comp.id")
Rui Ueyama57fe78d2015-06-08 19:43:59 +0000218 return nullptr;
Rui Ueyamacd3f99b2015-07-24 23:51:14 +0000219 // COFF spec 5.10.1. The .sxdata section.
220 if (Name == "@feat.00") {
221 if (Sym.getValue() & 1)
222 SEHCompat = true;
223 return nullptr;
224 }
Rui Ueyamaccde19d2015-06-26 03:09:23 +0000225 return new (Alloc) DefinedAbsolute(Name, Sym);
Rui Ueyama57fe78d2015-06-08 19:43:59 +0000226 }
Peter Collingbournec7b685d2015-06-24 00:05:50 +0000227 if (Sym.getSectionNumber() == llvm::COFF::IMAGE_SYM_DEBUG)
228 return nullptr;
Chandler Carruthee5bf522015-06-29 21:32:37 +0000229
230 // Nothing else to do without a section chunk.
231 auto *SC = cast_or_null<SectionChunk>(SparseChunks[Sym.getSectionNumber()]);
232 if (!SC)
233 return nullptr;
234
Rui Ueyama80141a42015-06-08 05:00:42 +0000235 // Handle associative sections
Rui Ueyama411c63602015-05-28 19:09:30 +0000236 if (IsFirst && AuxP) {
Chandler Carruthee5bf522015-06-29 21:32:37 +0000237 auto *Aux = reinterpret_cast<const coff_aux_section_definition *>(AuxP);
238 if (Aux->Selection == IMAGE_COMDAT_SELECT_ASSOCIATIVE)
239 if (auto *ParentSC = cast_or_null<SectionChunk>(
240 SparseChunks[Aux->getNumber(Sym.isBigObj())]))
241 ParentSC->addAssociative(SC);
Rui Ueyama411c63602015-05-28 19:09:30 +0000242 }
Chandler Carruthee5bf522015-06-29 21:32:37 +0000243
244 auto *B = new (Alloc) DefinedRegular(this, Sym, SC);
245 if (SC->isCOMDAT() && Sym.getValue() == 0 && !AuxP)
246 SC->setSymbol(B);
247
248 return B;
Rui Ueyama411c63602015-05-28 19:09:30 +0000249}
250
Rafael Espindolab835ae82015-08-06 14:58:50 +0000251void ObjectFile::initializeSEH() {
Rui Ueyamacd3f99b2015-07-24 23:51:14 +0000252 if (!SEHCompat || !SXData)
Rafael Espindolab835ae82015-08-06 14:58:50 +0000253 return;
Rui Ueyamacd3f99b2015-07-24 23:51:14 +0000254 ArrayRef<uint8_t> A;
255 COFFObj->getSectionContents(SXData, A);
Rafael Espindolab835ae82015-08-06 14:58:50 +0000256 if (A.size() % 4 != 0)
257 error(".sxdata must be an array of symbol table indices");
Rui Ueyamacd3f99b2015-07-24 23:51:14 +0000258 auto *I = reinterpret_cast<const ulittle32_t *>(A.data());
259 auto *E = reinterpret_cast<const ulittle32_t *>(A.data() + A.size());
260 for (; I != E; ++I)
261 SEHandlers.insert(SparseSymbolBodies[*I]);
Rui Ueyamacd3f99b2015-07-24 23:51:14 +0000262}
263
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000264MachineTypes ObjectFile::getMachineType() {
265 if (COFFObj)
266 return static_cast<MachineTypes>(COFFObj->getMachine());
267 return IMAGE_FILE_MACHINE_UNKNOWN;
268}
269
Rui Ueyamaa841bb02015-07-09 20:22:41 +0000270StringRef ltrim1(StringRef S, const char *Chars) {
271 if (!S.empty() && strchr(Chars, S[0]))
272 return S.substr(1);
273 return S;
274}
275
Rafael Espindolab835ae82015-08-06 14:58:50 +0000276void ImportFile::parse() {
Rui Ueyamad7c2f582015-05-31 21:04:56 +0000277 const char *Buf = MB.getBufferStart();
278 const char *End = MB.getBufferEnd();
Rui Ueyama411c63602015-05-28 19:09:30 +0000279 const auto *Hdr = reinterpret_cast<const coff_import_header *>(Buf);
280
281 // Check if the total size is valid.
Rafael Espindolab835ae82015-08-06 14:58:50 +0000282 if ((size_t)(End - Buf) != (sizeof(*Hdr) + Hdr->SizeOfData))
283 error("broken import library");
Rui Ueyama411c63602015-05-28 19:09:30 +0000284
285 // Read names and create an __imp_ symbol.
286 StringRef Name = StringAlloc.save(StringRef(Buf + sizeof(*Hdr)));
287 StringRef ImpName = StringAlloc.save(Twine("__imp_") + Name);
Rui Ueyamad1570882015-08-17 08:30:31 +0000288 const char *NameStart = Buf + sizeof(coff_import_header) + Name.size() + 1;
289 DLLName = StringRef(NameStart).lower();
Rui Ueyama1c79ce92015-07-08 20:22:50 +0000290 StringRef ExtName;
291 switch (Hdr->getNameType()) {
292 case IMPORT_ORDINAL:
293 ExtName = "";
294 break;
295 case IMPORT_NAME:
296 ExtName = Name;
297 break;
298 case IMPORT_NAME_NOPREFIX:
Rui Ueyamaa841bb02015-07-09 20:22:41 +0000299 ExtName = ltrim1(Name, "?@_");
Rui Ueyama1c79ce92015-07-08 20:22:50 +0000300 break;
301 case IMPORT_NAME_UNDECORATE:
Rui Ueyamaa841bb02015-07-09 20:22:41 +0000302 ExtName = ltrim1(Name, "?@_");
Rui Ueyama1c79ce92015-07-08 20:22:50 +0000303 ExtName = ExtName.substr(0, ExtName.find('@'));
304 break;
305 }
Rui Ueyamae73e4182015-08-17 07:27:45 +0000306 ImpSym = new (Alloc) DefinedImportData(DLLName, ImpName, ExtName, Hdr);
Rui Ueyama411c63602015-05-28 19:09:30 +0000307 SymbolBodies.push_back(ImpSym);
308
309 // If type is function, we need to create a thunk which jump to an
310 // address pointed by the __imp_ symbol. (This allows you to call
311 // DLL functions just like regular non-DLL functions.)
Rui Ueyamae73e4182015-08-17 07:27:45 +0000312 if (Hdr->getType() != llvm::COFF::IMPORT_CODE)
313 return;
314 ThunkSym = new (Alloc) DefinedImportThunk(Name, ImpSym, Hdr->Machine);
315 SymbolBodies.push_back(ThunkSym);
Rui Ueyama411c63602015-05-28 19:09:30 +0000316}
317
Rafael Espindolab835ae82015-08-06 14:58:50 +0000318void BitcodeFile::parse() {
Peter Collingbourne60c16162015-06-01 20:10:10 +0000319 std::string Err;
Rui Ueyama81b030c2015-06-01 21:19:43 +0000320 M.reset(LTOModule::createFromBuffer(MB.getBufferStart(),
321 MB.getBufferSize(),
322 llvm::TargetOptions(), Err));
Rafael Espindolab835ae82015-08-06 14:58:50 +0000323 if (!Err.empty())
324 error(Err);
Peter Collingbourne60c16162015-06-01 20:10:10 +0000325
Rafael Espindolaf0461ba2015-08-13 01:07:08 +0000326 llvm::StringSaver Saver(Alloc);
Peter Collingbourne60c16162015-06-01 20:10:10 +0000327 for (unsigned I = 0, E = M->getSymbolCount(); I != E; ++I) {
Peter Collingbournedf637ea2015-06-08 20:21:28 +0000328 lto_symbol_attributes Attrs = M->getSymbolAttributes(I);
329 if ((Attrs & LTO_SYMBOL_SCOPE_MASK) == LTO_SYMBOL_SCOPE_INTERNAL)
330 continue;
331
Rui Ueyama223fe1b2015-06-18 20:29:41 +0000332 StringRef SymName = Saver.save(M->getSymbolName(I));
Peter Collingbournedf637ea2015-06-08 20:21:28 +0000333 int SymbolDef = Attrs & LTO_SYMBOL_DEFINITION_MASK;
334 if (SymbolDef == LTO_SYMBOL_DEFINITION_UNDEFINED) {
Peter Collingbourne60c16162015-06-01 20:10:10 +0000335 SymbolBodies.push_back(new (Alloc) Undefined(SymName));
336 } else {
Peter Collingbourne2612a322015-07-04 05:28:41 +0000337 bool Replaceable =
338 (SymbolDef == LTO_SYMBOL_DEFINITION_TENTATIVE || // common
339 (Attrs & LTO_SYMBOL_COMDAT) || // comdat
340 (SymbolDef == LTO_SYMBOL_DEFINITION_WEAK && // weak external
341 (Attrs & LTO_SYMBOL_ALIAS)));
Peter Collingbournef7b27d12015-06-30 00:47:52 +0000342 SymbolBodies.push_back(new (Alloc) DefinedBitcode(this, SymName,
343 Replaceable));
Peter Collingbourne60c16162015-06-01 20:10:10 +0000344 }
345 }
Peter Collingbourneace2f092015-06-06 02:00:45 +0000346
Peter Collingbourne79cfd432015-06-29 23:26:28 +0000347 Directives = M->getLinkerOpts();
Peter Collingbourne60c16162015-06-01 20:10:10 +0000348}
Rui Ueyama81b030c2015-06-01 21:19:43 +0000349
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000350MachineTypes BitcodeFile::getMachineType() {
351 if (!M)
352 return IMAGE_FILE_MACHINE_UNKNOWN;
353 switch (Triple(M->getTargetTriple()).getArch()) {
354 case Triple::x86_64:
Rui Ueyama5e706b32015-07-25 21:54:50 +0000355 return AMD64;
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000356 case Triple::x86:
Rui Ueyama5e706b32015-07-25 21:54:50 +0000357 return I386;
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000358 case Triple::arm:
Rui Ueyama5e706b32015-07-25 21:54:50 +0000359 return ARMNT;
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000360 default:
361 return IMAGE_FILE_MACHINE_UNKNOWN;
362 }
363}
364
Rui Ueyama411c63602015-05-28 19:09:30 +0000365} // namespace coff
366} // namespace lld