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 "llvm/ADT/ArrayRef.h" 13 #include "llvm/Support/raw_ostream.h" 14 15 namespace lld { 16 struct SafeReturn { 17 int ret; 18 bool canRunAgain; 19 }; 20 21 // Generic entry point when using LLD as a library, safe for re-entry, supports 22 // crash recovery. Returns a general completion code and a boolean telling 23 // whether it can be called again. In some cases, a crash could corrupt memory 24 // and re-entry would not be possible anymore. Use exitLld() in that case to 25 // properly exit your application and avoid intermittent crashes on exit caused 26 // by cleanup. 27 SafeReturn safeLldMain(int argc, const char **argv, llvm::raw_ostream &stdoutOS, 28 llvm::raw_ostream &stderrOS); 29 30 namespace coff { 31 bool link(llvm::ArrayRef<const char *> args, bool canExitEarly, 32 llvm::raw_ostream &stdoutOS, llvm::raw_ostream &stderrOS); 33 } 34 35 namespace mingw { 36 bool link(llvm::ArrayRef<const char *> args, bool canExitEarly, 37 llvm::raw_ostream &stdoutOS, llvm::raw_ostream &stderrOS); 38 } 39 40 namespace elf { 41 bool link(llvm::ArrayRef<const char *> args, bool canExitEarly, 42 llvm::raw_ostream &stdoutOS, llvm::raw_ostream &stderrOS); 43 } 44 45 namespace mach_o { 46 bool link(llvm::ArrayRef<const char *> args, bool canExitEarly, 47 llvm::raw_ostream &stdoutOS, llvm::raw_ostream &stderrOS); 48 } 49 50 namespace macho { 51 bool link(llvm::ArrayRef<const char *> args, bool canExitEarly, 52 llvm::raw_ostream &stdoutOS, llvm::raw_ostream &stderrOS); 53 } 54 55 namespace wasm { 56 bool link(llvm::ArrayRef<const char *> args, bool canExitEarly, 57 llvm::raw_ostream &stdoutOS, llvm::raw_ostream &stderrOS); 58 } 59 } 60 61 #endif 62