Lines Matching refs:relocator

97 static inline bool lookup_symbol(Relocator& relocator, uint32_t r_sym, const char* sym_name,  in lookup_symbol()  argument
99 if (r_sym == relocator.cache_sym_val) { in lookup_symbol()
100 *found_in = relocator.cache_si; in lookup_symbol()
101 *sym = relocator.cache_sym; in lookup_symbol()
105 if (!relocator.si->lookup_version_info(relocator.version_tracker, r_sym, sym_name, &vi)) { in lookup_symbol()
110 …const ElfW(Sym)* local_sym = soinfo_do_lookup(sym_name, vi, &local_found_in, relocator.lookup_list… in lookup_symbol()
112 relocator.cache_sym_val = r_sym; in lookup_symbol()
113 relocator.cache_si = local_found_in; in lookup_symbol()
114 relocator.cache_sym = local_sym; in lookup_symbol()
120 if (ELF_ST_BIND(relocator.si_symtab[r_sym].st_info) != STB_WEAK) { in lookup_symbol()
121 …DL_ERR("cannot locate symbol \"%s\" referenced by \"%s\"...", sym_name, relocator.si->get_realpath… in lookup_symbol()
158 static bool process_relocation_general(Relocator& relocator, const rel_t& reloc);
162 static bool process_relocation_impl(Relocator& relocator, const rel_t& reloc) { in process_relocation_impl() argument
165 void* const rel_target = reinterpret_cast<void*>(reloc.r_offset + relocator.si->load_bias); in process_relocation_impl()
175 sym_name = relocator.get_string(relocator.si_symtab[r_sym].st_name); in process_relocation_impl()
186 const bool handle_text_relocs = IsGeneral && relocator.si->has_text_relocations; in process_relocation_impl()
189 if (phdr_table_protect_segments(relocator.si->phdr, relocator.si->phnum, in process_relocation_impl()
190 relocator.si->load_bias, in process_relocation_impl()
191 relocator.si->should_pad_segments()) < 0) { in process_relocation_impl()
193 relocator.si->get_realpath(), strerror(errno)); in process_relocation_impl()
200 if (phdr_table_unprotect_segments(relocator.si->phdr, relocator.si->phnum, in process_relocation_impl()
201 relocator.si->load_bias, in process_relocation_impl()
202 relocator.si->should_pad_segments()) < 0) { in process_relocation_impl()
204 relocator.si->get_realpath(), strerror(errno)); in process_relocation_impl()
239 return process_relocation_general(relocator, reloc); in process_relocation_impl()
246 found_in = relocator.si; in process_relocation_impl()
247 } else if (ELF_ST_BIND(relocator.si_symtab[r_sym].st_info) == STB_LOCAL) { in process_relocation_impl()
254 sym = &relocator.si_symtab[r_sym]; in process_relocation_impl()
258 relocator.si->get_realpath(), sym_type, r_type); in process_relocation_impl()
262 sym_name, relocator.si->get_realpath(), sym_type, r_type); in process_relocation_impl()
265 } else if (!lookup_symbol<IsGeneral>(relocator, r_sym, sym_name, &found_in, &sym)) { in process_relocation_impl()
278 sym_name, relocator.si->get_realpath()); in process_relocation_impl()
287 if (!lookup_symbol<IsGeneral>(relocator, r_sym, sym_name, &found_in, &sym)) return false; in process_relocation_impl()
290 found_in == relocator.si && in process_relocation_impl()
349 const ElfW(Addr) result = relocator.si->load_bias + get_addend_rel(); in process_relocation_impl()
361 return process_relocation_general(relocator, reloc); in process_relocation_impl()
369 if (!relocator.si->is_linker()) { in process_relocation_impl()
371 const ElfW(Addr) ifunc_addr = relocator.si->load_bias + get_addend_rel(); in process_relocation_impl()
389 DL_ERR("%s COPY relocations are not supported", relocator.si->get_realpath()); in process_relocation_impl()
402 tpoff += mod.static_offset - relocator.tls_tp_base; in process_relocation_impl()
405 sym_name, found_in->get_realpath(), relocator.si->get_realpath()); in process_relocation_impl()
461 desc->arg = mod.static_offset - relocator.tls_tp_base + sym_addr + addend; in process_relocation_impl()
463 rel_target, mod.static_offset, relocator.tls_tp_base, in process_relocation_impl()
467 relocator.tlsdesc_args->push_back({ in process_relocation_impl()
474 relocator.deferred_tlsdesc_relocs.push_back({ in process_relocation_impl()
475 desc, relocator.tlsdesc_args->size() - 1 in process_relocation_impl()
477 const TlsDynamicResolverArg& desc_arg = relocator.tlsdesc_args->back(); in process_relocation_impl()
524 DL_ERR("unknown reloc type %d in \"%s\"", r_type, relocator.si->get_realpath()); in process_relocation_impl()
531 static bool process_relocation_general(Relocator& relocator, const rel_t& reloc) { in process_relocation_general() argument
532 return process_relocation_impl<RelocMode::General>(relocator, reloc); in process_relocation_general()
537 static inline bool process_relocation(Relocator& relocator, const rel_t& reloc) { in process_relocation() argument
539 process_relocation_general(relocator, reloc) : in process_relocation()
540 process_relocation_impl<Mode>(relocator, reloc); in process_relocation()
545 static bool plain_relocate_impl(Relocator& relocator, rel_t* rels, size_t rel_count) { in plain_relocate_impl() argument
547 if (!process_relocation<Mode>(relocator, rels[i])) { in plain_relocate_impl()
556 static bool packed_relocate_impl(Relocator& relocator, sleb128_decoder decoder) { in packed_relocate_impl() argument
558 return process_relocation<Mode>(relocator, reloc); in packed_relocate_impl()
562 static bool needs_slow_relocate_loop(const Relocator& relocator __unused) { in needs_slow_relocate_loop()
568 if (relocator.si->has_text_relocations) return true; in needs_slow_relocate_loop()
578 static bool plain_relocate(Relocator& relocator, Args ...args) { in plain_relocate() argument
579 return needs_slow_relocate_loop(relocator) ? in plain_relocate()
580 plain_relocate_impl<RelocMode::General>(relocator, args...) : in plain_relocate()
581 plain_relocate_impl<OptMode>(relocator, args...); in plain_relocate()
585 static bool packed_relocate(Relocator& relocator, Args ...args) { in packed_relocate() argument
586 return needs_slow_relocate_loop(relocator) ? in packed_relocate()
587 packed_relocate_impl<RelocMode::General>(relocator, args...) : in packed_relocate()
588 packed_relocate_impl<OptMode>(relocator, args...); in packed_relocate()
604 Relocator relocator(version_tracker, lookup_list); in relocate() local
605 relocator.si = this; in relocate()
606 relocator.si_strtab = strtab_; in relocate()
607 relocator.si_strtab_size = has_min_version(1) ? strtab_size_ : SIZE_MAX; in relocate()
608 relocator.si_symtab = symtab_; in relocate()
609 relocator.tlsdesc_args = &tlsdesc_args_; in relocate()
610 relocator.tls_tp_base = __libc_shared_globals()->static_tls_layout.offset_thread_pointer(); in relocate()
635 …if (!packed_relocate<RelocMode::Typical>(relocator, sleb128_decoder(packed_relocs, packed_relocs_s… in relocate()
648 if (!plain_relocate<RelocMode::Typical>(relocator, rela_, rela_count_)) { in relocate()
654 if (!plain_relocate<RelocMode::JumpTable>(relocator, plt_rela_, plt_rela_count_)) { in relocate()
661 if (!plain_relocate<RelocMode::Typical>(relocator, rel_, rel_count_)) { in relocate()
667 if (!plain_relocate<RelocMode::JumpTable>(relocator, plt_rel_, plt_rel_count_)) { in relocate()
677 for (const std::pair<TlsDescriptor*, size_t>& pair : relocator.deferred_tlsdesc_relocs) { in relocate()