Skip to content

Commit

Permalink
[RFC][MC][MachO]Only emits compact-unwind format for "canonical" pers…
Browse files Browse the repository at this point in the history
…onality symbols. For the rest, use DWARFs.

Details: rust-lang/rust#102754

The MachO format uses 2 bits to encode these personality funtions, with 0 reserved for "no-personality".
This means we can only have up to 3 personality. There are already three popular personalities:  __gxx_personality_v0, __gcc_personality_v0, and __objc_personality_v0.
As a result, any system that needs custom-personality will run into a problem.

This patch implemented jyknight's proposal to simply force DWARFs for all non-canonical personality functions.

Differential Revision: https://reviews.llvm.org/D144999
  • Loading branch information
oontvoo committed May 18, 2023
1 parent 3f43abc commit 09aaf53
Show file tree
Hide file tree
Showing 38 changed files with 232 additions and 59 deletions.
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/CodeGenOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ CODEGENOPT(StackSizeSection , 1, 0) ///< Set when -fstack-size-section is enabl
CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when -fforce-dwarf-frame is
///< enabled.

///< Set when -femit-compact-unwind-non-canonical is enabled.
CODEGENOPT(EmitCompactUnwindNonCanonical, 1, 0)

///< Set when -femit-dwarf-unwind is passed.
ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
llvm::EmitDwarfUnwindType::Default)
Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -3244,6 +3244,9 @@ def femit_dwarf_unwind_EQ : Joined<["-"], "femit-dwarf-unwind=">,
NormalizedValues<["Always", "NoCompactUnwind", "Default"]>,
NormalizedValuesScope<"llvm::EmitDwarfUnwindType">,
MarshallingInfoEnum<CodeGenOpts<"EmitDwarfUnwind">, "Default">;
defm emit_compact_unwind_non_canonical : BoolFOption<"emit-compact-unwind-non-canonical",
CodeGenOpts<"EmitCompactUnwindNonCanonical">, DefaultFalse,
PosFlag<SetTrue, [CC1Option, CC1AsOption], "Try emitting Compact-Unwind for non-canonical entries. Maybe overriden by other constraints">, NegFlag<SetFalse>>;
def g_Flag : Flag<["-"], "g">, Group<g_Group>,
Flags<[CoreOption,FlangOption]>, HelpText<"Generate source-level debug information">;
def gline_tables_only : Flag<["-"], "gline-tables-only">, Group<gN_Group>,
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,8 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,

Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
Options.MCOptions.EmitDwarfUnwind = CodeGenOpts.getEmitDwarfUnwind();
Options.MCOptions.EmitCompactUnwindNonCanonical =
CodeGenOpts.EmitCompactUnwindNonCanonical;
Options.MCOptions.MCRelaxAll = CodeGenOpts.RelaxAll;
Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels;
Options.MCOptions.MCUseDwarfDirectory =
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2511,6 +2511,9 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,

Args.AddLastArg(CmdArgs, options::OPT_femit_dwarf_unwind_EQ);

Args.addOptInFlag(CmdArgs, options::OPT_femit_compact_unwind_non_canonical,
options::OPT_fno_emit_compact_unwind_non_canonical);

// If you add more args here, also add them to the block below that
// starts with "// If CollectArgsForIntegratedAssembler() isn't called below".

Expand Down
4 changes: 2 additions & 2 deletions clang/test/Driver/femit-dwarf-unwind.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// REQUIRES: x86-registered-target

// RUN: rm -rf %t; mkdir %t
// RUN: %clang -target x86_64-apple-macos11.0 -c %s -o %t/x86_64.o
// RUN: %clang -target x86_64-apple-macos11.0 -femit-dwarf-unwind=no-compact-unwind -c %s -o %t/x86_64-no-dwarf.o
// RUN: %clang -target x86_64-apple-macos11.0 -c %s -o %t/x86_64.o -femit-compact-unwind-non-canonical
// RUN: %clang -target x86_64-apple-macos11.0 -femit-dwarf-unwind=no-compact-unwind -femit-compact-unwind-non-canonical -c %s -o %t/x86_64-no-dwarf.o
// RUN: llvm-objdump --macho --dwarf=frames %t/x86_64.o | FileCheck %s --check-prefix=WITH-FDE
// RUN: llvm-objdump --macho --dwarf=frames %t/x86_64-no-dwarf.o | FileCheck %s --check-prefix=NO-FDE

