Coverage Report

Created: 2018-10-23 15:26

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/wasm/Driver.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- 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 "lld/Common/Driver.h"
11
#include "Config.h"
12
#include "InputChunks.h"
13
#include "InputGlobal.h"
14
#include "MarkLive.h"
15
#include "SymbolTable.h"
16
#include "Writer.h"
17
#include "lld/Common/Args.h"
18
#include "lld/Common/ErrorHandler.h"
19
#include "lld/Common/Memory.h"
20
#include "lld/Common/Strings.h"
21
#include "lld/Common/Threads.h"
22
#include "lld/Common/Version.h"
23
#include "llvm/ADT/Twine.h"
24
#include "llvm/Object/Wasm.h"
25
#include "llvm/Option/ArgList.h"
26
#include "llvm/Support/CommandLine.h"
27
#include "llvm/Support/Path.h"
28
#include "llvm/Support/Process.h"
29
#include "llvm/Support/TargetSelect.h"
30
31
#define DEBUG_TYPE "lld"
32
33
using namespace llvm;
34
using namespace llvm::sys;
35
using namespace llvm::wasm;
36
37
using namespace lld;
38
using namespace lld::wasm;
39
40
Configuration *lld::wasm::Config;
41
42
namespace {
43
44
// Create enum with OPT_xxx values for each option in Options.td
45
enum {
46
  OPT_INVALID = 0,
47
#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11, _12) OPT_##ID,
48
#include "Options.inc"
49
#undef OPTION
50
};
51
52
// This function is called on startup. We need this for LTO since
53
// LTO calls LLVM functions to compile bitcode files to native code.
54
// Technically this can be delayed until we read bitcode files, but
55
// we don't bother to do lazily because the initialization is fast.
56
124
static void initLLVM() {
57
124
  InitializeAllTargets();
58
124
  InitializeAllTargetMCs();
59
124
  InitializeAllAsmPrinters();
60
124
  InitializeAllAsmParsers();
61
124
}
62
63
class LinkerDriver {
64
public:
65
  void link(ArrayRef<const char *> ArgsArr);
66
67
private:
68
  void createFiles(opt::InputArgList &Args);
69
  void addFile(StringRef Path);
70
  void addLibrary(StringRef Name);
71
72
  // True if we are in --whole-archive and --no-whole-archive.
73
  bool InWholeArchive = false;
74
75
  std::vector<InputFile *> Files;
76
};
77
} // anonymous namespace
78
79
bool lld::wasm::link(ArrayRef<const char *> Args, bool CanExitEarly,
80
124
                     raw_ostream &Error) {
81
124
  errorHandler().LogName = args::getFilenameWithoutExe(Args[0]);
82
124
  errorHandler().ErrorOS = &Error;
83
124
  errorHandler().ColorDiagnostics = Error.has_colors();
84
124
  errorHandler().ErrorLimitExceededMsg =
85
124
      "too many errors emitted, stopping now (use "
86
124
      "-error-limit=0 to see all errors)";
87
124
88
124
  Config = make<Configuration>();
89
124
  Symtab = make<SymbolTable>();
90
124
91
124
  initLLVM();
92
124
  LinkerDriver().link(Args);
93
124
94
124
  // Exit immediately if we don't need to return to the caller.
95
124
  // This saves time because the overhead of calling destructors
96
124
  // for all globally-allocated objects is not negligible.
97
124
  if (CanExitEarly)
98
0
    exitLld(errorCount() ? 1 : 0);
99
124
100
124
  freeArena();
101
124
  return !errorCount();
102
124
}
103
104
// Create prefix string literals used in Options.td
105
#define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
106
#include "Options.inc"
107
#undef PREFIX
108
109
// Create table mapping all options defined in Options.td
110
static const opt::OptTable::Info OptInfo[] = {
111
#define OPTION(X1, X2, ID, KIND, GROUP, ALIAS, X7, X8, X9, X10, X11, X12)      \
112
  {X1, X2, X10,         X11,         OPT_##ID, opt::Option::KIND##Class,       \
113
   X9, X8, OPT_##GROUP, OPT_##ALIAS, X7,       X12},
114
#include "Options.inc"
115
#undef OPTION
116
};
117
118
namespace {
119
class WasmOptTable : public llvm::opt::OptTable {
120
public:
121
124
  WasmOptTable() : OptTable(OptInfo) {}
122
  opt::InputArgList parse(ArrayRef<const char *> Argv);
123
};
124
} // namespace
125
126
// Set color diagnostics according to -color-diagnostics={auto,always,never}
127
// or -no-color-diagnostics flags.
128
124
static void handleColorDiagnostics(opt::InputArgList &Args) {
129
124
  auto *Arg = Args.getLastArg(OPT_color_diagnostics, OPT_color_diagnostics_eq,
130
124
                              OPT_no_color_diagnostics);
131
124
  if (!Arg)
132
124
    return;
133
0
  if (Arg->getOption().getID() == OPT_color_diagnostics) {
134
0
    errorHandler().ColorDiagnostics = true;
135
0
  } else if (Arg->getOption().getID() == OPT_no_color_diagnostics) {
136
0
    errorHandler().ColorDiagnostics = false;
137
0
  } else {
138
0
    StringRef S = Arg->getValue();
139
0
    if (S == "always")
140
0
      errorHandler().ColorDiagnostics = true;
141
0
    else if (S == "never")
142
0
      errorHandler().ColorDiagnostics = false;
143
0
    else if (S != "auto")
144
0
      error("unknown option: --color-diagnostics=" + S);
145
0
  }
146
0
}
147
148
// Find a file by concatenating given paths.
149
static Optional<std::string> findFile(StringRef Path1, const Twine &Path2) {
150
  SmallString<128> S;
151
  path::append(S, Path1, Path2);
152
  if (fs::exists(S))
153
    return S.str().str();
154
  return None;
155
}
156
157
124
opt::InputArgList WasmOptTable::parse(ArrayRef<const char *> Argv) {
158
124
  SmallVector<const char *, 256> Vec(Argv.data(), Argv.data() + Argv.size());
159
124
160
124
  unsigned MissingIndex;
161
124
  unsigned MissingCount;
162
124
163
124
  // Expand response files (arguments in the form of @<filename>)
164
124
  cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, Vec);
165
124
166
124
  opt::InputArgList Args = this->ParseArgs(Vec, MissingIndex, MissingCount);
167
124
168
124
  handleColorDiagnostics(Args);
169
124
  for (auto *Arg : Args.filtered(OPT_UNKNOWN))
170
0
    error("unknown argument: " + Arg->getSpelling());
171
124
  return Args;
172
124
}
173
174
// Currently we allow a ".imports" to live alongside a library. This can
175
// be used to specify a list of symbols which can be undefined at link
176
// time (imported from the environment.  For example libc.a include an
177
// import file that lists the syscall functions it relies on at runtime.
178
// In the long run this information would be better stored as a symbol
179
// attribute/flag in the object file itself.
180
// See: https://github.com/WebAssembly/tool-conventions/issues/35
181
5
static void readImportFile(StringRef Filename) {
182
5
  if (Optional<MemoryBufferRef> Buf = readFile(Filename))
183
5
    for (StringRef Sym : args::getLines(*Buf))
184
5
      Config->AllowUndefinedSymbols.insert(Sym);
185
5
}
186
187
// Returns slices of MB by parsing MB as an archive file.
188
// Each slice consists of a member file in the archive.
189
std::vector<MemoryBufferRef> static getArchiveMembers(MemoryBufferRef MB) {
190
  std::unique_ptr<Archive> File =
191
      CHECK(Archive::create(MB),
192
            MB.getBufferIdentifier() + ": failed to parse archive");
193
194
  std::vector<MemoryBufferRef> V;
195
  Error Err = Error::success();
196
  for (const ErrorOr<Archive::Child> &COrErr : File->children(Err)) {
197
    Archive::Child C =
198
        CHECK(COrErr, MB.getBufferIdentifier() +
199
                          ": could not get the child of the archive");
200
    MemoryBufferRef MBRef =
201
        CHECK(C.getMemoryBufferRef(),
202
              MB.getBufferIdentifier() +
203
                  ": could not get the buffer for a child of the archive");
204
    V.push_back(MBRef);
205
  }
206
  if (Err)
207
    fatal(MB.getBufferIdentifier() +
208
          ": Archive::children failed: " + toString(std::move(Err)));
209
210
  // Take ownership of memory buffers created for members of thin archives.
211
  for (std::unique_ptr<MemoryBuffer> &MB : File->takeThinBuffers())
212
    make<std::unique_ptr<MemoryBuffer>>(std::move(MB));
213
214
  return V;
215
}
216
217
192
void LinkerDriver::addFile(StringRef Path) {
218
192
  Optional<MemoryBufferRef> Buffer = readFile(Path);
219
192
  if (!Buffer.hasValue())
220
1
    return;
221
191
  MemoryBufferRef MBRef = *Buffer;
222
191
223
191
  switch (identify_magic(MBRef.getBuffer())) {
224
191
  case file_magic::archive: {
225
18
    // Handle -whole-archive.
226
18
    if (InWholeArchive) {
227
3
      for (MemoryBufferRef &M : getArchiveMembers(MBRef))
228
3
        Files.push_back(createObjectFile(M));
229
3
      return;
230
3
    }
231
15
232
15
    SmallString<128> ImportFile = Path;
233
15
    path::replace_extension(ImportFile, ".imports");
234
15
    if (fs::exists(ImportFile))
235
4
      readImportFile(ImportFile.str());
236
15
237
15
    Files.push_back(make<ArchiveFile>(MBRef));
238
15
    return;
239
15
  }
240
173
  case file_magic::bitcode:
241
173
  case file_magic::wasm_object:
242
173
    Files.push_back(createObjectFile(MBRef));
243
173
    break;
244
173
  default:
245
0
    error("unknown file type: " + MBRef.getBufferIdentifier());
246
191
  }
247
191
}
248
249
// Add a given library by searching it from input search paths.
250
0
void LinkerDriver::addLibrary(StringRef Name) {
251
0
  for (StringRef Dir : Config->SearchPaths) {
252
0
    if (Optional<std::string> S = findFile(Dir, "lib" + Name + ".a")) {
253
0
      addFile(*S);
254
0
      return;
255
0
    }
256
0
  }
257
0
258
0
  error("unable to find library -l" + Name);
259
0
}
260
261
122
void LinkerDriver::createFiles(opt::InputArgList &Args) {
262
469
  for (auto *Arg : Args) {
263
469
    switch (Arg->getOption().getUnaliasedOption().getID()) {
264
469
    case OPT_l:
265
0
      addLibrary(Arg->getValue());
266
0
      break;
267
469
    case OPT_INPUT:
268
192
      addFile(Arg->getValue());
269
192
      break;
270
469
    case OPT_whole_archive:
271
5
      InWholeArchive = true;
272
5
      break;
273
469
    case OPT_no_whole_archive:
274
3
      InWholeArchive = false;
275
3
      break;
276
469
    }
277
469
  }
278
122
}
279
280
124
static StringRef getEntry(opt::InputArgList &Args, StringRef Default) {
281
124
  auto *Arg = Args.getLastArg(OPT_entry, OPT_no_entry);
282
124
  if (!Arg)
283
107
    return Default;
284
17
  if (Arg->getOption().getID() == OPT_no_entry)
285
8
    return "";
286
9
  return Arg->getValue();
287
9
}
288
289
static const uint8_t UnreachableFn[] = {
290
    0x03 /* ULEB length */, 0x00 /* ULEB num locals */,
291
    0x00 /* opcode unreachable */, 0x0b /* opcode end */
292
};
293
294
// For weak undefined functions, there may be "call" instructions that reference
295
// the symbol. In this case, we need to synthesise a dummy/stub function that
296
// will abort at runtime, so that relocations can still provided an operand to
297
// the call instruction that passes Wasm validation.
298
94
static void handleWeakUndefines() {
299
771
  for (Symbol *Sym : Symtab->getSymbols()) {
300
771
    if (!Sym->isUndefined() || 
!Sym->isWeak()30
)
301
763
      continue;
302
8
    auto *FuncSym = dyn_cast<FunctionSymbol>(Sym);
303
8
    if (!FuncSym)
304
1
      continue;
305
7
306
7
    // It is possible for undefined functions not to have a signature (eg. if
307
7
    // added via "--undefined"), but weak undefined ones do have a signature.
308
7
    assert(FuncSym->FunctionType);
309
7
    const WasmSignature &Sig = *FuncSym->FunctionType;
310
7
311
7
    // Add a synthetic dummy for weak undefined functions.  These dummies will
312
7
    // be GC'd if not used as the target of any "call" instructions.
313
7
    Optional<std::string> SymName = demangleItanium(Sym->getName());
314
7
    StringRef DebugName =
315
7
        Saver.save("undefined function " +
316
7
                   (SymName ? 
StringRef(*SymName)2
:
Sym->getName()5
));
317
7
    SyntheticFunction *Func =
318
7
        make<SyntheticFunction>(Sig, Sym->getName(), DebugName);
319
7
    Func->setBody(UnreachableFn);
320
7
    // Ensure it compares equal to the null pointer, and so that table relocs
321
7
    // don't pull in the stub body (only call-operand relocs should do that).
322
7
    Func->setTableIndex(0);
323
7
    Symtab->SyntheticFunctions.emplace_back(Func);
324
7
    // Hide our dummy to prevent export.
325
7
    uint32_t Flags = WASM_SYMBOL_VISIBILITY_HIDDEN;
326
7
    replaceSymbol<DefinedFunction>(Sym, Sym->getName(), Flags, nullptr, Func);
327
7
  }
328
94
}
329
330
// Force Sym to be entered in the output. Used for -u or equivalent.
331
103
static Symbol *handleUndefined(StringRef Name) {
332
103
  Symbol *Sym = Symtab->find(Name);
333
103
  if (!Sym)
334
8
    return nullptr;
335
95
336
95
  // Since symbol S may not be used inside the program, LTO may
337
95
  // eliminate it. Mark the symbol as "used" to prevent it.
338
95
  Sym->IsUsedInRegularObj = true;
339
95
340
95
  if (auto *LazySym = dyn_cast<LazySymbol>(Sym))
341
3
    LazySym->fetch();
342
95
343
95
  return Sym;
344
95
}
345
346
124
void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
347
124
  WasmOptTable Parser;
