@@ -201,8 +201,8 @@ class CIE : public FrameEntry {
201
201
SmallString<8 > Augmentation, uint8_t AddressSize,
202
202
uint8_t SegmentDescriptorSize, uint64_t CodeAlignmentFactor,
203
203
int64_t DataAlignmentFactor, uint64_t ReturnAddressRegister,
204
- SmallString<8 > AugmentationData, Optional< uint32_t > FDEPointerEncoding,
205
- Optional< uint32_t > LSDAPointerEncoding)
204
+ SmallString<8 > AugmentationData, uint32_t FDEPointerEncoding,
205
+ uint32_t LSDAPointerEncoding)
206
206
: FrameEntry(FK_CIE, Offset, Length), Version(Version),
207
207
Augmentation (std::move(Augmentation)),
208
208
AddressSize(AddressSize),
@@ -219,10 +219,10 @@ class CIE : public FrameEntry {
219
219
StringRef getAugmentationString () const { return Augmentation; }
220
220
uint64_t getCodeAlignmentFactor () const { return CodeAlignmentFactor; }
221
221
int64_t getDataAlignmentFactor () const { return DataAlignmentFactor; }
222
- Optional< uint32_t > getFDEPointerEncoding () const {
222
+ uint32_t getFDEPointerEncoding () const {
223
223
return FDEPointerEncoding;
224
224
}
225
- Optional< uint32_t > getLSDAPointerEncoding () const {
225
+ uint32_t getLSDAPointerEncoding () const {
226
226
return LSDAPointerEncoding;
227
227
}
228
228
@@ -265,8 +265,8 @@ class CIE : public FrameEntry {
265
265
266
266
// The following are used when the CIE represents an EH frame entry.
267
267
SmallString<8 > AugmentationData;
268
- Optional< uint32_t > FDEPointerEncoding;
269
- Optional< uint32_t > LSDAPointerEncoding;
268
+ uint32_t FDEPointerEncoding;
269
+ uint32_t LSDAPointerEncoding;
270
270
};
271
271
272
272
@@ -556,25 +556,23 @@ void DWARFDebugFrame::parse(DataExtractor Data) {
556
556
uint64_t ReturnAddressRegister = Data.getULEB128 (&Offset);
557
557
558
558
// Parse the augmentation data for EH CIEs
559
- StringRef AugmentationData;
560
- Optional< uint32_t > FDEPointerEncoding;
561
- Optional< uint32_t > LSDAPointerEncoding;
559
+ StringRef AugmentationData ( " " ) ;
560
+ uint32_t FDEPointerEncoding = DW_EH_PE_omit ;
561
+ uint32_t LSDAPointerEncoding = DW_EH_PE_omit ;
562
562
if (IsEH) {
563
563
Optional<uint32_t > PersonalityEncoding;
564
564
Optional<uint64_t > Personality;
565
565
566
- uint64_t AugmentationLength = 0 ;
567
- uint32_t StartAugmentationOffset = 0 ;
568
- uint32_t EndAugmentationOffset = 0 ;
566
+ Optional< uint64_t > AugmentationLength;
567
+ uint32_t StartAugmentationOffset;
568
+ uint32_t EndAugmentationOffset;
569
569
570
570
// Walk the augmentation string to get all the augmentation data.
571
571
for (unsigned i = 0 , e = AugmentationString.size (); i != e; ++i) {
572
572
switch (AugmentationString[i]) {
573
573
default :
574
574
ReportError (" Unknown augmentation character in entry at %lx" );
575
575
case ' L' :
576
- if (LSDAPointerEncoding)
577
- ReportError (" Duplicate LSDA encoding in entry at %lx" );
578
576
LSDAPointerEncoding = Data.getU8 (&Offset);
579
577
break ;
580
578
case ' P' : {
@@ -585,8 +583,6 @@ void DWARFDebugFrame::parse(DataExtractor Data) {
585
583
break ;
586
584
}
587
585
case ' R' :
588
- if (FDEPointerEncoding)
589
- ReportError (" Duplicate FDE encoding in entry at %lx" );
590
586
FDEPointerEncoding = Data.getU8 (&Offset);
591
587
break ;
592
588
case ' z' :
@@ -596,20 +592,22 @@ void DWARFDebugFrame::parse(DataExtractor Data) {
596
592
// the string contains a 'z'.
597
593
AugmentationLength = Data.getULEB128 (&Offset);
598
594
StartAugmentationOffset = Offset;
599
- EndAugmentationOffset =
600
- Offset + static_cast <uint32_t >(AugmentationLength);
595
+ EndAugmentationOffset = Offset +
596
+ static_cast <uint32_t >(* AugmentationLength);
601
597
}
602
598
}
603
599
604
- if (Offset != EndAugmentationOffset)
605
- ReportError (" Parsing augmentation data at %lx failed" );
600
+ if (AugmentationLength.hasValue ()) {
601
+ if (Offset != EndAugmentationOffset)
602
+ ReportError (" Parsing augmentation data at %lx failed" );
606
603
607
- AugmentationData = Data.getData ().slice (StartAugmentationOffset,
608
- EndAugmentationOffset);
604
+ AugmentationData = Data.getData ().slice (StartAugmentationOffset,
605
+ EndAugmentationOffset);
606
+ }
609
607
}
610
608
611
609
auto Cie = make_unique<CIE>(StartOffset, Length, Version,
612
- StringRef (Augmentation) , AddressSize,
610
+ AugmentationString , AddressSize,
613
611
SegmentDescriptorSize, CodeAlignmentFactor,
614
612
DataAlignmentFactor, ReturnAddressRegister,
615
613
AugmentationData, FDEPointerEncoding,
@@ -628,12 +626,11 @@ void DWARFDebugFrame::parse(DataExtractor Data) {
628
626
if (!Cie)
629
627
ReportError (" Parsing FDE data at %lx failed due to missing CIE" );
630
628
631
- Optional<uint32_t > FDEPointerEncoding = Cie->getFDEPointerEncoding ();
632
- if (!FDEPointerEncoding)
633
- ReportError (" Parsing at %lx failed due to missing pointer encoding" );
629
+ InitialLocation = readPointer (Data, Offset,
630
+ Cie->getFDEPointerEncoding ());
631
+ AddressRange = readPointer (Data, Offset,
632
+ Cie->getFDEPointerEncoding ());
634
633
635
- InitialLocation = readPointer (Data, Offset, *FDEPointerEncoding);
636
- AddressRange = readPointer (Data, Offset, *FDEPointerEncoding);
637
634
StringRef AugmentationString = Cie->getAugmentationString ();
638
635
if (!AugmentationString.empty ()) {
639
636
// Parse the augmentation length and data for this FDE.
@@ -644,8 +641,8 @@ void DWARFDebugFrame::parse(DataExtractor Data) {
644
641
645
642
// Decode the LSDA if the CIE augmentation string said we should.
646
643
uint64_t LSDA = 0 ;
647
- if (Optional< uint32_t > Encoding = Cie->getLSDAPointerEncoding ())
648
- LSDA = readPointer (Data, Offset, *Encoding );
644
+ if (Cie->getLSDAPointerEncoding () != DW_EH_PE_omit )
645
+ LSDA = readPointer (Data, Offset, Cie-> getLSDAPointerEncoding () );
649
646
650
647
if (Offset != EndAugmentationOffset)
651
648
ReportError (" Parsing augmentation data at %lx failed" );
0 commit comments