Lines Matching refs:relocator

95 static inline bool lookup_symbol(Relocator& relocator, uint32_t r_sym, const char* sym_name,  in lookup_symbol()  argument
97 if (r_sym == relocator.cache_sym_val) { in lookup_symbol()
98 *found_in = relocator.cache_si; in lookup_symbol()
99 *sym = relocator.cache_sym; in lookup_symbol()
103 if (!relocator.si->lookup_version_info(relocator.version_tracker, r_sym, sym_name, &vi)) { in lookup_symbol()
108 …const ElfW(Sym)* local_sym = soinfo_do_lookup(sym_name, vi, &local_found_in, relocator.lookup_list… in lookup_symbol()
110 relocator.cache_sym_val = r_sym; in lookup_symbol()
111 relocator.cache_si = local_found_in; in lookup_symbol()
112 relocator.cache_sym = local_sym; in lookup_symbol()
118 if (ELF_ST_BIND(relocator.si_symtab[r_sym].st_info) != STB_WEAK) { in lookup_symbol()
119 …DL_ERR("cannot locate symbol \"%s\" referenced by \"%s\"...", sym_name, relocator.si->get_realpath… in lookup_symbol()
156 static bool process_relocation_general(Relocator& relocator, const rel_t& reloc);
160 static bool process_relocation_impl(Relocator& relocator, const rel_t& reloc) { in process_relocation_impl() argument
163 void* const rel_target = reinterpret_cast<void*>(reloc.r_offset + relocator.si->load_bias); in process_relocation_impl()
173 sym_name = relocator.get_string(relocator.si_symtab[r_sym].st_name); in process_relocation_impl()
184 const bool handle_text_relocs = IsGeneral && relocator.si->has_text_relocations; in process_relocation_impl()
187 if (phdr_table_protect_segments(relocator.si->phdr, relocator.si->phnum, in process_relocation_impl()
188 relocator.si->load_bias) < 0) { in process_relocation_impl()
190 relocator.si->get_realpath(), strerror(errno)); in process_relocation_impl()
197 if (phdr_table_unprotect_segments(relocator.si->phdr, relocator.si->phnum, in process_relocation_impl()
198 relocator.si->load_bias) < 0) { in process_relocation_impl()
200 relocator.si->get_realpath(), strerror(errno)); in process_relocation_impl()
236 found_in = relocator.si; in process_relocation_impl()
237 } else if (ELF_ST_BIND(relocator.si_symtab[r_sym].st_info) == STB_LOCAL) { in process_relocation_impl()
244 sym = &relocator.si_symtab[r_sym]; in process_relocation_impl()
246 sym_name, relocator.si->get_realpath(), ELF_ST_TYPE(sym->st_info), r_type); in process_relocation_impl()
248 } else if (!lookup_symbol<IsGeneral>(relocator, r_sym, sym_name, &found_in, &sym)) { in process_relocation_impl()
261 sym_name, relocator.si->get_realpath()); in process_relocation_impl()
270 if (!lookup_symbol<IsGeneral>(relocator, r_sym, sym_name, &found_in, &sym)) return false; in process_relocation_impl()
273 found_in == relocator.si && in process_relocation_impl()
332 const ElfW(Addr) result = relocator.si->load_bias + get_addend_rel(); in process_relocation_impl()
344 return process_relocation_general(relocator, reloc); in process_relocation_impl()
352 if (!relocator.si->is_linker()) { in process_relocation_impl()
354 const ElfW(Addr) ifunc_addr = relocator.si->load_bias + get_addend_rel(); in process_relocation_impl()
372 DL_ERR("%s COPY relocations are not supported", relocator.si->get_realpath()); in process_relocation_impl()
385 tpoff += mod.static_offset - relocator.tls_tp_base; in process_relocation_impl()
388 sym_name, found_in->get_realpath(), relocator.si->get_realpath()); in process_relocation_impl()
443 desc->arg = mod.static_offset - relocator.tls_tp_base + sym_addr + addend; in process_relocation_impl()
445 rel_target, mod.static_offset, relocator.tls_tp_base, in process_relocation_impl()
449 relocator.tlsdesc_args->push_back({ in process_relocation_impl()
456 relocator.deferred_tlsdesc_relocs.push_back({ in process_relocation_impl()
457 desc, relocator.tlsdesc_args->size() - 1 in process_relocation_impl()
459 const TlsDynamicResolverArg& desc_arg = relocator.tlsdesc_args->back(); in process_relocation_impl()
506 DL_ERR("unknown reloc type %d in \"%s\"", r_type, relocator.si->get_realpath()); in process_relocation_impl()
513 static bool process_relocation_general(Relocator& relocator, const rel_t& reloc) { in process_relocation_general() argument
514 return process_relocation_impl<RelocMode::General>(relocator, reloc); in process_relocation_general()
519 static inline bool process_relocation(Relocator& relocator, const rel_t& reloc) { in process_relocation() argument
521 process_relocation_general(relocator, reloc) : in process_relocation()
522 process_relocation_impl<Mode>(relocator, reloc); in process_relocation()
527 static bool plain_relocate_impl(Relocator& relocator, rel_t* rels, size_t rel_count) { in plain_relocate_impl() argument
529 if (!process_relocation<Mode>(relocator, rels[i])) { in plain_relocate_impl()
538 static bool packed_relocate_impl(Relocator& relocator, sleb128_decoder decoder) { in packed_relocate_impl() argument
540 return process_relocation<Mode>(relocator, reloc); in packed_relocate_impl()
544 static bool needs_slow_relocate_loop(const Relocator& relocator __unused) { in needs_slow_relocate_loop()
550 if (relocator.si->has_text_relocations) return true; in needs_slow_relocate_loop()
560 static bool plain_relocate(Relocator& relocator, Args ...args) { in plain_relocate() argument
561 return needs_slow_relocate_loop(relocator) ? in plain_relocate()
562 plain_relocate_impl<RelocMode::General>(relocator, args...) : in plain_relocate()
563 plain_relocate_impl<OptMode>(relocator, args...); in plain_relocate()
567 static bool packed_relocate(Relocator& relocator, Args ...args) { in packed_relocate() argument
568 return needs_slow_relocate_loop(relocator) ? in packed_relocate()
569 packed_relocate_impl<RelocMode::General>(relocator, args...) : in packed_relocate()
570 packed_relocate_impl<OptMode>(relocator, args...); in packed_relocate()
581 Relocator relocator(version_tracker, lookup_list); in relocate() local
582 relocator.si = this; in relocate()
583 relocator.si_strtab = strtab_; in relocate()
584 relocator.si_strtab_size = has_min_version(1) ? strtab_size_ : SIZE_MAX; in relocate()
585 relocator.si_symtab = symtab_; in relocate()
586 relocator.tlsdesc_args = &tlsdesc_args_; in relocate()
587 relocator.tls_tp_base = __libc_shared_globals()->static_tls_layout.offset_thread_pointer(); in relocate()
601 …if (!packed_relocate<RelocMode::Typical>(relocator, sleb128_decoder(packed_relocs, packed_relocs_s… in relocate()
621 if (!plain_relocate<RelocMode::Typical>(relocator, rela_, rela_count_)) { in relocate()
627 if (!plain_relocate<RelocMode::JumpTable>(relocator, plt_rela_, plt_rela_count_)) { in relocate()
634 if (!plain_relocate<RelocMode::Typical>(relocator, rel_, rel_count_)) { in relocate()
640 if (!plain_relocate<RelocMode::JumpTable>(relocator, plt_rel_, plt_rel_count_)) { in relocate()
650 for (const std::pair<TlsDescriptor*, size_t>& pair : relocator.deferred_tlsdesc_relocs) { in relocate()