1; REQUIRES: system-linux 2 3; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5_main.s -o %tmain.o 4; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5_helper.s -o %thelper.o 5; RUN: %clang %cflags -dwarf-5 %tmain.o %thelper.o -o %t.exe -Wl,-q 6; RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --create-debug-names-section=true 7; RUN: llvm-dwarfdump --debug-info -r 0 --debug-names %t.bolt > %t.txt 8; RUN: cat %t.txt | FileCheck --check-prefix=BOLT %s 9 10;; Tests BOLT generates .debug_names with --create-debug-names-section. 11;; Also applicable when binary has CUs that do not contribute to .debug_names pre-bolt. 12 13; BOLT: [[OFFSET1:0x[0-9a-f]*]]: Compile Unit 14; BOLT: [[OFFSET2:0x[0-9a-f]*]]: Compile Unit 15; BOLT: Name Index @ 0x0 { 16; BOLT-NEXT: Header { 17; BOLT-NEXT: Length: 0x155 18; BOLT-NEXT: Format: DWARF32 19; BOLT-NEXT: Version: 5 20; BOLT-NEXT: CU count: 2 21; BOLT-NEXT: Local TU count: 0 22; BOLT-NEXT: Foreign TU count: 0 23; BOLT-NEXT: Bucket count: 10 24; BOLT-NEXT: Name count: 10 25; BOLT-NEXT: Abbreviations table size: 0x29 26; BOLT-NEXT: Augmentation: 'BOLT' 27; BOLT-NEXT: } 28; BOLT-NEXT: Compilation Unit offsets [ 29; BOLT-NEXT: CU[0]: [[OFFSET1]] 30; BOLT-NEXT: CU[1]: [[OFFSET2]] 31; BOLT-NEXT: ] 32; BOLT-NEXT: Abbreviations [ 33; BOLT-NEXT: Abbreviation [[ABBREV1:0x[0-9a-f]*]] { 34; BOLT-NEXT: Tag: DW_TAG_subprogram 35; BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1 36; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4 37; BOLT-NEXT: DW_IDX_parent: DW_FORM_flag_present 38; BOLT-NEXT: } 39; BOLT-NEXT: Abbreviation [[ABBREV2:0x[0-9a-f]*]] { 40; BOLT-NEXT: Tag: DW_TAG_inlined_subroutine 41; BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1 42; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4 43; BOLT-NEXT: DW_IDX_parent: DW_FORM_ref4 44; BOLT-NEXT: } 45; BOLT-NEXT: Abbreviation [[ABBREV3:0x[0-9a-f]*]] { 46; BOLT-NEXT: Tag: DW_TAG_variable 47; BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1 48; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4 49; BOLT-NEXT: DW_IDX_parent: DW_FORM_flag_present 50; BOLT-NEXT: } 51; BOLT-NEXT: Abbreviation [[ABBREV4:0x[0-9a-f]*]] { 52; BOLT-NEXT: Tag: DW_TAG_base_type 53; BOLT-NEXT: DW_IDX_compile_unit: DW_FORM_data1 54; BOLT-NEXT: DW_IDX_die_offset: DW_FORM_ref4 55; BOLT-NEXT: DW_IDX_parent: DW_FORM_flag_present 56; BOLT-NEXT: } 57; BOLT-NEXT: ] 58; BOLT-NEXT: Bucket 0 [ 59; BOLT-NEXT: Name 1 { 60; BOLT-NEXT: Hash: 0x2124BB36 61; BOLT-NEXT: String: {{.+}} "useFoo" 62; BOLT-NEXT: Entry @ {{.+}} { 63; BOLT-NEXT: Abbrev: [[ABBREV1]] 64; BOLT-NEXT: Tag: DW_TAG_subprogram 65; BOLT-NEXT: DW_IDX_compile_unit: 0x01 66; BOLT-NEXT: DW_IDX_die_offset: 0x00000037 67; BOLT-NEXT: DW_IDX_parent: <parent not indexed> 68; BOLT-NEXT: } 69; BOLT-NEXT: Entry @ {{.+}} { 70; BOLT-NEXT: Abbrev: [[ABBREV2]] 71; BOLT-NEXT: Tag: DW_TAG_inlined_subroutine 72; BOLT-NEXT: DW_IDX_compile_unit: 0x01 73; BOLT-NEXT: DW_IDX_die_offset: 0x00000081 74; BOLT-NEXT: DW_IDX_parent: Entry @ 0x14b 75; BOLT-NEXT: } 76; BOLT-NEXT: } 77; BOLT-NEXT: ] 78; BOLT-NEXT: Bucket 1 [ 79; BOLT-NEXT: EMPTY 80; BOLT-NEXT: ] 81; BOLT-NEXT: Bucket 2 [ 82; BOLT-NEXT: Name 2 { 83; BOLT-NEXT: Hash: 0xFDE4B5D2 84; BOLT-NEXT: String: {{.+}} "fooVar" 85; BOLT-NEXT: Entry @ {{.+}} { 86; BOLT-NEXT: Abbrev: [[ABBREV3]] 87; BOLT-NEXT: Tag: DW_TAG_variable 88; BOLT-NEXT: DW_IDX_compile_unit: 0x01 89; BOLT-NEXT: DW_IDX_die_offset: 0x00000028 90; BOLT-NEXT: DW_IDX_parent: <parent not indexed> 91; BOLT-NEXT: } 92; BOLT-NEXT: } 93; BOLT-NEXT: ] 94; BOLT-NEXT: Bucket 3 [ 95; BOLT-NEXT: EMPTY 96; BOLT-NEXT: ] 97; BOLT-NEXT: Bucket 4 [ 98; BOLT-NEXT: EMPTY 99; BOLT-NEXT: ] 100; BOLT-NEXT: Bucket 5 [ 101; BOLT-NEXT: EMPTY 102; BOLT-NEXT: ] 103; BOLT-NEXT: Bucket 6 [ 104; BOLT-NEXT: Name 3 { 105; BOLT-NEXT: Hash: 0xB88B3D2 106; BOLT-NEXT: String: {{.+}} "use" 107; BOLT-NEXT: Entry @ {{.+}} { 108; BOLT-NEXT: Abbrev: [[ABBREV1]] 109; BOLT-NEXT: Tag: DW_TAG_subprogram 110; BOLT-NEXT: DW_IDX_compile_unit: 0x00 111; BOLT-NEXT: DW_IDX_die_offset: 0x00000028 112; BOLT-NEXT: DW_IDX_parent: <parent not indexed> 113; BOLT-NEXT: } 114; BOLT-NEXT: } 115; BOLT-NEXT: Name 4 { 116; BOLT-NEXT: Hash: 0x69A7307E 117; BOLT-NEXT: String: {{.+}} "_Z6useFooPi" 118; BOLT-NEXT: Entry @ {{.+}} { 119; BOLT-NEXT: Abbrev: [[ABBREV1]] 120; BOLT-NEXT: Tag: DW_TAG_subprogram 121; BOLT-NEXT: DW_IDX_compile_unit: 0x01 122; BOLT-NEXT: DW_IDX_die_offset: 0x00000037 123; BOLT-NEXT: DW_IDX_parent: <parent not indexed> 124; BOLT-NEXT: } 125; BOLT-NEXT: Entry @ {{.+}} { 126; BOLT-NEXT: Abbrev: [[ABBREV2]] 127; BOLT-NEXT: Tag: DW_TAG_inlined_subroutine 128; BOLT-NEXT: DW_IDX_compile_unit: 0x01 129; BOLT-NEXT: DW_IDX_die_offset: 0x00000081 130; BOLT-NEXT: DW_IDX_parent: Entry @ 0x14b 131; BOLT-NEXT: } 132; BOLT-NEXT: } 133; BOLT-NEXT: Name 5 { 134; BOLT-NEXT: Hash: 0x7C9A7F6A 135; BOLT-NEXT: String: {{.+}} "main" 136; BOLT-NEXT: Entry @ {{.+}} { 137; BOLT-NEXT: Abbrev: [[ABBREV1]] 138; BOLT-NEXT: Tag: DW_TAG_subprogram 139; BOLT-NEXT: DW_IDX_compile_unit: 0x00 140; BOLT-NEXT: DW_IDX_die_offset: 0x00000049 141; BOLT-NEXT: DW_IDX_parent: <parent not indexed> 142; BOLT-NEXT: } 143; BOLT-NEXT: } 144; BOLT-NEXT: Name 6 { 145; BOLT-NEXT: Hash: 0xB5063CFE 146; BOLT-NEXT: String: {{.+}} "_Z3fooi" 147; BOLT-NEXT: Entry @ {{.+}} { 148; BOLT-NEXT: Abbrev: [[ABBREV1]] 149; BOLT-NEXT: Tag: DW_TAG_subprogram 150; BOLT-NEXT: DW_IDX_compile_unit: 0x01 151; BOLT-NEXT: DW_IDX_die_offset: 0x0000005e 152; BOLT-NEXT: DW_IDX_parent: <parent not indexed> 153; BOLT-NEXT: } 154; BOLT-NEXT: } 155; BOLT-NEXT: ] 156; BOLT-NEXT: Bucket 7 [ 157; BOLT-NEXT: Name 7 { 158; BOLT-NEXT: Hash: 0x8C06E589 159; BOLT-NEXT: String: {{.+}} "_Z3usePiS_" 160; BOLT-NEXT: Entry @ {{.+}} { 161; BOLT-NEXT: Abbrev: [[ABBREV1]] 162; BOLT-NEXT: Tag: DW_TAG_subprogram 163; BOLT-NEXT: DW_IDX_compile_unit: 0x00 164; BOLT-NEXT: DW_IDX_die_offset: 0x00000028 165; BOLT-NEXT: DW_IDX_parent: <parent not indexed> 166; BOLT-NEXT: } 167; BOLT-NEXT: } 168; BOLT-NEXT: ] 169; BOLT-NEXT: Bucket 8 [ 170; BOLT-NEXT: Name 8 { 171; BOLT-NEXT: Hash: 0xB888030 172; BOLT-NEXT: String: {{.+}} "int" 173; BOLT-NEXT: Entry @ {{.+}} { 174; BOLT-NEXT: Abbrev: [[ABBREV4]] 175; BOLT-NEXT: Tag: DW_TAG_base_type 176; BOLT-NEXT: DW_IDX_compile_unit: 0x01 177; BOLT-NEXT: DW_IDX_die_offset: 0x00000033 178; BOLT-NEXT: DW_IDX_parent: <parent not indexed> 179; BOLT-NEXT: } 180; BOLT-NEXT: Entry @ 0x{{.+}} { 181; BOLT-NEXT: Abbrev: [[ABBREV4]] 182; BOLT-NEXT: Tag: DW_TAG_base_type 183; BOLT-NEXT: DW_IDX_compile_unit: 0x00 184; BOLT-NEXT: DW_IDX_die_offset: 0x0000007f 185; BOLT-NEXT: DW_IDX_parent: <parent not indexed> 186; BOLT-NEXT: } 187; BOLT-NEXT: } 188; BOLT-NEXT: ] 189; BOLT-NEXT: Bucket 9 [ 190; BOLT-NEXT: Name 9 { 191; BOLT-NEXT: Hash: 0xB887389 192; BOLT-NEXT: String: {{.+}} "foo" 193; BOLT-NEXT: Entry @ 0x14b { 194; BOLT-NEXT: Abbrev: [[ABBREV1]] 195; BOLT-NEXT: Tag: DW_TAG_subprogram 196; BOLT-NEXT: DW_IDX_compile_unit: 0x01 197; BOLT-NEXT: DW_IDX_die_offset: 0x0000005e 198; BOLT-NEXT: DW_IDX_parent: <parent not indexed> 199; BOLT-NEXT: } 200; BOLT-NEXT: } 201; BOLT-NEXT: Name 10 { 202; BOLT-NEXT: Hash: 0x7C952063 203; BOLT-NEXT: String: {{.+}} "char" 204; BOLT-NEXT: Entry @ {{.+}} { 205; BOLT-NEXT: Abbrev: [[ABBREV4]] 206; BOLT-NEXT: Tag: DW_TAG_base_type 207; BOLT-NEXT: DW_IDX_compile_unit: 0x00 208; BOLT-NEXT: DW_IDX_die_offset: 0x00000092 209; BOLT-NEXT: DW_IDX_parent: <parent not indexed> 210; BOLT-NEXT: } 211; BOLT-NEXT: } 212; BOLT-NEXT: ] 213; BOLT-NEXT: } 214