@@ -835,6 +835,20 @@ DebugRangelistsSectionRef::create(MCCASBuilder &MB,
835
835
return get (B->build ());
836
836
}
837
837
838
+ Expected<DebugLineStrSectionRef>
839
+ DebugLineStrSectionRef::create (MCCASBuilder &MB,
840
+ ArrayRef<cas::ObjectRef> Fragments) {
841
+ Expected<Builder> B = Builder::startNode (MB.Schema , KindString);
842
+ if (!B)
843
+ return B.takeError ();
844
+
845
+ if (auto E = createGenericDebugSection<DebugLineStrSectionRef>(
846
+ MB, Fragments, B->Data , B->Refs ))
847
+ return E;
848
+
849
+ return get (B->build ());
850
+ }
851
+
838
852
Expected<uint64_t > SectionRef::materialize (MCCASReader &Reader,
839
853
raw_ostream *Stream) const {
840
854
// Start a new section for relocations.
@@ -1327,6 +1341,14 @@ DebugRangelistsSectionRef::materialize(MCCASReader &Reader,
1327
1341
Reader, Remaining, *this );
1328
1342
}
1329
1343
1344
+ Expected<uint64_t >
1345
+ DebugLineStrSectionRef::materialize (MCCASReader &Reader,
1346
+ raw_ostream *Stream) const {
1347
+ StringRef Remaining = getData ();
1348
+ return materializeGenericDebugSection<DebugLineStrSectionRef>(
1349
+ Reader, Remaining, *this );
1350
+ }
1351
+
1330
1352
Expected<AtomRef> AtomRef::create (MCCASBuilder &MB,
1331
1353
ArrayRef<cas::ObjectRef> Fragments) {
1332
1354
Expected<Builder> B = Builder::startNode (MB.Schema , KindString);
@@ -1660,7 +1682,8 @@ DwarfSectionsCache mccasformats::v1::getDwarfSections(MCAssembler &Asm) {
1660
1682
Asm.getContext ().getObjectFileInfo ()->getDwarfLocSection (),
1661
1683
Asm.getContext ().getObjectFileInfo ()->getDwarfLoclistsSection (),
1662
1684
Asm.getContext ().getObjectFileInfo ()->getDwarfRangesSection (),
1663
- Asm.getContext ().getObjectFileInfo ()->getDwarfRnglistsSection ()};
1685
+ Asm.getContext ().getObjectFileInfo ()->getDwarfRnglistsSection (),
1686
+ Asm.getContext ().getObjectFileInfo ()->getDwarfLineStrSection ()};
1664
1687
}
1665
1688
1666
1689
Error MCCASBuilder::prepare () {
@@ -2570,6 +2593,23 @@ Error MCCASBuilder::createDebugRangelistsSection() {
2570
2593
return finalizeSection<DebugRangelistsSectionRef>();
2571
2594
}
2572
2595
2596
+ Error MCCASBuilder::createDebugLineStrSection () {
2597
+
2598
+ auto MaybeDebugLineStrRef =
2599
+ createGenericDebugRef<DebugLineStrRef>(DwarfSections.LineStr );
2600
+ if (!MaybeDebugLineStrRef)
2601
+ return Error::success ();
2602
+
2603
+ if (!*MaybeDebugLineStrRef)
2604
+ return MaybeDebugLineStrRef->takeError ();
2605
+
2606
+ startSection (DwarfSections.LineStr );
2607
+ addNode (**MaybeDebugLineStrRef);
2608
+ if (auto E = createPaddingRef (DwarfSections.LineStr ))
2609
+ return E;
2610
+ return finalizeSection<DebugLineStrSectionRef>();
2611
+ }
2612
+
2573
2613
static ArrayRef<char > getFragmentContents (const MCFragment &Fragment) {
2574
2614
switch (Fragment.getKind ()) {
2575
2615
#define MCFRAGMENT_NODE_REF (MCFragmentName, MCEnumName, MCEnumIdentifier ) \
@@ -2736,6 +2776,13 @@ Error MCCASBuilder::buildFragments() {
2736
2776
continue ;
2737
2777
}
2738
2778
2779
+ // Handle Debug LineStr sections separately.
2780
+ if (&Sec == DwarfSections.LineStr ) {
2781
+ if (auto E = createDebugLineStrSection ())
2782
+ return E;
2783
+ continue ;
2784
+ }
2785
+
2739
2786
// Start Subsection for one section.
2740
2787
startSection (&Sec);
2741
2788
@@ -2897,7 +2944,7 @@ void MCCASBuilder::startSection(const MCSection *Sec) {
2897
2944
if (R.F && Sec != DwarfSections.Line && Sec != DwarfSections.DebugInfo &&
2898
2945
Sec != DwarfSections.Abbrev && Sec != DwarfSections.StrOffsets &&
2899
2946
Sec != DwarfSections.Loclists && Sec != DwarfSections.Ranges &&
2900
- Sec != DwarfSections.Rangelists )
2947
+ Sec != DwarfSections.Rangelists && Sec != DwarfSections. LineStr )
2901
2948
RelMap[R.F ].push_back (R.MRE );
2902
2949
else
2903
2950
// If the fragment is nullptr, it should a section with only relocation
@@ -3110,6 +3157,8 @@ Expected<uint64_t> MCCASReader::materializeGroup(cas::ObjectRef ID) {
3110
3157
return F->materialize (*this );
3111
3158
if (auto F = DebugRangelistsSectionRef::Cast (*Node))
3112
3159
return F->materialize (*this );
3160
+ if (auto F = DebugLineStrSectionRef::Cast (*Node))
3161
+ return F->materialize (*this );
3113
3162
if (auto F = CStringRef::Cast (*Node)) {
3114
3163
auto Size = F->materialize (OS);
3115
3164
if (!Size)
@@ -3184,6 +3233,8 @@ Expected<uint64_t> MCCASReader::materializeSection(cas::ObjectRef ID,
3184
3233
return F->materialize (*Stream);
3185
3234
if (auto F = DebugRangelistsRef::Cast (*Node))
3186
3235
return F->materialize (*Stream);
3236
+ if (auto F = DebugLineStrRef::Cast (*Node))
3237
+ return F->materialize (*Stream);
3187
3238
if (auto F = AddendsRef::Cast (*Node))
3188
3239
// AddendsRef is already handled when materializing Atoms, skip.
3189
3240
return 0 ;
0 commit comments