@@ -843,7 +843,8 @@ void writeChainedFixup(uint8_t *buf, const Symbol *sym, int64_t addend);
843
843
struct InStruct {
844
844
const uint8_t *bufferStart = nullptr ;
845
845
MachHeaderSection *header = nullptr ;
846
- llvm::StringMap<CStringSection *> cStringSectionMap;
846
+ llvm::SmallVector<CStringSection *> cStringSections;
847
+ CStringSection *cStringSection = nullptr ;
847
848
DeduplicatedCStringSection *objcMethnameSection = nullptr ;
848
849
WordLiteralSection *wordLiteralSection = nullptr ;
849
850
RebaseSection *rebase = nullptr ;
@@ -864,20 +865,25 @@ struct InStruct {
864
865
ObjCMethListSection *objcMethList = nullptr ;
865
866
ChainedFixupsSection *chainedFixups = nullptr ;
866
867
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 ()];
871
874
872
875
std::string &nameData = *make<std::string>(name);
873
876
CStringSection *sec;
874
- if (config->dedupStrings )
877
+ if (config->dedupStrings || forceDedupStrings )
875
878
sec = make<DeduplicatedCStringSection>(nameData.c_str ());
876
879
else
877
880
sec = make<CStringSection>(nameData.c_str ());
878
- cStringSectionMap[name] = sec;
881
+ cStringSections. push_back ( sec) ;
879
882
return sec;
880
883
}
884
+
885
+ private:
886
+ llvm::StringMap<unsigned > cStringSectionMap;
881
887
};
882
888
883
889
extern InStruct in;
0 commit comments