llvm.org GIT mirror llvm / 09f089a
[DWARF] Add CIE header fields address_size and segment_size when generating dwarf-4 The DWARF-4 specification added 2 new fields in the CIE header called address_size and segment_size. Create these 2 new fields when generating dwarf-4 CIE entries, print out the new fields when dumping the CIE and update tests Differential Revision: http://reviews.llvm.org/D9558 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237145 91177308-0d34-0410-b5e6-96231b3b80d8 Keith Walker 4 years ago
5 changed file(s) with 56 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
188188 // CIEs (and FDEs) are simply container classes, so the only sensible way to
189189 // create them is by providing the full parsed contents in the constructor.
190190 CIE(uint64_t Offset, uint64_t Length, uint8_t Version,
191 SmallString<8> Augmentation, uint64_t CodeAlignmentFactor,
191 SmallString<8> Augmentation, uint8_t AddressSize,
192 uint8_t SegmentDescriptorSize, uint64_t CodeAlignmentFactor,
192193 int64_t DataAlignmentFactor, uint64_t ReturnAddressRegister)
193194 : FrameEntry(FK_CIE, Offset, Length), Version(Version),
194195 Augmentation(std::move(Augmentation)),
196 AddressSize(AddressSize),
197 SegmentDescriptorSize(SegmentDescriptorSize),
195198 CodeAlignmentFactor(CodeAlignmentFactor),
196199 DataAlignmentFactor(DataAlignmentFactor),
197200 ReturnAddressRegister(ReturnAddressRegister) {}
207210 << "\n";
208211 OS << format(" Version: %d\n", Version);
209212 OS << " Augmentation: \"" << Augmentation << "\"\n";
213 if (Version >= 4) {
214 OS << format(" Address size: %u\n",
215 (uint32_t)AddressSize);
216 OS << format(" Segment desc size: %u\n",
217 (uint32_t)SegmentDescriptorSize);
218 }
210219 OS << format(" Code alignment factor: %u\n",
211220 (uint32_t)CodeAlignmentFactor);
212221 OS << format(" Data alignment factor: %d\n",
221230 }
222231
223232 private:
224 /// The following fields are defined in section 6.4.1 of the DWARF standard v3
233 /// The following fields are defined in section 6.4.1 of the DWARF standard v4
225234 uint8_t Version;
226235 SmallString<8> Augmentation;
236 uint8_t AddressSize;
237 uint8_t SegmentDescriptorSize;
227238 uint64_t CodeAlignmentFactor;
228239 int64_t DataAlignmentFactor;
229240 uint64_t ReturnAddressRegister;
460471 bool IsCIE = ((IsDWARF64 && Id == DW64_CIE_ID) || Id == DW_CIE_ID);
461472
462473 if (IsCIE) {
463 // Note: this is specifically DWARFv3 CIE header structure. It was
464 // changed in DWARFv4. We currently don't support reading DWARFv4
465 // here because LLVM itself does not emit it (and LLDB doesn't
466 // support it either).
467474 uint8_t Version = Data.getU8(&Offset);
468475 const char *Augmentation = Data.getCStr(&Offset);
476 uint8_t AddressSize = Version < 4 ? Data.getAddressSize() : Data.getU8(&Offset);
477 Data.setAddressSize(AddressSize);
478 uint8_t SegmentDescriptorSize = Version < 4 ? 0 : Data.getU8(&Offset);
469479 uint64_t CodeAlignmentFactor = Data.getULEB128(&Offset);
470480 int64_t DataAlignmentFactor = Data.getSLEB128(&Offset);
471481 uint64_t ReturnAddressRegister = Data.getULEB128(&Offset);
472482
473483 auto Cie = make_unique(StartOffset, Length, Version,
474 StringRef(Augmentation), CodeAlignmentFactor,
484 StringRef(Augmentation), AddressSize,
485 SegmentDescriptorSize, CodeAlignmentFactor,
475486 DataAlignmentFactor, ReturnAddressRegister);
476487 CIEs[StartOffset] = Cie.get();
477488 Entries.emplace_back(std::move(Cie));
13011301 }
13021302 streamer.EmitIntValue(0, 1);
13031303
1304 if (CIEVersion >= 4) {
1305 // Address Size
1306 streamer.EmitIntValue(context.getAsmInfo()->getPointerSize(), 1);
1307
1308 // Segment Descriptor Size
1309 streamer.EmitIntValue(0, 1);
1310 }
1311
13041312 // Code Alignment Factor
13051313 streamer.EmitULEB128IntValue(context.getAsmInfo()->getMinInstAlignment());
13061314
1212 # When llvm-dwarfdump prints the full info for the DW_CFA_def_cfa
1313 # field, we can check that here too.
1414 # CHECK: DW_CFA_def_cfa:
15 # The following 2 DW_CFA_nop instructions are "padding"
16 # CHECK: DW_CFA_nop:
17 # CHECK: DW_CFA_nop:
1518 # CHECK-NOT: DW_CFA
1619 # CHECK: FDE
None // RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -sd | FileCheck -check-prefix=ELF_64 %s
1 // RUN: llvm-mc -filetype=obj -triple i686-pc-linux-gnu %s -o - | llvm-readobj -s -sd | FileCheck -check-prefix=ELF_32 %s
0 // RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu -dwarf-version 2 %s -o - | llvm-readobj -s -sd | FileCheck -check-prefix=ELF_64 -check-prefix=ELF_64_DWARF_2 %s
1 // RUN: llvm-mc -filetype=obj -triple i686-pc-linux-gnu -dwarf-version 2 %s -o - | llvm-readobj -s -sd | FileCheck -check-prefix=ELF_32 -check-prefix=ELF_32_DWARF_2 %s
2
3 // RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu -dwarf-version 3 %s -o - | llvm-readobj -s -sd | FileCheck -check-prefix=ELF_64 -check-prefix=ELF_64_DWARF_3 %s
4 // RUN: llvm-mc -filetype=obj -triple i686-pc-linux-gnu -dwarf-version 3 %s -o - | llvm-readobj -s -sd | FileCheck -check-prefix=ELF_32 -check-prefix=ELF_32_DWARF_3 %s
5
6 // RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu -dwarf-version 4 %s -o - | llvm-readobj -s -sd | FileCheck -check-prefix=ELF_64 -check-prefix=ELF_64_DWARF_4 %s
7 // RUN: llvm-mc -filetype=obj -triple i686-pc-linux-gnu -dwarf-version 4 %s -o - | llvm-readobj -s -sd | FileCheck -check-prefix=ELF_32 -check-prefix=ELF_32_DWARF_4 %s
28
39 .cfi_sections .debug_frame
410
2531 // ELF_64-NEXT: AddressAlignment: 8
2632 // ELF_64-NEXT: EntrySize: 0
2733 // ELF_64-NEXT: SectionData (
28 // ELF_64-NEXT: 0000: 14000000 FFFFFFFF 04000178 100C0708
29 // ELF_64-NEXT: 0010: 90010000 00000000 14000000 00000000
34 // ELF_64_DWARF_2-NEXT: 0000: 14000000 FFFFFFFF 01000178 100C0708
35 // ELF_64_DWARF_2-NEXT: 0010: 90010000 00000000 14000000 00000000
36 // ELF_64_DWARF_3-NEXT: 0000: 14000000 FFFFFFFF 03000178 100C0708
37 // ELF_64_DWARF_3-NEXT: 0010: 90010000 00000000 14000000 00000000
38 // ELF_64_DWARF_4-NEXT: 0000: 14000000 FFFFFFFF 04000800 0178100C
39 // ELF_64_DWARF_4-NEXT: 0010: 07089001 00000000 14000000 00000000
3040 // ELF_64-NEXT: 0020: 00000000 00000000 01000000 00000000
3141 // ELF_64-NEXT: 0030: 14000000 00000000 00000000 00000000
3242 // ELF_64-NEXT: 0040: 01000000 00000000
4656 // ELF_32-NEXT: AddressAlignment: 4
4757 // ELF_32-NEXT: EntrySize: 0
4858 // ELF_32-NEXT: SectionData (
49 // ELF_32-NEXT: 0000: 10000000 FFFFFFFF 0400017C 080C0404
50 // ELF_32-NEXT: 0010: 88010000 0C000000 00000000 00000000
59 // ELF_32_DWARF_2-NEXT: 0000: 10000000 FFFFFFFF 0100017C 080C0404
60 // ELF_32_DWARF_2-NEXT: 0010: 88010000 0C000000 00000000 00000000
61 // ELF_32_DWARF_3-NEXT: 0000: 10000000 FFFFFFFF 0300017C 080C0404
62 // ELF_32_DWARF_3-NEXT: 0010: 88010000 0C000000 00000000 00000000
63 // ELF_32_DWARF_4-NEXT: 0000: 10000000 FFFFFFFF 04000400 017C080C
64 // ELF_32_DWARF_4-NEXT: 0010: 04048801 0C000000 00000000 00000000
5165 // ELF_32-NEXT: 0020: 01000000 0C000000 00000000 01000000
5266 // ELF_32-NEXT: 0030: 01000000
67
5368 // ELF_32-NEXT: )
5469 // ELF_32-NEXT: }
3838 ; DWARF2: .debug_frame contents:
3939 ; DWARF2: Version: 1
4040 ; DWARF2-NEXT: Augmentation:
41 ; DWARF2-NOT: Address size:
42 ; DWARF2-NOT: Segment desc size:
4143
4244 ; DWARF3: .debug_frame contents:
4345 ; DWARF3: Version: 3
4446 ; DWARF3-NEXT: Augmentation:
47 ; DWARF3-NOT: Address size:
48 ; DWARF3-NOT: Segment desc size:
4549
4650 ; DWARF4: .debug_frame contents:
4751 ; DWARF4: Version: 4
4852 ; DWARF4-NEXT: Augmentation:
53 ; DWARF4: Address size:
54 ; DWARF4: Segment desc size: