1 //===- lld/Common/Driver.h - Linker Driver Emulator -----------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLD_COMMON_DRIVER_H
10 #define LLD_COMMON_DRIVER_H
11 
12 #include "lld/Common/CommonLinkerContext.h"
13 #include "llvm/ADT/ArrayRef.h"
14 #include "llvm/Support/raw_ostream.h"
15 
16 namespace lld {
17 struct SafeReturn {
18   int ret;
19   bool canRunAgain;
20 };
21 
22 // Generic entry point when using LLD as a library, safe for re-entry, supports
23 // crash recovery. Returns a general completion code and a boolean telling
24 // whether it can be called again. In some cases, a crash could corrupt memory
25 // and re-entry would not be possible anymore. Use exitLld() in that case to
26 // properly exit your application and avoid intermittent crashes on exit caused
27 // by cleanup.
28 SafeReturn safeLldMain(int argc, const char **argv, llvm::raw_ostream &stdoutOS,
29                        llvm::raw_ostream &stderrOS);
30 
31 namespace coff {
32 bool link(llvm::ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
33           llvm::raw_ostream &stderrOS, bool exitEarly, bool disableOutput);
34 }
35 
36 namespace mingw {
37 bool link(llvm::ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
38           llvm::raw_ostream &stderrOS, bool exitEarly, bool disableOutput);
39 }
40 
41 namespace elf {
42 bool link(llvm::ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
43           llvm::raw_ostream &stderrOS, bool exitEarly, bool disableOutput);
44 }
45 
46 namespace macho {
47 bool link(llvm::ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
48           llvm::raw_ostream &stderrOS, bool exitEarly, bool disableOutput);
49 }
50 
51 namespace wasm {
52 bool link(llvm::ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
53           llvm::raw_ostream &stderrOS, bool exitEarly, bool disableOutput);
54 }
55 }
56 
57 #endif
58