348
124
  opt::InputArgList Args = Parser.parse(ArgsArr.slice(1));
349
124
350
124
  // Handle --help
351
124
  if (Args.hasArg(OPT_help)) {
352
0
    Parser.PrintHelp(outs(),
353
0
                     (std::string(ArgsArr[0]) + " [options] file...").c_str(),
354
0
                     "LLVM Linker", false);
355
0
    return;
356
0
  }
357
124
358
124
  // Handle --version
359
124
  if (Args.hasArg(OPT_version) || Args.hasArg(OPT_v)) {
360
0
    outs() << getLLDVersion() << "\n";
361
0
    return;
362
0
  }
363
124
364
124
  // Parse and evaluate -mllvm options.
365
124
  std::vector<const char *> V;
366
124
  V.push_back("wasm-ld (LLVM option parsing)");
367
124
  for (auto *Arg : Args.filtered(OPT_mllvm))
368
2
    V.push_back(Arg->getValue());
369
124
  cl::ParseCommandLineOptions(V.size(), V.data());
370
124
371
124
  errorHandler().ErrorLimit = args::getInteger(Args, OPT_error_limit, 20);
372
124
373
124
  Config->AllowUndefined = Args.hasArg(OPT_allow_undefined);
374
124
  Config->Demangle = Args.hasFlag(OPT_demangle, OPT_no_demangle, true);
