@@ -426,18 +426,7 @@ StringRef ObjFile<ELFT>::getShtGroupSignature(ArrayRef<Elf_Shdr> sections,
426
426
if (sec.sh_info >= symbols.size ())
427
427
fatal (toString (this ) + " : invalid symbol index" );
428
428
const typename ELFT::Sym &sym = symbols[sec.sh_info ];
429
- StringRef signature = CHECK (sym.getName (this ->stringTable ), this );
430
-
431
- // As a special case, if a symbol is a section symbol and has no name,
432
- // we use a section name as a signature.
433
- //
434
- // Such SHT_GROUP sections are invalid from the perspective of the ELF
435
- // standard, but GNU gold 1.14 (the newest version as of July 2017) or
436
- // older produce such sections as outputs for the -r option, so we need
437
- // a bug-compatibility.
438
- if (signature.empty () && sym.getType () == STT_SECTION)
439
- return getSectionName (sec);
440
- return signature;
429
+ return CHECK (sym.getName (this ->stringTable ), this );
441
430
}
442
431
443
432
template <class ELFT >
@@ -565,10 +554,9 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats) {
565
554
const ELFFile<ELFT> &obj = this ->getObj ();
566
555
567
556
ArrayRef<Elf_Shdr> objSections = CHECK (obj.sections (), this );
557
+ StringRef shstrtab = CHECK (obj.getSectionStringTable (objSections), this );
568
558
uint64_t size = objSections.size ();
569
559
this ->sections .resize (size);
570
- this ->sectionStringTable =
571
- CHECK (obj.getSectionStringTable (objSections), this );
572
560
573
561
std::vector<ArrayRef<Elf_Word>> selectedGroups;
574
562
@@ -624,7 +612,7 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats) {
624
612
.second ;
625
613
if (keepGroup) {
626
614
if (config->relocatable )
627
- this ->sections [i] = createInputSection (sec);
615
+ this ->sections [i] = createInputSection (sec, shstrtab );
628
616
selectedGroups.push_back (entries);
629
617
continue ;
630
618
}
@@ -648,7 +636,7 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats) {
648
636
case SHT_NULL:
649
637
break ;
650
638
default :
651
- this ->sections [i] = createInputSection (sec);
639
+ this ->sections [i] = createInputSection (sec, shstrtab );
652
640
}
653
641
}
654
642
@@ -665,7 +653,7 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats) {
665
653
const Elf_Shdr &sec = objSections[i];
666
654
667
655
if (sec.sh_type == SHT_REL || sec.sh_type == SHT_RELA)
668
- this ->sections [i] = createInputSection (sec);
656
+ this ->sections [i] = createInputSection (sec, shstrtab );
669
657
670
658
// A SHF_LINK_ORDER section with sh_link=0 is handled as if it did not have
671
659
// the flag.
@@ -874,8 +862,9 @@ static InputSection *toRegularSection(MergeInputSection *sec) {
874
862
}
875
863
876
864
template <class ELFT >
877
- InputSectionBase *ObjFile<ELFT>::createInputSection(const Elf_Shdr &sec) {
878
- StringRef name = getSectionName (sec);
865
+ InputSectionBase *ObjFile<ELFT>::createInputSection(const Elf_Shdr &sec,
866
+ StringRef shstrtab) {
867
+ StringRef name = CHECK (getObj ().getSectionName (sec, shstrtab), this );
879
868
880
869
if (config->emachine == EM_ARM && sec.sh_type == SHT_ARM_ATTRIBUTES) {
881
870
ARMAttributeParser attributes;
@@ -1072,11 +1061,6 @@ InputSectionBase *ObjFile<ELFT>::createInputSection(const Elf_Shdr &sec) {
1072
1061
return make<InputSection>(*this , sec, name);
1073
1062
}
1074
1063
1075
- template <class ELFT >
1076
- StringRef ObjFile<ELFT>::getSectionName(const Elf_Shdr &sec) {
1077
- return CHECK (getObj ().getSectionName (sec, sectionStringTable), this );
1078
- }
1079
-
1080
1064
// Initialize this->Symbols. this->Symbols is a parallel array as
1081
1065
// its corresponding ELF symbol table.
1082
1066
template <class ELFT > void ObjFile<ELFT>::initializeSymbols() {
0 commit comments