2020-04-03 02:54:05 +08:00
|
|
|
set(LLVM_TARGET_DEFINITIONS Options.td)
|
|
|
|
tablegen(LLVM Options.inc -gen-opt-parser-defs)
|
|
|
|
add_public_tablegen_target(MachOOptionsTableGen)
|
|
|
|
|
2020-08-21 04:05:13 +08:00
|
|
|
include_directories(${LLVM_MAIN_SRC_DIR}/../libunwind/include)
|
|
|
|
|
2021-08-05 09:52:41 +08:00
|
|
|
add_lld_library(lldMachO
|
2021-05-01 04:17:25 +08:00
|
|
|
Arch/ARM.cpp
|
2020-09-27 04:00:22 +08:00
|
|
|
Arch/ARM64.cpp
|
2021-04-16 09:14:32 +08:00
|
|
|
Arch/ARM64Common.cpp
|
|
|
|
Arch/ARM64_32.cpp
|
2021-05-01 04:17:25 +08:00
|
|
|
Arch/X86_64.cpp
|
2021-05-26 02:57:16 +08:00
|
|
|
ConcatOutputSection.cpp
|
2020-04-03 02:54:05 +08:00
|
|
|
Driver.cpp
|
2020-08-14 04:48:47 +08:00
|
|
|
DriverUtils.cpp
|
[lld-macho] Emit STABS symbols for debugging, and drop debug sections
Debug sections contain a large amount of data. In order not to bloat the size
of the final binary, we remove them and instead emit STABS symbols for
`dsymutil` and the debugger to locate their contents in the object files.
With this diff, `dsymutil` is able to locate the debug info. However, we need
a few more features before `lldb` is able to work well with our binaries --
e.g. having `LC_DYSYMTAB` accurately reflect the number of local symbols,
emitting `LC_UUID`, and more. Those will be handled in follow-up diffs.
Note also that the STABS we emit differ slightly from what ld64 does. First, we
emit the path to the source file as one `N_SO` symbol instead of two. (`ld64`
emits one `N_SO` for the dirname and one of the basename.) Second, we do not
emit `N_BNSYM` and `N_ENSYM` STABS to mark the start and end of functions,
because the `N_FUN` STABS already serve that purpose. @clayborg recommended
these changes based on his knowledge of what the debugging tools look for.
Additionally, this current implementation doesn't accurately reflect the size
of function symbols. It uses the size of their containing sectioins as a proxy,
but that is only accurate if `.subsections_with_symbols` is set, and if there
isn't an `N_ALT_ENTRY` in that particular subsection. I think we have two
options to solve this:
1. We can split up subsections by symbol even if `.subsections_with_symbols`
is not set, but include constraints to ensure those subsections retain
their order in the final output. This is `ld64`'s approach.
2. We could just add a `size` field to our `Symbol` class. This seems simpler,
and I'm more inclined toward it, but I'm not sure if there are use cases
that it doesn't handle well. As such I'm punting on the decision for now.
Reviewed By: clayborg
Differential Revision: https://reviews.llvm.org/D89257
2020-12-02 06:45:01 +08:00
|
|
|
Dwarf.cpp
|
2020-04-30 06:42:19 +08:00
|
|
|
ExportTrie.cpp
|
2021-05-20 00:58:17 +08:00
|
|
|
ICF.cpp
|
2020-04-03 02:54:05 +08:00
|
|
|
InputFiles.cpp
|
|
|
|
InputSection.cpp
|
2020-10-27 10:18:29 +08:00
|
|
|
LTO.cpp
|
2021-05-26 02:57:16 +08:00
|
|
|
MapFile.cpp
|
[lld/mac] Implement -dead_strip
Also adds support for live_support sections, no_dead_strip sections,
.no_dead_strip symbols.
Chromium Framework 345MB unstripped -> 250MB stripped
(vs 290MB unstripped -> 236M stripped with ld64).
Doing dead stripping is a bit faster than not, because so much less
data needs to be processed:
% ministat lld_*
x lld_nostrip.txt
+ lld_strip.txt
N Min Max Median Avg Stddev
x 10 3.929414 4.07692 4.0269079 4.0089678 0.044214794
+ 10 3.8129408 3.9025559 3.8670411 3.8642573 0.024779651
Difference at 95.0% confidence
-0.144711 +/- 0.0336749
-3.60967% +/- 0.839989%
(Student's t, pooled s = 0.0358398)
This interacts with many parts of the linker. I tried to add test coverage
for all added `isLive()` checks, so that some test will fail if any of them
is removed. I checked that the test expectations for the most part match
ld64's behavior (except for live-support-iterations.s, see the comment
in the test). Interacts with:
- debug info
- export tries
- import opcodes
- flags like -exported_symbol(s_list)
- -U / dynamic_lookup
- mod_init_funcs, mod_term_funcs
- weak symbol handling
- unwind info
- stubs
- map files
- -sectcreate
- undefined, dylib, common, defined (both absolute and normal) symbols
It's possible it interacts with more features I didn't think of,
of course.
I also did some manual testing:
- check-llvm check-clang check-lld work with lld with this patch
as host linker and -dead_strip enabled
- Chromium still starts
- Chromium's base_unittests still pass, including unwind tests
Implemenation-wise, this is InputSection-based, so it'll work for
object files with .subsections_via_symbols (which includes all
object files generated by clang). I first based this on the COFF
implementation, but later realized that things are more similar to ELF.
I think it'd be good to refactor MarkLive.cpp to look more like the ELF
part at some point, but I'd like to get a working state checked in first.
Mechanical parts:
- Rename canOmitFromOutput to wasCoalesced (no behavior change)
since it really is for weak coalesced symbols
- Add noDeadStrip to Defined, corresponding to N_NO_DEAD_STRIP
(`.no_dead_strip` in asm)
Fixes PR49276.
Differential Revision: https://reviews.llvm.org/D103324
2021-05-08 05:10:05 +08:00
|
|
|
MarkLive.cpp
|
2020-08-19 05:37:04 +08:00
|
|
|
ObjC.cpp
|
2020-05-02 07:29:06 +08:00
|
|
|
OutputSection.cpp
|
2020-04-03 02:54:05 +08:00
|
|
|
OutputSegment.cpp
|
2021-03-12 02:28:09 +08:00
|
|
|
Relocations.cpp
|
2022-01-25 05:51:51 +08:00
|
|
|
SectionPriorities.cpp
|
2020-04-03 02:54:05 +08:00
|
|
|
SymbolTable.cpp
|
|
|
|
Symbols.cpp
|
2020-04-22 04:37:57 +08:00
|
|
|
SyntheticSections.cpp
|
2020-04-03 02:54:05 +08:00
|
|
|
Target.cpp
|
2021-05-26 02:57:16 +08:00
|
|
|
UnwindInfoSection.cpp
|
2020-04-03 02:54:05 +08:00
|
|
|
Writer.cpp
|
|
|
|
|
|
|
|
LINK_COMPONENTS
|
|
|
|
${LLVM_TARGETS_TO_BUILD}
|
|
|
|
BinaryFormat
|
2021-02-04 02:31:42 +08:00
|
|
|
BitReader
|
2020-04-03 02:54:05 +08:00
|
|
|
Core
|
2020-12-02 11:00:46 +08:00
|
|
|
DebugInfoDWARF
|
2022-01-05 11:05:10 +08:00
|
|
|
Demangle
|
2020-10-27 10:18:29 +08:00
|
|
|
LTO
|
|
|
|
MC
|
2021-01-25 22:43:39 +08:00
|
|
|
ObjCARCOpts
|
2020-04-03 02:54:05 +08:00
|
|
|
Object
|
|
|
|
Option
|
2020-10-27 10:18:29 +08:00
|
|
|
Passes
|
2020-04-03 02:54:05 +08:00
|
|
|
Support
|
2020-06-09 04:12:58 +08:00
|
|
|
TextAPI
|
2020-04-03 02:54:05 +08:00
|
|
|
|
|
|
|
LINK_LIBS
|
|
|
|
lldCommon
|
|
|
|
${LLVM_PTHREAD_LIB}
|
2021-05-19 23:07:39 +08:00
|
|
|
${XAR_LIB}
|
2020-04-03 02:54:05 +08:00
|
|
|
|
|
|
|
DEPENDS
|
|
|
|
MachOOptionsTableGen
|
|
|
|
${tablegen_deps}
|
|
|
|
)
|
2021-06-04 02:58:43 +08:00
|
|
|
|
|
|
|
if(LLVM_HAVE_LIBXAR)
|
2021-08-05 09:52:41 +08:00
|
|
|
target_link_libraries(lldMachO PRIVATE ${XAR_LIB})
|
2021-06-04 02:58:43 +08:00
|
|
|
endif()
|