-
Notifications
You must be signed in to change notification settings - Fork 12.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lld-macho] Canonicalize personality pointers in EH frames
We already do this for personality pointers referenced from compact unwind entries; this patch extends that behavior to personalities referenced via EH frames as well. This reduces the number of distinct personalities we need in the final binary, and helps us avoid hitting the "too many personalities" error. I renamed `UnwindInfoSection::prepareRelocations()` to simply `prepare` since we now do some non-reloc-specific stuff within. Fixes #58277. Reviewed By: #lld-macho, oontvoo Differential Revision: https://reviews.llvm.org/D135728
- Loading branch information
Showing
4 changed files
with
75 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# REQUIRES: x86 | ||
# RUN: rm -rf %t; split-file %s %t | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/eh-frame.s -o %t/eh-frame.o | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/cu.s -o %t/cu.o | ||
# RUN: %lld -dylib %t/cu.o %t/eh-frame.o -o %t/out | ||
|
||
## Sanity check: we want our input to contain a section (and not symbol) | ||
## relocation for the personality reference. | ||
# RUN: llvm-readobj --relocations %t/cu.o | FileCheck %s --check-prefix=SECT-RELOC | ||
# SECT-RELOC: Section __compact_unwind { | ||
# SECT-RELOC-NEXT: __text | ||
# SECT-RELOC-NEXT: __text | ||
# SECT-RELOC-NEXT: } | ||
|
||
## Verify that the personality referenced via a symbol reloc in eh-frame.s gets | ||
## dedup'ed with the personality referenced via a section reloc in cu.s. | ||
# RUN: llvm-objdump --macho --unwind-info %t/out | FileCheck %s | ||
# CHECK: Personality functions: (count = 1) | ||
|
||
#--- eh-frame.s | ||
_fun: | ||
.cfi_startproc | ||
.cfi_personality 155, _my_personality | ||
## cfi_escape cannot be encoded in compact unwind | ||
.cfi_escape 0 | ||
ret | ||
.cfi_endproc | ||
|
||
.subsections_via_symbols | ||
|
||
#--- cu.s | ||
.globl _my_personality | ||
_fun: | ||
.cfi_startproc | ||
.cfi_personality 155, _my_personality | ||
.cfi_def_cfa_offset 16 | ||
ret | ||
.cfi_endproc | ||
|
||
_my_personality: | ||
nop | ||
|
||
.subsections_via_symbols |