diff options
author | Jez Ng <jezng@fb.com> | 2020-03-31 11:45:47 -0700 |
---|---|---|
committer | Shoaib Meenai <smeenai@fb.com> | 2020-03-31 11:58:47 -0700 |
commit | 03f43b3aca363e16c45d8733400fd0083b1af4d8 (patch) | |
tree | 1e9333eba9f8622a8f89bb61b5838507fba8ab99 /lld/tools | |
parent | 6d20937c29a1a1d67fc5e8caf8538b4aa5614505 (diff) | |
download | llvm-03f43b3aca363e16c45d8733400fd0083b1af4d8.tar.gz |
[lld] Initial commit for new Mach-O backend
Summary:
This is the first commit for the new Mach-O backend, designed to roughly
follow the architecture of the existing ELF and COFF backends, and
building off work that @ruiu and @pcc did in a branch a while back. Note
that this is a very stripped-down commit with the bare minimum of
functionality for ease of review. We'll be following up with more diffs
soon.
Currently, we're able to generate a simple "Hello World!" executable
that runs on OS X Catalina (and possibly on earlier OS X versions; I
haven't tested them). (This executable can be obtained by compiling
`test/MachO/relocations.s`.) We're mocking out a few load commands to
achieve this -- for example, we can't load dynamic libraries, but
Catalina requires binaries to be linked against `dyld`, so we hardcode
the emission of a `LC_LOAD_DYLIB` command. Other mocked out load
commands include LC_SYMTAB and LC_DYSYMTAB.
Differential Revision: https://reviews.llvm.org/D75382
Diffstat (limited to 'lld/tools')
-rw-r--r-- | lld/tools/lld/CMakeLists.txt | 1 | ||||
-rw-r--r-- | lld/tools/lld/lld.cpp | 12 |
2 files changed, 9 insertions, 4 deletions
diff --git a/lld/tools/lld/CMakeLists.txt b/lld/tools/lld/CMakeLists.txt index a37c2c702bd5..2cdd9b854246 100644 --- a/lld/tools/lld/CMakeLists.txt +++ b/lld/tools/lld/CMakeLists.txt @@ -16,6 +16,7 @@ target_link_libraries(lld lldCOFF lldDriver lldELF + lldMachO2 lldMinGW lldWasm ) diff --git a/lld/tools/lld/lld.cpp b/lld/tools/lld/lld.cpp index 646fc3d6468e..58a291d1e921 100644 --- a/lld/tools/lld/lld.cpp +++ b/lld/tools/lld/lld.cpp @@ -45,10 +45,11 @@ using namespace llvm::sys; enum Flavor { Invalid, - Gnu, // -flavor gnu - WinLink, // -flavor link - Darwin, // -flavor darwin - Wasm, // -flavor wasm + Gnu, // -flavor gnu + WinLink, // -flavor link + Darwin, // -flavor darwin + DarwinNew, // -flavor darwinnew + Wasm, // -flavor wasm }; LLVM_ATTRIBUTE_NORETURN static void die(const Twine &s) { @@ -62,6 +63,7 @@ static Flavor getFlavor(StringRef s) { .CasesLower("wasm", "ld-wasm", Wasm) .CaseLower("link", WinLink) .CasesLower("ld64", "ld64.lld", "darwin", Darwin) + .CaseLower("darwinnew", DarwinNew) .Default(Invalid); } @@ -157,6 +159,8 @@ int main(int argc, const char **argv) { return !coff::link(args, canExitEarly(), llvm::outs(), llvm::errs()); case Darwin: return !mach_o::link(args, canExitEarly(), llvm::outs(), llvm::errs()); + case DarwinNew: + return !macho::link(args, canExitEarly(), llvm::outs(), llvm::errs()); case Wasm: return !wasm::link(args, canExitEarly(), llvm::outs(), llvm::errs()); default: |