xref: /aosp_15_r20/external/elfutils/tests/testfile-dwp-cu-index-overflow.source (revision 7304104da70ce23c86437a01be71edd1a2d7f37e)
1# Dummy program that we patch to generate a dwp file with more than 4GB of
2# .debug_info.
3
4# Generate 2 dummy files that result in DWARF blocks.
5$ for (( i = 1; i <= 2; i++ )); do echo 'constexpr int filler'$i'[] = { 1 };' > filler$i.cc; done
6$ g++ -O2 -g -gsplit-dwarf -fdebug-types-section -dA -S filler{1,2}.cc foo.cc bar.cc main.cc
7# Patch the DWARF blocks to be 2GB.
8$ for (( i = 1; i <= 2; i++ )); do patch -p1 << EOF
9--- a/filler$i.s
10+++ b/filler$i.s
11@@ -7,5 +7,5 @@
12 	.section	.debug_info.dwo,"e",@progbits
13 .Ldebug_info0:
14-	.long	0x49	# Length of Compilation Unit Info
15+	.long	0x80000048	# Length of Compilation Unit Info
16 	.value	0x5	# DWARF version number
17 	.byte	0x5	# DW_UT_split_compile
18@@ -51,9 +51,6 @@
19 	.long	0x29	# DW_AT_type
20 			# DW_AT_const_expr
21-	.byte	0x4	# DW_AT_const_value
22-	.byte	0x1	# fp or vector constant word 0
23-	.byte	0	# fp or vector constant word 1
24-	.byte	0	# fp or vector constant word 2
25-	.byte	0	# fp or vector constant word 3
26+	.long	0x80000000	# DW_AT_const_value
27+	.fill	0x80000000
28 	.byte	0	# end of children of DIE 0x14
29 	.section	.debug_info,"",@progbits
30@@ -171,5 +168,5 @@
31 	.uleb128 0x19	# (DW_FORM_flag_present)
32 	.uleb128 0x1c	# (DW_AT_const_value)
33-	.uleb128 0xa	# (DW_FORM_block1)
34+	.uleb128 0x4	# (DW_FORM_block4)
35 	.byte	0
36 	.byte	0
37EOF
38done
39$ for (( i = 1; i <= 2; i++ )); do as filler$i.s -o filler$i.o; done
40$ as foo.s -o foo.o
41$ as bar.s -o bar.o
42$ as main.s -o main.o
43$ g++ filler1.o foo.o filler2.o bar.o main.o -o testfile-dwp-5-cu-index-overflow
44# -continue-on-cu-index-overflow was added in LLVM 17:
45# https://reviews.llvm.org/D144565.
46$ llvm-dwp -continue-on-cu-index-overflow filler1.o foo.o filler2.o bar.o main.o -o testfile-dwp-5-cu-index-overflow.dwp
47
48# Same thing for DWARF 4.
49$ g++ -O2 -g -gdwarf-4 -gsplit-dwarf -fdebug-types-section -dA -S filler{1,2}.cc foo.cc bar.cc main.cc
50$ for (( i = 1; i <= 2; i++ )); do patch -p1 << EOF
51--- a/filler$i.s
52+++ b/filler$i.s
53@@ -6,5 +6,5 @@
54 	.section	.debug_info.dwo,"e",@progbits
55 .Ldebug_info0:
56-	.long	0x48	# Length of Compilation Unit Info
57+	.long	0x80000047	# Length of Compilation Unit Info
58 	.value	0x4	# DWARF version number
59 	.long	.Ldebug_abbrev0	# Offset Into Abbrev. Section
60@@ -49,9 +49,6 @@
61 	.long	0x28	# DW_AT_type
62 			# DW_AT_const_expr
63-	.byte	0x4	# DW_AT_const_value
64-	.byte	0x1	# fp or vector constant word 0
65-	.byte	0	# fp or vector constant word 1
66-	.byte	0	# fp or vector constant word 2
67-	.byte	0	# fp or vector constant word 3
68+	.long	0x80000000	# DW_AT_const_value
69+	.fill	0x80000000
70 	.byte	0	# end of children of DIE 0xb
71 	.section	.debug_info,"",@progbits
72@@ -172,5 +169,5 @@
73 	.uleb128 0x19	# (DW_FORM_flag_present)
74 	.uleb128 0x1c	# (DW_AT_const_value)
75-	.uleb128 0xa	# (DW_FORM_block1)
76+	.uleb128 0x4	# (DW_FORM_block4)
77 	.byte	0
78 	.byte	0
79EOF
80done
81$ for (( i = 1; i <= 2; i++ )); do as filler$i.s -o filler$i.o; done
82$ as foo.s -o foo.o
83$ as bar.s -o bar.o
84$ as main.s -o main.o
85$ g++ filler1.o foo.o filler2.o bar.o main.o -o testfile-dwp-4-cu-index-overflow
86$ llvm-dwp -continue-on-cu-index-overflow filler1.o foo.o filler2.o bar.o main.o -o testfile-dwp-4-cu-index-overflow.dwp
87