@@ -905,6 +905,20 @@ AppleNamespaceSectionRef::create(MCCASBuilder &MB,
905
905
return get (B->build ());
906
906
}
907
907
908
+ Expected<AppleObjCSectionRef>
909
+ AppleObjCSectionRef::create (MCCASBuilder &MB,
910
+ ArrayRef<cas::ObjectRef> Fragments) {
911
+ Expected<Builder> B = Builder::startNode (MB.Schema , KindString);
912
+ if (!B)
913
+ return B.takeError ();
914
+
915
+ if (auto E = createGenericDebugSection<AppleObjCSectionRef>(MB, Fragments,
916
+ B->Data , B->Refs ))
917
+ return E;
918
+
919
+ return get (B->build ());
920
+ }
921
+
908
922
Expected<uint64_t > SectionRef::materialize (MCCASReader &Reader,
909
923
raw_ostream *Stream) const {
910
924
// Start a new section for relocations.
@@ -1437,6 +1451,13 @@ AppleNamespaceSectionRef::materialize(MCCASReader &Reader,
1437
1451
Reader, Remaining, *this );
1438
1452
}
1439
1453
1454
+ Expected<uint64_t > AppleObjCSectionRef::materialize (MCCASReader &Reader,
1455
+ raw_ostream *Stream) const {
1456
+ StringRef Remaining = getData ();
1457
+ return materializeGenericDebugSection<AppleObjCSectionRef>(Reader, Remaining,
1458
+ *this );
1459
+ }
1460
+
1440
1461
Expected<AtomRef> AtomRef::create (MCCASBuilder &MB,
1441
1462
ArrayRef<cas::ObjectRef> Fragments) {
1442
1463
Expected<Builder> B = Builder::startNode (MB.Schema , KindString);
@@ -1775,7 +1796,8 @@ DwarfSectionsCache mccasformats::v1::getDwarfSections(MCAssembler &Asm) {
1775
1796
Asm.getContext ().getObjectFileInfo ()->getDwarfDebugNamesSection (),
1776
1797
Asm.getContext ().getObjectFileInfo ()->getDwarfAccelNamesSection (),
1777
1798
Asm.getContext ().getObjectFileInfo ()->getDwarfAccelTypesSection (),
1778
- Asm.getContext ().getObjectFileInfo ()->getDwarfAccelNamespaceSection ()};
1799
+ Asm.getContext ().getObjectFileInfo ()->getDwarfAccelNamespaceSection (),
1800
+ Asm.getContext ().getObjectFileInfo ()->getDwarfAccelObjCSection ()};
1779
1801
}
1780
1802
1781
1803
Error MCCASBuilder::prepare () {
@@ -2770,6 +2792,23 @@ Error MCCASBuilder::createAppleNamespaceSection() {
2770
2792
return finalizeSection<AppleNamespaceSectionRef>();
2771
2793
}
2772
2794
2795
+ Error MCCASBuilder::createAppleObjCSection () {
2796
+
2797
+ auto MaybeAppleObjCRef =
2798
+ createGenericDebugRef<AppleObjCRef>(DwarfSections.AppleObjC );
2799
+ if (!MaybeAppleObjCRef)
2800
+ return Error::success ();
2801
+
2802
+ if (!*MaybeAppleObjCRef)
2803
+ return MaybeAppleObjCRef->takeError ();
2804
+
2805
+ startSection (DwarfSections.AppleObjC );
2806
+ addNode (**MaybeAppleObjCRef);
2807
+ if (auto E = createPaddingRef (DwarfSections.AppleObjC ))
2808
+ return E;
2809
+ return finalizeSection<AppleObjCSectionRef>();
2810
+ }
2811
+
2773
2812
static ArrayRef<char > getFragmentContents (const MCFragment &Fragment) {
2774
2813
switch (Fragment.getKind ()) {
2775
2814
#define MCFRAGMENT_NODE_REF (MCFragmentName, MCEnumName, MCEnumIdentifier ) \
@@ -2971,6 +3010,13 @@ Error MCCASBuilder::buildFragments() {
2971
3010
continue ;
2972
3011
}
2973
3012
3013
+ // Handle Debug AppleObjC sections separately.
3014
+ if (&Sec == DwarfSections.AppleObjC ) {
3015
+ if (auto E = createAppleObjCSection ())
3016
+ return E;
3017
+ continue ;
3018
+ }
3019
+
2974
3020
// Start Subsection for one section.
2975
3021
startSection (&Sec);
2976
3022
@@ -3135,7 +3181,7 @@ void MCCASBuilder::startSection(const MCSection *Sec) {
3135
3181
Sec != DwarfSections.Rangelists && Sec != DwarfSections.LineStr &&
3136
3182
Sec != DwarfSections.Names && Sec != DwarfSections.AppleNames &&
3137
3183
Sec != DwarfSections.AppleTypes &&
3138
- Sec != DwarfSections.AppleNamespace )
3184
+ Sec != DwarfSections.AppleNamespace && Sec != DwarfSections. AppleObjC )
3139
3185
RelMap[R.F ].push_back (R.MRE );
3140
3186
else
3141
3187
// If the fragment is nullptr, it should a section with only relocation
@@ -3358,6 +3404,8 @@ Expected<uint64_t> MCCASReader::materializeGroup(cas::ObjectRef ID) {
3358
3404
return F->materialize (*this );
3359
3405
if (auto F = AppleNamespaceSectionRef::Cast (*Node))
3360
3406
return F->materialize (*this );
3407
+ if (auto F = AppleObjCSectionRef::Cast (*Node))
3408
+ return F->materialize (*this );
3361
3409
if (auto F = CStringRef::Cast (*Node)) {
3362
3410
auto Size = F->materialize (OS);
3363
3411
if (!Size)
@@ -3442,6 +3490,8 @@ Expected<uint64_t> MCCASReader::materializeSection(cas::ObjectRef ID,
3442
3490
return F->materialize (*Stream);
3443
3491
if (auto F = AppleNamespaceRef::Cast (*Node))
3444
3492
return F->materialize (*Stream);
3493
+ if (auto F = AppleObjCRef::Cast (*Node))
3494
+ return F->materialize (*Stream);
3445
3495
if (auto F = AddendsRef::Cast (*Node))
3446
3496
// AddendsRef is already handled when materializing Atoms, skip.
3447
3497
return 0 ;
0 commit comments