375
124
  Config->DisableVerify = Args.hasArg(OPT_disable_verify);
376
124
  Config->Entry = getEntry(Args, Args.hasArg(OPT_relocatable) ? 
""18
:
"_start"106
);
377
124
  Config->ExportAll = Args.hasArg(OPT_export_all);
378
124
  Config->ExportDynamic = Args.hasFlag(OPT_export_dynamic,
379
124
      OPT_no_export_dynamic, false);
380
124
  Config->ExportTable = Args.hasArg(OPT_export_table);
381
124
  errorHandler().FatalWarnings =
382
124
      Args.hasFlag(OPT_fatal_warnings, OPT_no_fatal_warnings, false);
383
124
  Config->ImportMemory = Args.hasArg(OPT_import_memory);
384
124
  Config->ImportTable = Args.hasArg(OPT_import_table);
385
124
  Config->LTOO = args::getInteger(Args, OPT_lto_O, 2);
386
124
  Config->LTOPartitions = args::getInteger(Args, OPT_lto_partitions, 1);
387
124
  Config->Optimize = args::getInteger(Args, OPT_O, 0);
388
124
  Config->OutputFile = Args.getLastArgValue(OPT_o);
389
124
  Config->Relocatable = Args.hasArg(OPT_relocatable);
390
124
  Config->GcSections =
