@@ -126,7 +126,7 @@ Error COFFWriter::finalizeSymIdxContents() {
126126 if (!NeedUpdate)
127127 return Error::success ();
128128
129- for (auto &Sec : Obj.getMutableSections ()) {
129+ for (Section &Sec : Obj.getMutableSections ()) {
130130 if (!IsSymIdxSection (Sec.Name ))
131131 continue ;
132132
@@ -136,7 +136,8 @@ Error COFFWriter::finalizeSymIdxContents() {
136136 if (RawIds.size () == 0 )
137137 continue ;
138138
139- if (!SecIdMap.contains (Sec.UniqueId ))
139+ auto SecDefIt = SecIdMap.find (Sec.UniqueId );
140+ if (SecDefIt == SecIdMap.end ())
140141 return createStringError (object_error::invalid_symbol_index,
141142 " section '%s' does not have the corresponding "
142143 " symbol or the symbol has unexpected format" ,
@@ -147,21 +148,22 @@ Error COFFWriter::finalizeSymIdxContents() {
147148 reinterpret_cast <const support::ulittle32_t *>(RawIds.data ()),
148149 RawIds.size () / 4 );
149150 std::vector<support::ulittle32_t > NewIds;
150- for (auto Id : Ids) {
151- if (!SymIdMap.contains (Id))
151+ for (support::ulittle32_t Id : Ids) {
152+ auto SymIdIt = SymIdMap.find (Id);
153+ if (SymIdIt == SymIdMap.end ())
152154 return createStringError (object_error::invalid_symbol_index,
153155 " section '%s' contains a .symidx (%d) that is "
154156 " incorrect or was stripped" ,
155157 Sec.Name .str ().c_str (), Id.value ());
156- NewIds.push_back (support::ulittle32_t (SymIdMap[Id] ));
158+ NewIds.push_back (support::ulittle32_t (SymIdIt-> getSecond () ));
157159 }
158160 ArrayRef<uint8_t > NewRawIds (reinterpret_cast <uint8_t *>(NewIds.data ()),
159161 RawIds.size ());
160162 // Update check sum
161163 JamCRC JC (/* Init=*/ 0 );
162164 JC.update (NewRawIds);
163- SecIdMap[Sec. UniqueId ] ->CheckSum = JC.getCRC ();
164- // Set new content
165+ SecDefIt-> getSecond () ->CheckSum = JC.getCRC ();
166+ // Set new content.
165167 Sec.setOwnedContents (NewRawIds.vec ());
166168 }
167169 return Error::success ();
0 commit comments