/*-1* Copyright (c) 2019 Leandro Lupori2* Copyright (c) 2021 The FreeBSD Foundation3*4* Portions of this software were developed by Andrew Turner5* under sponsorship from the FreeBSD Foundation.6*7* Redistribution and use in source and binary forms, with or without8* modification, are permitted provided that the following conditions9* are met:10* 1. Redistributions of source code must retain the above copyright11* notice, this list of conditions and the following disclaimer.12*13* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND14* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE15* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE16* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE17* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS19* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)20* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT21* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY22* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF23* SUCH DAMAGE.24*/2526#include <sys/cdefs.h>2728static void29ifunc_init(const Elf_Auxinfo *aux __unused)30{31}3233static void34crt1_handle_rela(const Elf_Rela *r)35{36typedef Elf_Addr (*ifunc_resolver_t)(37uint64_t, uint64_t, uint64_t, uint64_t,38uint64_t, uint64_t, uint64_t, uint64_t);39Elf_Addr *ptr, *where, target;4041switch (ELF_R_TYPE(r->r_info)) {42case R_AARCH64_IRELATIVE:43ptr = (Elf_Addr *)r->r_addend;44where = (Elf_Addr *)r->r_offset;45target = ((ifunc_resolver_t)ptr)(0, 0, 0, 0, 0, 0, 0, 0);46*where = target;47break;48}49}505152