@@ -823,6 +823,8 @@ Expected<const DWARFDebugFrame *> DWARFContext::getDebugFrame() {
823823 if (DebugFrame)
824824 return DebugFrame.get ();
825825
826+ const DWARFSection &DS = DObj->getFrameSection ();
827+
826828 // There's a "bug" in the DWARFv3 standard with respect to the target address
827829 // size within debug frame sections. While DWARF is supposed to be independent
828830 // of its container, FDEs have fields with size being "target address size",
@@ -832,10 +834,11 @@ Expected<const DWARFDebugFrame *> DWARFContext::getDebugFrame() {
832834 // provides this information). This problem is fixed in DWARFv4
833835 // See this dwarf-discuss discussion for more details:
834836 // http://lists.dwarfstd.org/htdig.cgi/dwarf-discuss-dwarfstd.org/2011-December/001173.html
835- DWARFDataExtractor debugFrameData (*DObj, DObj->getFrameSection (),
836- isLittleEndian (), DObj->getAddressSize ());
837- auto DF = std::make_unique<DWARFDebugFrame>(getArch (), /* IsEH=*/ false );
838- if (Error E = DF ->parse (debugFrameData))
837+ DWARFDataExtractor DebugFrameData (*DObj, DS , isLittleEndian (),
838+ DObj->getAddressSize ());
839+ auto DF =
840+ std::make_unique<DWARFDebugFrame>(getArch (), /* IsEH=*/ false , DS .Address );
841+ if (Error E = DF ->parse (DebugFrameData))
839842 return std::move (E);
840843
841844 DebugFrame.swap (DF );
@@ -846,11 +849,13 @@ Expected<const DWARFDebugFrame *> DWARFContext::getEHFrame() {
846849 if (EHFrame)
847850 return EHFrame.get ();
848851
849- DWARFDataExtractor debugFrameData (*DObj, DObj->getEHFrameSection (),
850- isLittleEndian (), DObj->getAddressSize ());
852+ const DWARFSection &DS = DObj->getEHFrameSection ();
853+ DWARFDataExtractor DebugFrameData (*DObj, DS , isLittleEndian (),
854+ DObj->getAddressSize ());
851855
852- auto DF = std::make_unique<DWARFDebugFrame>(getArch (), /* IsEH=*/ true );
853- if (Error E = DF ->parse (debugFrameData))
856+ auto DF =
857+ std::make_unique<DWARFDebugFrame>(getArch (), /* IsEH=*/ true , DS .Address );
858+ if (Error E = DF ->parse (DebugFrameData))
854859 return std::move (E);
855860 DebugFrame.swap (DF );
856861 return DebugFrame.get ();
@@ -1707,6 +1712,9 @@ class DWARFObjInMemory final : public DWARFObject {
17071712 if (Name == " debug_ranges" ) {
17081713 // FIXME: Use the other dwo range section when we emit it.
17091714 RangesDWOSection.Data = Data;
1715+ } else if (Name == " debug_frame" || Name == " eh_frame" ) {
1716+ if (DWARFSection *S = mapNameToDWARFSection (Name))
1717+ S->Address = Section.getAddress ();
17101718 }
17111719 } else if (InfoSectionMap *Sections =
17121720 StringSwitch<InfoSectionMap *>(Name)
0 commit comments