[lld] Initial commit for new Mach-O backend
authorJez Ng <jezng@fb.com>
Tue, 31 Mar 2020 18:45:47 +0000 (11:45 -0700)
committerShoaib Meenai <smeenai@fb.com>
Tue, 31 Mar 2020 18:58:47 +0000 (11:58 -0700)
commit03f43b3aca363e16c45d8733400fd0083b1af4d8
tree1e9333eba9f8622a8f89bb61b5838507fba8ab99
parent6d20937c29a1a1d67fc5e8caf8538b4aa5614505
[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
36 files changed:
lld/CMakeLists.txt
lld/MachO/Arch/X86_64.cpp [new file with mode: 0644]
lld/MachO/CMakeLists.txt [new file with mode: 0644]
lld/MachO/Config.h [new file with mode: 0644]
lld/MachO/Driver.cpp [new file with mode: 0644]
lld/MachO/Driver.h [new file with mode: 0644]
lld/MachO/InputFiles.cpp [new file with mode: 0644]
lld/MachO/InputFiles.h [new file with mode: 0644]
lld/MachO/InputSection.cpp [new file with mode: 0644]
lld/MachO/InputSection.h [new file with mode: 0644]
lld/MachO/Options.td [new file with mode: 0644]
lld/MachO/OutputSegment.cpp [new file with mode: 0644]
lld/MachO/OutputSegment.h [new file with mode: 0644]
lld/MachO/SymbolTable.cpp [new file with mode: 0644]
lld/MachO/SymbolTable.h [new file with mode: 0644]
lld/MachO/Symbols.cpp [new file with mode: 0644]
lld/MachO/Symbols.h [new file with mode: 0644]
lld/MachO/Target.cpp [new file with mode: 0644]
lld/MachO/Target.h [new file with mode: 0644]
lld/MachO/Writer.cpp [new file with mode: 0644]
lld/MachO/Writer.h [new file with mode: 0644]
lld/include/lld/Common/Driver.h
lld/test/MachO/alignment-too-large.yaml [new file with mode: 0644]
lld/test/MachO/arch.s [new file with mode: 0644]
lld/test/MachO/duplicate-symbol.s [new file with mode: 0644]
lld/test/MachO/entry-symbol.s [new file with mode: 0644]
lld/test/MachO/invalid-executable.s [new file with mode: 0644]
lld/test/MachO/load-commands.s [new file with mode: 0644]
lld/test/MachO/no-such-file.s [new file with mode: 0644]
lld/test/MachO/relocations.s [new file with mode: 0644]
lld/test/MachO/section-headers.s [new file with mode: 0644]
lld/test/MachO/segments.s [new file with mode: 0644]
lld/test/MachO/silent-ignore.test [new file with mode: 0644]
lld/test/MachO/text-segment.s [new file with mode: 0644]
lld/tools/lld/CMakeLists.txt
lld/tools/lld/lld.cpp