2 # RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos %s -o %t.o
3 # RUN: not %lld -arch arm64 %t.o -o /dev/null 2>&1 | FileCheck %s
5 # CHECK: undefined symbol: _undef
6 # CHECK-NEXT: >>> referenced by test.c:3
7 # CHECK-NEXT: >>> {{.*}}.o:(symbol _main+0x0)
8 # CHECK-NEXT: >>> referenced by test.c:2
9 # CHECK-NEXT >>> {{.*}}.o:(symbol _ptr+0x0)
11 ## This is the output of `clang -g2 -O2 -fdebug-compilation-dir=. -fno-ident` called on the following file, with the
12 ## Apple DWARF tables removed:
15 ## int (*ptr)() = &undef;
16 ## int main() { return undef(); };
19 .section __TEXT,__text,regular,pure_instructions
20 .build_version macos, 12, 0 sdk_version 13, 0
22 .globl _main ; -- Begin function main
26 .loc 1 3 0 ; test.c:3:0
29 .loc 1 3 21 prologue_end ; test.c:3:21
35 .section __DATA,__data
41 .section __DWARF,__debug_abbrev,regular,debug
43 .byte 1 ; Abbreviation Code
44 .byte 17 ; DW_TAG_compile_unit
45 .byte 1 ; DW_CHILDREN_yes
46 .byte 37 ; DW_AT_producer
47 .byte 14 ; DW_FORM_strp
48 .byte 19 ; DW_AT_language
49 .byte 5 ; DW_FORM_data2
51 .byte 14 ; DW_FORM_strp
52 .ascii "\202|" ; DW_AT_LLVM_sysroot
53 .byte 14 ; DW_FORM_strp
54 .ascii "\357\177" ; DW_AT_APPLE_sdk
55 .byte 14 ; DW_FORM_strp
56 .byte 16 ; DW_AT_stmt_list
57 .byte 23 ; DW_FORM_sec_offset
58 .byte 27 ; DW_AT_comp_dir
59 .byte 14 ; DW_FORM_strp
60 .ascii "\341\177" ; DW_AT_APPLE_optimized
61 .byte 25 ; DW_FORM_flag_present
62 .byte 17 ; DW_AT_low_pc
63 .byte 1 ; DW_FORM_addr
64 .byte 18 ; DW_AT_high_pc
65 .byte 6 ; DW_FORM_data4
68 .byte 2 ; Abbreviation Code
69 .byte 52 ; DW_TAG_variable
70 .byte 0 ; DW_CHILDREN_no
72 .byte 14 ; DW_FORM_strp
74 .byte 19 ; DW_FORM_ref4
75 .byte 63 ; DW_AT_external
76 .byte 25 ; DW_FORM_flag_present
77 .byte 58 ; DW_AT_decl_file
78 .byte 11 ; DW_FORM_data1
79 .byte 59 ; DW_AT_decl_line
80 .byte 11 ; DW_FORM_data1
81 .byte 2 ; DW_AT_location
82 .byte 24 ; DW_FORM_exprloc
85 .byte 3 ; Abbreviation Code
86 .byte 15 ; DW_TAG_pointer_type
87 .byte 0 ; DW_CHILDREN_no
89 .byte 19 ; DW_FORM_ref4
92 .byte 4 ; Abbreviation Code
93 .byte 21 ; DW_TAG_subroutine_type
94 .byte 1 ; DW_CHILDREN_yes
96 .byte 19 ; DW_FORM_ref4
99 .byte 5 ; Abbreviation Code
100 .byte 24 ; DW_TAG_unspecified_parameters
101 .byte 0 ; DW_CHILDREN_no
104 .byte 6 ; Abbreviation Code
105 .byte 36 ; DW_TAG_base_type
106 .byte 0 ; DW_CHILDREN_no
108 .byte 14 ; DW_FORM_strp
109 .byte 62 ; DW_AT_encoding
110 .byte 11 ; DW_FORM_data1
111 .byte 11 ; DW_AT_byte_size
112 .byte 11 ; DW_FORM_data1
115 .byte 7 ; Abbreviation Code
116 .byte 46 ; DW_TAG_subprogram
117 .byte 0 ; DW_CHILDREN_no
118 .byte 17 ; DW_AT_low_pc
119 .byte 1 ; DW_FORM_addr
120 .byte 18 ; DW_AT_high_pc
121 .byte 6 ; DW_FORM_data4
122 .ascii "\347\177" ; DW_AT_APPLE_omit_frame_ptr
123 .byte 25 ; DW_FORM_flag_present
124 .byte 64 ; DW_AT_frame_base
125 .byte 24 ; DW_FORM_exprloc
127 .byte 14 ; DW_FORM_strp
128 .byte 58 ; DW_AT_decl_file
129 .byte 11 ; DW_FORM_data1
130 .byte 59 ; DW_AT_decl_line
131 .byte 11 ; DW_FORM_data1
132 .byte 73 ; DW_AT_type
133 .byte 19 ; DW_FORM_ref4
134 .byte 63 ; DW_AT_external
135 .byte 25 ; DW_FORM_flag_present
136 .ascii "\341\177" ; DW_AT_APPLE_optimized
137 .byte 25 ; DW_FORM_flag_present
141 .section __DWARF,__debug_info,regular,debug
144 .set Lset0, Ldebug_info_end0-Ldebug_info_start0 ; Length of Unit
147 .short 4 ; DWARF version number
148 .set Lset1, Lsection_abbrev-Lsection_abbrev ; Offset Into Abbrev. Section
150 .byte 8 ; Address Size (in bytes)
151 .byte 1 ; Abbrev [1] 0xb:0x69 DW_TAG_compile_unit
152 .long 0 ; DW_AT_producer
153 .short 12 ; DW_AT_language
155 .long 8 ; DW_AT_LLVM_sysroot
156 .long 60 ; DW_AT_APPLE_sdk
157 .set Lset2, Lline_table_start0-Lsection_line ; DW_AT_stmt_list
159 .long 71 ; DW_AT_comp_dir
160 ; DW_AT_APPLE_optimized
161 .quad Lfunc_begin0 ; DW_AT_low_pc
162 .set Lset3, Lfunc_end0-Lfunc_begin0 ; DW_AT_high_pc
164 .byte 2 ; Abbrev [2] 0x32:0x15 DW_TAG_variable
165 .long 73 ; DW_AT_name
166 .long 71 ; DW_AT_type
168 .byte 1 ; DW_AT_decl_file
169 .byte 2 ; DW_AT_decl_line
170 .byte 9 ; DW_AT_location
173 .byte 3 ; Abbrev [3] 0x47:0x5 DW_TAG_pointer_type
174 .long 76 ; DW_AT_type
175 .byte 4 ; Abbrev [4] 0x4c:0x7 DW_TAG_subroutine_type
176 .long 83 ; DW_AT_type
177 .byte 5 ; Abbrev [5] 0x51:0x1 DW_TAG_unspecified_parameters
178 .byte 0 ; End Of Children Mark
179 .byte 6 ; Abbrev [6] 0x53:0x7 DW_TAG_base_type
180 .long 77 ; DW_AT_name
181 .byte 5 ; DW_AT_encoding
182 .byte 4 ; DW_AT_byte_size
183 .byte 7 ; Abbrev [7] 0x5a:0x19 DW_TAG_subprogram
184 .quad Lfunc_begin0 ; DW_AT_low_pc
185 .set Lset4, Lfunc_end0-Lfunc_begin0 ; DW_AT_high_pc
187 ; DW_AT_APPLE_omit_frame_ptr
188 .byte 1 ; DW_AT_frame_base
190 .long 81 ; DW_AT_name
191 .byte 1 ; DW_AT_decl_file
192 .byte 3 ; DW_AT_decl_line
193 .long 83 ; DW_AT_type
195 ; DW_AT_APPLE_optimized
196 .byte 0 ; End Of Children Mark
198 .section __DWARF,__debug_str,regular,debug
200 .byte 0 ; string offset=0
201 .asciz "test.c" ; string offset=1
202 .asciz "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" ; string offset=8
203 .asciz "MacOSX.sdk" ; string offset=60
204 .asciz "." ; string offset=71
205 .asciz "ptr" ; string offset=73
206 .asciz "int" ; string offset=77
207 .asciz "main" ; string offset=81
208 .section __DWARF,__debug_line,regular,debug