@@ -779,6 +779,20 @@ DebugStringOffsetsSectionRef::create(MCCASBuilder &MB,
779
779
return get (B->build ());
780
780
}
781
781
782
+ Expected<DebugLoclistsSectionRef>
783
+ DebugLoclistsSectionRef::create (MCCASBuilder &MB,
784
+ ArrayRef<cas::ObjectRef> Fragments) {
785
+ Expected<Builder> B = Builder::startNode (MB.Schema , KindString);
786
+ if (!B)
787
+ return B.takeError ();
788
+
789
+ if (auto E = createGenericDebugSection<DebugLoclistsSectionRef>(
790
+ MB, Fragments, B->Data , B->Refs ))
791
+ return E;
792
+
793
+ return get (B->build ());
794
+ }
795
+
782
796
Expected<uint64_t > SectionRef::materialize (MCCASReader &Reader,
783
797
raw_ostream *Stream) const {
784
798
// Start a new section for relocations.
@@ -1240,6 +1254,14 @@ DebugStringOffsetsSectionRef::materialize(MCCASReader &Reader,
1240
1254
Reader, Remaining, *this );
1241
1255
}
1242
1256
1257
+ Expected<uint64_t >
1258
+ DebugLoclistsSectionRef::materialize (MCCASReader &Reader,
1259
+ raw_ostream *Stream) const {
1260
+ StringRef Remaining = getData ();
1261
+ return materializeGenericDebugSection<DebugLoclistsSectionRef>(
1262
+ Reader, Remaining, *this );
1263
+ }
1264
+
1243
1265
Expected<AtomRef> AtomRef::create (MCCASBuilder &MB,
1244
1266
ArrayRef<cas::ObjectRef> Fragments) {
1245
1267
Expected<Builder> B = Builder::startNode (MB.Schema , KindString);
@@ -1569,7 +1591,8 @@ DwarfSectionsCache mccasformats::v1::getDwarfSections(MCAssembler &Asm) {
1569
1591
Asm.getContext ().getObjectFileInfo ()->getDwarfLineSection (),
1570
1592
Asm.getContext ().getObjectFileInfo ()->getDwarfStrSection (),
1571
1593
Asm.getContext ().getObjectFileInfo ()->getDwarfAbbrevSection (),
1572
- Asm.getContext ().getObjectFileInfo ()->getDwarfStrOffSection ()};
1594
+ Asm.getContext ().getObjectFileInfo ()->getDwarfStrOffSection (),
1595
+ Asm.getContext ().getObjectFileInfo ()->getDwarfLoclistsSection ()};
1573
1596
}
1574
1597
1575
1598
Error MCCASBuilder::prepare () {
@@ -2412,6 +2435,23 @@ Error MCCASBuilder::createDebugStrOffsetsSection() {
2412
2435
return finalizeSection<DebugStringOffsetsSectionRef>();
2413
2436
}
2414
2437
2438
+ Error MCCASBuilder::createDebugLoclistsSection () {
2439
+
2440
+ auto MaybeDebugLoclistsRef =
2441
+ createGenericDebugRef<DebugLoclistsRef>(DwarfSections.Loclists );
2442
+ if (!MaybeDebugLoclistsRef)
2443
+ return Error::success ();
2444
+
2445
+ if (!*MaybeDebugLoclistsRef)
2446
+ return MaybeDebugLoclistsRef->takeError ();
2447
+
2448
+ startSection (DwarfSections.Loclists );
2449
+ addNode (**MaybeDebugLoclistsRef);
2450
+ if (auto E = createPaddingRef (DwarfSections.Loclists ))
2451
+ return E;
2452
+ return finalizeSection<DebugLoclistsSectionRef>();
2453
+ }
2454
+
2415
2455
static ArrayRef<char > getFragmentContents (const MCFragment &Fragment) {
2416
2456
switch (Fragment.getKind ()) {
2417
2457
#define MCFRAGMENT_NODE_REF (MCFragmentName, MCEnumName, MCEnumIdentifier ) \
@@ -2550,6 +2590,13 @@ Error MCCASBuilder::buildFragments() {
2550
2590
continue ;
2551
2591
}
2552
2592
2593
+ // Handle Debug Loclists sections separately.
2594
+ if (&Sec == DwarfSections.Loclists ) {
2595
+ if (auto E = createDebugLoclistsSection ())
2596
+ return E;
2597
+ continue ;
2598
+ }
2599
+
2553
2600
// Start Subsection for one section.
2554
2601
startSection (&Sec);
2555
2602
@@ -2709,7 +2756,8 @@ void MCCASBuilder::startSection(const MCSection *Sec) {
2709
2756
// For the Dwarf Sections, just append the relocations to the
2710
2757
// SectionRelocs. No Atoms are considered for this section.
2711
2758
if (R.F && Sec != DwarfSections.Line && Sec != DwarfSections.DebugInfo &&
2712
- Sec != DwarfSections.Abbrev && Sec != DwarfSections.StrOffsets )
2759
+ Sec != DwarfSections.Abbrev && Sec != DwarfSections.StrOffsets &&
2760
+ Sec != DwarfSections.Loclists )
2713
2761
RelMap[R.F ].push_back (R.MRE );
2714
2762
else
2715
2763
// If the fragment is nullptr, it should a section with only relocation
@@ -2914,6 +2962,8 @@ Expected<uint64_t> MCCASReader::materializeGroup(cas::ObjectRef ID) {
2914
2962
return F->materialize (*this );
2915
2963
if (auto F = DebugStringOffsetsSectionRef::Cast (*Node))
2916
2964
return F->materialize (*this );
2965
+ if (auto F = DebugLoclistsSectionRef::Cast (*Node))
2966
+ return F->materialize (*this );
2917
2967
if (auto F = CStringRef::Cast (*Node)) {
2918
2968
auto Size = F->materialize (OS);
2919
2969
if (!Size)
@@ -2980,6 +3030,8 @@ Expected<uint64_t> MCCASReader::materializeSection(cas::ObjectRef ID,
2980
3030
}
2981
3031
if (auto F = DebugStrOffsetsRef::Cast (*Node))
2982
3032
return F->materialize (*Stream);
3033
+ if (auto F = DebugLoclistsRef::Cast (*Node))
3034
+ return F->materialize (*Stream);
2983
3035
if (auto F = AddendsRef::Cast (*Node))
2984
3036
// AddendsRef is already handled when materializing Atoms, skip.
2985
3037
return 0 ;
0 commit comments