llvm.org GIT mirror llvm / 98ef347
Downgrade DWARF2 section limit error to a warning We currently emit an error when trying to assemble a file with more than one section using DWARF2 debug info. This should be a warning instead, as the resulting file will still be usable, but with a degraded debug illusion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218241 91177308-0d34-0410-b5e6-96231b3b80d8 Oliver Stannard 6 years ago
4 changed file(s) with 75 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
535535 MCOS->EmitULEB128IntValue(dwarf::DW_TAG_compile_unit);
536536 MCOS->EmitIntValue(dwarf::DW_CHILDREN_yes, 1);
537537 EmitAbbrev(MCOS, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4);
538 if (MCOS->getContext().getGenDwarfSectionSyms().size() > 1) {
538 if (MCOS->getContext().getGenDwarfSectionSyms().size() > 1 &&
539 MCOS->getContext().getDwarfVersion() >= 3) {
539540 EmitAbbrev(MCOS, dwarf::DW_AT_ranges, dwarf::DW_FORM_data4);
540541 } else {
541542 EmitAbbrev(MCOS, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr);
872873 if (MCOS->getContext().getGenDwarfSectionSyms().empty())
873874 return;
874875
875 // We only need to use the .debug_ranges section if we have multiple
876 // code sections.
876 // We only use the .debug_ranges section if we have multiple code sections,
877 // and we are emitting a DWARF version which supports it.
877878 const bool UseRangesSection =
878 MCOS->getContext().getGenDwarfSectionSyms().size() > 1;
879 MCOS->getContext().getGenDwarfSectionSyms().size() > 1 &&
880 MCOS->getContext().getDwarfVersion() >= 3;
879881 CreateDwarfSectionSymbols |= UseRangesSection;
880882
881883 MCOS->SwitchSection(context.getObjectFileInfo()->getDwarfInfoSection());
554554 std::make_pair(ELFSection, std::make_pair(nullptr, nullptr)));
555555 if (InsertResult.second) {
556556 if (getContext().getDwarfVersion() <= 2)
557 Error(loc, "DWARF2 only supports one section per compilation unit");
557 Warning(loc, "DWARF2 only supports one section per compilation unit");
558558
559559 MCSymbol *SectionStartSymbol = getContext().CreateTempSymbol();
560560 getStreamer().EmitLabel(SectionStartSymbol);
0 // RUN: llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -fdebug-compilation-dir=/tmp -dwarf-version 2 2>&1 | FileCheck -check-prefix MESSAGES %s
1 // RUN: llvm-dwarfdump %t | FileCheck -check-prefix DWARF %s
2 // RUN: llvm-objdump -r %t | FileCheck -check-prefix RELOC %s
3
4 .section .text, "ax"
5 a:
6 mov r0, r0
7
8 .section foo, "ax"
9 b:
10 mov r1, r1
11
12 // MESSAGES: warning: DWARF2 only supports one section per compilation unit
13
14 // DWARF: .debug_abbrev contents:
15 // DWARF: Abbrev table for offset: 0x00000000
16 // DWARF: [1] DW_TAG_compile_unit DW_CHILDREN_yes
17 // DWARF: DW_AT_stmt_list DW_FORM_data4
18 // DWARF: DW_AT_low_pc DW_FORM_addr
19 // DWARF: DW_AT_high_pc DW_FORM_addr
20 // DWARF: DW_AT_name DW_FORM_string
21 // DWARF: DW_AT_comp_dir DW_FORM_string
22 // DWARF: DW_AT_producer DW_FORM_string
23 // DWARF: DW_AT_language DW_FORM_data2
24
25 // DWARF: .debug_info contents:
26 // DWARF: 0x{{[0-9a-f]+}}: DW_TAG_compile_unit [1]
27 // CHECK-NOT-DWARF: DW_TAG_
28 // DWARF: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
29 // DWARF: DW_AT_high_pc [DW_FORM_addr] (0x0000000000000004)
30
31 // DWARF: 0x{{[0-9a-f]+}}: DW_TAG_label [2] *
32 // DWARF-NEXT: DW_AT_name [DW_FORM_string] ("a")
33
34
35 // DWARF: .debug_aranges contents:
36 // DWARF-NEXT: Address Range Header: length = 0x00000024, version = 0x0002, cu_offset = 0x00000000, addr_size = 0x04, seg_size = 0x00
37 // DWARF-NEXT: [0x00000000 - 0x00000004)
38 // DWARF-NEXT: [0x00000000 - 0x00000004)
39
40 // DWARF: .debug_line contents:
41 // DWARF: 0x0000000000000000 7 0 1 0 0 is_stmt
42 // DWARF-NEXT: 0x0000000000000004 7 0 1 0 0 is_stmt end_sequence
43 // DWARF: 0x0000000000000000 11 0 1 0 0 is_stmt
44 // DWARF-NEXT: 0x0000000000000004 11 0 1 0 0 is_stmt end_sequence
45
46
47 // DWARF: .debug_ranges contents:
48 // DWARF-NOT: {{0-9a-f}}
49 // DWARF: .debug_pubnames contents:
50
51
52 // RELOC: RELOCATION RECORDS FOR [.rel.debug_info]:
53 // RELOC-NEXT: 00000006 R_ARM_ABS32 .debug_abbrev
54 // RELOC-NEXT: 0000000c R_ARM_ABS32 .debug_line
55 // RELOC-NEXT: R_ARM_ABS32 .text
56 // RELOC-NEXT: R_ARM_ABS32 .text
57 // RELOC-NEXT: R_ARM_ABS32 .text
58 // RELOC-NEXT: R_ARM_ABS32 foo
59
60 // RELOC-NOT: RELOCATION RECORDS FOR [.rel.debug_ranges]:
61
62 // RELOC: RELOCATION RECORDS FOR [.rel.debug_aranges]:
63 // RELOC-NEXT: 00000006 R_ARM_ABS32 .debug_info
64 // RELOC-NEXT: 00000010 R_ARM_ABS32 .text
65 // RELOC-NEXT: 00000018 R_ARM_ABS32 foo
0 // RUN: llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -fdebug-compilation-dir=/tmp
11 // RUN: llvm-dwarfdump %t | FileCheck -check-prefix DWARF %s
22 // RUN: llvm-objdump -r %t | FileCheck -check-prefix RELOC %s
3 // RUN: not llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -dwarf-version 2 2>&1 | FileCheck -check-prefix VERSION %s
3 // RUN: llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -dwarf-version 2 2>&1 | FileCheck -check-prefix VERSION %s
44 // RUN: not llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -dwarf-version 1 2>&1 | FileCheck -check-prefix DWARF1 %s
55 // RUN: not llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -dwarf-version 5 2>&1 | FileCheck -check-prefix DWARF5 %s
66 .section .text, "ax"
7272 // RELOC-NEXT: 00000018 R_ARM_ABS32 foo
7373
7474
75 // VERSION: {{.*}} error: DWARF2 only supports one section per compilation unit
75 // VERSION: {{.*}} warning: DWARF2 only supports one section per compilation unit
7676
7777 // DWARF1: Dwarf version 1 is not supported.
7878 // DWARF5: Dwarf version 5 is not supported.