[lld-macho][reland] Initial support for EH FramesThis reverts commit 942f4e3a7cc9a9f8b2654817cff12907d1276031.The additional change required to avoid the assertion errors seenpreviously is: -
[lld-macho][reland] Initial support for EH FramesThis reverts commit 942f4e3a7cc9a9f8b2654817cff12907d1276031.The additional change required to avoid the assertion errors seenpreviously is: --- a/lld/MachO/ICF.cpp +++ b/lld/MachO/ICF.cpp @@ -443,7 +443,9 @@ void macho::foldIdenticalSections() { /*relocVA=*/0); isec->data = copy; } - } else { + } else if (!isEhFrameSection(isec)) { + // EH frames are gathered as hashables from unwindEntry above; give a + // unique ID to everything else. isec->icfEqClass[0] = ++icfUniqueID; } }Differential Revision: https://reviews.llvm.org/D123435
show more ...
Revert "[lld-macho] Initial support for EH Frames"This reverts commit 826be330af9c0a8553a5b32718ecd2d97e10438e.This was causing a test failure on build bots: - https://lab.llvm.org/buildbot/#/b
Revert "[lld-macho] Initial support for EH Frames"This reverts commit 826be330af9c0a8553a5b32718ecd2d97e10438e.This was causing a test failure on build bots: - https://lab.llvm.org/buildbot/#/builders/36/builds/21770 - https://lab.llvm.org/buildbot/#/builders/58/builds/23913
[lld-macho] Initial support for EH Frames== Background ==`llvm-mc` generates unwind info in both compact unwind and DWARFformats. LLD already handles the compact unwind format; this diff getsus
[lld-macho] Initial support for EH Frames== Background ==`llvm-mc` generates unwind info in both compact unwind and DWARFformats. LLD already handles the compact unwind format; this diff getsus close to handling the DWARF format properly.== Caveats ==It's not quite done yet, but I figure it's worth getting this reviewedand landed first as it's shaping up to be a fairly large code change.**Known limitations of the current code:*** Only works for x86_64, for which `llvm-mc` emits "abs-ified" relocations as described in https://github.com/llvm/llvm-project/commit/618def651b59bd42c05bbd91d825af2fb2145683. `llvm-mc` emits regular relocations for ARM EH frames, which we do not yet handle correctly.Since the feature is not ready for real use yet, I've gated it behind aflag that only gets toggled on during test suite runs. With most of thenew code disabled, we see just a hint of perf regression, so I don'tthink it'd be remiss to land this as-is: base diff difference (95% CI) sys_time 1.926 ± 0.168 1.979 ± 0.117 [ -1.2% .. +6.6%] user_time 3.590 ± 0.033 3.606 ± 0.028 [ +0.0% .. +0.9%] wall_time 7.104 ± 0.184 7.179 ± 0.151 [ -0.2% .. +2.3%] samples 30 31== Design ==Like compact unwind entries, EH frames are also represented as regularConcatInputSections that get pointed to via `Defined::unwindEntry`. Thisallows them to be handled generically by e.g. the MarkLive and ICFcode. (But note that unlike compact unwind subsections, EH framesubsections do end up in the final binary.)In order to make EH frames "look like" a regular ConcatInputSection,some processing is required. First, we need to split the `__eh_frame`section along EH frame boundaries rather than along symbol boundaries.We do this by decoding the length field of each EH frame. Second, theabs-ified relocations need to be turned into regular Relocs.== Next Steps ==In order to support EH frames on ARM targets, we will either have toteach LLD how to handle EH frames with explicit relocs, or we can try tomake `llvm-mc` emit abs-ified relocs for ARM as well. I'm hoping to dothe latter as I think it will make the LLD implementation both simplerand faster to execute.== Misc ==The `obj-file-with-stabs.s` test had to be updated as the previousversion would trip assertion errors in the code. It appears that in ourattempt to produce a minimal YAML test input, we created a file withinvalid EH frame data. I've fixed this by re-generating the YAML and notdoing any hand-pruning of it.Reviewed By: #lld-macho, RogerDifferential Revision: https://reviews.llvm.org/D123435
[lld/mac] Add explicit "no unwind info" entries for functions without unwind infoFixes PR50529. With this, lld-linked Chromium base_unittests passes on arm macs.Surprisingly, no measurable impact
[lld/mac] Add explicit "no unwind info" entries for functions without unwind infoFixes PR50529. With this, lld-linked Chromium base_unittests passes on arm macs.Surprisingly, no measurable impact on link time.Differential Revision: https://reviews.llvm.org/D104681
[lld-macho] Implement branch-range-extension thunksExtend the range of calls beyond an architecture's limited branch range by first calling a thunk, which loads the far address into a scratch regis
[lld-macho] Implement branch-range-extension thunksExtend the range of calls beyond an architecture's limited branch range by first calling a thunk, which loads the far address into a scratch register (x16 on ARM64) and branches through it.Other ports (COFF, ELF) use multiple passes with successively-refined guesses regarding the expansion of text-space imposed by thunk-space overhead. This MachO algorithm places thunks during MergedOutputSection::finalize() in a single pass using exact thunk-space overheads. Thunks are kept in a separate vector to avoid the overhead of inserting into the `inputs` vector of `MergedOutputSection`.FIXME:* arm64-stubs.s test is broken* add thunk tests* Handle thunks to DylibSymbol in MergedOutputSection::finalize()Differential Revision: https://reviews.llvm.org/D100818
[lld-macho] Emit personalities in compact unwindNote that there is a triple indirection involved withpersonalities and compact unwind:1. Two bits of each CU encoding are used as an offset into t
[lld-macho] Emit personalities in compact unwindNote that there is a triple indirection involved withpersonalities and compact unwind:1. Two bits of each CU encoding are used as an offset into the personality array.2. Each entry of the personality array is an offset from the image base. The resulting address (after adding the image base) should point within the GOT.3. The corresponding GOT entry contains the actual pointer to the personality function.To further complicate things, when the personality function is in theobject file (as opposed to a dylib), its references in`__compact_unwind` may refer to it via a section + offset relocationinstead of a symbol relocation. Since our GOT implementation can onlycreate entries for symbols, we have to create a synthetic symbol at thegiven section offset.Reviewed By: clayborgDifferential Revision: https://reviews.llvm.org/D95809
Handle overflow beyond the 127 common encodings limitThe common encodings table holds only 127 entries. The encodings index for compact entries is 8 bits wide, and indexes 127..255 are stored local
Handle overflow beyond the 127 common encodings limitThe common encodings table holds only 127 entries. The encodings index for compact entries is 8 bits wide, and indexes 127..255 are stored locally to each second-level page. Prior to this diff, lld would `fatal()` if encodings overflowed the 127 limit.This diff populates a per-second-level-page encodings table as needed. When the per-page encodings table hits its limit, we must terminate the page. If such early termination would consume fewer entries than a regular (non-compact) encoding page, then we prefer the regular format.Caveat: one reason the common-encoding table might overflow is because of DWARF debug-info references, which are not yet implemented and will come with a later diff.Differential Revision: https://reviews.llvm.org/D93267
lld/mach-o: Make tool scripts from 2124ca1d5cb py2.7-compatible
[lld-macho] create __TEXT,__unwind_info from __LD,__compact_unwindDigest the input `__LD,__compact_unwind` and produce the output `__TEXT,__unwind_info`. This is the initial commit with the major f
[lld-macho] create __TEXT,__unwind_info from __LD,__compact_unwindDigest the input `__LD,__compact_unwind` and produce the output `__TEXT,__unwind_info`. This is the initial commit with the major functionality.Successor commits will add handling for ...* `__TEXT,__eh_frame`* personalities & LSDA* `-r` pass-throughDifferential Revision: https://reviews.llvm.org/D86805