lld/MachO/SyntheticSections.cpp
uint32_t LazyBindingSection::encode(const DylibSymbol &sym) {
  uint32_t opstreamOffset = contents.size();
  OutputSegment *dataSeg = in.lazyPointers->parent;
  os << static_cast<uint8_t>(BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB |
                             dataSeg->index);
  uint64_t offset = in.lazyPointers->addr - dataSeg->addr +
                    sym.stubsIndex * target->wordSize;
  encodeULEB128(offset, os);
  encodeDylibOrdinal(ordinalForDylibSymbol(sym), os);

  uint8_t flags = BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM;
  if (sym.isWeakRef())
    flags |= BIND_SYMBOL_FLAGS_WEAK_IMPORT;

  os << flags << sym.getName() << '\0'
     << static_cast<uint8_t>(BIND_OPCODE_DO_BIND)
     << static_cast<uint8_t>(BIND_OPCODE_DONE);
  return opstreamOffset;
}
// Unlike the non-lazy binding section, the bind opcodes in this section aren't
// interpreted all at once. Rather, dyld will start interpreting opcodes at a
// given offset, typically only binding a single symbol before it finds a
// BIND_OPCODE_DONE terminator. As such, unlike in the non-lazy-binding case,
// we cannot encode just the differences between symbols; we have to emit the
// complete bind information for each symbol.
Unlike the non-lazy binding section, the bind opcodes in this section aren't
interpreted all at once. Rather, dyld will start interpreting opcodes at a
given offset, typically only binding a single symbol before it finds a
BIND_OPCODE_DONE terminator. As such, unlike in the non-lazy-binding case,
we cannot encode just the differences between symbols; we have to emit the
complete bind information for each symbol.
Unlike the non - lazy binding section the bind opcodes in this section aren ' t interpreted all at once . Rather dyld will start interpreting opcodes at a given offset typically only binding a single symbol before it finds a BIND_OPCODE_DONE terminator . As such unlike in the non - lazy - binding case we cannot encode just the differences between symbols ; we have to emit the complete bind information for each symbol .
uint32_t LazyBindingSection::encode(const DylibSymbol &sym) {
  uint32_t opstreamOffset = contents.size();
  OutputSegment *dataSeg = in.lazyPointers->parent;
  os << static_cast<uint8_t>(BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB |
                             dataSeg->index);
  uint64_t offset = in.lazyPointers->addr - dataSeg->addr +
                    sym.stubsIndex * target->wordSize;
  encodeULEB128(offset, os);
  encodeDylibOrdinal(ordinalForDylibSymbol(sym), os);
  uint8_t flags = BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM;
  if (sym.isWeakRef())
    flags |= BIND_SYMBOL_FLAGS_WEAK_IMPORT;
  os << flags << sym.getName() << '\0'
     << static_cast<uint8_t>(BIND_OPCODE_DO_BIND)
     << static_cast<uint8_t>(BIND_OPCODE_DONE);
  return opstreamOffset;
}
uint32_t LazyBindingSection :: encode ( const DylibSymbol & sym ) { uint32_t opstreamOffset = contents . size ( ) ; OutputSegment * dataSeg = in . lazyPointers -> parent ; os << static_cast < uint8_t > ( BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB | dataSeg -> index ) ; uint64_t offset = in . lazyPointers -> addr - dataSeg -> addr + sym . stubsIndex * target -> wordSize ; encodeULEB128 ( offset , os ) ; encodeDylibOrdinal ( ordinalForDylibSymbol ( sym ) , os ) ; uint8_t flags = BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM ; if ( sym . isWeakRef ( ) ) flags |= BIND_SYMBOL_FLAGS_WEAK_IMPORT ; os << flags << sym . getName ( ) << ' \0 ' << static_cast < uint8_t > ( BIND_OPCODE_DO_BIND ) << static_cast < uint8_t > ( BIND_OPCODE_DONE ) ; return opstreamOffset ; }
Unlike the non-lazy binding section, the bind opcodes in this section aren't
interpreted all at once.
Unlike the non - lazy binding section the bind opcodes in this section aren ' t interpreted all at once .