@@ -849,6 +849,20 @@ DebugLineStrSectionRef::create(MCCASBuilder &MB,
849
849
return get (B->build ());
850
850
}
851
851
852
+ Expected<DebugNamesSectionRef>
853
+ DebugNamesSectionRef::create (MCCASBuilder &MB,
854
+ ArrayRef<cas::ObjectRef> Fragments) {
855
+ Expected<Builder> B = Builder::startNode (MB.Schema , KindString);
856
+ if (!B)
857
+ return B.takeError ();
858
+
859
+ if (auto E = createGenericDebugSection<DebugNamesSectionRef>(
860
+ MB, Fragments, B->Data , B->Refs ))
861
+ return E;
862
+
863
+ return get (B->build ());
864
+ }
865
+
852
866
Expected<uint64_t > SectionRef::materialize (MCCASReader &Reader,
853
867
raw_ostream *Stream) const {
854
868
// Start a new section for relocations.
@@ -1349,6 +1363,14 @@ DebugLineStrSectionRef::materialize(MCCASReader &Reader,
1349
1363
Reader, Remaining, *this );
1350
1364
}
1351
1365
1366
+ Expected<uint64_t >
1367
+ DebugNamesSectionRef::materialize (MCCASReader &Reader,
1368
+ raw_ostream *Stream) const {
1369
+ StringRef Remaining = getData ();
1370
+ return materializeGenericDebugSection<DebugNamesSectionRef>(Reader, Remaining,
1371
+ *this );
1372
+ }
1373
+
1352
1374
Expected<AtomRef> AtomRef::create (MCCASBuilder &MB,
1353
1375
ArrayRef<cas::ObjectRef> Fragments) {
1354
1376
Expected<Builder> B = Builder::startNode (MB.Schema , KindString);
@@ -1683,7 +1705,8 @@ DwarfSectionsCache mccasformats::v1::getDwarfSections(MCAssembler &Asm) {
1683
1705
Asm.getContext ().getObjectFileInfo ()->getDwarfLoclistsSection (),
1684
1706
Asm.getContext ().getObjectFileInfo ()->getDwarfRangesSection (),
1685
1707
Asm.getContext ().getObjectFileInfo ()->getDwarfRnglistsSection (),
1686
- Asm.getContext ().getObjectFileInfo ()->getDwarfLineStrSection ()};
1708
+ Asm.getContext ().getObjectFileInfo ()->getDwarfLineStrSection (),
1709
+ Asm.getContext ().getObjectFileInfo ()->getDwarfDebugNamesSection ()};
1687
1710
}
1688
1711
1689
1712
Error MCCASBuilder::prepare () {
@@ -2610,6 +2633,23 @@ Error MCCASBuilder::createDebugLineStrSection() {
2610
2633
return finalizeSection<DebugLineStrSectionRef>();
2611
2634
}
2612
2635
2636
+ Error MCCASBuilder::createDebugNamesSection () {
2637
+
2638
+ auto MaybeDebugNamesRef =
2639
+ createGenericDebugRef<DebugNamesRef>(DwarfSections.Names );
2640
+ if (!MaybeDebugNamesRef)
2641
+ return Error::success ();
2642
+
2643
+ if (!*MaybeDebugNamesRef)
2644
+ return MaybeDebugNamesRef->takeError ();
2645
+
2646
+ startSection (DwarfSections.Names );
2647
+ addNode (**MaybeDebugNamesRef);
2648
+ if (auto E = createPaddingRef (DwarfSections.Names ))
2649
+ return E;
2650
+ return finalizeSection<DebugNamesSectionRef>();
2651
+ }
2652
+
2613
2653
static ArrayRef<char > getFragmentContents (const MCFragment &Fragment) {
2614
2654
switch (Fragment.getKind ()) {
2615
2655
#define MCFRAGMENT_NODE_REF (MCFragmentName, MCEnumName, MCEnumIdentifier ) \
@@ -2783,6 +2823,13 @@ Error MCCASBuilder::buildFragments() {
2783
2823
continue ;
2784
2824
}
2785
2825
2826
+ // Handle Debug Names sections separately.
2827
+ if (&Sec == DwarfSections.Names ) {
2828
+ if (auto E = createDebugNamesSection ())
2829
+ return E;
2830
+ continue ;
2831
+ }
2832
+
2786
2833
// Start Subsection for one section.
2787
2834
startSection (&Sec);
2788
2835
@@ -2944,7 +2991,8 @@ void MCCASBuilder::startSection(const MCSection *Sec) {
2944
2991
if (R.F && Sec != DwarfSections.Line && Sec != DwarfSections.DebugInfo &&
2945
2992
Sec != DwarfSections.Abbrev && Sec != DwarfSections.StrOffsets &&
2946
2993
Sec != DwarfSections.Loclists && Sec != DwarfSections.Ranges &&
2947
- Sec != DwarfSections.Rangelists && Sec != DwarfSections.LineStr )
2994
+ Sec != DwarfSections.Rangelists && Sec != DwarfSections.LineStr &&
2995
+ Sec != DwarfSections.Names )
2948
2996
RelMap[R.F ].push_back (R.MRE );
2949
2997
else
2950
2998
// If the fragment is nullptr, it should a section with only relocation
@@ -3159,6 +3207,8 @@ Expected<uint64_t> MCCASReader::materializeGroup(cas::ObjectRef ID) {
3159
3207
return F->materialize (*this );
3160
3208
if (auto F = DebugLineStrSectionRef::Cast (*Node))
3161
3209
return F->materialize (*this );
3210
+ if (auto F = DebugNamesSectionRef::Cast (*Node))
3211
+ return F->materialize (*this );
3162
3212
if (auto F = CStringRef::Cast (*Node)) {
3163
3213
auto Size = F->materialize (OS);
3164
3214
if (!Size)
@@ -3235,6 +3285,8 @@ Expected<uint64_t> MCCASReader::materializeSection(cas::ObjectRef ID,
3235
3285
return F->materialize (*Stream);
3236
3286
if (auto F = DebugLineStrRef::Cast (*Node))
3237
3287
return F->materialize (*Stream);
3288
+ if (auto F = DebugNamesRef::Cast (*Node))
3289
+ return F->materialize (*Stream);
3238
3290
if (auto F = AddendsRef::Cast (*Node))
3239
3291
// AddendsRef is already handled when materializing Atoms, skip.
3240
3292
return 0 ;
0 commit comments