1# Create .debug_line containing absolute path in filename. Show that the path is sensibly printed/found/etc.
2# REQUIRES: x86-registered-target
3
4# RUN: sed s!FILEPATH!%/s! %s > %t.s
5# RUN: llvm-mc --filetype=obj --triple=x86_64-pc-linux %t.s -o %t.o
6# RUN: llvm-symbolizer --obj=%t.o 0 | FileCheck %s -DPATH=%/s
7
8# CHECK: {{^}}[[PATH]]:1:0
9
10.type _start,@function
11_start:
12.Lfunc_begin0:
13    ret
14.Lfunc_end0:
15
16.section .debug_str,"MS",@progbits,1
17.Linfo_string1:
18    .asciz "test.c"
19.Linfo_string2:
20    .asciz "/some/dir"
21.Linfo_string3:
22    .asciz "_start"
23
24.section    .debug_abbrev,"",@progbits
25    .byte   1                       # Abbreviation Code
26    .byte   17                      # DW_TAG_compile_unit
27    .byte   1                       # DW_CHILDREN_yes
28    .byte   3                       # DW_AT_name
29    .byte   14                      # DW_FORM_strp
30    .byte   16                      # DW_AT_stmt_list
31    .byte   23                      # DW_FORM_sec_offset
32    .byte   27                      # DW_AT_comp_dir
33    .byte   14                      # DW_FORM_strp
34    .byte   17                      # DW_AT_low_pc
35    .byte   1                       # DW_FORM_addr
36    .byte   18                      # DW_AT_high_pc
37    .byte   6                       # DW_FORM_data4
38    .byte   0                       # EOM(1)
39    .byte   0                       # EOM(2)
40    .byte   2                       # Abbreviation Code
41    .byte   46                      # DW_TAG_subprogram
42    .byte   0                       # DW_CHILDREN_no
43    .byte   17                      # DW_AT_low_pc
44    .byte   1                       # DW_FORM_addr
45    .byte   18                      # DW_AT_high_pc
46    .byte   6                       # DW_FORM_data4
47    .byte   3                       # DW_AT_name
48    .byte   14                      # DW_FORM_strp
49    .byte   58                      # DW_AT_decl_file
50    .byte   11                      # DW_FORM_data1
51    .byte   59                      # DW_AT_decl_line
52    .byte   11                      # DW_FORM_data1
53    .byte   63                      # DW_AT_external
54    .byte   25                      # DW_FORM_flag_present
55    .byte   0                       # EOM(1)
56    .byte   0                       # EOM(2)
57    .byte   0                       # EOM(3)
58    .section    .debug_info,"",@progbits
59    .long   .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
60.Ldebug_info_start0:
61    .short  4                       # DWARF version number
62    .long   .debug_abbrev           # Offset Into Abbrev. Section
63    .byte   8                       # Address Size (in bytes)
64    .byte   1                       # Abbrev [1] 0xb:0x35 DW_TAG_compile_unit
65    .long   .Linfo_string1          # DW_AT_name
66    .long   .Lline_table_start0     # DW_AT_stmt_list
67    .long   .Linfo_string2          # DW_AT_comp_dir
68    .quad   .Lfunc_begin0           # DW_AT_low_pc
69    .long   .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
70    .byte   2                       # Abbrev [2] 0x2a:0x15 DW_TAG_subprogram
71    .quad   .Lfunc_begin0           # DW_AT_low_pc
72    .long   .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
73    .long   .Linfo_string3          # DW_AT_name
74    .byte   1                       # DW_AT_decl_file
75    .byte   1                       # DW_AT_decl_line
76                                        # DW_AT_external
77    .byte   0                       # End Of Children Mark
78.Ldebug_info_end0:
79
80# Hand-written .debug_line to allow replacing in the absolute path
81# into the filename table at runtime.
82.section .debug_line,"",@progbits
83.Lline_table_start0:
84    .long .Ltable_end - .Ltable_start   # unit length
85.Ltable_start:
86    .short 4                            # version
87    .long .Lheader_end - .Lheader_start # header length
88.Lheader_start:
89    .byte 1                             # min instruction length
90    .byte 1                             # max ops per instruction
91    .byte 1                             # default is_stmt
92    .byte -5                            # line base
93    .byte 14                            # line range
94    .byte 13                            # opcode base
95    .byte 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 # standard opcode lengths
96    .byte 0                             # directory table
97    .asciz "FILEPATH"                   # filename table
98    .byte 0, 0, 0
99    .byte 0
100.Lheader_end:
101    .byte 0, 9, 2                       # DW_LNE_set_address
102    .quad .Lfunc_begin0
103    .byte 1                             # DW_LNS_copy
104    .byte 33                            # +1 address, +1 line
105    .byte 0, 1, 1                       # DW_LNE_end_sequence
106.Ltable_end:
107