@@ -906,6 +906,20 @@ AppleNamespaceSectionRef::create(MCCASBuilder &MB,
906
906
return get (B->build ());
907
907
}
908
908
909
+ Expected<AppleObjCSectionRef>
910
+ AppleObjCSectionRef::create (MCCASBuilder &MB,
911
+ ArrayRef<cas::ObjectRef> Fragments) {
912
+ Expected<Builder> B = Builder::startNode (MB.Schema , KindString);
913
+ if (!B)
914
+ return B.takeError ();
915
+
916
+ if (auto E = createGenericDebugSection<AppleObjCSectionRef>(MB, Fragments,
917
+ B->Data , B->Refs ))
918
+ return E;
919
+
920
+ return get (B->build ());
921
+ }
922
+
909
923
Expected<uint64_t > SectionRef::materialize (MCCASReader &Reader,
910
924
raw_ostream *Stream) const {
911
925
// Start a new section for relocations.
@@ -1432,6 +1446,13 @@ AppleNamespaceSectionRef::materialize(MCCASReader &Reader,
1432
1446
Reader, Remaining, *this );
1433
1447
}
1434
1448
1449
+ Expected<uint64_t > AppleObjCSectionRef::materialize (MCCASReader &Reader,
1450
+ raw_ostream *Stream) const {
1451
+ StringRef Remaining = getData ();
1452
+ return materializeGenericDebugSection<AppleObjCSectionRef>(Reader, Remaining,
1453
+ *this );
1454
+ }
1455
+
1435
1456
Expected<AtomRef> AtomRef::create (MCCASBuilder &MB,
1436
1457
ArrayRef<cas::ObjectRef> Fragments) {
1437
1458
Expected<Builder> B = Builder::startNode (MB.Schema , KindString);
@@ -1770,7 +1791,8 @@ DwarfSectionsCache mccasformats::v1::getDwarfSections(MCAssembler &Asm) {
1770
1791
Asm.getContext ().getObjectFileInfo ()->getDwarfDebugNamesSection (),
1771
1792
Asm.getContext ().getObjectFileInfo ()->getDwarfAccelNamesSection (),
1772
1793
Asm.getContext ().getObjectFileInfo ()->getDwarfAccelTypesSection (),
1773
- Asm.getContext ().getObjectFileInfo ()->getDwarfAccelNamespaceSection ()};
1794
+ Asm.getContext ().getObjectFileInfo ()->getDwarfAccelNamespaceSection (),
1795
+ Asm.getContext ().getObjectFileInfo ()->getDwarfAccelObjCSection ()};
1774
1796
}
1775
1797
1776
1798
Error MCCASBuilder::prepare () {
@@ -2760,6 +2782,23 @@ Error MCCASBuilder::createAppleNamespaceSection() {
2760
2782
return finalizeSection<AppleNamespaceSectionRef>();
2761
2783
}
2762
2784
2785
+ Error MCCASBuilder::createAppleObjCSection () {
2786
+
2787
+ auto MaybeAppleObjCRef =
2788
+ createGenericDebugRef<AppleObjCRef>(DwarfSections.AppleObjC );
2789
+ if (!MaybeAppleObjCRef)
2790
+ return Error::success ();
2791
+
2792
+ if (!*MaybeAppleObjCRef)
2793
+ return MaybeAppleObjCRef->takeError ();
2794
+
2795
+ startSection (DwarfSections.AppleObjC );
2796
+ addNode (**MaybeAppleObjCRef);
2797
+ if (auto E = createPaddingRef (DwarfSections.AppleObjC ))
2798
+ return E;
2799
+ return finalizeSection<AppleObjCSectionRef>();
2800
+ }
2801
+
2763
2802
static ArrayRef<char > getFragmentContents (const MCFragment &Fragment) {
2764
2803
switch (Fragment.getKind ()) {
2765
2804
#define MCFRAGMENT_NODE_REF (MCFragmentName, MCEnumName, MCEnumIdentifier ) \
@@ -2961,6 +3000,13 @@ Error MCCASBuilder::buildFragments() {
2961
3000
continue ;
2962
3001
}
2963
3002
3003
+ // Handle Debug AppleObjC sections separately.
3004
+ if (&Sec == DwarfSections.AppleObjC ) {
3005
+ if (auto E = createAppleObjCSection ())
3006
+ return E;
3007
+ continue ;
3008
+ }
3009
+
2964
3010
// Start Subsection for one section.
2965
3011
startSection (&Sec);
2966
3012
@@ -3125,7 +3171,7 @@ void MCCASBuilder::startSection(const MCSection *Sec) {
3125
3171
Sec != DwarfSections.Rangelists && Sec != DwarfSections.LineStr &&
3126
3172
Sec != DwarfSections.Names && Sec != DwarfSections.AppleNames &&
3127
3173
Sec != DwarfSections.AppleTypes &&
3128
- Sec != DwarfSections.AppleNamespace )
3174
+ Sec != DwarfSections.AppleNamespace && Sec != DwarfSections. AppleObjC )
3129
3175
RelMap[R.F ].push_back (R.MRE );
3130
3176
else
3131
3177
// If the fragment is nullptr, it should a section with only relocation
@@ -3348,6 +3394,8 @@ Expected<uint64_t> MCCASReader::materializeGroup(cas::ObjectRef ID) {
3348
3394
return F->materialize (*this );
3349
3395
if (auto F = AppleNamespaceSectionRef::Cast (*Node))
3350
3396
return F->materialize (*this );
3397
+ if (auto F = AppleObjCSectionRef::Cast (*Node))
3398
+ return F->materialize (*this );
3351
3399
if (auto F = CStringRef::Cast (*Node)) {
3352
3400
auto Size = F->materialize (OS);
3353
3401
if (!Size)
@@ -3432,6 +3480,8 @@ Expected<uint64_t> MCCASReader::materializeSection(cas::ObjectRef ID,
3432
3480
return F->materialize (*Stream);
3433
3481
if (auto F = AppleNamespaceRef::Cast (*Node))
3434
3482
return F->materialize (*Stream);
3483
+ if (auto F = AppleObjCRef::Cast (*Node))
3484
+ return F->materialize (*Stream);
3435
3485
if (auto F = AddendsRef::Cast (*Node))
3436
3486
// AddendsRef is already handled when materializing Atoms, skip.
3437
3487
return 0 ;
0 commit comments