@@ -891,6 +891,20 @@ AppleTypesSectionRef::create(MCCASBuilder &MB,
891
891
return get (B->build ());
892
892
}
893
893
894
+ Expected<AppleNamespaceSectionRef>
895
+ AppleNamespaceSectionRef::create (MCCASBuilder &MB,
896
+ ArrayRef<cas::ObjectRef> Fragments) {
897
+ Expected<Builder> B = Builder::startNode (MB.Schema , KindString);
898
+ if (!B)
899
+ return B.takeError ();
900
+
901
+ if (auto E = createGenericDebugSection<AppleNamespaceSectionRef>(
902
+ MB, Fragments, B->Data , B->Refs ))
903
+ return E;
904
+
905
+ return get (B->build ());
906
+ }
907
+
894
908
Expected<uint64_t > SectionRef::materialize (MCCASReader &Reader,
895
909
raw_ostream *Stream) const {
896
910
// Start a new section for relocations.
@@ -1415,6 +1429,14 @@ AppleTypesSectionRef::materialize(MCCASReader &Reader,
1415
1429
*this );
1416
1430
}
1417
1431
1432
+ Expected<uint64_t >
1433
+ AppleNamespaceSectionRef::materialize (MCCASReader &Reader,
1434
+ raw_ostream *Stream) const {
1435
+ StringRef Remaining = getData ();
1436
+ return materializeGenericDebugSection<AppleNamespaceSectionRef>(
1437
+ Reader, Remaining, *this );
1438
+ }
1439
+
1418
1440
Expected<AtomRef> AtomRef::create (MCCASBuilder &MB,
1419
1441
ArrayRef<cas::ObjectRef> Fragments) {
1420
1442
Expected<Builder> B = Builder::startNode (MB.Schema , KindString);
@@ -1752,7 +1774,8 @@ DwarfSectionsCache mccasformats::v1::getDwarfSections(MCAssembler &Asm) {
1752
1774
Asm.getContext ().getObjectFileInfo ()->getDwarfLineStrSection (),
1753
1775
Asm.getContext ().getObjectFileInfo ()->getDwarfDebugNamesSection (),
1754
1776
Asm.getContext ().getObjectFileInfo ()->getDwarfAccelNamesSection (),
1755
- Asm.getContext ().getObjectFileInfo ()->getDwarfAccelTypesSection ()};
1777
+ Asm.getContext ().getObjectFileInfo ()->getDwarfAccelTypesSection (),
1778
+ Asm.getContext ().getObjectFileInfo ()->getDwarfAccelNamespaceSection ()};
1756
1779
}
1757
1780
1758
1781
Error MCCASBuilder::prepare () {
@@ -2730,6 +2753,23 @@ Error MCCASBuilder::createAppleTypesSection() {
2730
2753
return finalizeSection<AppleTypesSectionRef>();
2731
2754
}
2732
2755
2756
+ Error MCCASBuilder::createAppleNamespaceSection () {
2757
+
2758
+ auto MaybeAppleNamespaceRef =
2759
+ createGenericDebugRef<AppleNamespaceRef>(DwarfSections.AppleNamespace );
2760
+ if (!MaybeAppleNamespaceRef)
2761
+ return Error::success ();
2762
+
2763
+ if (!*MaybeAppleNamespaceRef)
2764
+ return MaybeAppleNamespaceRef->takeError ();
2765
+
2766
+ startSection (DwarfSections.AppleNamespace );
2767
+ addNode (**MaybeAppleNamespaceRef);
2768
+ if (auto E = createPaddingRef (DwarfSections.AppleNamespace ))
2769
+ return E;
2770
+ return finalizeSection<AppleNamespaceSectionRef>();
2771
+ }
2772
+
2733
2773
static ArrayRef<char > getFragmentContents (const MCFragment &Fragment) {
2734
2774
switch (Fragment.getKind ()) {
2735
2775
#define MCFRAGMENT_NODE_REF (MCFragmentName, MCEnumName, MCEnumIdentifier ) \
@@ -2924,6 +2964,13 @@ Error MCCASBuilder::buildFragments() {
2924
2964
continue ;
2925
2965
}
2926
2966
2967
+ // Handle Debug AppleNamespace sections separately.
2968
+ if (&Sec == DwarfSections.AppleNamespace ) {
2969
+ if (auto E = createAppleNamespaceSection ())
2970
+ return E;
2971
+ continue ;
2972
+ }
2973
+
2927
2974
// Start Subsection for one section.
2928
2975
startSection (&Sec);
2929
2976
@@ -3087,7 +3134,8 @@ void MCCASBuilder::startSection(const MCSection *Sec) {
3087
3134
Sec != DwarfSections.Loclists && Sec != DwarfSections.Ranges &&
3088
3135
Sec != DwarfSections.Rangelists && Sec != DwarfSections.LineStr &&
3089
3136
Sec != DwarfSections.Names && Sec != DwarfSections.AppleNames &&
3090
- Sec != DwarfSections.AppleTypes )
3137
+ Sec != DwarfSections.AppleTypes &&
3138
+ Sec != DwarfSections.AppleNamespace )
3091
3139
RelMap[R.F ].push_back (R.MRE );
3092
3140
else
3093
3141
// If the fragment is nullptr, it should a section with only relocation
@@ -3308,6 +3356,8 @@ Expected<uint64_t> MCCASReader::materializeGroup(cas::ObjectRef ID) {
3308
3356
return F->materialize (*this );
3309
3357
if (auto F = AppleTypesSectionRef::Cast (*Node))
3310
3358
return F->materialize (*this );
3359
+ if (auto F = AppleNamespaceSectionRef::Cast (*Node))
3360
+ return F->materialize (*this );
3311
3361
if (auto F = CStringRef::Cast (*Node)) {
3312
3362
auto Size = F->materialize (OS);
3313
3363
if (!Size)
@@ -3390,6 +3440,8 @@ Expected<uint64_t> MCCASReader::materializeSection(cas::ObjectRef ID,
3390
3440
return F->materialize (*Stream);
3391
3441
if (auto F = AppleTypesRef::Cast (*Node))
3392
3442
return F->materialize (*Stream);
3443
+ if (auto F = AppleNamespaceRef::Cast (*Node))
3444
+ return F->materialize (*Stream);
3393
3445
if (auto F = AddendsRef::Cast (*Node))
3394
3446
// AddendsRef is already handled when materializing Atoms, skip.
3395
3447
return 0 ;
0 commit comments