@@ -556,7 +556,17 @@ DWARFDie DIEBuilder::resolveDIEReference(
556
556
const DWARFAbbreviationDeclaration::AttributeSpec AttrSpec,
557
557
DWARFUnit *&RefCU, DWARFDebugInfoEntry &DwarfDebugInfoEntry) {
558
558
assert (RefValue.isFormClass (DWARFFormValue::FC_Reference));
559
- uint64_t RefOffset = *RefValue.getAsReference ();
559
+ uint64_t RefOffset;
560
+ if (std::optional<uint64_t > Off = RefValue.getAsRelativeReference ()) {
561
+ RefOffset = RefValue.getUnit ()->getOffset () + *Off;
562
+ } else if (Off = RefValue.getAsDebugInfoReference (); Off) {
563
+ RefOffset = *Off;
564
+ } else {
565
+ BC.errs ()
566
+ << " BOLT-WARNING: [internal-dwarf-error]: unsupported reference type: "
567
+ << FormEncodingString (RefValue.getForm ()) << " .\n " ;
568
+ return DWARFDie ();
569
+ }
560
570
return resolveDIEReference (AttrSpec, RefOffset, RefCU, DwarfDebugInfoEntry);
561
571
}
562
572
@@ -607,7 +617,13 @@ void DIEBuilder::cloneDieReferenceAttribute(
607
617
DIE &Die, const DWARFUnit &U, const DWARFDie &InputDIE,
608
618
const DWARFAbbreviationDeclaration::AttributeSpec AttrSpec,
609
619
const DWARFFormValue &Val) {
610
- const uint64_t Ref = *Val.getAsReference ();
620
+ uint64_t Ref;
621
+ if (std::optional<uint64_t > Off = Val.getAsRelativeReference ())
622
+ Ref = Val.getUnit ()->getOffset () + *Off;
623
+ else if (Off = Val.getAsDebugInfoReference (); Off)
624
+ Ref = *Off;
625
+ else
626
+ return ;
611
627
612
628
DIE *NewRefDie = nullptr ;
613
629
DWARFUnit *RefUnit = nullptr ;
0 commit comments