@@ -765,6 +765,20 @@ static Error createGenericDebugSection(MCCASBuilder &MB,
765
765
return Error::success ();
766
766
}
767
767
768
+ Expected<DebugStringOffsetsSectionRef>
769
+ DebugStringOffsetsSectionRef::create (MCCASBuilder &MB,
770
+ ArrayRef<cas::ObjectRef> Fragments) {
771
+ Expected<Builder> B = Builder::startNode (MB.Schema , KindString);
772
+ if (!B)
773
+ return B.takeError ();
774
+
775
+ if (auto E = createGenericDebugSection<DebugStringOffsetsSectionRef>(
776
+ MB, Fragments, B->Data , B->Refs ))
777
+ return E;
778
+
779
+ return get (B->build ());
780
+ }
781
+
768
782
Expected<uint64_t > SectionRef::materialize (MCCASReader &Reader,
769
783
raw_ostream *Stream) const {
770
784
// Start a new section for relocations.
@@ -1218,6 +1232,14 @@ static Expected<uint64_t> materializeGenericDebugSection(MCCASReader &Reader,
1218
1232
return Size;
1219
1233
}
1220
1234
1235
+ Expected<uint64_t >
1236
+ DebugStringOffsetsSectionRef::materialize (MCCASReader &Reader,
1237
+ raw_ostream *Stream) const {
1238
+ StringRef Remaining = getData ();
1239
+ return materializeGenericDebugSection<DebugStringOffsetsSectionRef>(
1240
+ Reader, Remaining, *this );
1241
+ }
1242
+
1221
1243
Expected<AtomRef> AtomRef::create (MCCASBuilder &MB,
1222
1244
ArrayRef<cas::ObjectRef> Fragments) {
1223
1245
Expected<Builder> B = Builder::startNode (MB.Schema , KindString);
@@ -2373,6 +2395,23 @@ MCCASBuilder::createGenericDebugRef(MCSection *Section) {
2373
2395
return *DebugCASRef;
2374
2396
}
2375
2397
2398
+ Error MCCASBuilder::createDebugStrOffsetsSection () {
2399
+
2400
+ auto MaybeDebugStringOffsetsRef =
2401
+ createGenericDebugRef<DebugStrOffsetsRef>(DwarfSections.StrOffsets );
2402
+ if (!MaybeDebugStringOffsetsRef)
2403
+ return Error::success ();
2404
+
2405
+ if (!*MaybeDebugStringOffsetsRef)
2406
+ return MaybeDebugStringOffsetsRef->takeError ();
2407
+
2408
+ startSection (DwarfSections.StrOffsets );
2409
+ addNode (**MaybeDebugStringOffsetsRef);
2410
+ if (auto E = createPaddingRef (DwarfSections.StrOffsets ))
2411
+ return E;
2412
+ return finalizeSection<DebugStringOffsetsSectionRef>();
2413
+ }
2414
+
2376
2415
static ArrayRef<char > getFragmentContents (const MCFragment &Fragment) {
2377
2416
switch (Fragment.getKind ()) {
2378
2417
#define MCFRAGMENT_NODE_REF (MCFragmentName, MCEnumName, MCEnumIdentifier ) \
@@ -2504,6 +2543,13 @@ Error MCCASBuilder::buildFragments() {
2504
2543
continue ;
2505
2544
}
2506
2545
2546
+ // Handle Debug Str Offsets sections separately.
2547
+ if (&Sec == DwarfSections.StrOffsets ) {
2548
+ if (auto E = createDebugStrOffsetsSection ())
2549
+ return E;
2550
+ continue ;
2551
+ }
2552
+
2507
2553
// Start Subsection for one section.
2508
2554
startSection (&Sec);
2509
2555
@@ -2663,7 +2709,7 @@ void MCCASBuilder::startSection(const MCSection *Sec) {
2663
2709
// For the Dwarf Sections, just append the relocations to the
2664
2710
// SectionRelocs. No Atoms are considered for this section.
2665
2711
if (R.F && Sec != DwarfSections.Line && Sec != DwarfSections.DebugInfo &&
2666
- Sec != DwarfSections.Abbrev )
2712
+ Sec != DwarfSections.Abbrev && Sec != DwarfSections. StrOffsets )
2667
2713
RelMap[R.F ].push_back (R.MRE );
2668
2714
else
2669
2715
// If the fragment is nullptr, it should a section with only relocation
@@ -2866,6 +2912,8 @@ Expected<uint64_t> MCCASReader::materializeGroup(cas::ObjectRef ID) {
2866
2912
return F->materialize (*this );
2867
2913
if (auto F = DebugStringSectionRef::Cast (*Node))
2868
2914
return F->materialize (*this );
2915
+ if (auto F = DebugStringOffsetsSectionRef::Cast (*Node))
2916
+ return F->materialize (*this );
2869
2917
if (auto F = CStringRef::Cast (*Node)) {
2870
2918
auto Size = F->materialize (OS);
2871
2919
if (!Size)
@@ -2930,6 +2978,8 @@ Expected<uint64_t> MCCASReader::materializeSection(cas::ObjectRef ID,
2930
2978
Stream->write_zeros (1 );
2931
2979
return *Size + 1 ;
2932
2980
}
2981
+ if (auto F = DebugStrOffsetsRef::Cast (*Node))
2982
+ return F->materialize (*Stream);
2933
2983
if (auto F = AddendsRef::Cast (*Node))
2934
2984
// AddendsRef is already handled when materializing Atoms, skip.
2935
2985
return 0 ;
0 commit comments