@@ -351,30 +351,28 @@ class ObjcCategoryMerger {
351
351
// alignment as already used in existing (input) categories. To do this we
352
352
// have InfoCategoryWriter which contains the various sections that the
353
353
// generated categories will be written to.
354
- template < typename T> struct InfoWriteSection {
354
+ struct InfoWriteSection {
355
355
bool valid = false ; // Data has been successfully collected from input
356
356
uint32_t align = 0 ;
357
357
Section *inputSection;
358
358
Reloc relocTemplate;
359
- T *outputSection;
359
+ OutputSection *outputSection;
360
360
};
361
361
362
362
struct InfoCategoryWriter {
363
- InfoWriteSection<ConcatOutputSection> catListInfo;
364
- InfoWriteSection<ConcatOutputSection> catBodyInfo;
365
- InfoWriteSection<CStringSection> catNameInfo;
366
- InfoWriteSection<ConcatOutputSection> catPtrListInfo;
363
+ InfoWriteSection catListInfo;
364
+ InfoWriteSection catBodyInfo;
365
+ InfoWriteSection catNameInfo;
366
+ InfoWriteSection catPtrListInfo;
367
367
};
368
368
369
369
// Information about a pointer list in the original categories (method lists,
370
370
// protocol lists, etc)
371
371
struct PointerListInfo {
372
- PointerListInfo (const char *_categoryPrefix, uint32_t _categoryOffset,
373
- uint32_t _pointersPerStruct)
374
- : categoryPrefix(_categoryPrefix), categoryOffset(_categoryOffset),
372
+ PointerListInfo (const char *_categoryPrefix, uint32_t _pointersPerStruct)
373
+ : categoryPrefix(_categoryPrefix),
375
374
pointersPerStruct (_pointersPerStruct) {}
376
375
const char *categoryPrefix;
377
- uint32_t categoryOffset = 0 ;
378
376
379
377
uint32_t pointersPerStruct = 0 ;
380
378
@@ -399,25 +397,16 @@ class ObjcCategoryMerger {
399
397
// In case we generate new data, mark the new data as belonging to this file
400
398
ObjFile *objFileForMergeData = nullptr ;
401
399
402
- PointerListInfo instanceMethods = {
403
- objc::symbol_names::categoryInstanceMethods,
404
- /* _categoryOffset=*/ catLayout.instanceMethodsOffset ,
405
- /* pointersPerStruct=*/ 3 };
406
- PointerListInfo classMethods = {
407
- objc::symbol_names::categoryClassMethods,
408
- /* _categoryOffset=*/ catLayout.classMethodsOffset ,
409
- /* pointersPerStruct=*/ 3 };
400
+ PointerListInfo instanceMethods = {objc::symbol_names::instanceMethods,
401
+ /* pointersPerStruct=*/ 3 };
402
+ PointerListInfo classMethods = {objc::symbol_names::categoryClassMethods,
403
+ /* pointersPerStruct=*/ 3 };
410
404
PointerListInfo protocols = {objc::symbol_names::categoryProtocols,
411
- /* _categoryOffset=*/ catLayout.protocolsOffset ,
412
405
/* pointersPerStruct=*/ 0 };
413
- PointerListInfo instanceProps = {
414
- objc::symbol_names::listProprieties,
415
- /* _categoryOffset=*/ catLayout.instancePropsOffset ,
416
- /* pointersPerStruct=*/ 2 };
417
- PointerListInfo classProps = {
418
- objc::symbol_names::klassPropList,
419
- /* _categoryOffset=*/ catLayout.classPropsOffset ,
420
- /* pointersPerStruct=*/ 2 };
406
+ PointerListInfo instanceProps = {objc::symbol_names::listProprieties,
407
+ /* pointersPerStruct=*/ 2 };
408
+ PointerListInfo classProps = {objc::symbol_names::klassPropList,
409
+ /* pointersPerStruct=*/ 2 };
421
410
};
422
411
423
412
public:
@@ -436,9 +425,8 @@ class ObjcCategoryMerger {
436
425
void generateCatListForNonErasedCategories (
437
426
std::map<ConcatInputSection *, std::set<uint64_t >>
438
427
catListToErasedOffsets);
439
- template <typename T>
440
428
void collectSectionWriteInfoFromIsec (const InputSection *isec,
441
- InfoWriteSection<T> &catWriteInfo);
429
+ InfoWriteSection &catWriteInfo);
442
430
void collectCategoryWriterInfoFromCategory (const InfoInputCategory &catInfo);
443
431
void parseCatInfoToExtInfo (const InfoInputCategory &catInfo,
444
432
ClassExtensionInfo &extInfo);
@@ -511,15 +499,12 @@ ObjcCategoryMerger::ObjcCategoryMerger(
511
499
protocolListHeaderLayout(target->wordSize),
512
500
allInputSections(_allInputSections) {}
513
501
514
- // This is a template so that it can be used both for CStringSection and
515
- // ConcatOutputSection
516
- template <typename T>
517
502
void ObjcCategoryMerger::collectSectionWriteInfoFromIsec (
518
- const InputSection *isec, InfoWriteSection<T> &catWriteInfo) {
503
+ const InputSection *isec, InfoWriteSection &catWriteInfo) {
519
504
520
505
catWriteInfo.inputSection = const_cast <Section *>(&isec->section );
521
506
catWriteInfo.align = isec->align ;
522
- catWriteInfo.outputSection = dyn_cast_or_null<T>( isec->parent ) ;
507
+ catWriteInfo.outputSection = isec->parent ;
523
508
524
509
assert (catWriteInfo.outputSection &&
525
510
" outputSection may not be null in collectSectionWriteInfoFromIsec." );
@@ -576,19 +561,19 @@ void ObjcCategoryMerger::collectCategoryWriterInfoFromCategory(
576
561
const InfoInputCategory &catInfo) {
577
562
578
563
if (!infoCategoryWriter.catListInfo .valid )
579
- collectSectionWriteInfoFromIsec<ConcatOutputSection>(
580
- catInfo. catListIsec , infoCategoryWriter.catListInfo );
564
+ collectSectionWriteInfoFromIsec (catInfo. catListIsec ,
565
+ infoCategoryWriter.catListInfo );
581
566
if (!infoCategoryWriter.catBodyInfo .valid )
582
- collectSectionWriteInfoFromIsec<ConcatOutputSection>(
583
- catInfo. catBodyIsec , infoCategoryWriter.catBodyInfo );
567
+ collectSectionWriteInfoFromIsec (catInfo. catBodyIsec ,
568
+ infoCategoryWriter.catBodyInfo );
584
569
585
570
if (!infoCategoryWriter.catNameInfo .valid ) {
586
571
lld::macho::Defined *catNameSym =
587
572
tryGetDefinedAtIsecOffset (catInfo.catBodyIsec , catLayout.nameOffset );
588
573
assert (catNameSym && " Category does not have a valid name Symbol" );
589
574
590
- collectSectionWriteInfoFromIsec<CStringSection>(
591
- catNameSym-> isec (), infoCategoryWriter.catNameInfo );
575
+ collectSectionWriteInfoFromIsec (catNameSym-> isec (),
576
+ infoCategoryWriter.catNameInfo );
592
577
}
593
578
594
579
// Collect writer info from all the category lists (we're assuming they all
@@ -598,8 +583,8 @@ void ObjcCategoryMerger::collectCategoryWriterInfoFromCategory(
598
583
off <= catLayout.classPropsOffset ; off += target->wordSize ) {
599
584
if (Defined *ptrList =
600
585
tryGetDefinedAtIsecOffset (catInfo.catBodyIsec , off)) {
601
- collectSectionWriteInfoFromIsec<ConcatOutputSection>(
602
- ptrList-> isec (), infoCategoryWriter.catPtrListInfo );
586
+ collectSectionWriteInfoFromIsec (ptrList-> isec (),
587
+ infoCategoryWriter.catPtrListInfo );
603
588
// we've successfully collected data, so we can break
604
589
break ;
605
590
}
0 commit comments