blob: 2056484311d0b3d27e20f449848cd4c047d0db68 [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
Rui Ueyama417553d2016-02-28 19:54:51 +000043bool 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;
Rui Ueyama417553d2016-02-28 19:54:51 +000048 Driver->link(Args);
49 return true;
Rui Ueyamaa9cbbf82015-05-31 19:17:09 +000050}
Rui Ueyama411c63602015-05-28 19:09:30 +000051
Rui Ueyamaad660982015-06-07 00:20:32 +000052// Drop directory components and replace extension with ".exe".
53static std::string getOutputPath(StringRef Path) {
54 auto P = Path.find_last_of("\\/");
55 StringRef S = (P == StringRef::npos) ? Path : Path.substr(P + 1);
56 return (S.substr(0, S.rfind('.')) + ".exe").str();
Rui Ueyama411c63602015-05-28 19:09:30 +000057}
58
Rui Ueyamad7c2f582015-05-31 21:04:56 +000059// Opens a file. Path has to be resolved already.
60// Newly created memory buffers are owned by this driver.
Rafael Espindolab835ae82015-08-06 14:58:50 +000061MemoryBufferRef LinkerDriver::openFile(StringRef Path) {
Rui Ueyamad7c2f582015-05-31 21:04:56 +000062 auto MBOrErr = MemoryBuffer::getFile(Path);
Rafael Espindolab835ae82015-08-06 14:58:50 +000063 error(MBOrErr, Twine("Could not open ") + Path);
64 std::unique_ptr<MemoryBuffer> &MB = *MBOrErr;
Rui Ueyamad7c2f582015-05-31 21:04:56 +000065 MemoryBufferRef MBRef = MB->getMemBufferRef();
66 OwningMBs.push_back(std::move(MB)); // take ownership
Rui Ueyama2bf6a122015-06-14 21:50:50 +000067 return MBRef;
68}
Rui Ueyama711cd2d2015-05-31 21:17:10 +000069
Rui Ueyama2bf6a122015-06-14 21:50:50 +000070static std::unique_ptr<InputFile> createFile(MemoryBufferRef MB) {
Rui Ueyama711cd2d2015-05-31 21:17:10 +000071 // File type is detected by contents, not by file extension.
Rui Ueyama2bf6a122015-06-14 21:50:50 +000072 file_magic Magic = identify_magic(MB.getBuffer());
Rui Ueyama711cd2d2015-05-31 21:17:10 +000073 if (Magic == file_magic::archive)
Rui Ueyama2bf6a122015-06-14 21:50:50 +000074 return std::unique_ptr<InputFile>(new ArchiveFile(MB));
Peter Collingbourne60c16162015-06-01 20:10:10 +000075 if (Magic == file_magic::bitcode)
Rui Ueyama2bf6a122015-06-14 21:50:50 +000076 return std::unique_ptr<InputFile>(new BitcodeFile(MB));
Rui Ueyamaad660982015-06-07 00:20:32 +000077 if (Config->OutputFile == "")
Rui Ueyama2bf6a122015-06-14 21:50:50 +000078 Config->OutputFile = getOutputPath(MB.getBufferIdentifier());
79 return std::unique_ptr<InputFile>(new ObjectFile(MB));
Rui Ueyama411c63602015-05-28 19:09:30 +000080}
81
Rui Ueyamaf10a3202015-08-31 08:43:21 +000082static bool isDecorated(StringRef Sym) {
83 return Sym.startswith("_") || Sym.startswith("@") || Sym.startswith("?");
84}
85
Rui Ueyama411c63602015-05-28 19:09:30 +000086// Parses .drectve section contents and returns a list of files
87// specified by /defaultlib.
Rafael Espindolab835ae82015-08-06 14:58:50 +000088void LinkerDriver::parseDirectives(StringRef S) {
89 llvm::opt::InputArgList Args = Parser.parse(S);
Rui Ueyama411c63602015-05-28 19:09:30 +000090
David Blaikie6521ed92015-06-22 22:06:52 +000091 for (auto *Arg : Args) {
Rui Ueyama562daa82015-06-18 21:50:38 +000092 switch (Arg->getOption().getID()) {
93 case OPT_alternatename:
Rafael Espindolab835ae82015-08-06 14:58:50 +000094 parseAlternateName(Arg->getValue());
Rui Ueyama562daa82015-06-18 21:50:38 +000095 break;
96 case OPT_defaultlib:
97 if (Optional<StringRef> Path = findLib(Arg->getValue())) {
Rafael Espindolab835ae82015-08-06 14:58:50 +000098 MemoryBufferRef MB = openFile(*Path);
99 Symtab.addFile(createFile(MB));
Rui Ueyama562daa82015-06-18 21:50:38 +0000100 }
101 break;
102 case OPT_export: {
Rafael Espindolab835ae82015-08-06 14:58:50 +0000103 Export E = parseExport(Arg->getValue());
Rui Ueyamaf10a3202015-08-31 08:43:21 +0000104 E.Directives = true;
Rafael Espindolab835ae82015-08-06 14:58:50 +0000105 Config->Exports.push_back(E);
Rui Ueyama562daa82015-06-18 21:50:38 +0000106 break;
107 }
108 case OPT_failifmismatch:
Rafael Espindolab835ae82015-08-06 14:58:50 +0000109 checkFailIfMismatch(Arg->getValue());
Rui Ueyama562daa82015-06-18 21:50:38 +0000110 break;
Rui Ueyama08d5e182015-06-18 23:20:11 +0000111 case OPT_incl:
Rui Ueyama32f8e1c2015-06-26 03:44:00 +0000112 addUndefined(Arg->getValue());
Rui Ueyama08d5e182015-06-18 23:20:11 +0000113 break;
Rui Ueyamace86c992015-06-18 23:22:39 +0000114 case OPT_merge:
Rafael Espindolab835ae82015-08-06 14:58:50 +0000115 parseMerge(Arg->getValue());
Rui Ueyamace86c992015-06-18 23:22:39 +0000116 break;
117 case OPT_nodefaultlib:
118 Config->NoDefaultLibs.insert(doFindLib(Arg->getValue()));
119 break;
Rui Ueyama3c4737d2015-08-11 16:46:08 +0000120 case OPT_editandcontinue:
Rui Ueyama31e66e32015-09-03 16:20:47 +0000121 case OPT_guardsym:
Rui Ueyama432383172015-07-29 21:01:15 +0000122 case OPT_throwingnew:
Rui Ueyama46682632015-07-29 20:29:15 +0000123 break;
Rui Ueyama562daa82015-06-18 21:50:38 +0000124 default:
Rafael Espindolab835ae82015-08-06 14:58:50 +0000125 error(Twine(Arg->getSpelling()) + " is not allowed in .drectve");
Rui Ueyamad7c2f582015-05-31 21:04:56 +0000126 }
127 }
Rui Ueyama411c63602015-05-28 19:09:30 +0000128}
129
Rui Ueyama54b71da2015-05-31 19:17:12 +0000130// Find file from search paths. You can omit ".obj", this function takes
131// care of that. Note that the returned path is not guaranteed to exist.
Rui Ueyamad21b00b2015-05-31 19:17:14 +0000132StringRef LinkerDriver::doFindFile(StringRef Filename) {
Rui Ueyama54b71da2015-05-31 19:17:12 +0000133 bool hasPathSep = (Filename.find_first_of("/\\") != StringRef::npos);
134 if (hasPathSep)
135 return Filename;
136 bool hasExt = (Filename.find('.') != StringRef::npos);
137 for (StringRef Dir : SearchPaths) {
138 SmallString<128> Path = Dir;
139 llvm::sys::path::append(Path, Filename);
140 if (llvm::sys::fs::exists(Path.str()))
141 return Alloc.save(Path.str());
142 if (!hasExt) {
143 Path.append(".obj");
144 if (llvm::sys::fs::exists(Path.str()))
145 return Alloc.save(Path.str());
146 }
147 }
148 return Filename;
149}
150
Rui Ueyamad21b00b2015-05-31 19:17:14 +0000151// Resolves a file path. This never returns the same path
152// (in that case, it returns None).
153Optional<StringRef> LinkerDriver::findFile(StringRef Filename) {
154 StringRef Path = doFindFile(Filename);
155 bool Seen = !VisitedFiles.insert(Path.lower()).second;
156 if (Seen)
157 return None;
158 return Path;
Rui Ueyama54b71da2015-05-31 19:17:12 +0000159}
160
Rui Ueyamad21b00b2015-05-31 19:17:14 +0000161// Find library file from search path.
162StringRef LinkerDriver::doFindLib(StringRef Filename) {
163 // Add ".lib" to Filename if that has no file extension.
Rui Ueyama54b71da2015-05-31 19:17:12 +0000164 bool hasExt = (Filename.find('.') != StringRef::npos);
Rui Ueyamad21b00b2015-05-31 19:17:14 +0000165 if (!hasExt)
166 Filename = Alloc.save(Filename + ".lib");
167 return doFindFile(Filename);
168}
169
170// Resolves a library path. /nodefaultlib options are taken into
171// consideration. This never returns the same path (in that case,
172// it returns None).
173Optional<StringRef> LinkerDriver::findLib(StringRef Filename) {
174 if (Config->NoDefaultLibAll)
175 return None;
176 StringRef Path = doFindLib(Filename);
177 if (Config->NoDefaultLibs.count(Path))
178 return None;
179 bool Seen = !VisitedFiles.insert(Path.lower()).second;
180 if (Seen)
181 return None;
182 return Path;
Rui Ueyama54b71da2015-05-31 19:17:12 +0000183}
184
185// Parses LIB environment which contains a list of search paths.
Rui Ueyamaf00df0a2015-06-19 22:39:48 +0000186void LinkerDriver::addLibSearchPaths() {
Rui Ueyama54b71da2015-05-31 19:17:12 +0000187 Optional<std::string> EnvOpt = Process::GetEnv("LIB");
188 if (!EnvOpt.hasValue())
Rui Ueyamaf00df0a2015-06-19 22:39:48 +0000189 return;
Rui Ueyama54b71da2015-05-31 19:17:12 +0000190 StringRef Env = Alloc.save(*EnvOpt);
191 while (!Env.empty()) {
192 StringRef Path;
193 std::tie(Path, Env) = Env.split(';');
Rui Ueyamaf00df0a2015-06-19 22:39:48 +0000194 SearchPaths.push_back(Path);
Rui Ueyama54b71da2015-05-31 19:17:12 +0000195 }
Rui Ueyama54b71da2015-05-31 19:17:12 +0000196}
197
Rui Ueyama6bf638e2015-07-02 00:04:14 +0000198Undefined *LinkerDriver::addUndefined(StringRef Name) {
199 Undefined *U = Symtab.addUndefined(Name);
Rui Ueyama18f8d2c2015-07-02 00:21:08 +0000200 Config->GCRoot.insert(U);
Rui Ueyama6bf638e2015-07-02 00:04:14 +0000201 return U;
Rui Ueyama32f8e1c2015-06-26 03:44:00 +0000202}
203
Rui Ueyama7c3e23f2015-07-09 01:25:49 +0000204// Symbol names are mangled by appending "_" prefix on x86.
205StringRef LinkerDriver::mangle(StringRef Sym) {
Rui Ueyama5e706b32015-07-25 21:54:50 +0000206 assert(Config->Machine != IMAGE_FILE_MACHINE_UNKNOWN);
207 if (Config->Machine == I386)
Rui Ueyama7c3e23f2015-07-09 01:25:49 +0000208 return Alloc.save("_" + Sym);
209 return Sym;
210}
211
Rui Ueyama45044f42015-06-29 01:03:53 +0000212// Windows specific -- find default entry point name.
213StringRef LinkerDriver::findDefaultEntry() {
214 // User-defined main functions and their corresponding entry points.
215 static const char *Entries[][2] = {
216 {"main", "mainCRTStartup"},
217 {"wmain", "wmainCRTStartup"},
218 {"WinMain", "WinMainCRTStartup"},
219 {"wWinMain", "wWinMainCRTStartup"},
220 };
221 for (auto E : Entries) {
Rui Ueyamaa50387f2015-07-14 02:58:13 +0000222 StringRef Entry = Symtab.findMangle(mangle(E[0]));
223 if (!Entry.empty() && !isa<Undefined>(Symtab.find(Entry)->Body))
Rui Ueyama7c3e23f2015-07-09 01:25:49 +0000224 return mangle(E[1]);
Rui Ueyama45044f42015-06-29 01:03:53 +0000225 }
226 return "";
227}
228
229WindowsSubsystem LinkerDriver::inferSubsystem() {
Rui Ueyama97dff9e2015-06-17 00:16:33 +0000230 if (Config->DLL)
231 return IMAGE_SUBSYSTEM_WINDOWS_GUI;
Rui Ueyama611add22015-08-08 00:23:37 +0000232 if (Symtab.findUnderscore("main") || Symtab.findUnderscore("wmain"))
Rui Ueyama45044f42015-06-29 01:03:53 +0000233 return IMAGE_SUBSYSTEM_WINDOWS_CUI;
Rui Ueyama611add22015-08-08 00:23:37 +0000234 if (Symtab.findUnderscore("WinMain") || Symtab.findUnderscore("wWinMain"))
Rui Ueyama45044f42015-06-29 01:03:53 +0000235 return IMAGE_SUBSYSTEM_WINDOWS_GUI;
236 return IMAGE_SUBSYSTEM_UNKNOWN;
Rui Ueyama97dff9e2015-06-17 00:16:33 +0000237}
238
Rui Ueyama5c437cd2015-07-25 21:42:33 +0000239static uint64_t getDefaultImageBase() {
240 if (Config->is64())
241 return Config->DLL ? 0x180000000 : 0x140000000;
242 return Config->DLL ? 0x10000000 : 0x400000;
243}
244
Rafael Espindolab835ae82015-08-06 14:58:50 +0000245void LinkerDriver::link(llvm::ArrayRef<const char *> ArgsArr) {
Rui Ueyama27e470a2015-08-09 20:45:17 +0000246 // If the first command line argument is "/lib", link.exe acts like lib.exe.
247 // We call our own implementation of lib.exe that understands bitcode files.
248 if (ArgsArr.size() > 1 && StringRef(ArgsArr[1]).equals_lower("/lib")) {
249 if (llvm::libDriverMain(ArgsArr.slice(1)) != 0)
250 error("lib failed");
251 return;
252 }
253
Peter Collingbourne60c16162015-06-01 20:10:10 +0000254 // Needed for LTO.
255 llvm::InitializeAllTargetInfos();
256 llvm::InitializeAllTargets();
257 llvm::InitializeAllTargetMCs();
258 llvm::InitializeAllAsmParsers();
259 llvm::InitializeAllAsmPrinters();
260 llvm::InitializeAllDisassemblers();
261
Rui Ueyama411c63602015-05-28 19:09:30 +0000262 // Parse command line options.
Rafael Espindolab835ae82015-08-06 14:58:50 +0000263 llvm::opt::InputArgList Args = Parser.parseLINK(ArgsArr.slice(1));
Rui Ueyama411c63602015-05-28 19:09:30 +0000264
Rui Ueyama5c726432015-05-29 16:11:52 +0000265 // Handle /help
David Blaikie6521ed92015-06-22 22:06:52 +0000266 if (Args.hasArg(OPT_help)) {
David Blaikieb2b1c7c2015-06-21 06:32:10 +0000267 printHelp(ArgsArr[0]);
Rafael Espindolab835ae82015-08-06 14:58:50 +0000268 return;
Rui Ueyama5c726432015-05-29 16:11:52 +0000269 }
270
Rafael Espindolab835ae82015-08-06 14:58:50 +0000271 if (Args.filtered_begin(OPT_INPUT) == Args.filtered_end())
272 error("no input files.");
Rui Ueyama3d3e6fb2015-05-29 16:06:00 +0000273
Rui Ueyamaf00df0a2015-06-19 22:39:48 +0000274 // Construct search path list.
275 SearchPaths.push_back("");
David Blaikie6521ed92015-06-22 22:06:52 +0000276 for (auto *Arg : Args.filtered(OPT_libpath))
Rui Ueyamaf00df0a2015-06-19 22:39:48 +0000277 SearchPaths.push_back(Arg->getValue());
278 addLibSearchPaths();
279
Rui Ueyamaad660982015-06-07 00:20:32 +0000280 // Handle /out
David Blaikie6521ed92015-06-22 22:06:52 +0000281 if (auto *Arg = Args.getLastArg(OPT_out))
Rui Ueyamaad660982015-06-07 00:20:32 +0000282 Config->OutputFile = Arg->getValue();
283
Rui Ueyama3d3e6fb2015-05-29 16:06:00 +0000284 // Handle /verbose
David Blaikie6521ed92015-06-22 22:06:52 +0000285 if (Args.hasArg(OPT_verbose))
Rui Ueyama411c63602015-05-28 19:09:30 +0000286 Config->Verbose = true;
Rui Ueyama3d3e6fb2015-05-29 16:06:00 +0000287
Rui Ueyama95925fd2015-06-28 19:35:15 +0000288 // Handle /force or /force:unresolved
289 if (Args.hasArg(OPT_force) || Args.hasArg(OPT_force_unresolved))
290 Config->Force = true;
291
Rui Ueyama6600eb12015-07-04 23:37:32 +0000292 // Handle /debug
293 if (Args.hasArg(OPT_debug))
294 Config->Debug = true;
295
Rui Ueyamaa8b60452015-06-28 19:56:30 +0000296 // Handle /noentry
297 if (Args.hasArg(OPT_noentry)) {
Rafael Espindolab835ae82015-08-06 14:58:50 +0000298 if (!Args.hasArg(OPT_dll))
299 error("/noentry must be specified with /dll");
Rui Ueyamaa8b60452015-06-28 19:56:30 +0000300 Config->NoEntry = true;
301 }
302
Rui Ueyama97dff9e2015-06-17 00:16:33 +0000303 // Handle /dll
David Blaikie6521ed92015-06-22 22:06:52 +0000304 if (Args.hasArg(OPT_dll)) {
Rui Ueyama97dff9e2015-06-17 00:16:33 +0000305 Config->DLL = true;
Rui Ueyama24c5fd02015-06-18 00:12:42 +0000306 Config->ManifestID = 2;
307 }
Rui Ueyama97dff9e2015-06-17 00:16:33 +0000308
Rui Ueyama588e8322015-06-15 01:23:58 +0000309 // Handle /fixed
David Blaikie6521ed92015-06-22 22:06:52 +0000310 if (Args.hasArg(OPT_fixed)) {
Rafael Espindolab835ae82015-08-06 14:58:50 +0000311 if (Args.hasArg(OPT_dynamicbase))
312 error("/fixed must not be specified with /dynamicbase");
Rui Ueyama588e8322015-06-15 01:23:58 +0000313 Config->Relocatable = false;
Rui Ueyama6592ff82015-06-16 23:13:00 +0000314 Config->DynamicBase = false;
315 }
Rui Ueyama588e8322015-06-15 01:23:58 +0000316
Rui Ueyama3d3e6fb2015-05-29 16:06:00 +0000317 // Handle /machine
Rafael Espindolab835ae82015-08-06 14:58:50 +0000318 if (auto *Arg = Args.getLastArg(OPT_machine))
319 Config->Machine = getMachineType(Arg->getValue());
Rui Ueyama3d3e6fb2015-05-29 16:06:00 +0000320
Rui Ueyamad21b00b2015-05-31 19:17:14 +0000321 // Handle /nodefaultlib:<filename>
David Blaikie6521ed92015-06-22 22:06:52 +0000322 for (auto *Arg : Args.filtered(OPT_nodefaultlib))
Rui Ueyamad21b00b2015-05-31 19:17:14 +0000323 Config->NoDefaultLibs.insert(doFindLib(Arg->getValue()));
324
325 // Handle /nodefaultlib
David Blaikie6521ed92015-06-22 22:06:52 +0000326 if (Args.hasArg(OPT_nodefaultlib_all))
Rui Ueyamad21b00b2015-05-31 19:17:14 +0000327 Config->NoDefaultLibAll = true;
328
Rui Ueyama804a8b62015-05-29 16:18:15 +0000329 // Handle /base
Rafael Espindolab835ae82015-08-06 14:58:50 +0000330 if (auto *Arg = Args.getLastArg(OPT_base))
331 parseNumbers(Arg->getValue(), &Config->ImageBase);
Rui Ueyamab41b7e52015-05-29 16:21:11 +0000332
333 // Handle /stack
Rafael Espindolab835ae82015-08-06 14:58:50 +0000334 if (auto *Arg = Args.getLastArg(OPT_stack))
335 parseNumbers(Arg->getValue(), &Config->StackReserve, &Config->StackCommit);
Rui Ueyama804a8b62015-05-29 16:18:15 +0000336
Rui Ueyamac377e9a2015-05-29 16:23:40 +0000337 // Handle /heap
Rafael Espindolab835ae82015-08-06 14:58:50 +0000338 if (auto *Arg = Args.getLastArg(OPT_heap))
339 parseNumbers(Arg->getValue(), &Config->HeapReserve, &Config->HeapCommit);
Rui Ueyamac377e9a2015-05-29 16:23:40 +0000340
Rui Ueyamab9dcdb52015-05-29 16:28:29 +0000341 // Handle /version
Rafael Espindolab835ae82015-08-06 14:58:50 +0000342 if (auto *Arg = Args.getLastArg(OPT_version))
343 parseVersion(Arg->getValue(), &Config->MajorImageVersion,
344 &Config->MinorImageVersion);
Rui Ueyamab9dcdb52015-05-29 16:28:29 +0000345
Rui Ueyama15cc47e2015-05-29 16:34:31 +0000346 // Handle /subsystem
Rafael Espindolab835ae82015-08-06 14:58:50 +0000347 if (auto *Arg = Args.getLastArg(OPT_subsystem))
348 parseSubsystem(Arg->getValue(), &Config->Subsystem, &Config->MajorOSVersion,
349 &Config->MinorOSVersion);
Rui Ueyama15cc47e2015-05-29 16:34:31 +0000350
Rui Ueyama2edb35a2015-06-18 19:09:30 +0000351 // Handle /alternatename
David Blaikie6521ed92015-06-22 22:06:52 +0000352 for (auto *Arg : Args.filtered(OPT_alternatename))
Rafael Espindolab835ae82015-08-06 14:58:50 +0000353 parseAlternateName(Arg->getValue());
Rui Ueyama2edb35a2015-06-18 19:09:30 +0000354
Rui Ueyama08d5e182015-06-18 23:20:11 +0000355 // Handle /include
David Blaikie6521ed92015-06-22 22:06:52 +0000356 for (auto *Arg : Args.filtered(OPT_incl))
Rui Ueyama32f8e1c2015-06-26 03:44:00 +0000357 addUndefined(Arg->getValue());
Rui Ueyama08d5e182015-06-18 23:20:11 +0000358
Rui Ueyamab95188c2015-06-18 20:27:09 +0000359 // Handle /implib
David Blaikie6521ed92015-06-22 22:06:52 +0000360 if (auto *Arg = Args.getLastArg(OPT_implib))
Rui Ueyamab95188c2015-06-18 20:27:09 +0000361 Config->Implib = Arg->getValue();
362
Rui Ueyamae2cbfea2015-06-07 03:17:42 +0000363 // Handle /opt
David Blaikie6521ed92015-06-22 22:06:52 +0000364 for (auto *Arg : Args.filtered(OPT_opt)) {
Rui Ueyama75656ee2015-10-19 19:40:43 +0000365 std::string Str = StringRef(Arg->getValue()).lower();
366 SmallVector<StringRef, 1> Vec;
367 StringRef(Str).split(Vec, ',');
368 for (StringRef S : Vec) {
369 if (S == "noref") {
370 Config->DoGC = false;
371 Config->DoICF = false;
372 continue;
373 }
374 if (S == "icf" || StringRef(S).startswith("icf=")) {
375 Config->DoICF = true;
376 continue;
377 }
378 if (S == "noicf") {
379 Config->DoICF = false;
380 continue;
381 }
382 if (StringRef(S).startswith("lldlto=")) {
383 StringRef OptLevel = StringRef(S).substr(7);
384 if (OptLevel.getAsInteger(10, Config->LTOOptLevel) ||
385 Config->LTOOptLevel > 3)
386 error("/opt:lldlto: invalid optimization level: " + OptLevel);
387 continue;
388 }
389 if (StringRef(S).startswith("lldltojobs=")) {
390 StringRef Jobs = StringRef(S).substr(11);
391 if (Jobs.getAsInteger(10, Config->LTOJobs) || Config->LTOJobs == 0)
392 error("/opt:lldltojobs: invalid job count: " + Jobs);
393 continue;
394 }
395 if (S != "ref" && S != "lbr" && S != "nolbr")
396 error(Twine("/opt: unknown option: ") + S);
Rui Ueyamae2cbfea2015-06-07 03:17:42 +0000397 }
Rui Ueyamae2cbfea2015-06-07 03:17:42 +0000398 }
399
Rui Ueyama8854d8a2015-06-04 19:21:24 +0000400 // Handle /failifmismatch
David Blaikie6521ed92015-06-22 22:06:52 +0000401 for (auto *Arg : Args.filtered(OPT_failifmismatch))
Rafael Espindolab835ae82015-08-06 14:58:50 +0000402 checkFailIfMismatch(Arg->getValue());
Rui Ueyama8854d8a2015-06-04 19:21:24 +0000403
Rui Ueyama6600eb12015-07-04 23:37:32 +0000404 // Handle /merge
405 for (auto *Arg : Args.filtered(OPT_merge))
Rafael Espindolab835ae82015-08-06 14:58:50 +0000406 parseMerge(Arg->getValue());
Rui Ueyama6600eb12015-07-04 23:37:32 +0000407
Rui Ueyama24c5fd02015-06-18 00:12:42 +0000408 // Handle /manifest
Rafael Espindolab835ae82015-08-06 14:58:50 +0000409 if (auto *Arg = Args.getLastArg(OPT_manifest_colon))
410 parseManifest(Arg->getValue());
Rui Ueyama24c5fd02015-06-18 00:12:42 +0000411
412 // Handle /manifestuac
Rafael Espindolab835ae82015-08-06 14:58:50 +0000413 if (auto *Arg = Args.getLastArg(OPT_manifestuac))
414 parseManifestUAC(Arg->getValue());
Rui Ueyama24c5fd02015-06-18 00:12:42 +0000415
416 // Handle /manifestdependency
David Blaikie6521ed92015-06-22 22:06:52 +0000417 if (auto *Arg = Args.getLastArg(OPT_manifestdependency))
Rui Ueyama24c5fd02015-06-18 00:12:42 +0000418 Config->ManifestDependency = Arg->getValue();
419
420 // Handle /manifestfile
David Blaikie6521ed92015-06-22 22:06:52 +0000421 if (auto *Arg = Args.getLastArg(OPT_manifestfile))
Rui Ueyama24c5fd02015-06-18 00:12:42 +0000422 Config->ManifestFile = Arg->getValue();
423
Rui Ueyama6592ff82015-06-16 23:13:00 +0000424 // Handle miscellaneous boolean flags.
David Blaikie6521ed92015-06-22 22:06:52 +0000425 if (Args.hasArg(OPT_allowbind_no))
426 Config->AllowBind = false;
427 if (Args.hasArg(OPT_allowisolation_no))
428 Config->AllowIsolation = false;
429 if (Args.hasArg(OPT_dynamicbase_no))
430 Config->DynamicBase = false;
David Blaikie6521ed92015-06-22 22:06:52 +0000431 if (Args.hasArg(OPT_nxcompat_no))
432 Config->NxCompat = false;
433 if (Args.hasArg(OPT_tsaware_no))
434 Config->TerminalServerAware = false;
Rui Ueyama96401732015-09-21 23:43:31 +0000435 if (Args.hasArg(OPT_nosymtab))
436 Config->WriteSymtab = false;
Rui Ueyama6592ff82015-06-16 23:13:00 +0000437
Rui Ueyamad21b00b2015-05-31 19:17:14 +0000438 // Create a list of input files. Files can be given as arguments
439 // for /defaultlib option.
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000440 std::vector<StringRef> Paths;
441 std::vector<MemoryBufferRef> MBs;
David Blaikie6521ed92015-06-22 22:06:52 +0000442 for (auto *Arg : Args.filtered(OPT_INPUT))
Rui Ueyamad21b00b2015-05-31 19:17:14 +0000443 if (Optional<StringRef> Path = findFile(Arg->getValue()))
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000444 Paths.push_back(*Path);
David Blaikie6521ed92015-06-22 22:06:52 +0000445 for (auto *Arg : Args.filtered(OPT_defaultlib))
Rui Ueyamad21b00b2015-05-31 19:17:14 +0000446 if (Optional<StringRef> Path = findLib(Arg->getValue()))
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000447 Paths.push_back(*Path);
Rafael Espindolab835ae82015-08-06 14:58:50 +0000448 for (StringRef Path : Paths)
449 MBs.push_back(openFile(Path));
Rui Ueyamad21b00b2015-05-31 19:17:14 +0000450
Rui Ueyama24c5fd02015-06-18 00:12:42 +0000451 // Windows specific -- Create a resource file containing a manifest file.
452 if (Config->Manifest == Configuration::Embed) {
Rafael Espindolab835ae82015-08-06 14:58:50 +0000453 std::unique_ptr<MemoryBuffer> MB = createManifestRes();
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000454 MBs.push_back(MB->getMemBufferRef());
Rui Ueyama24c5fd02015-06-18 00:12:42 +0000455 OwningMBs.push_back(std::move(MB)); // take ownership
456 }
457
Rui Ueyama2bf6a122015-06-14 21:50:50 +0000458 // Windows specific -- Input files can be Windows resource files (.res files).
459 // We invoke cvtres.exe to convert resource files to a regular COFF file
460 // then link the result file normally.
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000461 std::vector<MemoryBufferRef> Resources;
Rui Ueyama77731b42015-06-26 23:59:13 +0000462 auto NotResource = [](MemoryBufferRef MB) {
463 return identify_magic(MB.getBuffer()) != file_magic::windows_resource;
Rui Ueyama2bf6a122015-06-14 21:50:50 +0000464 };
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000465 auto It = std::stable_partition(MBs.begin(), MBs.end(), NotResource);
466 if (It != MBs.end()) {
467 Resources.insert(Resources.end(), It, MBs.end());
468 MBs.erase(It, MBs.end());
Rui Ueyama2bf6a122015-06-14 21:50:50 +0000469 }
470
Rui Ueyama85225b02015-07-02 03:15:15 +0000471 // Read all input files given via the command line. Note that step()
472 // doesn't read files that are specified by directive sections.
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000473 for (MemoryBufferRef MB : MBs)
Rui Ueyama0d2e9992015-06-23 23:56:39 +0000474 Symtab.addFile(createFile(MB));
Rafael Espindolab835ae82015-08-06 14:58:50 +0000475 Symtab.step();
Rui Ueyama5cff6852015-05-31 03:34:08 +0000476
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000477 // Determine machine type and check if all object files are
478 // for the same CPU type. Note that this needs to be done before
479 // any call to mangle().
480 for (std::unique_ptr<InputFile> &File : Symtab.getFiles()) {
481 MachineTypes MT = File->getMachineType();
482 if (MT == IMAGE_FILE_MACHINE_UNKNOWN)
483 continue;
Rui Ueyama5e706b32015-07-25 21:54:50 +0000484 if (Config->Machine == IMAGE_FILE_MACHINE_UNKNOWN) {
485 Config->Machine = MT;
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000486 continue;
487 }
Rafael Espindolab835ae82015-08-06 14:58:50 +0000488 if (Config->Machine != MT)
489 error(Twine(File->getShortName()) + ": machine type " + machineToStr(MT) +
490 " conflicts with " + machineToStr(Config->Machine));
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000491 }
Rui Ueyama5e706b32015-07-25 21:54:50 +0000492 if (Config->Machine == IMAGE_FILE_MACHINE_UNKNOWN) {
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000493 llvm::errs() << "warning: /machine is not specified. x64 is assumed.\n";
Rui Ueyama5e706b32015-07-25 21:54:50 +0000494 Config->Machine = AMD64;
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000495 }
496
497 // Windows specific -- Convert Windows resource files to a COFF file.
498 if (!Resources.empty()) {
Rafael Espindolab835ae82015-08-06 14:58:50 +0000499 std::unique_ptr<MemoryBuffer> MB = convertResToCOFF(Resources);
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000500 Symtab.addFile(createFile(MB->getMemBufferRef()));
501 OwningMBs.push_back(std::move(MB)); // take ownership
502 }
503
Rui Ueyama4d545342015-07-28 03:12:00 +0000504 // Handle /largeaddressaware
505 if (Config->is64() || Args.hasArg(OPT_largeaddressaware))
506 Config->LargeAddressAware = true;
507
Rui Ueyamad68e2112015-07-28 03:15:57 +0000508 // Handle /highentropyva
509 if (Config->is64() && !Args.hasArg(OPT_highentropyva_no))
510 Config->HighEntropyVA = true;
511
Rui Ueyamabbdec4f2015-07-09 22:51:41 +0000512 // Handle /entry and /dll
513 if (auto *Arg = Args.getLastArg(OPT_entry)) {
514 Config->Entry = addUndefined(mangle(Arg->getValue()));
515 } else if (Args.hasArg(OPT_dll) && !Config->NoEntry) {
Rui Ueyama5e706b32015-07-25 21:54:50 +0000516 StringRef S = (Config->Machine == I386) ? "__DllMainCRTStartup@12"
517 : "_DllMainCRTStartup";
Rui Ueyamabbdec4f2015-07-09 22:51:41 +0000518 Config->Entry = addUndefined(S);
519 } else if (!Config->NoEntry) {
520 // Windows specific -- If entry point name is not given, we need to
521 // infer that from user-defined entry name.
Rui Ueyama45044f42015-06-29 01:03:53 +0000522 StringRef S = findDefaultEntry();
Rafael Espindolab835ae82015-08-06 14:58:50 +0000523 if (S.empty())
524 error("entry point must be defined");
Rui Ueyama6bf638e2015-07-02 00:04:14 +0000525 Config->Entry = addUndefined(S);
Rui Ueyama85225b02015-07-02 03:15:15 +0000526 if (Config->Verbose)
527 llvm::outs() << "Entry name inferred: " << S << "\n";
Rui Ueyama45044f42015-06-29 01:03:53 +0000528 }
529
Rui Ueyamabbdec4f2015-07-09 22:51:41 +0000530 // Handle /export
531 for (auto *Arg : Args.filtered(OPT_export)) {
Rafael Espindolab835ae82015-08-06 14:58:50 +0000532 Export E = parseExport(Arg->getValue());
Rui Ueyamaf10a3202015-08-31 08:43:21 +0000533 if (Config->Machine == I386) {
534 if (!isDecorated(E.Name))
535 E.Name = Alloc.save("_" + E.Name);
536 if (!E.ExtName.empty() && !isDecorated(E.ExtName))
537 E.ExtName = Alloc.save("_" + E.ExtName);
538 }
Rafael Espindolab835ae82015-08-06 14:58:50 +0000539 Config->Exports.push_back(E);
Rui Ueyamabbdec4f2015-07-09 22:51:41 +0000540 }
541
542 // Handle /def
543 if (auto *Arg = Args.getLastArg(OPT_deffile)) {
Rafael Espindolab835ae82015-08-06 14:58:50 +0000544 MemoryBufferRef MB = openFile(Arg->getValue());
Rui Ueyamabbdec4f2015-07-09 22:51:41 +0000545 // parseModuleDefs mutates Config object.
Rafael Espindolab835ae82015-08-06 14:58:50 +0000546 parseModuleDefs(MB, &Alloc);
Rui Ueyamabbdec4f2015-07-09 22:51:41 +0000547 }
548
Rui Ueyama6d249082015-07-13 22:31:45 +0000549 // Handle /delayload
550 for (auto *Arg : Args.filtered(OPT_delayload)) {
551 Config->DelayLoads.insert(StringRef(Arg->getValue()).lower());
Rui Ueyama5e706b32015-07-25 21:54:50 +0000552 if (Config->Machine == I386) {
Rui Ueyama6d249082015-07-13 22:31:45 +0000553 Config->DelayLoadHelper = addUndefined("___delayLoadHelper2@8");
Rui Ueyama35ccb0f2015-07-25 00:20:06 +0000554 } else {
555 Config->DelayLoadHelper = addUndefined("__delayLoadHelper2");
Rui Ueyama6d249082015-07-13 22:31:45 +0000556 }
557 }
558
Rui Ueyama5c437cd2015-07-25 21:42:33 +0000559 // Set default image base if /base is not given.
560 if (Config->ImageBase == uint64_t(-1))
561 Config->ImageBase = getDefaultImageBase();
562
Rui Ueyama3cb895c2015-07-24 22:58:44 +0000563 Symtab.addRelative(mangle("__ImageBase"), 0);
Rui Ueyama5e706b32015-07-25 21:54:50 +0000564 if (Config->Machine == I386) {
Rui Ueyamacd3f99b2015-07-24 23:51:14 +0000565 Config->SEHTable = Symtab.addRelative("___safe_se_handler_table", 0);
566 Config->SEHCount = Symtab.addAbsolute("___safe_se_handler_count", 0);
567 }
Rui Ueyamabbdec4f2015-07-09 22:51:41 +0000568
Rui Ueyama107db552015-08-09 21:01:06 +0000569 // We do not support /guard:cf (control flow protection) yet.
570 // Define CFG symbols anyway so that we can link MSVC 2015 CRT.
571 Symtab.addAbsolute(mangle("__guard_fids_table"), 0);
572 Symtab.addAbsolute(mangle("__guard_fids_count"), 0);
573 Symtab.addAbsolute(mangle("__guard_flags"), 0x100);
574
Rui Ueyamaea533cd2015-07-09 19:54:13 +0000575 // Read as much files as we can from directives sections.
Rafael Espindolab835ae82015-08-06 14:58:50 +0000576 Symtab.run();
Rui Ueyama85225b02015-07-02 03:15:15 +0000577
578 // Resolve auxiliary symbols until we get a convergence.
Rui Ueyama573bf7d2015-06-19 21:12:48 +0000579 // (Trying to resolve a symbol may trigger a Lazy symbol to load a new file.
580 // A new file may contain a directive section to add new command line options.
581 // That's why we have to repeat until converge.)
582 for (;;) {
Rui Ueyama6bf638e2015-07-02 00:04:14 +0000583 // Windows specific -- if entry point is not found,
584 // search for its mangled names.
585 if (Config->Entry)
586 Symtab.mangleMaybe(Config->Entry);
587
Rui Ueyama573bf7d2015-06-19 21:12:48 +0000588 // Windows specific -- Make sure we resolve all dllexported symbols.
Rui Ueyama6bf638e2015-07-02 00:04:14 +0000589 for (Export &E : Config->Exports) {
Rui Ueyama84425d72016-01-09 01:22:00 +0000590 if (!E.ForwardTo.empty())
591 continue;
Rui Ueyama6bf638e2015-07-02 00:04:14 +0000592 E.Sym = addUndefined(E.Name);
Rui Ueyamaf10a3202015-08-31 08:43:21 +0000593 if (!E.Directives)
594 Symtab.mangleMaybe(E.Sym);
Rui Ueyama6bf638e2015-07-02 00:04:14 +0000595 }
Rui Ueyama573bf7d2015-06-19 21:12:48 +0000596
597 // Add weak aliases. Weak aliases is a mechanism to give remaining
598 // undefined symbols final chance to be resolved successfully.
Rui Ueyama3d4c69c2015-07-02 02:38:59 +0000599 for (auto Pair : Config->AlternateNames) {
600 StringRef From = Pair.first;
601 StringRef To = Pair.second;
Rui Ueyama458d7442015-07-02 03:59:04 +0000602 Symbol *Sym = Symtab.find(From);
Rui Ueyama3d4c69c2015-07-02 02:38:59 +0000603 if (!Sym)
604 continue;
Rui Ueyama183f53f2015-07-06 17:45:22 +0000605 if (auto *U = dyn_cast<Undefined>(Sym->Body))
Rui Ueyama3d4c69c2015-07-02 02:38:59 +0000606 if (!U->WeakAlias)
607 U->WeakAlias = Symtab.addUndefined(To);
Rui Ueyama2edb35a2015-06-18 19:09:30 +0000608 }
Rui Ueyama573bf7d2015-06-19 21:12:48 +0000609
Rui Ueyamacd3f99b2015-07-24 23:51:14 +0000610 // Windows specific -- if __load_config_used can be resolved, resolve it.
Rui Ueyama8ebdc8c2015-08-07 22:43:53 +0000611 if (Symtab.findUnderscore("_load_config_used"))
612 addUndefined(mangle("_load_config_used"));
Rui Ueyamacd3f99b2015-07-24 23:51:14 +0000613
Rui Ueyama3d4c69c2015-07-02 02:38:59 +0000614 if (Symtab.queueEmpty())
615 break;
Rafael Espindolab835ae82015-08-06 14:58:50 +0000616 Symtab.run();
Rui Ueyama2edb35a2015-06-18 19:09:30 +0000617 }
618
Peter Collingbournedf5783b2015-08-28 22:16:09 +0000619 // Do LTO by compiling bitcode input files to a set of native COFF files then
620 // link those files.
621 Symtab.addCombinedLTOObjects();
Peter Collingbourne60c16162015-06-01 20:10:10 +0000622
Peter Collingbourne2612a322015-07-04 05:28:41 +0000623 // Make sure we have resolved all symbols.
Rafael Espindolab835ae82015-08-06 14:58:50 +0000624 Symtab.reportRemainingUndefines(/*Resolve=*/true);
Peter Collingbourne2612a322015-07-04 05:28:41 +0000625
Rui Ueyama3ee0fe42015-05-31 03:55:46 +0000626 // Windows specific -- if no /subsystem is given, we need to infer
627 // that from entry point name.
628 if (Config->Subsystem == IMAGE_SUBSYSTEM_UNKNOWN) {
Rui Ueyama97dff9e2015-06-17 00:16:33 +0000629 Config->Subsystem = inferSubsystem();
Rafael Espindolab835ae82015-08-06 14:58:50 +0000630 if (Config->Subsystem == IMAGE_SUBSYSTEM_UNKNOWN)
631 error("subsystem must be defined");
Rui Ueyama3ee0fe42015-05-31 03:55:46 +0000632 }
633
Rui Ueyamaff88d5a2015-07-29 20:25:40 +0000634 // Handle /safeseh.
Rui Ueyama13563d82015-09-15 00:33:11 +0000635 if (Args.hasArg(OPT_safeseh))
636 for (ObjectFile *File : Symtab.ObjectFiles)
637 if (!File->SEHCompat)
638 error("/safeseh: " + File->getName() + " is not compatible with SEH");
Rui Ueyamaff88d5a2015-07-29 20:25:40 +0000639
Rui Ueyama151d8622015-06-17 20:40:43 +0000640 // Windows specific -- when we are creating a .dll file, we also
641 // need to create a .lib file.
Rui Ueyama100ffac2015-09-01 09:15:58 +0000642 if (!Config->Exports.empty() || Config->DLL) {
Rafael Espindolab835ae82015-08-06 14:58:50 +0000643 fixupExports();
644 writeImportLibrary();
Rui Ueyama8765fba2015-07-15 22:21:08 +0000645 assignExportOrdinals();
646 }
Rui Ueyama97dff9e2015-06-17 00:16:33 +0000647
Rui Ueyama24c5fd02015-06-18 00:12:42 +0000648 // Windows specific -- Create a side-by-side manifest file.
649 if (Config->Manifest == Configuration::SideBySide)
Rafael Espindolab835ae82015-08-06 14:58:50 +0000650 createSideBySideManifest();
Rui Ueyama24c5fd02015-06-18 00:12:42 +0000651
Rui Ueyama0fc26d22015-06-29 14:27:12 +0000652 // Create a dummy PDB file to satisfy build sytem rules.
653 if (auto *Arg = Args.getLastArg(OPT_pdb))
Rui Ueyamae7378242015-12-04 23:11:05 +0000654 createPDB(Arg->getValue());
Rui Ueyama0fc26d22015-06-29 14:27:12 +0000655
Rui Ueyamaa5f0f752015-09-19 21:36:28 +0000656 // Identify unreferenced COMDAT sections.
657 if (Config->DoGC)
658 markLive(Symtab.getChunks());
659
660 // Identify identical COMDAT sections to merge them.
661 if (Config->DoICF)
662 doICF(Symtab.getChunks());
663
Rui Ueyama411c63602015-05-28 19:09:30 +0000664 // Write the result.
Rafael Espindolab835ae82015-08-06 14:58:50 +0000665 writeResult(&Symtab);
Peter Collingbournebe549552015-06-26 18:58:24 +0000666
Rui Ueyama016414f2015-06-28 20:07:08 +0000667 // Create a symbol map file containing symbol VAs and their names
668 // to help debugging.
Peter Collingbournebe549552015-06-26 18:58:24 +0000669 if (auto *Arg = Args.getLastArg(OPT_lldmap)) {
670 std::error_code EC;
Peter Collingbournebaf5f872015-06-26 19:20:09 +0000671 llvm::raw_fd_ostream Out(Arg->getValue(), EC, OpenFlags::F_Text);
Rafael Espindolab835ae82015-08-06 14:58:50 +0000672 error(EC, "Could not create the symbol map");
Peter Collingbournebe549552015-06-26 18:58:24 +0000673 Symtab.printMap(Out);
674 }
Rui Ueyamaa51ce712015-07-03 05:31:35 +0000675 // Call exit to avoid calling destructors.
676 exit(0);
Rui Ueyama411c63602015-05-28 19:09:30 +0000677}
678
Rui Ueyama411c63602015-05-28 19:09:30 +0000679} // namespace coff
680} // namespace lld