2 # RUN: rm -rf %t; split-file %s %t
4 ## Test that we correctly handle the sdata4 DWARF pointer encoding. llvm-mc's
5 ## CFI directives always generate EH frames using the absptr (i.e. system
6 ## pointer size) encoding, but it is possible to hand-roll your own EH frames
7 ## that use the sdata4 encoding. For instance, libffi does this.
9 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos10.15 %t/sdata4.s -o %t/sdata4.o
10 # RUN: %lld -lSystem %t/sdata4.o -o %t/sdata4
11 # RUN: llvm-objdump --macho --syms --dwarf=frames %t/sdata4 | FileCheck %s
13 # CHECK: SYMBOL TABLE:
14 # CHECK: [[#%.16x,MAIN:]] g F __TEXT,__text _main
16 # CHECK: .eh_frame contents:
17 # CHECK: 00000000 00000010 00000000 CIE
18 # CHECK: Format: DWARF32
20 # CHECK: Augmentation: "zR"
21 # CHECK: Code alignment factor: 1
22 # CHECK: Data alignment factor: 1
23 # CHECK: Return address column: 1
24 # CHECK: Augmentation data: 1B
25 # CHECK: DW_CFA_def_cfa: reg7 +8
28 # CHECK: 00000014 00000010 00000018 FDE cie=00000000 pc=[[#%x,MAIN]]...[[#%x,MAIN+1]]
29 # CHECK: Format: DWARF32
30 # CHECK: DW_CFA_GNU_args_size: +16
32 # CHECK: 0x[[#%x,MAIN]]: CFA=reg7+8
41 .section __TEXT,__eh_frame
42 # Although we don't reference this EhFrame symbol directly, we must have at
43 # least one non-local symbol in this section, otherwise llvm-mc generates bogus
44 # subtractor relocations.
47 .long LCieEnd - LCieStart
52 .byte 1 # Code alignment
53 .byte 1 # Data alignment
55 .byte 1 # Augmentation size
56 .byte 0x1b # FDE pointer encoding (pcrel | sdata4)
57 .byte 0xc, 7, 8 # DW_CFA_def_cfa reg7 +8
62 .long LFdeEnd - LFdeStart
64 .long LFdeStart - LCieHdr
65 # The next two fields are longs instead of quads because of the sdata4
67 .long _main - . # Function address
68 .long LmainEnd - _main # Function length
70 ## Insert DW_CFA_GNU_args_size to prevent ld64 from creating a compact unwind
71 ## entry to replace this FDE. Makes it easier for us to cross-check behavior
72 ## across the two linkers (LLD never bothers trying to synthesize compact
73 ## unwind if it is not already present).
74 .byte 0x2e, 0x10 # DW_CFA_GNU_args_size
80 .subsections_via_symbols