xref: /llvm-project/lld/test/ELF/debug-line-str.s (revision 81cebfd0080e3873d0cef5ee5215b8c97332ff96)
1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux -dwarf-version=5 %s -o %t.o
3# RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
4
5# Check we do not crash and able to report the source location.
6
7# CHECK:      error: undefined symbol: foo()
8# CHECK-NEXT: >>> referenced by test.cpp:3
9# CHECK-NEXT: >>>               {{.*}}.o:(.text+0x1)
10
11# The code below is the reduced version of the output
12# from the following invocation and source:
13#
14# // test.cpp:
15# int foo();
16# int main() {
17#   return foo();
18# }
19#
20# clang -gdwarf-5 test.cpp -o test.s -S
21# clang version 8.0.0 (trunk 343487)
22
23.text
24.file "test.cpp"
25.globl main
26.type main,@function
27main:
28.Lfunc_begin0:
29 .file 0 "/home/path" "test.cpp" md5 0x8ed32099ab837bd13543fd3e8102739f
30 .loc 0 3 10 prologue_end
31 jmp _Z3foov
32.Lfunc_end0:
33
34.Lstr_offsets_base0:
35.section .debug_str,"MS",@progbits,1
36 .asciz "stub"
37
38.section .debug_str_offsets,"",@progbits
39 .long 0
40
41.section .debug_abbrev,"",@progbits
42 .byte 1                           # Abbreviation Code
43 .byte 17                          # DW_TAG_compile_unit
44 .byte 0                           # DW_CHILDREN_yes
45 .byte 37                          # DW_AT_producer
46 .byte 37                          # DW_FORM_strx1
47 .byte 19                          # DW_AT_language
48 .byte 5                           # DW_FORM_data2
49 .byte 3                           # DW_AT_name
50 .byte 37                          # DW_FORM_strx1
51 .byte 114                         # DW_AT_str_offsets_base
52 .byte 23                          # DW_FORM_sec_offset
53 .byte 16                          # DW_AT_stmt_list
54 .byte 23                          # DW_FORM_sec_offset
55 .byte 27                          # DW_AT_comp_dir
56 .byte 37                          # DW_FORM_strx1
57 .byte 17                          # DW_AT_low_pc
58 .byte 1                           # DW_FORM_addr
59 .byte 18                          # DW_AT_high_pc
60 .byte 6                           # DW_FORM_data4
61 .byte 0                           # EOM(1)
62 .byte 0                           # EOM(2)
63
64 .byte 2                           # Abbreviation Code
65 .byte 46                          # DW_TAG_subprogram
66 .byte 0                           # DW_CHILDREN_no
67 .byte 17                          # DW_AT_low_pc
68 .byte 1                           # DW_FORM_addr
69 .byte 18                          # DW_AT_high_pc
70 .byte 6                           # DW_FORM_data4
71 .byte 64                          # DW_AT_frame_base
72 .byte 24                          # DW_FORM_exprloc
73 .byte 3                           # DW_AT_name
74 .byte 37                          # DW_FORM_strx1
75 .byte 58                          # DW_AT_decl_file
76 .byte 11                          # DW_FORM_data1
77 .byte 59                          # DW_AT_decl_line
78 .byte 11                          # DW_FORM_data1
79 .byte 73                          # DW_AT_type
80 .byte 19                          # DW_FORM_ref4
81 .byte 63                          # DW_AT_external
82 .byte 25                          # DW_FORM_flag_present
83 .byte 0                           # EOM(1)
84 .byte 0                           # EOM(2)
85
86 .byte 3                           # Abbreviation Code
87 .byte 36                          # DW_TAG_base_type
88 .byte 0                           # DW_CHILDREN_no
89 .byte 3                           # DW_AT_name
90 .byte 37                          # DW_FORM_strx1
91 .byte 62                          # DW_AT_encoding
92 .byte 11                          # DW_FORM_data1
93 .byte 11                          # DW_AT_byte_size
94 .byte 11                          # DW_FORM_data1
95 .byte 0                           # EOM(1)
96 .byte 0                           # EOM(2)
97 .byte 0                           # EOM(3)
98
99.section .debug_info,"",@progbits
100.Lcu_begin0:
101 .long 61                         # Length of Unit
102 .short 5                         # DWARF version number
103 .byte  1                         # DWARF Unit Type
104 .byte  8                         # Address Size (in bytes)
105 .long  .debug_abbrev             # Offset Into Abbrev. Section
106
107 .byte  1                         # Abbrev [1] 0xc:0x35 DW_TAG_compile_unit
108 .byte  0                         # DW_AT_producer
109 .short 0                         # DW_AT_language
110 .byte  0                         # DW_AT_name
111 .long  .Lstr_offsets_base0       # DW_AT_str_offsets_base
112 .long  .Lline_table_start0       # DW_AT_stmt_list
113 .byte  0                         # DW_AT_comp_dir
114 .quad  .Lfunc_begin0             # DW_AT_low_pc
115 .long  .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
116
117 .byte  2                         # Abbrev [2] 0x26:0x16 DW_TAG_subprogram
118 .quad  .Lfunc_begin0             # DW_AT_low_pc
119 .long  .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
120 .byte  1                         # DW_AT_frame_base
121 .byte  87
122 .byte  0                         # DW_AT_name
123 .byte  1                         # DW_AT_decl_file
124 .byte  2                         # DW_AT_decl_line
125 .long  60                        # DW_AT_type
126                                  # DW_AT_external
127
128 .byte  3                         # Abbrev [3] 0x3c:0x4 DW_TAG_base_type
129 .byte  0                         # DW_AT_name
130 .byte  5                         # DW_AT_encoding
131 .byte  4                         # DW_AT_byte_size
132 .byte  0                         # End Of Children Mark
133
134.section .debug_line,"",@progbits
135.Lline_table_start0:
136