Expand Down
4 changes: 2 additions & 2 deletions clang/test/Driver/femit-dwarf-unwind.s
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// REQUIRES: x86-registered-target

// RUN: rm -rf %t; mkdir %t
// RUN: %clang -target x86_64-apple-macos11.0 -c %s -o %t/x86_64.o
// RUN: %clang -target x86_64-apple-macos11.0 -femit-dwarf-unwind=no-compact-unwind -c %s -o %t/x86_64-no-dwarf.o
// RUN: %clang -target x86_64-apple-macos11.0 -c %s -o %t/x86_64.o -femit-compact-unwind-non-canonical
// RUN: %clang -target x86_64-apple-macos11.0 -femit-dwarf-unwind=no-compact-unwind -c %s -o %t/x86_64-no-dwarf.o -femit-compact-unwind-non-canonical
// RUN: llvm-objdump --macho --dwarf=frames %t/x86_64.o | FileCheck %s --check-prefix=WITH-FDE
// RUN: llvm-objdump --macho --dwarf=frames %t/x86_64-no-dwarf.o | FileCheck %s --check-prefix=NO-FDE

Expand Down
9 changes: 9 additions & 0 deletions clang/tools/driver/cc1as_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ struct AssemblerInvocation {
/// Whether to emit DWARF unwind info.
EmitDwarfUnwindType EmitDwarfUnwind;

// Whether to emit compact-unwind for non-canonical entries.
// Note: maybe overriden by other constraints.
unsigned EmitCompactUnwindNonCanonical : 1;

/// The name of the relocation model to use.
std::string RelocationModel;

Expand Down Expand Up @@ -181,6 +185,7 @@ struct AssemblerInvocation {
DwarfVersion = 0;
EmbedBitcode = 0;
EmitDwarfUnwind = EmitDwarfUnwindType::Default;
EmitCompactUnwindNonCanonical = false;
}

static bool CreateFromArgs(AssemblerInvocation &Res,
Expand Down Expand Up @@ -348,6 +353,9 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
.Case("default", EmitDwarfUnwindType::Default);
}

Opts.EmitCompactUnwindNonCanonical =
Args.hasArg(OPT_femit_compact_unwind_non_canonical);

Opts.AsSecureLogFile = Args.getLastArgValue(OPT_as_secure_log_file);

return Success;
Expand Down Expand Up @@ -401,6 +409,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,

MCTargetOptions MCOptions;
MCOptions.EmitDwarfUnwind = Opts.EmitDwarfUnwind;
MCOptions.EmitCompactUnwindNonCanonical = Opts.EmitCompactUnwindNonCanonical;
MCOptions.AsSecureLogFile = Opts.AsSecureLogFile;

std::unique_ptr<MCAsmInfo> MAI(
Expand Down
7 changes: 5 additions & 2 deletions lld/MachO/UnwindInfoSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ void UnwindInfoSectionImpl::relocateCompactUnwind(
if (!d->unwindEntry)
return;

// If we have DWARF unwind info, create a CU entry that points to it.
// If we have DWARF unwind info, create a slimmed-down CU entry that points
// to it.
if (d->unwindEntry->getName() == section_names::ehFrame) {
// The unwinder will look for the DWARF entry starting at the hint,
// assuming the hint points to a valid CFI record start. If it
Expand All @@ -360,7 +361,9 @@ void UnwindInfoSectionImpl::relocateCompactUnwind(
cu.encoding = target->modeDwarfEncoding | dwarfOffsetHint;
const FDE &fde = cast<ObjFile>(d->getFile())->fdes[d->unwindEntry];
cu.functionLength = fde.funcLength;
cu.personality = fde.personality;
// Omit the DWARF personality from compact-unwind entry so that we
// don't need to encode it.
cu.personality = nullptr;
cu.lsda = fde.lsda;
return;
}
Expand Down
Binary file modified lld/test/MachO/Inputs/eh-frame-x86_64-r.o
Binary file not shown.
85 changes: 83 additions & 2 deletions lld/test/MachO/compact-unwind-both-local-and-dylib-personality.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@

# REQUIRES: x86
# RUN: rm -rf %t; split-file %s %t
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/user_2.s -o %t/user_2.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/user_3.s -o %t/user_3.o
# RUN: llvm-mc -emit-compact-unwind-non-canonical=true -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/user_2.s -o %t/user_2.o
# RUN: llvm-mc -emit-compact-unwind-non-canonical=true -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/user_3.s -o %t/user_3.o

## Test case for linking 3+ personaltiies (all globals) without crashing because all the non-canonical are DWARFs
# RUN: llvm-mc -emit-compact-unwind-non-canonical=false -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/user_4.s -o %t/user_4.o

# RUN: yaml2obj %t/combined.yaml > %t/combined.o

## Pre-condition: check that ___gxx_personality_v0 really is locally defined in combined.o before we proceed.
Expand All @@ -21,6 +25,12 @@
## ___gxx_personality_v0 (global), ___gxx_personality_v0(local), _personality_1, and _personality_2
# RUN: %lld -lSystem -dylib %t/user_3.o %t/combined.o %t/user_2.o -o %t/c.out

## check that we can link with 3+ personalities without crashing because
## non-canonical personalities are dwarf.
## This has ___gxx_personality_v0(global), ___gxx_personality_v0(local), and _personality_{1,2,3,4}
## Only the ___gxx_personality_v0(global) should have compact-unwind. The rest should have DWARFs.
# RUN: %lld -lSystem -lc++ %t/user_4.o %t/combined.o -o %t/d.out

## Postlink checks.
# RUN: llvm-nm %t/a.out | FileCheck %s --check-prefix=POSTCHECK
# POSTCHECK: {{.*}} U ___gxx_personality_v0
Expand All @@ -30,6 +40,8 @@
# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --bind %t/b.out | FileCheck %s --check-prefixes=BC,CHECK -D#%x,OFF=0x100000000
# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --bind %t/c.out | FileCheck %s --check-prefixes=BC,C,CHECK -D#%x,OFF=0

# RUN: llvm-objdump --macho --indirect-symbols --unwind-info --bind %t/d.out | FileCheck %s --check-prefixes=D -D#%x,OFF=0x100000000

# A: Indirect symbols for (__DATA_CONST,__got)
# A-NEXT: address index name
# A: 0x[[#%x,GXX_PERSONALITY_LO:]] [[#]] ___gxx_personality_v0
Expand All @@ -53,11 +65,80 @@
# A-NEXT: segment section address type addend dylib symbol
# A-NEXT: __DATA_CONST __got 0x[[#GXX_PERSONALITY_LO-0]] pointer 0 libc++abi ___gxx_personality_v0


# D: Indirect symbols for (__DATA_CONST,__got)
# D-NEXT: address index name
# D: 0x[[#%x,GXX_PERSONALITY_HI:]] [[#]] ___gxx_personality_v0
# D: 0x[[#%x,PERSONALITY_1:]] [[#]] _personality_1
# D: 0x[[#%x,PERSONALITY_2:]] [[#]] _personality_2
# D: 0x[[#%x,PERSONALITY_3:]] [[#]] _personality_3
# D: 0x[[#%x,PERSONALITY_4:]] [[#]] _personality_4
# D: 0x[[#%x,GXX_PERSONALITY_LO:]] [[#]] ___gxx_personality_v0

# D: Contents of __unwind_info section:
# D: Personality functions: (count = 1)
personality[1]: 0x{{0*}}[[#GXX_PERSONALITY_HI-OFF]]

# D: Bind table:
# D: segment section address type addend dylib symbol
# D: __DATA_CONST __got 0x[[#GXX_PERSONALITY_HI-0]] pointer 0 libc++abi ___gxx_personality_v0


## Error cases.
## Check that dylib symbols are picked (which means without libc++, we'd get an undefined symbol error.
# RUN: not %lld -lSystem %t/user_2.o %t/combined.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERRORCHECK
# ERRORCHECK: {{.*}} undefined symbol: ___gxx_personality_v0

#--- user_4.s
.globl _main, _personality_1, _personality_2, _personality_3, _personality_4

.text

_baz1:
.cfi_startproc
.cfi_personality 155, _personality_1
.cfi_def_cfa_offset 16
retq
.cfi_endproc

_baz2:
.cfi_startproc
.cfi_personality 155, _personality_2
.cfi_def_cfa_offset 16
retq
.cfi_endproc

_baz3:
.cfi_startproc
.cfi_personality 155, _personality_3
.cfi_def_cfa_offset 16
retq
.cfi_endproc


_baz4:
.cfi_startproc
.cfi_personality 155, _personality_4
.cfi_def_cfa_offset 16
retq
.cfi_endproc

_main:
.cfi_startproc
.cfi_personality 155, ___gxx_personality_v0
.cfi_def_cfa_offset 16
retq
.cfi_endproc

_personality_1:
retq
_personality_2:
retq
_personality_3:
retq
_personality_4:
retq

#--- user_3.s
.globl _baz3
.private_extern ___gxx_personality_v0
Expand Down
2 changes: 1 addition & 1 deletion lld/test/MachO/compact-unwind-generated.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# those from the linked output

# RUN: %python %S/tools/generate-cfi-funcs.py --seed=johnnyapple >%t.s
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 -o %t.o %t.s
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 -emit-compact-unwind-non-canonical=true -o %t.o %t.s
# RUN: %lld -Z -L%S/Inputs/MacOSX.sdk/usr/lib -lSystem -o %t %t.o
# RUN: llvm-objdump --unwind-info --syms %t %t.o >%t.dump
# RUN: %python %S/tools/validate-unwind-info.py %t.dump
2 changes: 1 addition & 1 deletion lld/test/MachO/compact-unwind-lsda-folding.s
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# REQUIRES: x86
# RUN: rm -rf %t; mkdir %t
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos11.0 -o %t/lsda.o %s
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos11.0 -emit-compact-unwind-non-canonical=true -o %t/lsda.o %s
# RUN: %lld -dylib --icf=all -lSystem -lc++ -o %t/liblsda.dylib %t/lsda.o
# RUN: llvm-objdump --macho --syms --unwind-info %t/liblsda.dylib | FileCheck %s

Expand Down
2 changes: 1 addition & 1 deletion lld/test/MachO/compact-unwind-stack-ind.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %s -o %t.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 -emit-compact-unwind-non-canonical=true %s -o %t.o
# RUN: %lld -arch x86_64 -dylib %t.o -o %t.dylib
# RUN: llvm-objdump --macho --syms --unwind-info %t.dylib | FileCheck %s

Expand Down
12 changes: 6 additions & 6 deletions lld/test/MachO/compact-unwind.s
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# REQUIRES: x86, aarch64
# RUN: rm -rf %t; split-file %s %t
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/my-personality.s -o %t/x86_64-my-personality.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/main.s -o %t/x86_64-main.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 -emit-compact-unwind-non-canonical=true %t/my-personality.s -o %t/x86_64-my-personality.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 -emit-compact-unwind-non-canonical=true %t/main.s -o %t/x86_64-main.o
# RUN: %lld -arch x86_64 -lSystem -lc++ %t/x86_64-my-personality.o %t/x86_64-main.o -o %t/x86_64-personality-first
# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/x86_64-personality-first | FileCheck %s --check-prefixes=FIRST,CHECK -D#%x,BASE=0x100000000 -DSEG=__TEXT
# RUN: %lld -dead_strip -arch x86_64 -lSystem -lc++ %t/x86_64-main.o %t/x86_64-my-personality.o -o %t/x86_64-personality-second
# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/x86_64-personality-second | FileCheck %s --check-prefixes=SECOND,CHECK -D#%x,BASE=0x100000000 -DSEG=__TEXT

# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin19.0.0 %t/my-personality.s -o %t/arm64-my-personality.o
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin19.0.0 %t/main.s -o %t/arm64-main.o
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin19.0.0 -emit-compact-unwind-non-canonical=true %t/my-personality.s -o %t/arm64-my-personality.o
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin19.0.0 -emit-compact-unwind-non-canonical=true %t/main.s -o %t/arm64-main.o
# RUN: %lld -arch arm64 -lSystem -lc++ %t/arm64-my-personality.o %t/arm64-main.o -o %t/arm64-personality-first
# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/arm64-personality-first | FileCheck %s --check-prefixes=FIRST,CHECK -D#%x,BASE=0x100000000 -DSEG=__TEXT
# RUN: %lld -dead_strip -arch arm64 -lSystem -lc++ %t/arm64-main.o %t/arm64-my-personality.o -o %t/arm64-personality-second
# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/arm64-personality-second | FileCheck %s --check-prefixes=SECOND,CHECK -D#%x,BASE=0x100000000 -DSEG=__TEXT

# RUN: llvm-mc -filetype=obj -triple=arm64_32-apple-watchos %t/my-personality.s -o %t/arm64-32-my-personality.o
# RUN: llvm-mc -filetype=obj -triple=arm64_32-apple-watchos %t/main.s -o %t/arm64-32-main.o
# RUN: llvm-mc -filetype=obj -triple=arm64_32-apple-watchos -emit-compact-unwind-non-canonical=true %t/my-personality.s -o %t/arm64-32-my-personality.o
# RUN: llvm-mc -filetype=obj -triple=arm64_32-apple-watchos -emit-compact-unwind-non-canonical=true %t/main.s -o %t/arm64-32-main.o
# RUN: %lld-watchos -lSystem -lc++ %t/arm64-32-my-personality.o %t/arm64-32-main.o -o %t/arm64-32-personality-first
# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/arm64-32-personality-first | FileCheck %s --check-prefixes=FIRST,CHECK -D#%x,BASE=0x4000 -DSEG=__TEXT
# RUN: %lld-watchos -dead_strip -lSystem -lc++ %t/arm64-32-main.o %t/arm64-32-my-personality.o -o %t/arm64-32-personality-second
Expand Down
4 changes: 2 additions & 2 deletions lld/test/MachO/eh-frame-personality-dedup.s
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 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: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 -emit-compact-unwind-non-canonical=true %t/eh-frame.s -o %t/eh-frame.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 -emit-compact-unwind-non-canonical=true %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)
Expand Down
19 changes: 9 additions & 10 deletions lld/test/MachO/eh-frame.s
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# REQUIRES: x86, aarch64
# RUN: rm -rf %t; mkdir %t

# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos10.15 %s -o %t/eh-frame-x86_64.o
# RUN: llvm-mc -emit-compact-unwind-non-canonical=true -filetype=obj -triple=x86_64-apple-macos10.15 %s -o %t/eh-frame-x86_64.o
# RUN: %lld -lSystem -lc++ %t/eh-frame-x86_64.o -o %t/eh-frame-x86_64
# RUN: llvm-objdump --macho --syms --indirect-symbols --unwind-info \
# RUN: --dwarf=frames %t/eh-frame-x86_64 | FileCheck %s -D#BASE=0x100000000 -D#DWARF_ENC=4
Expand All @@ -20,7 +20,7 @@
# RUN: llvm-nm -m %t/eh-frame-x86_64-r | FileCheck %s --check-prefix NO-EH-SYMS
# RUN: llvm-readobj --section-headers %t/eh-frame-x86_64-r | FileCheck %s --check-prefix=ALIGN -D#ALIGN=3

# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos11.0 %s -o %t/eh-frame-arm64.o
# RUN: llvm-mc -filetype=obj -emit-compact-unwind-non-canonical=true -triple=arm64-apple-macos11.0 %s -o %t/eh-frame-arm64.o
# RUN: %lld -arch arm64 -lSystem -lc++ %t/eh-frame-arm64.o -o %t/eh-frame-arm64
# RUN: llvm-objdump --macho --syms --indirect-symbols --unwind-info \
# RUN: --dwarf=frames %t/eh-frame-arm64 | FileCheck %s -D#BASE=0x100000000 -D#DWARF_ENC=3
Expand Down Expand Up @@ -56,22 +56,21 @@
# CHECK-DAG: [[#%x,MY_PERSONALITY:]] g F __TEXT,__text _my_personality
# CHECK: Contents of __unwind_info section:
# CHECK: Version: 0x1
# CHECK: Number of personality functions in array: 0x2
# CHECK: Number of personality functions in array: 0x1
# CHECK: Number of indices in array: 0x2
# CHECK: Personality functions: (count = 2)
# CHECK: Personality functions: (count = 1)
# CHECK: personality[1]: 0x[[#%.8x,GXX_PERSONALITY_GOT - BASE]]
# CHECK: personality[2]: 0x[[#%.8x,MY_PERSONALITY_GOT - BASE]]
# CHECK: LSDA descriptors:
# CHECK: [0]: function offset=0x[[#%.8x,F - BASE]], LSDA offset=0x[[#%.8x,EXCEPT0 - BASE]]
# CHECK: [1]: function offset=0x[[#%.8x,G - BASE]], LSDA offset=0x[[#%.8x,EXCEPT1 - BASE]]
# CHECK: [2]: function offset=0x[[#%.8x,H - BASE]], LSDA offset=0x[[#%.8x,EXCEPT2 - BASE]]
# CHECK: Second level indices:
# CHECK: Second level index[0]:
# CHECK: [0]: function offset=0x[[#%.8x,F - BASE]], encoding[{{.*}}]=0x52{{.*}}
# CHECK: [1]: function offset=0x[[#%.8x,NO_UNWIND - BASE]], encoding[{{.*}}]=0x00000000
# CHECK: [2]: function offset=0x[[#%.8x,G - BASE]], encoding[{{.*}}]=0x1[[#%x,DWARF_ENC]][[#%.6x, G_DWARF_OFF:]]
# CHECK: [3]: function offset=0x[[#%.8x,H - BASE]], encoding[{{.*}}]=0x2[[#%x,DWARF_ENC]][[#%.6x, H_DWARF_OFF:]]
# CHECK: [4]: function offset=0x[[#%.8x,MY_PERSONALITY - BASE]], encoding[{{.*}}]=0x00000000
# CHECK [0]: function offset=0x[[#%.8x,F - BASE]], encoding[{{.*}}]=0x52{{.*}}
# CHECK [1]: function offset=0x[[#%.8x,NO_UNWIND - BASE]], encoding[{{.*}}]=0x00000000
# CHECK: [2]: function offset=0x[[#%.8x,G - BASE]], encoding[{{.*}}]=0x0[[#%x,DWARF_ENC]][[#%.6x, G_DWARF_OFF:]]
# CHECK: [3]: function offset=0x[[#%.8x,H - BASE]], encoding[{{.*}}]=0x0[[#%x,DWARF_ENC]][[#%.6x, H_DWARF_OFF:]]
# CHECK: [4]: function offset=0x[[#%.8x,MY_PERSONALITY - BASE]], encoding[{{.*}}]=0x00000000

# CHECK: .debug_frame contents:
# CHECK: .eh_frame contents:
Expand Down
2 changes: 1 addition & 1 deletion lld/test/MachO/icf-only-lsda-folded.s
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
## the broken output would only appear if the compact unwind entry that pointed
## to it was not itself folded.

# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/test.s -o %t/test.o
# RUN: llvm-mc -emit-compact-unwind-non-canonical=true -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/test.s -o %t/test.o
# RUN: %lld -dylib -dead_strip --icf=all %t/test.o -o %t/test
# RUN: llvm-objdump --macho --syms --unwind-info %t/test | FileCheck %s

Expand Down
4 changes: 2 additions & 2 deletions lld/test/MachO/icf.s
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
## groups, we use `mov` instructions with a variety of immediates, with
## different immediate values for each group.

# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/main.s -o %t/main.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/abs.s -o %t/abs.o
# RUN: llvm-mc -emit-compact-unwind-non-canonical=true -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/main.s -o %t/main.o
# RUN: llvm-mc -emit-compact-unwind-non-canonical=true -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/abs.s -o %t/abs.o
# RUN: %lld -lSystem --icf=all -o %t/main %t/main.o %t/abs.o
# RUN: llvm-objdump -d --syms --dwarf=frames %t/main | FileCheck %s

Expand Down
Loading

0 comments on commit 09aaf53

Please sign in to comment.