blob: 4cacf0ff552a0f691ab0eae66f1c164fba37dde7 [file] [log] [blame]
Rui Ueyama411c63602015-05-28 19:09:30 +00001//===- Driver.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 "Config.h"
11#include "Driver.h"
Rui Ueyama562daa82015-06-18 21:50:38 +000012#include "Error.h"
Rui Ueyama411c63602015-05-28 19:09:30 +000013#include "InputFiles.h"
Rui Ueyama411c63602015-05-28 19:09:30 +000014#include "SymbolTable.h"
Rui Ueyama685c41c2015-08-05 23:43:53 +000015#include "Symbols.h"
Rui Ueyama411c63602015-05-28 19:09:30 +000016#include "Writer.h"
Rui Ueyama411c63602015-05-28 19:09:30 +000017#include "llvm/ADT/Optional.h"
Peter Collingbournebd1cb792015-06-09 21:52:48 +000018#include "llvm/LibDriver/LibDriver.h"
Rui Ueyama411c63602015-05-28 19:09:30 +000019#include "llvm/Option/Arg.h"
20#include "llvm/Option/ArgList.h"
21#include "llvm/Option/Option.h"
Rui Ueyama411c63602015-05-28 19:09:30 +000022#include "llvm/Support/Debug.h"
Rui Ueyama411c63602015-05-28 19:09:30 +000023#include "llvm/Support/Path.h"
Rui Ueyama54b71da2015-05-31 19:17:12 +000024#include "llvm/Support/Process.h"
Peter Collingbourne60c16162015-06-01 20:10:10 +000025#include "llvm/Support/TargetSelect.h"
Rui Ueyama411c63602015-05-28 19:09:30 +000026#include "llvm/Support/raw_ostream.h"
Rui Ueyama2bf6a122015-06-14 21:50:50 +000027#include <algorithm>
Rui Ueyama411c63602015-05-28 19:09:30 +000028#include <memory>
29
30using namespace llvm;
Rui Ueyama84936e02015-07-07 23:39:18 +000031using namespace llvm::COFF;
Rui Ueyama54b71da2015-05-31 19:17:12 +000032using llvm::sys::Process;
Peter Collingbournebaf5f872015-06-26 19:20:09 +000033using llvm::sys::fs::OpenFlags;
Rui Ueyama711cd2d2015-05-31 21:17:10 +000034using llvm::sys::fs::file_magic;
35using llvm::sys::fs::identify_magic;
Rui Ueyama411c63602015-05-28 19:09:30 +000036
Rui Ueyama3500f662015-05-28 20:30:06 +000037namespace lld {
38namespace coff {
Rui Ueyama411c63602015-05-28 19:09:30 +000039
Rui Ueyama3500f662015-05-28 20:30:06 +000040Configuration *Config;
Rui Ueyamaa9cbbf82015-05-31 19:17:09 +000041LinkerDriver *Driver;
42
Rafael Espindolab835ae82015-08-06 14:58:50 +000043void link(llvm::ArrayRef<const char *> Args) {
Rui Ueyama570752c2015-08-18 09:13:25 +000044 Configuration C;
45 LinkerDriver D;
46 Config = &C;
47 Driver = &D;
David Blaikieb2b1c7c2015-06-21 06:32:10 +000048 return Driver->link(Args);
Rui Ueyamaa9cbbf82015-05-31 19:17:09 +000049}
Rui Ueyama411c63602015-05-28 19:09:30 +000050
Rui Ueyamaad660982015-06-07 00:20:32 +000051// Drop directory components and replace extension with ".exe".
52static std::string getOutputPath(StringRef Path) {
53 auto P = Path.find_last_of("\\/");
54 StringRef S = (P == StringRef::npos) ? Path : Path.substr(P + 1);
55 return (S.substr(0, S.rfind('.')) + ".exe").str();
Rui Ueyama411c63602015-05-28 19:09:30 +000056}
57
Rui Ueyamad7c2f582015-05-31 21:04:56 +000058// Opens a file. Path has to be resolved already.
59// Newly created memory buffers are owned by this driver.
Rafael Espindolab835ae82015-08-06 14:58:50 +000060MemoryBufferRef LinkerDriver::openFile(StringRef Path) {
Rui Ueyamad7c2f582015-05-31 21:04:56 +000061 auto MBOrErr = MemoryBuffer::getFile(Path);
Rafael Espindolab835ae82015-08-06 14:58:50 +000062 error(MBOrErr, Twine("Could not open ") + Path);
63 std::unique_ptr<MemoryBuffer> &MB = *MBOrErr;
Rui Ueyamad7c2f582015-05-31 21:04:56 +000064 MemoryBufferRef MBRef = MB->getMemBufferRef();
65 OwningMBs.push_back(std::move(MB)); // take ownership
Rui Ueyama2bf6a122015-06-14 21:50:50 +000066 return MBRef;
67}
Rui Ueyama711cd2d2015-05-31 21:17:10 +000068
Rui Ueyama2bf6a122015-06-14 21:50:50 +000069static std::unique_ptr<InputFile> createFile(MemoryBufferRef MB) {
Rui Ueyama711cd2d2015-05-31 21:17:10 +000070 // File type is detected by contents, not by file extension.
Rui Ueyama2bf6a122015-06-14 21:50:50 +000071 file_magic Magic = identify_magic(MB.getBuffer());
Rui Ueyama711cd2d2015-05-31 21:17:10 +000072 if (Magic == file_magic::archive)
Rui Ueyama2bf6a122015-06-14 21:50:50 +000073 return std::unique_ptr<InputFile>(new ArchiveFile(MB));
Peter Collingbourne60c16162015-06-01 20:10:10 +000074 if (Magic == file_magic::bitcode)
Rui Ueyama2bf6a122015-06-14 21:50:50 +000075 return std::unique_ptr<InputFile>(new BitcodeFile(MB));
Rui Ueyamaad660982015-06-07 00:20:32 +000076 if (Config->OutputFile == "")
Rui Ueyama2bf6a122015-06-14 21:50:50 +000077 Config->OutputFile = getOutputPath(MB.getBufferIdentifier());
78 return std::unique_ptr<InputFile>(new ObjectFile(MB));
Rui Ueyama411c63602015-05-28 19:09:30 +000079}
80
Rui Ueyamaf10a3202015-08-31 08:43:21 +000081static bool isDecorated(StringRef Sym) {
82 return Sym.startswith("_") || Sym.startswith("@") || Sym.startswith("?");
83}
84
Rui Ueyama411c63602015-05-28 19:09:30 +000085// Parses .drectve section contents and returns a list of files
86// specified by /defaultlib.
Rafael Espindolab835ae82015-08-06 14:58:50 +000087void LinkerDriver::parseDirectives(StringRef S) {
88 llvm::opt::InputArgList Args = Parser.parse(S);
Rui Ueyama411c63602015-05-28 19:09:30 +000089
David Blaikie6521ed92015-06-22 22:06:52 +000090 for (auto *Arg : Args) {
Rui Ueyama562daa82015-06-18 21:50:38 +000091 switch (Arg->getOption().getID()) {
92 case OPT_alternatename:
Rafael Espindolab835ae82015-08-06 14:58:50 +000093 parseAlternateName(Arg->getValue());
Rui Ueyama562daa82015-06-18 21:50:38 +000094 break;
95 case OPT_defaultlib:
96 if (Optional<StringRef> Path = findLib(Arg->getValue())) {
Rafael Espindolab835ae82015-08-06 14:58:50 +000097 MemoryBufferRef MB = openFile(*Path);
98 Symtab.addFile(createFile(MB));
Rui Ueyama562daa82015-06-18 21:50:38 +000099 }
100 break;
101 case OPT_export: {
Rafael Espindolab835ae82015-08-06 14:58:50 +0000102 Export E = parseExport(Arg->getValue());
Rui Ueyamaf10a3202015-08-31 08:43:21 +0000103 E.Directives = true;
Rafael Espindolab835ae82015-08-06 14:58:50 +0000104 Config->Exports.push_back(E);
Rui Ueyama562daa82015-06-18 21:50:38 +0000105 break;
106 }
107 case OPT_failifmismatch:
Rafael Espindolab835ae82015-08-06 14:58:50 +0000108 checkFailIfMismatch(Arg->getValue());
Rui Ueyama562daa82015-06-18 21:50:38 +0000109 break;
Rui Ueyama08d5e182015-06-18 23:20:11 +0000110 case OPT_incl:
Rui Ueyama32f8e1c2015-06-26 03:44:00 +0000111 addUndefined(Arg->getValue());
Rui Ueyama08d5e182015-06-18 23:20:11 +0000112 break;
Rui Ueyamace86c992015-06-18 23:22:39 +0000113 case OPT_merge:
Rafael Espindolab835ae82015-08-06 14:58:50 +0000114 parseMerge(Arg->getValue());
Rui Ueyamace86c992015-06-18 23:22:39 +0000115 break;
116 case OPT_nodefaultlib:
117 Config->NoDefaultLibs.insert(doFindLib(Arg->getValue()));
118 break;
Rui Ueyama3c4737d2015-08-11 16:46:08 +0000119 case OPT_editandcontinue:
Rui Ueyama31e66e32015-09-03 16:20:47 +0000120 case OPT_guardsym:
Rui Ueyama432383172015-07-29 21:01:15 +0000121 case OPT_throwingnew:
Rui Ueyama46682632015-07-29 20:29:15 +0000122 break;
Rui Ueyama562daa82015-06-18 21:50:38 +0000123 default:
Rafael Espindolab835ae82015-08-06 14:58:50 +0000124 error(Twine(Arg->getSpelling()) + " is not allowed in .drectve");
Rui Ueyamad7c2f582015-05-31 21:04:56 +0000125 }
126 }
Rui Ueyama411c63602015-05-28 19:09:30 +0000127}
128
Rui Ueyama54b71da2015-05-31 19:17:12 +0000129// Find file from search paths. You can omit ".obj", this function takes
130// care of that. Note that the returned path is not guaranteed to exist.
Rui Ueyamad21b00b2015-05-31 19:17:14 +0000131StringRef LinkerDriver::doFindFile(StringRef Filename) {
Rui Ueyama54b71da2015-05-31 19:17:12 +0000132 bool hasPathSep = (Filename.find_first_of("/\\") != StringRef::npos);
133 if (hasPathSep)
134 return Filename;
135 bool hasExt = (Filename.find('.') != StringRef::npos);
136 for (StringRef Dir : SearchPaths) {
137 SmallString<128> Path = Dir;
138 llvm::sys::path::append(Path, Filename);
139 if (llvm::sys::fs::exists(Path.str()))
140 return Alloc.save(Path.str());
141 if (!hasExt) {
142 Path.append(".obj");
143 if (llvm::sys::fs::exists(Path.str()))
144 return Alloc.save(Path.str());
145 }
146 }
147 return Filename;
148}
149
Rui Ueyamad21b00b2015-05-31 19:17:14 +0000150// Resolves a file path. This never returns the same path
151// (in that case, it returns None).
152Optional<StringRef> LinkerDriver::findFile(StringRef Filename) {
153 StringRef Path = doFindFile(Filename);
154 bool Seen = !VisitedFiles.insert(Path.lower()).second;
155 if (Seen)
156 return None;
157 return Path;
Rui Ueyama54b71da2015-05-31 19:17:12 +0000158}
159
Rui Ueyamad21b00b2015-05-31 19:17:14 +0000160// Find library file from search path.
161StringRef LinkerDriver::doFindLib(StringRef Filename) {
162 // Add ".lib" to Filename if that has no file extension.
Rui Ueyama54b71da2015-05-31 19:17:12 +0000163 bool hasExt = (Filename.find('.') != StringRef::npos);
Rui Ueyamad21b00b2015-05-31 19:17:14 +0000164 if (!hasExt)
165 Filename = Alloc.save(Filename + ".lib");
166 return doFindFile(Filename);
167}
168
169// Resolves a library path. /nodefaultlib options are taken into
170// consideration. This never returns the same path (in that case,
171// it returns None).
172Optional<StringRef> LinkerDriver::findLib(StringRef Filename) {
173 if (Config->NoDefaultLibAll)
174 return None;
175 StringRef Path = doFindLib(Filename);
176 if (Config->NoDefaultLibs.count(Path))
177 return None;
178 bool Seen = !VisitedFiles.insert(Path.lower()).second;
179 if (Seen)
180 return None;
181 return Path;
Rui Ueyama54b71da2015-05-31 19:17:12 +0000182}
183
184// Parses LIB environment which contains a list of search paths.
Rui Ueyamaf00df0a2015-06-19 22:39:48 +0000185void LinkerDriver::addLibSearchPaths() {
Rui Ueyama54b71da2015-05-31 19:17:12 +0000186 Optional<std::string> EnvOpt = Process::GetEnv("LIB");
187 if (!EnvOpt.hasValue())
Rui Ueyamaf00df0a2015-06-19 22:39:48 +0000188 return;
Rui Ueyama54b71da2015-05-31 19:17:12 +0000189 StringRef Env = Alloc.save(*EnvOpt);
190 while (!Env.empty()) {
191 StringRef Path;
192 std::tie(Path, Env) = Env.split(';');
Rui Ueyamaf00df0a2015-06-19 22:39:48 +0000193 SearchPaths.push_back(Path);
Rui Ueyama54b71da2015-05-31 19:17:12 +0000194 }
Rui Ueyama54b71da2015-05-31 19:17:12 +0000195}
196
Rui Ueyama6bf638e2015-07-02 00:04:14 +0000197Undefined *LinkerDriver::addUndefined(StringRef Name) {
198 Undefined *U = Symtab.addUndefined(Name);
Rui Ueyama18f8d2c2015-07-02 00:21:08 +0000199 Config->GCRoot.insert(U);
Rui Ueyama6bf638e2015-07-02 00:04:14 +0000200 return U;
Rui Ueyama32f8e1c2015-06-26 03:44:00 +0000201}
202
Rui Ueyama7c3e23f2015-07-09 01:25:49 +0000203// Symbol names are mangled by appending "_" prefix on x86.
204StringRef LinkerDriver::mangle(StringRef Sym) {
Rui Ueyama5e706b32015-07-25 21:54:50 +0000205 assert(Config->Machine != IMAGE_FILE_MACHINE_UNKNOWN);
206 if (Config->Machine == I386)
Rui Ueyama7c3e23f2015-07-09 01:25:49 +0000207 return Alloc.save("_" + Sym);
208 return Sym;
209}
210
Rui Ueyama45044f42015-06-29 01:03:53 +0000211// Windows specific -- find default entry point name.
212StringRef LinkerDriver::findDefaultEntry() {
213 // User-defined main functions and their corresponding entry points.
214 static const char *Entries[][2] = {
215 {"main", "mainCRTStartup"},
216 {"wmain", "wmainCRTStartup"},
217 {"WinMain", "WinMainCRTStartup"},
218 {"wWinMain", "wWinMainCRTStartup"},
219 };
220 for (auto E : Entries) {
Rui Ueyamaa50387f2015-07-14 02:58:13 +0000221 StringRef Entry = Symtab.findMangle(mangle(E[0]));
222 if (!Entry.empty() && !isa<Undefined>(Symtab.find(Entry)->Body))
Rui Ueyama7c3e23f2015-07-09 01:25:49 +0000223 return mangle(E[1]);
Rui Ueyama45044f42015-06-29 01:03:53 +0000224 }
225 return "";
226}
227
228WindowsSubsystem LinkerDriver::inferSubsystem() {
Rui Ueyama97dff9e2015-06-17 00:16:33 +0000229 if (Config->DLL)
230 return IMAGE_SUBSYSTEM_WINDOWS_GUI;
Rui Ueyama611add22015-08-08 00:23:37 +0000231 if (Symtab.findUnderscore("main") || Symtab.findUnderscore("wmain"))
Rui Ueyama45044f42015-06-29 01:03:53 +0000232 return IMAGE_SUBSYSTEM_WINDOWS_CUI;
Rui Ueyama611add22015-08-08 00:23:37 +0000233 if (Symtab.findUnderscore("WinMain") || Symtab.findUnderscore("wWinMain"))
Rui Ueyama45044f42015-06-29 01:03:53 +0000234 return IMAGE_SUBSYSTEM_WINDOWS_GUI;
235 return IMAGE_SUBSYSTEM_UNKNOWN;
Rui Ueyama97dff9e2015-06-17 00:16:33 +0000236}
237
Rui Ueyama5c437cd2015-07-25 21:42:33 +0000238static uint64_t getDefaultImageBase() {
239 if (Config->is64())
240 return Config->DLL ? 0x180000000 : 0x140000000;
241 return Config->DLL ? 0x10000000 : 0x400000;
242}
243
Rafael Espindolab835ae82015-08-06 14:58:50 +0000244void LinkerDriver::link(llvm::ArrayRef<const char *> ArgsArr) {
Rui Ueyama27e470a2015-08-09 20:45:17 +0000245 // If the first command line argument is "/lib", link.exe acts like lib.exe.
246 // We call our own implementation of lib.exe that understands bitcode files.
247 if (ArgsArr.size() > 1 && StringRef(ArgsArr[1]).equals_lower("/lib")) {
248 if (llvm::libDriverMain(ArgsArr.slice(1)) != 0)
249 error("lib failed");
250 return;
251 }
252
Peter Collingbourne60c16162015-06-01 20:10:10 +0000253 // Needed for LTO.
254 llvm::InitializeAllTargetInfos();
255 llvm::InitializeAllTargets();
256 llvm::InitializeAllTargetMCs();
257 llvm::InitializeAllAsmParsers();
258 llvm::InitializeAllAsmPrinters();
259 llvm::InitializeAllDisassemblers();
260
Rui Ueyama411c63602015-05-28 19:09:30 +0000261 // Parse command line options.
Rafael Espindolab835ae82015-08-06 14:58:50 +0000262 llvm::opt::InputArgList Args = Parser.parseLINK(ArgsArr.slice(1));
Rui Ueyama411c63602015-05-28 19:09:30 +0000263
Rui Ueyama5c726432015-05-29 16:11:52 +0000264 // Handle /help
David Blaikie6521ed92015-06-22 22:06:52 +0000265 if (Args.hasArg(OPT_help)) {
David Blaikieb2b1c7c2015-06-21 06:32:10 +0000266 printHelp(ArgsArr[0]);
Rafael Espindolab835ae82015-08-06 14:58:50 +0000267 return;
Rui Ueyama5c726432015-05-29 16:11:52 +0000268 }
269
Rafael Espindolab835ae82015-08-06 14:58:50 +0000270 if (Args.filtered_begin(OPT_INPUT) == Args.filtered_end())
271 error("no input files.");
Rui Ueyama3d3e6fb2015-05-29 16:06:00 +0000272
Rui Ueyamaf00df0a2015-06-19 22:39:48 +0000273 // Construct search path list.
274 SearchPaths.push_back("");
David Blaikie6521ed92015-06-22 22:06:52 +0000275 for (auto *Arg : Args.filtered(OPT_libpath))
Rui Ueyamaf00df0a2015-06-19 22:39:48 +0000276 SearchPaths.push_back(Arg->getValue());
277 addLibSearchPaths();
278
Rui Ueyamaad660982015-06-07 00:20:32 +0000279 // Handle /out
David Blaikie6521ed92015-06-22 22:06:52 +0000280 if (auto *Arg = Args.getLastArg(OPT_out))
Rui Ueyamaad660982015-06-07 00:20:32 +0000281 Config->OutputFile = Arg->getValue();
282
Rui Ueyama3d3e6fb2015-05-29 16:06:00 +0000283 // Handle /verbose
David Blaikie6521ed92015-06-22 22:06:52 +0000284 if (Args.hasArg(OPT_verbose))
Rui Ueyama411c63602015-05-28 19:09:30 +0000285 Config->Verbose = true;
Rui Ueyama3d3e6fb2015-05-29 16:06:00 +0000286
Rui Ueyama95925fd2015-06-28 19:35:15 +0000287 // Handle /force or /force:unresolved
288 if (Args.hasArg(OPT_force) || Args.hasArg(OPT_force_unresolved))
289 Config->Force = true;
290
Rui Ueyama6600eb12015-07-04 23:37:32 +0000291 // Handle /debug
292 if (Args.hasArg(OPT_debug))
293 Config->Debug = true;
294
Rui Ueyamaa8b60452015-06-28 19:56:30 +0000295 // Handle /noentry
296 if (Args.hasArg(OPT_noentry)) {
Rafael Espindolab835ae82015-08-06 14:58:50 +0000297 if (!Args.hasArg(OPT_dll))
298 error("/noentry must be specified with /dll");
Rui Ueyamaa8b60452015-06-28 19:56:30 +0000299 Config->NoEntry = true;
300 }
301
Rui Ueyama97dff9e2015-06-17 00:16:33 +0000302 // Handle /dll
David Blaikie6521ed92015-06-22 22:06:52 +0000303 if (Args.hasArg(OPT_dll)) {
Rui Ueyama97dff9e2015-06-17 00:16:33 +0000304 Config->DLL = true;
Rui Ueyama24c5fd02015-06-18 00:12:42 +0000305 Config->ManifestID = 2;
306 }
Rui Ueyama97dff9e2015-06-17 00:16:33 +0000307
Rui Ueyama588e8322015-06-15 01:23:58 +0000308 // Handle /fixed
David Blaikie6521ed92015-06-22 22:06:52 +0000309 if (Args.hasArg(OPT_fixed)) {
Rafael Espindolab835ae82015-08-06 14:58:50 +0000310 if (Args.hasArg(OPT_dynamicbase))
311 error("/fixed must not be specified with /dynamicbase");
Rui Ueyama588e8322015-06-15 01:23:58 +0000312 Config->Relocatable = false;
Rui Ueyama6592ff82015-06-16 23:13:00 +0000313 Config->DynamicBase = false;
314 }
Rui Ueyama588e8322015-06-15 01:23:58 +0000315
Rui Ueyama3d3e6fb2015-05-29 16:06:00 +0000316 // Handle /machine
Rafael Espindolab835ae82015-08-06 14:58:50 +0000317 if (auto *Arg = Args.getLastArg(OPT_machine))
318 Config->Machine = getMachineType(Arg->getValue());
Rui Ueyama3d3e6fb2015-05-29 16:06:00 +0000319
Rui Ueyamad21b00b2015-05-31 19:17:14 +0000320 // Handle /nodefaultlib:<filename>
David Blaikie6521ed92015-06-22 22:06:52 +0000321 for (auto *Arg : Args.filtered(OPT_nodefaultlib))
Rui Ueyamad21b00b2015-05-31 19:17:14 +0000322 Config->NoDefaultLibs.insert(doFindLib(Arg->getValue()));
323
324 // Handle /nodefaultlib
David Blaikie6521ed92015-06-22 22:06:52 +0000325 if (Args.hasArg(OPT_nodefaultlib_all))
Rui Ueyamad21b00b2015-05-31 19:17:14 +0000326 Config->NoDefaultLibAll = true;
327
Rui Ueyama804a8b62015-05-29 16:18:15 +0000328 // Handle /base
Rafael Espindolab835ae82015-08-06 14:58:50 +0000329 if (auto *Arg = Args.getLastArg(OPT_base))
330 parseNumbers(Arg->getValue(), &Config->ImageBase);
Rui Ueyamab41b7e52015-05-29 16:21:11 +0000331
332 // Handle /stack
Rafael Espindolab835ae82015-08-06 14:58:50 +0000333 if (auto *Arg = Args.getLastArg(OPT_stack))
334 parseNumbers(Arg->getValue(), &Config->StackReserve, &Config->StackCommit);
Rui Ueyama804a8b62015-05-29 16:18:15 +0000335
Rui Ueyamac377e9a2015-05-29 16:23:40 +0000336 // Handle /heap
Rafael Espindolab835ae82015-08-06 14:58:50 +0000337 if (auto *Arg = Args.getLastArg(OPT_heap))
338 parseNumbers(Arg->getValue(), &Config->HeapReserve, &Config->HeapCommit);
Rui Ueyamac377e9a2015-05-29 16:23:40 +0000339
Rui Ueyamab9dcdb52015-05-29 16:28:29 +0000340 // Handle /version
Rafael Espindolab835ae82015-08-06 14:58:50 +0000341 if (auto *Arg = Args.getLastArg(OPT_version))
342 parseVersion(Arg->getValue(), &Config->MajorImageVersion,
343 &Config->MinorImageVersion);
Rui Ueyamab9dcdb52015-05-29 16:28:29 +0000344
Rui Ueyama15cc47e2015-05-29 16:34:31 +0000345 // Handle /subsystem
Rafael Espindolab835ae82015-08-06 14:58:50 +0000346 if (auto *Arg = Args.getLastArg(OPT_subsystem))
347 parseSubsystem(Arg->getValue(), &Config->Subsystem, &Config->MajorOSVersion,
348 &Config->MinorOSVersion);
Rui Ueyama15cc47e2015-05-29 16:34:31 +0000349
Rui Ueyama2edb35a2015-06-18 19:09:30 +0000350 // Handle /alternatename
David Blaikie6521ed92015-06-22 22:06:52 +0000351 for (auto *Arg : Args.filtered(OPT_alternatename))
Rafael Espindolab835ae82015-08-06 14:58:50 +0000352 parseAlternateName(Arg->getValue());
Rui Ueyama2edb35a2015-06-18 19:09:30 +0000353
Rui Ueyama08d5e182015-06-18 23:20:11 +0000354 // Handle /include
David Blaikie6521ed92015-06-22 22:06:52 +0000355 for (auto *Arg : Args.filtered(OPT_incl))
Rui Ueyama32f8e1c2015-06-26 03:44:00 +0000356 addUndefined(Arg->getValue());
Rui Ueyama08d5e182015-06-18 23:20:11 +0000357
Rui Ueyamab95188c2015-06-18 20:27:09 +0000358 // Handle /implib
David Blaikie6521ed92015-06-22 22:06:52 +0000359 if (auto *Arg = Args.getLastArg(OPT_implib))
Rui Ueyamab95188c2015-06-18 20:27:09 +0000360 Config->Implib = Arg->getValue();
361
Rui Ueyamae2cbfea2015-06-07 03:17:42 +0000362 // Handle /opt
David Blaikie6521ed92015-06-22 22:06:52 +0000363 for (auto *Arg : Args.filtered(OPT_opt)) {
Rui Ueyama75656ee2015-10-19 19:40:43 +0000364 std::string Str = StringRef(Arg->getValue()).lower();
365 SmallVector<StringRef, 1> Vec;
366 StringRef(Str).split(Vec, ',');
367 for (StringRef S : Vec) {
368 if (S == "noref") {
369 Config->DoGC = false;
370 Config->DoICF = false;
371 continue;
372 }
373 if (S == "icf" || StringRef(S).startswith("icf=")) {
374 Config->DoICF = true;
375 continue;
376 }
377 if (S == "noicf") {
378 Config->DoICF = false;
379 continue;
380 }
381 if (StringRef(S).startswith("lldlto=")) {
382 StringRef OptLevel = StringRef(S).substr(7);
383 if (OptLevel.getAsInteger(10, Config->LTOOptLevel) ||
384 Config->LTOOptLevel > 3)
385 error("/opt:lldlto: invalid optimization level: " + OptLevel);
386 continue;
387 }
388 if (StringRef(S).startswith("lldltojobs=")) {
389 StringRef Jobs = StringRef(S).substr(11);
390 if (Jobs.getAsInteger(10, Config->LTOJobs) || Config->LTOJobs == 0)
391 error("/opt:lldltojobs: invalid job count: " + Jobs);
392 continue;
393 }
394 if (S != "ref" && S != "lbr" && S != "nolbr")
395 error(Twine("/opt: unknown option: ") + S);
Rui Ueyamae2cbfea2015-06-07 03:17:42 +0000396 }
Rui Ueyamae2cbfea2015-06-07 03:17:42 +0000397 }
398
Rui Ueyama8854d8a2015-06-04 19:21:24 +0000399 // Handle /failifmismatch
David Blaikie6521ed92015-06-22 22:06:52 +0000400 for (auto *Arg : Args.filtered(OPT_failifmismatch))
Rafael Espindolab835ae82015-08-06 14:58:50 +0000401 checkFailIfMismatch(Arg->getValue());
Rui Ueyama8854d8a2015-06-04 19:21:24 +0000402
Rui Ueyama6600eb12015-07-04 23:37:32 +0000403 // Handle /merge
404 for (auto *Arg : Args.filtered(OPT_merge))
Rafael Espindolab835ae82015-08-06 14:58:50 +0000405 parseMerge(Arg->getValue());
Rui Ueyama6600eb12015-07-04 23:37:32 +0000406
Rui Ueyama24c5fd02015-06-18 00:12:42 +0000407 // Handle /manifest
Rafael Espindolab835ae82015-08-06 14:58:50 +0000408 if (auto *Arg = Args.getLastArg(OPT_manifest_colon))
409 parseManifest(Arg->getValue());
Rui Ueyama24c5fd02015-06-18 00:12:42 +0000410
411 // Handle /manifestuac
Rafael Espindolab835ae82015-08-06 14:58:50 +0000412 if (auto *Arg = Args.getLastArg(OPT_manifestuac))
413 parseManifestUAC(Arg->getValue());
Rui Ueyama24c5fd02015-06-18 00:12:42 +0000414
415 // Handle /manifestdependency
David Blaikie6521ed92015-06-22 22:06:52 +0000416 if (auto *Arg = Args.getLastArg(OPT_manifestdependency))
Rui Ueyama24c5fd02015-06-18 00:12:42 +0000417 Config->ManifestDependency = Arg->getValue();
418
419 // Handle /manifestfile
David Blaikie6521ed92015-06-22 22:06:52 +0000420 if (auto *Arg = Args.getLastArg(OPT_manifestfile))
Rui Ueyama24c5fd02015-06-18 00:12:42 +0000421 Config->ManifestFile = Arg->getValue();
422
Rui Ueyama6592ff82015-06-16 23:13:00 +0000423 // Handle miscellaneous boolean flags.
David Blaikie6521ed92015-06-22 22:06:52 +0000424 if (Args.hasArg(OPT_allowbind_no))
425 Config->AllowBind = false;
426 if (Args.hasArg(OPT_allowisolation_no))
427 Config->AllowIsolation = false;
428 if (Args.hasArg(OPT_dynamicbase_no))
429 Config->DynamicBase = false;
David Blaikie6521ed92015-06-22 22:06:52 +0000430 if (Args.hasArg(OPT_nxcompat_no))
431 Config->NxCompat = false;
432 if (Args.hasArg(OPT_tsaware_no))
433 Config->TerminalServerAware = false;
Rui Ueyama96401732015-09-21 23:43:31 +0000434 if (Args.hasArg(OPT_nosymtab))
435 Config->WriteSymtab = false;
Rui Ueyama6592ff82015-06-16 23:13:00 +0000436
Rui Ueyamad21b00b2015-05-31 19:17:14 +0000437 // Create a list of input files. Files can be given as arguments
438 // for /defaultlib option.
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000439 std::vector<StringRef> Paths;
440 std::vector<MemoryBufferRef> MBs;
David Blaikie6521ed92015-06-22 22:06:52 +0000441 for (auto *Arg : Args.filtered(OPT_INPUT))
Rui Ueyamad21b00b2015-05-31 19:17:14 +0000442 if (Optional<StringRef> Path = findFile(Arg->getValue()))
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000443 Paths.push_back(*Path);
David Blaikie6521ed92015-06-22 22:06:52 +0000444 for (auto *Arg : Args.filtered(OPT_defaultlib))
Rui Ueyamad21b00b2015-05-31 19:17:14 +0000445 if (Optional<StringRef> Path = findLib(Arg->getValue()))
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000446 Paths.push_back(*Path);
Rafael Espindolab835ae82015-08-06 14:58:50 +0000447 for (StringRef Path : Paths)
448 MBs.push_back(openFile(Path));
Rui Ueyamad21b00b2015-05-31 19:17:14 +0000449
Rui Ueyama24c5fd02015-06-18 00:12:42 +0000450 // Windows specific -- Create a resource file containing a manifest file.
451 if (Config->Manifest == Configuration::Embed) {
Rafael Espindolab835ae82015-08-06 14:58:50 +0000452 std::unique_ptr<MemoryBuffer> MB = createManifestRes();
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000453 MBs.push_back(MB->getMemBufferRef());
Rui Ueyama24c5fd02015-06-18 00:12:42 +0000454 OwningMBs.push_back(std::move(MB)); // take ownership
455 }
456
Rui Ueyama2bf6a122015-06-14 21:50:50 +0000457 // Windows specific -- Input files can be Windows resource files (.res files).
458 // We invoke cvtres.exe to convert resource files to a regular COFF file
459 // then link the result file normally.
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000460 std::vector<MemoryBufferRef> Resources;
Rui Ueyama77731b42015-06-26 23:59:13 +0000461 auto NotResource = [](MemoryBufferRef MB) {
462 return identify_magic(MB.getBuffer()) != file_magic::windows_resource;
Rui Ueyama2bf6a122015-06-14 21:50:50 +0000463 };
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000464 auto It = std::stable_partition(MBs.begin(), MBs.end(), NotResource);
465 if (It != MBs.end()) {
466 Resources.insert(Resources.end(), It, MBs.end());
467 MBs.erase(It, MBs.end());
Rui Ueyama2bf6a122015-06-14 21:50:50 +0000468 }
469
Rui Ueyama85225b02015-07-02 03:15:15 +0000470 // Read all input files given via the command line. Note that step()
471 // doesn't read files that are specified by directive sections.
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000472 for (MemoryBufferRef MB : MBs)
Rui Ueyama0d2e9992015-06-23 23:56:39 +0000473 Symtab.addFile(createFile(MB));
Rafael Espindolab835ae82015-08-06 14:58:50 +0000474 Symtab.step();
Rui Ueyama5cff6852015-05-31 03:34:08 +0000475
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000476 // Determine machine type and check if all object files are
477 // for the same CPU type. Note that this needs to be done before
478 // any call to mangle().
479 for (std::unique_ptr<InputFile> &File : Symtab.getFiles()) {
480 MachineTypes MT = File->getMachineType();
481 if (MT == IMAGE_FILE_MACHINE_UNKNOWN)
482 continue;
Rui Ueyama5e706b32015-07-25 21:54:50 +0000483 if (Config->Machine == IMAGE_FILE_MACHINE_UNKNOWN) {
484 Config->Machine = MT;
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000485 continue;
486 }
Rafael Espindolab835ae82015-08-06 14:58:50 +0000487 if (Config->Machine != MT)
488 error(Twine(File->getShortName()) + ": machine type " + machineToStr(MT) +
489 " conflicts with " + machineToStr(Config->Machine));
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000490 }
Rui Ueyama5e706b32015-07-25 21:54:50 +0000491 if (Config->Machine == IMAGE_FILE_MACHINE_UNKNOWN) {
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000492 llvm::errs() << "warning: /machine is not specified. x64 is assumed.\n";
Rui Ueyama5e706b32015-07-25 21:54:50 +0000493 Config->Machine = AMD64;
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000494 }
495
496 // Windows specific -- Convert Windows resource files to a COFF file.
497 if (!Resources.empty()) {
Rafael Espindolab835ae82015-08-06 14:58:50 +0000498 std::unique_ptr<MemoryBuffer> MB = convertResToCOFF(Resources);
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000499 Symtab.addFile(createFile(MB->getMemBufferRef()));
500 OwningMBs.push_back(std::move(MB)); // take ownership
501 }
502
Rui Ueyama4d545342015-07-28 03:12:00 +0000503 // Handle /largeaddressaware
504 if (Config->is64() || Args.hasArg(OPT_largeaddressaware))
505 Config->LargeAddressAware = true;
506
Rui Ueyamad68e2112015-07-28 03:15:57 +0000507 // Handle /highentropyva
508 if (Config->is64() && !Args.hasArg(OPT_highentropyva_no))
509 Config->HighEntropyVA = true;
510
Rui Ueyamabbdec4f2015-07-09 22:51:41 +0000511 // Handle /entry and /dll
512 if (auto *Arg = Args.getLastArg(OPT_entry)) {
513 Config->Entry = addUndefined(mangle(Arg->getValue()));
514 } else if (Args.hasArg(OPT_dll) && !Config->NoEntry) {
Rui Ueyama5e706b32015-07-25 21:54:50 +0000515 StringRef S = (Config->Machine == I386) ? "__DllMainCRTStartup@12"
516 : "_DllMainCRTStartup";
Rui Ueyamabbdec4f2015-07-09 22:51:41 +0000517 Config->Entry = addUndefined(S);
518 } else if (!Config->NoEntry) {
519 // Windows specific -- If entry point name is not given, we need to
520 // infer that from user-defined entry name.
Rui Ueyama45044f42015-06-29 01:03:53 +0000521 StringRef S = findDefaultEntry();
Rafael Espindolab835ae82015-08-06 14:58:50 +0000522 if (S.empty())
523 error("entry point must be defined");
Rui Ueyama6bf638e2015-07-02 00:04:14 +0000524 Config->Entry = addUndefined(S);
Rui Ueyama85225b02015-07-02 03:15:15 +0000525 if (Config->Verbose)
526 llvm::outs() << "Entry name inferred: " << S << "\n";
Rui Ueyama45044f42015-06-29 01:03:53 +0000527 }
528
Rui Ueyamabbdec4f2015-07-09 22:51:41 +0000529 // Handle /export
530 for (auto *Arg : Args.filtered(OPT_export)) {
Rafael Espindolab835ae82015-08-06 14:58:50 +0000531 Export E = parseExport(Arg->getValue());
Rui Ueyamaf10a3202015-08-31 08:43:21 +0000532 if (Config->Machine == I386) {
533 if (!isDecorated(E.Name))
534 E.Name = Alloc.save("_" + E.Name);
535 if (!E.ExtName.empty() && !isDecorated(E.ExtName))
536 E.ExtName = Alloc.save("_" + E.ExtName);
537 }
Rafael Espindolab835ae82015-08-06 14:58:50 +0000538 Config->Exports.push_back(E);
Rui Ueyamabbdec4f2015-07-09 22:51:41 +0000539 }
540
541 // Handle /def
542 if (auto *Arg = Args.getLastArg(OPT_deffile)) {
Rafael Espindolab835ae82015-08-06 14:58:50 +0000543 MemoryBufferRef MB = openFile(Arg->getValue());
Rui Ueyamabbdec4f2015-07-09 22:51:41 +0000544 // parseModuleDefs mutates Config object.
Rafael Espindolab835ae82015-08-06 14:58:50 +0000545 parseModuleDefs(MB, &Alloc);
Rui Ueyamabbdec4f2015-07-09 22:51:41 +0000546 }
547
Rui Ueyama6d249082015-07-13 22:31:45 +0000548 // Handle /delayload
549 for (auto *Arg : Args.filtered(OPT_delayload)) {
550 Config->DelayLoads.insert(StringRef(Arg->getValue()).lower());
Rui Ueyama5e706b32015-07-25 21:54:50 +0000551 if (Config->Machine == I386) {
Rui Ueyama6d249082015-07-13 22:31:45 +0000552 Config->DelayLoadHelper = addUndefined("___delayLoadHelper2@8");
Rui Ueyama35ccb0f2015-07-25 00:20:06 +0000553 } else {
554 Config->DelayLoadHelper = addUndefined("__delayLoadHelper2");
Rui Ueyama6d249082015-07-13 22:31:45 +0000555 }
556 }
557
Rui Ueyama5c437cd2015-07-25 21:42:33 +0000558 // Set default image base if /base is not given.
559 if (Config->ImageBase == uint64_t(-1))
560 Config->ImageBase = getDefaultImageBase();
561
Rui Ueyama3cb895c2015-07-24 22:58:44 +0000562 Symtab.addRelative(mangle("__ImageBase"), 0);
Rui Ueyama5e706b32015-07-25 21:54:50 +0000563 if (Config->Machine == I386) {
Rui Ueyamacd3f99b2015-07-24 23:51:14 +0000564 Config->SEHTable = Symtab.addRelative("___safe_se_handler_table", 0);
565 Config->SEHCount = Symtab.addAbsolute("___safe_se_handler_count", 0);
566 }
Rui Ueyamabbdec4f2015-07-09 22:51:41 +0000567
Rui Ueyama107db552015-08-09 21:01:06 +0000568 // We do not support /guard:cf (control flow protection) yet.
569 // Define CFG symbols anyway so that we can link MSVC 2015 CRT.
570 Symtab.addAbsolute(mangle("__guard_fids_table"), 0);
571 Symtab.addAbsolute(mangle("__guard_fids_count"), 0);
572 Symtab.addAbsolute(mangle("__guard_flags"), 0x100);
573
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000574 // Read as much files as we can from directives sections.
Rafael Espindolab835ae82015-08-06 14:58:50 +0000575 Symtab.run();
Rui Ueyama85225b02015-07-02 03:15:15 +0000576
577 // Resolve auxiliary symbols until we get a convergence.
Rui Ueyama573bf7d2015-06-19 21:12:48 +0000578 // (Trying to resolve a symbol may trigger a Lazy symbol to load a new file.
579 // A new file may contain a directive section to add new command line options.
580 // That's why we have to repeat until converge.)
581 for (;;) {
Rui Ueyama6bf638e2015-07-02 00:04:14 +0000582 // Windows specific -- if entry point is not found,
583 // search for its mangled names.
584 if (Config->Entry)
585 Symtab.mangleMaybe(Config->Entry);
586
Rui Ueyama573bf7d2015-06-19 21:12:48 +0000587 // Windows specific -- Make sure we resolve all dllexported symbols.
Rui Ueyama6bf638e2015-07-02 00:04:14 +0000588 for (Export &E : Config->Exports) {
Rui Ueyama84425d72016-01-09 01:22:00 +0000589 if (!E.ForwardTo.empty())
590 continue;
Rui Ueyama6bf638e2015-07-02 00:04:14 +0000591 E.Sym = addUndefined(E.Name);
Rui Ueyamaf10a3202015-08-31 08:43:21 +0000592 if (!E.Directives)
593 Symtab.mangleMaybe(E.Sym);
Rui Ueyama6bf638e2015-07-02 00:04:14 +0000594 }
Rui Ueyama573bf7d2015-06-19 21:12:48 +0000595
596 // Add weak aliases. Weak aliases is a mechanism to give remaining
597 // undefined symbols final chance to be resolved successfully.
Rui Ueyama3d4c69c2015-07-02 02:38:59 +0000598 for (auto Pair : Config->AlternateNames) {
599 StringRef From = Pair.first;
600 StringRef To = Pair.second;
Rui Ueyama458d7442015-07-02 03:59:04 +0000601 Symbol *Sym = Symtab.find(From);
Rui Ueyama3d4c69c2015-07-02 02:38:59 +0000602 if (!Sym)
603 continue;
Rui Ueyama183f53f2015-07-06 17:45:22 +0000604 if (auto *U = dyn_cast<Undefined>(Sym->Body))
Rui Ueyama3d4c69c2015-07-02 02:38:59 +0000605 if (!U->WeakAlias)
606 U->WeakAlias = Symtab.addUndefined(To);
Rui Ueyama2edb35a2015-06-18 19:09:30 +0000607 }
Rui Ueyama573bf7d2015-06-19 21:12:48 +0000608
Rui Ueyamacd3f99b2015-07-24 23:51:14 +0000609 // Windows specific -- if __load_config_used can be resolved, resolve it.
Rui Ueyama8ebdc8c2015-08-07 22:43:53 +0000610 if (Symtab.findUnderscore("_load_config_used"))
611 addUndefined(mangle("_load_config_used"));
Rui Ueyamacd3f99b2015-07-24 23:51:14 +0000612
Rui Ueyama3d4c69c2015-07-02 02:38:59 +0000613 if (Symtab.queueEmpty())
614 break;
Rafael Espindolab835ae82015-08-06 14:58:50 +0000615 Symtab.run();
Rui Ueyama2edb35a2015-06-18 19:09:30 +0000616 }
617
Peter Collingbournedf5783b2015-08-28 22:16:09 +0000618 // Do LTO by compiling bitcode input files to a set of native COFF files then
619 // link those files.
620 Symtab.addCombinedLTOObjects();
Peter Collingbourne60c16162015-06-01 20:10:10 +0000621
Peter Collingbourne2612a322015-07-04 05:28:41 +0000622 // Make sure we have resolved all symbols.
Rafael Espindolab835ae82015-08-06 14:58:50 +0000623 Symtab.reportRemainingUndefines(/*Resolve=*/true);
Peter Collingbourne2612a322015-07-04 05:28:41 +0000624
Rui Ueyama3ee0fe42015-05-31 03:55:46 +0000625 // Windows specific -- if no /subsystem is given, we need to infer
626 // that from entry point name.
627 if (Config->Subsystem == IMAGE_SUBSYSTEM_UNKNOWN) {
Rui Ueyama97dff9e2015-06-17 00:16:33 +0000628 Config->Subsystem = inferSubsystem();
Rafael Espindolab835ae82015-08-06 14:58:50 +0000629 if (Config->Subsystem == IMAGE_SUBSYSTEM_UNKNOWN)
630 error("subsystem must be defined");
Rui Ueyama3ee0fe42015-05-31 03:55:46 +0000631 }
632
Rui Ueyamaff88d5a2015-07-29 20:25:40 +0000633 // Handle /safeseh.
Rui Ueyama13563d82015-09-15 00:33:11 +0000634 if (Args.hasArg(OPT_safeseh))
635 for (ObjectFile *File : Symtab.ObjectFiles)
636 if (!File->SEHCompat)
637 error("/safeseh: " + File->getName() + " is not compatible with SEH");
Rui Ueyamaff88d5a2015-07-29 20:25:40 +0000638
Rui Ueyama151d8622015-06-17 20:40:43 +0000639 // Windows specific -- when we are creating a .dll file, we also
640 // need to create a .lib file.
Rui Ueyama100ffac2015-09-01 09:15:58 +0000641 if (!Config->Exports.empty() || Config->DLL) {
Rafael Espindolab835ae82015-08-06 14:58:50 +0000642 fixupExports();
643 writeImportLibrary();
Rui Ueyama8765fba2015-07-15 22:21:08 +0000644 assignExportOrdinals();
645 }
Rui Ueyama97dff9e2015-06-17 00:16:33 +0000646
Rui Ueyama24c5fd02015-06-18 00:12:42 +0000647 // Windows specific -- Create a side-by-side manifest file.
648 if (Config->Manifest == Configuration::SideBySide)
Rafael Espindolab835ae82015-08-06 14:58:50 +0000649 createSideBySideManifest();
Rui Ueyama24c5fd02015-06-18 00:12:42 +0000650
Rui Ueyama0fc26d22015-06-29 14:27:12 +0000651 // Create a dummy PDB file to satisfy build sytem rules.
652 if (auto *Arg = Args.getLastArg(OPT_pdb))
Rui Ueyamae7378242015-12-04 23:11:05 +0000653 createPDB(Arg->getValue());
Rui Ueyama0fc26d22015-06-29 14:27:12 +0000654
Rui Ueyamaa5f0f752015-09-19 21:36:28 +0000655 // Identify unreferenced COMDAT sections.
656 if (Config->DoGC)
657 markLive(Symtab.getChunks());
658
659 // Identify identical COMDAT sections to merge them.
660 if (Config->DoICF)
661 doICF(Symtab.getChunks());
662
Rui Ueyama411c63602015-05-28 19:09:30 +0000663 // Write the result.
Rafael Espindolab835ae82015-08-06 14:58:50 +0000664 writeResult(&Symtab);
Peter Collingbournebe549552015-06-26 18:58:24 +0000665
Rui Ueyama016414f2015-06-28 20:07:08 +0000666 // Create a symbol map file containing symbol VAs and their names
667 // to help debugging.
Peter Collingbournebe549552015-06-26 18:58:24 +0000668 if (auto *Arg = Args.getLastArg(OPT_lldmap)) {
669 std::error_code EC;
Peter Collingbournebaf5f872015-06-26 19:20:09 +0000670 llvm::raw_fd_ostream Out(Arg->getValue(), EC, OpenFlags::F_Text);
Rafael Espindolab835ae82015-08-06 14:58:50 +0000671 error(EC, "Could not create the symbol map");
Peter Collingbournebe549552015-06-26 18:58:24 +0000672 Symtab.printMap(Out);
673 }
Rui Ueyamaa51ce712015-07-03 05:31:35 +0000674 // Call exit to avoid calling destructors.
675 exit(0);
Rui Ueyama411c63602015-05-28 19:09:30 +0000676}
677
Rui Ueyama411c63602015-05-28 19:09:30 +0000678} // namespace coff
679} // namespace lld