@@ -516,8 +516,7 @@ void MachObjectWriter::bindIndirectSymbols(MCAssembler &Asm) {
516516
517517 // Report errors for use of .indirect_symbol not in a symbol pointer section
518518 // or stub section.
519- for (IndirectSymbolData &ISD : llvm::make_range (Asm.indirect_symbol_begin (),
520- Asm.indirect_symbol_end ())) {
519+ for (IndirectSymbolData &ISD : Asm.getIndirectSymbols ()) {
521520 const MCSectionMachO &Section = cast<MCSectionMachO>(*ISD.Section );
522521
523522 if (Section.getType () != MachO::S_NON_LAZY_SYMBOL_POINTERS &&
@@ -531,39 +530,35 @@ void MachObjectWriter::bindIndirectSymbols(MCAssembler &Asm) {
531530 }
532531
533532 // Bind non-lazy symbol pointers first.
534- unsigned IndirectIndex = 0 ;
535- for (MCAssembler::indirect_symbol_iterator it = Asm.indirect_symbol_begin (),
536- ie = Asm.indirect_symbol_end (); it != ie; ++it, ++IndirectIndex) {
537- const MCSectionMachO &Section = cast<MCSectionMachO>(*it->Section );
533+ for (auto [IndirectIndex, ISD] : enumerate(Asm.getIndirectSymbols ())) {
534+ const auto &Section = cast<MCSectionMachO>(*ISD.Section );
538535
539536 if (Section.getType () != MachO::S_NON_LAZY_SYMBOL_POINTERS &&
540537 Section.getType () != MachO::S_THREAD_LOCAL_VARIABLE_POINTERS)
541538 continue ;
542539
543540 // Initialize the section indirect symbol base, if necessary.
544- IndirectSymBase.insert (std::make_pair (it-> Section , IndirectIndex));
541+ IndirectSymBase.insert (std::make_pair (ISD. Section , IndirectIndex));
545542
546- Asm.registerSymbol (*it-> Symbol );
543+ Asm.registerSymbol (*ISD. Symbol );
547544 }
548545
549546 // Then lazy symbol pointers and symbol stubs.
550- IndirectIndex = 0 ;
551- for (MCAssembler::indirect_symbol_iterator it = Asm.indirect_symbol_begin (),
552- ie = Asm.indirect_symbol_end (); it != ie; ++it, ++IndirectIndex) {
553- const MCSectionMachO &Section = cast<MCSectionMachO>(*it->Section );
547+ for (auto [IndirectIndex, ISD] : enumerate(Asm.getIndirectSymbols ())) {
548+ const auto &Section = cast<MCSectionMachO>(*ISD.Section );
554549
555550 if (Section.getType () != MachO::S_LAZY_SYMBOL_POINTERS &&
556551 Section.getType () != MachO::S_SYMBOL_STUBS)
557552 continue ;
558553
559554 // Initialize the section indirect symbol base, if necessary.
560- IndirectSymBase.insert (std::make_pair (it-> Section , IndirectIndex));
555+ IndirectSymBase.insert (std::make_pair (ISD. Section , IndirectIndex));
561556
562557 // Set the symbol type to undefined lazy, but only on construction.
563558 //
564559 // FIXME: Do not hardcode.
565- if (Asm.registerSymbol (*it-> Symbol ))
566- cast<MCSymbolMachO>(it-> Symbol )->setReferenceTypeUndefinedLazy (true );
560+ if (Asm.registerSymbol (*ISD. Symbol ))
561+ cast<MCSymbolMachO>(ISD. Symbol )->setReferenceTypeUndefinedLazy (true );
567562 }
568563}
569564
@@ -975,7 +970,7 @@ uint64_t MachObjectWriter::writeObject(MCAssembler &Asm) {
975970 unsigned NumExternalSymbols = ExternalSymbolData.size ();
976971 unsigned FirstUndefinedSymbol = FirstExternalSymbol + NumExternalSymbols;
977972 unsigned NumUndefinedSymbols = UndefinedSymbolData.size ();
978- unsigned NumIndirectSymbols = Asm.indirect_symbol_size ();
973+ unsigned NumIndirectSymbols = Asm.getIndirectSymbols (). size ();
979974 unsigned NumSymTabSymbols =
980975 NumLocalSymbols + NumExternalSymbols + NumUndefinedSymbols;
981976 uint64_t IndirectSymbolSize = NumIndirectSymbols * 4 ;
@@ -1065,25 +1060,23 @@ uint64_t MachObjectWriter::writeObject(MCAssembler &Asm) {
10651060 // Write the symbol table data, if used.
10661061 if (NumSymbols) {
10671062 // Write the indirect symbol entries.
1068- for (MCAssembler::const_indirect_symbol_iterator
1069- it = Asm.indirect_symbol_begin (),
1070- ie = Asm.indirect_symbol_end (); it != ie; ++it) {
1063+ for (auto &ISD : Asm.getIndirectSymbols ()) {
10711064 // Indirect symbols in the non-lazy symbol pointer section have some
10721065 // special handling.
10731066 const MCSectionMachO &Section =
1074- static_cast <const MCSectionMachO &>(*it-> Section );
1067+ static_cast <const MCSectionMachO &>(*ISD. Section );
10751068 if (Section.getType () == MachO::S_NON_LAZY_SYMBOL_POINTERS) {
10761069 // If this symbol is defined and internal, mark it as such.
1077- if (it-> Symbol ->isDefined () && !it-> Symbol ->isExternal ()) {
1070+ if (ISD. Symbol ->isDefined () && !ISD. Symbol ->isExternal ()) {
10781071 uint32_t Flags = MachO::INDIRECT_SYMBOL_LOCAL;
1079- if (it-> Symbol ->isAbsolute ())
1072+ if (ISD. Symbol ->isAbsolute ())
10801073 Flags |= MachO::INDIRECT_SYMBOL_ABS;
10811074 W.write <uint32_t >(Flags);
10821075 continue ;
10831076 }
10841077 }
10851078
1086- W.write <uint32_t >(it-> Symbol ->getIndex ());
1079+ W.write <uint32_t >(ISD. Symbol ->getIndex ());
10871080 }
10881081
10891082 // FIXME: Check that offsets match computed ones.
0 commit comments