391
124
      Args.hasFlag(OPT_gc_sections, OPT_no_gc_sections, !Config->Relocatable);
392
124
  Config->MergeDataSegments =
393
124
      Args.hasFlag(OPT_merge_data_segments, OPT_no_merge_data_segments,
394
124
                   !Config->Relocatable);
395
124
  Config->PrintGcSections =
396
124
      Args.hasFlag(OPT_print_gc_sections, OPT_no_print_gc_sections, false);
397
124
  Config->SaveTemps = Args.hasArg(OPT_save_temps);
398
124
  Config->SearchPaths = args::getStrings(Args, OPT_L);
399
124
  Config->StripAll = Args.hasArg(OPT_strip_all);
400
124
  Config->StripDebug = Args.hasArg(OPT_strip_debug);
401
124
  Config->CompressRelocations = Args.hasArg(OPT_compress_relocations);
402
124
  Config->StackFirst = Args.hasArg(OPT_stack_first);
403
124
  Config->ThinLTOCacheDir = Args.getLastArgValue(OPT_thinlto_cache_dir);
404
124
  Config->ThinLTOCachePolicy = CHECK(
405
124
      parseCachePruningPolicy(Args.getLastArgValue(OPT_thinlto_cache_policy)),
406
124
      "--thinlto-cache-policy: invalid cache policy");
