blob: 3fb59e6b4d0280e5f1bdc27f1079417ae4d8ebb4 [file] [log] [blame]
Joel Jonesa5752e12018-06-06 13:56:511# REQUIRES: x86
George Rimar5f928ff2017-11-17 11:57:472# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
3
4# RUN: llvm-dwarfdump -v %t.o | FileCheck -check-prefix=INPUT %s
5# INPUT: .debug_info contents:
6# INPUT: DW_TAG_variable
7# INPUT-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000027] = "foo")
8# INPUT-NEXT: DW_AT_type [DW_FORM_ref4] (cu + 0x0033 => {0x00000033} "int")
9# INPUT-NEXT: DW_AT_external [DW_FORM_flag_present] (true)
10# INPUT-NEXT: DW_AT_decl_file [DW_FORM_data1] ("/home/path/test.c")
11# INPUT-NEXT: DW_AT_decl_line [DW_FORM_data1] (1)
12# INPUT-NEXT: DW_AT_location [DW_FORM_exprloc] (DW_OP_addr 0x0)
13# INPUT: DW_TAG_variable
14# INPUT-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000002f] = "bar")
15# INPUT-NEXT: DW_AT_type [DW_FORM_ref4] (cu + 0x0033 => {0x00000033} "int")
16# INPUT-NEXT: DW_AT_external [DW_FORM_flag_present] (true)
17# INPUT-NEXT: DW_AT_decl_file [DW_FORM_data1] ("/home/path/test.c")
18# INPUT-NEXT: DW_AT_decl_line [DW_FORM_data1] (2)
19# INPUT-NEXT: DW_AT_location [DW_FORM_exprloc] (DW_OP_addr 0x0)
20
21## Check we use information from .debug_info in messages.
Fangrui Song40a9f222018-07-02 17:48:2322# RUN: not ld.lld %t.o %t.o -o /dev/null 2>&1 | FileCheck %s
George Rimar5f928ff2017-11-17 11:57:4723# CHECK: duplicate symbol: bar
24# CHECK-NEXT: >>> defined at test.c:2
25# CHECK-NEXT: >>> {{.*}}:(bar)
26# CHECK-NEXT: >>> defined at test.c:2
27# CHECK-NEXT: >>> {{.*}}:(.data+0x0)
28# CHECK: duplicate symbol: foo
29# CHECK-NEXT: >>> defined at test.c:1
30# CHECK-NEXT: >>> {{.*}}:(foo)
31# CHECK-NEXT: >>> defined at test.c:1
32# CHECK-NEXT: >>> {{.*}}:(.bss+0x0)
33
34# Used reduced output from following code and clang
35# version 6.0.0 (trunk 316661) to produce this input file:
36# Source (test.c):
37# int foo = 0;
38# int bar = 1;
39# Invocation: clang -g -S test.c
40
41.text
42.file "test.c"
43.file 1 "test.c"
44
45.type foo,@object
46.bss
47.globl foo
48.p2align 2
49foo:
50 .long 0
51 .size foo, 4
52
53.type bar,@object
54.data
55.globl bar
56.p2align 2
57bar:
58 .long 1
59 .size bar, 4
60
61.section .debug_str,"MS",@progbits,1
62.Linfo_string0:
63 .asciz "clang version 6.0.0"
64.Linfo_string1:
65 .asciz "test.c"
66.Linfo_string2:
67 .asciz "/home/path/"
68.Linfo_string3:
69 .asciz "foo"
70.Linfo_string4:
71 .asciz "int"
72.Linfo_string5:
73 .asciz "bar"
74
75.section .debug_abbrev,"",@progbits
76 .byte 1 # Abbreviation Code
77 .byte 17 # DW_TAG_compile_unit
78 .byte 1 # DW_CHILDREN_yes
79 .byte 37 # DW_AT_producer
80 .byte 14 # DW_FORM_strp
81 .byte 19 # DW_AT_language
82 .byte 5 # DW_FORM_data2
83 .byte 3 # DW_AT_name
84 .byte 14 # DW_FORM_strp
85 .byte 16 # DW_AT_stmt_list
86 .byte 23 # DW_FORM_sec_offset
87 .byte 27 # DW_AT_comp_dir
88 .byte 14 # DW_FORM_strp
89 .ascii "\264B" # DW_AT_GNU_pubnames
90 .byte 25 # DW_FORM_flag_present
91 .byte 0 # EOM(1)
92 .byte 0 # EOM(2)
93
94 .byte 2 # Abbreviation Code
95 .byte 52 # DW_TAG_variable
96 .byte 0 # DW_CHILDREN_no
97 .byte 3 # DW_AT_name
98 .byte 14 # DW_FORM_strp
99 .byte 73 # DW_AT_type
100 .byte 19 # DW_FORM_ref4
101 .byte 63 # DW_AT_external
102 .byte 25 # DW_FORM_flag_present
103 .byte 58 # DW_AT_decl_file
104 .byte 11 # DW_FORM_data1
105 .byte 59 # DW_AT_decl_line
106 .byte 11 # DW_FORM_data1
107 .byte 2 # DW_AT_location
108 .byte 24 # DW_FORM_exprloc
109 .byte 0 # EOM(1)
110 .byte 0 # EOM(2)
111
112 .byte 3 # Abbreviation Code
113 .byte 36 # DW_TAG_base_type
114 .byte 0 # DW_CHILDREN_no
115 .byte 3 # DW_AT_name
116 .byte 14 # DW_FORM_strp
117 .byte 62 # DW_AT_encoding
118 .byte 11 # DW_FORM_data1
119 .byte 11 # DW_AT_byte_size
120 .byte 11 # DW_FORM_data1
121 .byte 0 # EOM(1)
122 .byte 0 # EOM(2)
123 .byte 0 # EOM(3)
124
125.section .debug_info,"",@progbits
126.Lcu_begin0:
127 .long 76 # Length of Unit
128 .short 4 # DWARF version number
129 .long .debug_abbrev # Offset Into Abbrev. Section
130 .byte 8 # Address Size (in bytes)
131
132 .byte 1 # Abbrev [1] 0xb:0x45 DW_TAG_compile_unit
133 .long .Linfo_string0 # DW_AT_producer
134 .short 12 # DW_AT_language
135 .long .Linfo_string1 # DW_AT_name
136 .long 0 # DW_AT_stmt_list
137 .long .Linfo_string2 # DW_AT_comp_dir
138
139 .byte 2 # Abbrev [2] 0x1e:0x15 DW_TAG_variable
140 .long .Linfo_string3 # DW_AT_name
141 .long 51 # DW_AT_type
142 .byte 1 # DW_AT_decl_file
143 .byte 1 # DW_AT_decl_line
144 .byte 9 # DW_AT_location
145 .byte 3
146 .quad foo
147
148 .byte 3 # Abbrev [3] 0x33:0x7 DW_TAG_base_type
149 .long .Linfo_string4 # DW_AT_name
150 .byte 5 # DW_AT_encoding
151 .byte 4 # DW_AT_byte_size
152
153 .byte 2 # Abbrev [2] 0x3a:0x15 DW_TAG_variable
154 .long .Linfo_string5 # DW_AT_name
155 .long 51 # DW_AT_type
156 .byte 1 # DW_AT_decl_file
157 .byte 2 # DW_AT_decl_line
158 .byte 9 # DW_AT_location
159 .byte 3
160 .quad bar
161 .byte 0 # End Of Children Mark