@@ -672,45 +672,44 @@ MCContext::getELFUniqueIDForEntsize(StringRef SectionName, unsigned Flags,
672672 : std::nullopt ;
673673}
674674
675- MCSectionGOFF *
676- MCContext::getGOFFSection (SectionKind Kind, GOFF::ESDSymbolType SymbolType,
677- StringRef Name, GOFF::SDAttr SDAttributes,
678- GOFF::EDAttr EDAttributes, GOFF::PRAttr PRAttributes,
679- MCSection *Parent) {
680- GOFFSectionKey T{Name, SymbolType};
675+ template <typename TAttr>
676+ MCSectionGOFF *MCContext::getGOFFSection (SectionKind Kind, StringRef Name,
677+ TAttr Attributes, MCSection *Parent) {
678+ std::string UniqueName (Name);
679+ if (Parent) {
680+ UniqueName.append (" /" ).append (Parent->getName ());
681+ if (auto *P = static_cast <MCSectionGOFF *>(Parent)->getParent ())
682+ UniqueName.append (" /" ).append (P->getName ());
683+ }
681684 // Do the lookup. If we don't have a hit, return a new section.
682- auto IterBool = GOFFUniquingMap.insert (std::make_pair (T , nullptr ));
685+ auto IterBool = GOFFUniquingMap.insert (std::make_pair (UniqueName , nullptr ));
683686 auto Iter = IterBool.first ;
684687 if (!IterBool.second )
685688 return Iter->second ;
686689
687- StringRef CachedName = Iter->first .SectionName ;
688- MCSectionGOFF *GOFFSection = new (GOFFAllocator.Allocate ())
689- MCSectionGOFF (CachedName, Kind, SymbolType, SDAttributes, EDAttributes,
690- PRAttributes, static_cast <MCSectionGOFF *>(Parent));
690+ StringRef CachedName = StringRef (Iter->first .c_str (), Name.size ());
691+ MCSectionGOFF *GOFFSection = new (GOFFAllocator.Allocate ()) MCSectionGOFF (
692+ CachedName, Kind, Attributes, static_cast <MCSectionGOFF *>(Parent));
691693 Iter->second = GOFFSection;
692694 allocInitialFragment (*GOFFSection);
693695 return GOFFSection;
694696}
695697
696698MCSectionGOFF *MCContext::getGOFFSection (SectionKind Kind, StringRef Name,
697699 GOFF::SDAttr SDAttributes) {
698- return getGOFFSection (Kind, GOFF::ESD_ST_SectionDefinition, Name,
699- SDAttributes, GOFF::EDAttr{}, GOFF::PRAttr{}, nullptr );
700+ return getGOFFSection<GOFF::SDAttr>(Kind, Name, SDAttributes, nullptr );
700701}
701702
702703MCSectionGOFF *MCContext::getGOFFSection (SectionKind Kind, StringRef Name,
703704 GOFF::EDAttr EDAttributes,
704705 MCSection *Parent) {
705- return getGOFFSection (Kind, GOFF::ESD_ST_ElementDefinition, Name,
706- GOFF::SDAttr{}, EDAttributes, GOFF::PRAttr{}, Parent);
706+ return getGOFFSection<GOFF::EDAttr>(Kind, Name, EDAttributes, Parent);
707707}
708708
709709MCSectionGOFF *MCContext::getGOFFSection (SectionKind Kind, StringRef Name,
710710 GOFF::PRAttr PRAttributes,
711711 MCSection *Parent) {
712- return getGOFFSection (Kind, GOFF::ESD_ST_PartReference, Name, GOFF::SDAttr{},
713- GOFF::EDAttr{}, PRAttributes, Parent);
712+ return getGOFFSection<GOFF::PRAttr>(Kind, Name, PRAttributes, Parent);
714713}
715714
716715MCSectionCOFF *MCContext::getCOFFSection (StringRef Section,
0 commit comments