407
124
  Config->ThinLTOJobs = args::getInteger(Args, OPT_thinlto_jobs, -1u);
408
124
  errorHandler().Verbose = Args.hasArg(OPT_verbose);
409
124
  ThreadsEnabled = Args.hasFlag(OPT_threads, OPT_no_threads, true);
410
124
411
124
  Config->InitialMemory = args::getInteger(Args, OPT_initial_memory, 0);
412
124
  Config->GlobalBase = args::getInteger(Args, OPT_global_base, 1024);
413
124
  Config->MaxMemory = args::getInteger(Args, OPT_max_memory, 0);
414
124
  Config->ZStackSize =
415
124
      args::getZOptionValue(Args, OPT_z, "stack-size", WasmPageSize);
416
124
417
124
  if (!Config->StripDebug && 
!Config->StripAll121
&&
Config->CompressRelocations121
)
418
1
    error("--compress-relocations is incompatible with output debug"
419
1
          " information. Please pass --strip-debug or --strip-all");
420
124
421
124
  if (Config->LTOO > 3)
422
0
    error("invalid optimization level for LTO: " + Twine(Config->LTOO));
423
124
  if (Config->LTOPartitions == 0)
424
0
    error("--lto-partitions: number of threads must be > 0");
425
124
  if (Config->ThinLTOJobs == 0)
426
0
    error("--thinlto-jobs: number of threads must be > 0");
427
124
428
124
  if (auto *Arg = Args.getLastArg(OPT_allow_undefined_file))
429
1
    readImportFile(Arg->getValue());
430
124
431
124
  if (!Args.hasArg(OPT_INPUT)) {
432
2
    error("no input files");
433
2
    return;
434
2
  }
435
122
436
122
  if (Config->OutputFile.empty())
437
3
    error("no output file specified");
438
122
439
122
  if (Config->ImportTable && 
Config->ExportTable2
)
440
1
    error("--import-table and --export-table may not be used together");
441
122
442
122
  if (Config->Relocatable) {
443
18
    if (!Config->Entry.empty())
444
0
      error("entry point specified for relocatable output file");
445
18
    if (Config->GcSections)
446
1
      error("-r and --gc-sections may not be used together");
447
18
    if (Config->CompressRelocations)
448
0
      error("-r -and --compress-relocations may not be used together");
449
18
    if (Args.hasArg(OPT_undefined))
450
0
      error("-r -and --undefined may not be used together");
451
18
  }
452
122
453
122
  Symbol *EntrySym = nullptr;
