1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
3# RUN: ld.lld --gdb-index %t.o -o %t
4# RUN: llvm-dwarfdump -gdb-index %t | FileCheck %s
5
6# cuIndexAndAttrs of _start:
7#   attributes << 24 | cuIndex = 48 << 24 | 0 = 0x30000000
8# cuIndexAndAttrs of foo:
9#   attributes << 24 | cuIndex = 48 << 24 | 1 = 0x30000001
10# CHECK:      Symbol table
11# CHECK-DAG:      String name: _start, CU vector index: 0
12# CHECK-DAG:      String name: foo, CU vector index: 1
13# CHECK:      Constant pool
14# CHECK-NEXT:   0(0x0): 0x30000000
15# CHECK-NEXT:   1(0x8): 0x30000001
16
17.globl _start, foo
18_start:
19foo:
20
21.section .debug_abbrev,"",@progbits
22	.byte	1              # Abbreviation Code
23	.byte	17             # DW_TAG_compile_unit
24	.byte	1              # DW_CHILDREN_yes
25	.ascii	"\264B"        # DW_AT_GNU_pubnames
26	.byte	25             # DW_FORM_flag_present
27	.byte	0              # EOM(1)
28	.byte	0              # EOM(2)
29	.byte	2              # Abbreviation Code
30	.byte	46             # DW_TAG_subprogram
31	.byte	0              # DW_CHILDREN_no
32	.byte	3              # DW_AT_name
33	.byte	8              # DW_FORM_string
34	.byte	0              # EOM(1)
35	.byte	0              # EOM(2)
36	.byte	0
37
38.section .debug_info,"",@progbits
39.Lcu_begin0:
40	.long	.Lcu_end0 - .Lcu_begin0 - 4
41	.short	4              # DWARF version number
42	.long	0              # Offset Into Abbrev. Section
43	.byte	4              # Address Size
44.Ldie0:
45	.byte	1              # Abbrev [1] DW_TAG_compile_unit
46	.byte	2              # Abbrev [2] DW_TAG_subprogram
47	.asciz	"_start"       # DW_AT_name
48	.byte	0
49	.byte	0
50.Lcu_end0:
51.Lcu_begin1:
52	.long	.Lcu_end1 - .Lcu_begin1 - 4
53	.short	4              # DWARF version number
54	.long	0              # Offset Into Abbrev. Section
55	.byte	4              # Address Size
56.Ldie1:
57	.byte	1              # Abbrev [1] DW_TAG_compile_unit
58	.byte	2              # Abbrev [2] DW_TAG_subprogram
59	.asciz	"foo"          # DW_AT_name
60	.byte	0
61.Lcu_end1:
62
63# Swap sets to test the case where pubnames are in a
64# different order than the CUs they refer to.
65.section .debug_gnu_pubnames,"",@progbits
66	# cuIndex: 1
67	.long	.LpubNames_end1 - .LpubNames_begin1
68.LpubNames_begin1:
69	.short	2              # Version
70	.long	.Lcu_begin1    # CU Offset
71	.long	.Lcu_end1 - .Lcu_begin1
72	.long	.Ldie1 - .Lcu_begin1
73	.byte	48             # Attributes: FUNCTION, EXTERNAL
74	.asciz	"foo"          # External Name
75	.long	0
76.LpubNames_end1:
77
78	# cuIndex: 0
79	.long	.LpubNames_end0 - .LpubNames_begin0
80.LpubNames_begin0:
81	.short	2              # Version
82	.long	.Lcu_begin0    # CU Offset
83	.long	.Lcu_end0 - .Lcu_begin0
84	.long	.Ldie0 - .Lcu_begin0
85	.byte	48             # Attributes: FUNCTION, EXTERNAL
86	.asciz	"_start"       # External Name
87	.long	0
88.LpubNames_end0:
89