@@ -843,7 +843,8 @@ void writeChainedFixup(uint8_t *buf, const Symbol *sym, int64_t addend);
843843struct InStruct {
844844 const uint8_t *bufferStart = nullptr ;
845845 MachHeaderSection *header = nullptr ;
846- llvm::StringMap<CStringSection *> cStringSectionMap;
846+ llvm::SmallVector<CStringSection *> cStringSections;
847+ CStringSection *cStringSection = nullptr ;
847848 DeduplicatedCStringSection *objcMethnameSection = nullptr ;
848849 WordLiteralSection *wordLiteralSection = nullptr ;
849850 RebaseSection *rebase = nullptr ;
@@ -864,20 +865,25 @@ struct InStruct {
864865 ObjCMethListSection *objcMethList = nullptr ;
865866 ChainedFixupsSection *chainedFixups = nullptr ;
866867
867- CStringSection *getOrCreateCStringSection (StringRef name) {
868- auto it = cStringSectionMap.find (name);
869- if (it != cStringSectionMap.end ())
870- return it->getValue ();
868+ CStringSection *getOrCreateCStringSection (StringRef name,
869+ bool forceDedupStrings = false ) {
870+ auto [it, didEmplace] =
871+ cStringSectionMap.try_emplace (name, cStringSections.size ());
872+ if (!didEmplace)
873+ return cStringSections[it->getValue ()];
871874
872875 std::string &nameData = *make<std::string>(name);
873876 CStringSection *sec;
874- if (config->dedupStrings )
877+ if (config->dedupStrings || forceDedupStrings )
875878 sec = make<DeduplicatedCStringSection>(nameData.c_str ());
876879 else
877880 sec = make<CStringSection>(nameData.c_str ());
878- cStringSectionMap[name] = sec;
881+ cStringSections. push_back ( sec) ;
879882 return sec;
880883 }
884+
885+ private:
886+ llvm::StringMap<unsigned > cStringSectionMap;
881887};
882888
883889extern InStruct in;
0 commit comments