454
122
  if (!Config->Relocatable) {
455
104
    llvm::wasm::WasmGlobal Global;
456
104
    Global.Type = {WASM_TYPE_I32, true};
457
104
    Global.InitExpr.Value.Int32 = 0;
458
104
    Global.InitExpr.Opcode = WASM_OPCODE_I32_CONST;
459
104
    Global.SymbolName = "__stack_pointer";
460
104
    InputGlobal *StackPointer = make<InputGlobal>(Global, nullptr);
461
104
    StackPointer->Live = true;
462
104
463
104
    static WasmSignature NullSignature = {{}, {}};
464
104
465
104
    // Add synthetic symbols before any others
466
104
    WasmSym::CallCtors = Symtab->addSyntheticFunction(
467
104
        "__wasm_call_ctors", WASM_SYMBOL_VISIBILITY_HIDDEN,
468
104
        make<SyntheticFunction>(NullSignature, "__wasm_call_ctors"));
469
104
    // TODO(sbc): Remove WASM_SYMBOL_VISIBILITY_HIDDEN when the mutable global
470
104
    // spec proposal is implemented in all major browsers.
471
104
    // See: https://github.com/WebAssembly/mutable-global
472
104
    WasmSym::StackPointer = Symtab->addSyntheticGlobal(
473
104
        "__stack_pointer", WASM_SYMBOL_VISIBILITY_HIDDEN, StackPointer);
474
104
    WasmSym::HeapBase = Symtab->addSyntheticDataSymbol("__heap_base", 0);
475
104
    WasmSym::DsoHandle = Symtab->addSyntheticDataSymbol(
476
104
        "__dso_handle", WASM_SYMBOL_VISIBILITY_HIDDEN);
477
104
    WasmSym::DataEnd = Symtab->addSyntheticDataSymbol("__data_end", 0);
478
104
479
104
    // These two synthetic symbols exist purely for the embedder so we always
480
104
    // want to export them.
481
104
    WasmSym::HeapBase->ForceExport = true;
482
104
    WasmSym::DataEnd->ForceExport = true;
483
104
  }
484
122
485
122
  createFiles(Args);
486
122
  if (errorCount())
487
5
    return;
488
117
489
117
  // Add all files to the symbol table. This will add almost all
490
117
  // symbols that we need to the symbol table.
491
117
  for (InputFile *F : Files)
492
186
    Symtab->addFile(F);
493
117
  if (errorCount())
494
6
    return;
495
111
496
111
  // Handle the `--undefined <sym>` options.
497
111
  for (auto *Arg : Args.filtered(OPT_undefined))
498
6
    handleUndefined(Arg->getValue());
499
111
500
111
  // Handle the `--export <sym>` options
501
111
  // This works like --undefined but also exports the symbol if its found
502
111
  for (auto *Arg : Args.filtered(OPT_export)) {
503
10
    Symbol *Sym = handleUndefined(Arg->getValue());
504
10
    if (Sym && 
Sym->isDefined()7
)
505
7
      Sym->ForceExport = true;
506
3
    else if (!Config->AllowUndefined)
507
2
      error(Twine("symbol exported via --export not found: ") +
508
2
            Arg->getValue());
509
10
  }
510
111
511
111
  if (!Config->Relocatable) {
512
94
    // Add synthetic dummies for weak undefined functions.
513
94
    handleWeakUndefines();
514
94
515
94
    if (!Config->Entry.empty()) {
516
87
      EntrySym = handleUndefined(Config->Entry);
517
87
      if (EntrySym && 
EntrySym->isDefined()84
)
518
84
        EntrySym->ForceExport = true;
519
3
      else
520
3
        error("entry symbol not defined (pass --no-entry to supress): " +
521
3
              Config->Entry);
522
87
    }
523
94
524
94
    // Make sure we have resolved all symbols.
525
94
    if (!Config->AllowUndefined)
526
84
      Symtab->reportRemainingUndefines();
527
94
  }
528
111
529
111
  if (errorCount())
530
10
    return;
531
101
532
101
  // Do link-time optimization if given files are LLVM bitcode files.
533
101
  // This compiles bitcode files into real object files.
534
101
  Symtab->addCombinedLTOObject();
535
101
  if (errorCount())
536
2
    return;
537
99
538
99
  if (EntrySym)
539
75
    EntrySym->setHidden(false);
540
99
541
99
  if (errorCount())
542
0
    return;
543
99
544
99
  // Do size optimizations: garbage collection
545
99
  markLive();
546
99
547
99
  // Write the result to the file.
548
99
  writeResult();
549
99
}