Path: blob/main/libexec/rtld-elf/powerpc/rtld_machdep.h
105462 views
/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 1999, 2000 John D. Polstra.4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14*15* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND16* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE17* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE18* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE19* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL20* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS21* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)22* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT23* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY24* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF25* SUCH DAMAGE.26*/2728#ifndef RTLD_MACHDEP_H29#define RTLD_MACHDEP_H 13031#include <sys/types.h>32#include <machine/atomic.h>33#include <machine/tls.h>3435struct Struct_Obj_Entry;3637#define MD_OBJ_ENTRY \38Elf_Addr *gotptr; /* GOT pointer (secure-plt only) */3940/* Return the address of the .dynamic section in the dynamic linker. */41#define rtld_dynamic(obj) (&_DYNAMIC)4243bool arch_digest_dynamic(struct Struct_Obj_Entry *, const Elf_Dyn *);4445/* No architecture specific notes */46#define arch_digest_note(obj, note) false4748void arch_fix_auxv(Elf_Auxinfo *aux, Elf_Auxinfo *aux_info[]);4950Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target,51const struct Struct_Obj_Entry *defobj, const struct Struct_Obj_Entry *obj,52const Elf_Rel *rel);53void reloc_non_plt_self(Elf_Dyn *dynp, Elf_Addr relocbase);5455#define make_function_pointer(def, defobj) \56((defobj)->relocbase + (def)->st_value)5758#define call_initfini_pointer(obj, target) \59(((InitFunc)(target))())6061#define call_init_pointer(obj, target) \62(((InitArrFunc)(target))(main_argc, main_argv, environ))6364extern u_long cpu_features; /* r3 */65extern u_long cpu_features2; /* r4 */66/* r5-10: ifunc resolver parameters reserved for future assignment. */67#define call_ifunc_resolver(ptr) \68(((Elf_Addr (*)(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, \69uint32_t, uint32_t, uint32_t))ptr)((uint32_t)cpu_features, \70(uint32_t)cpu_features2, 0, 0, 0, 0, 0, 0))7172/*73* PLT functions. Not really correct prototypes, but the74* symbol values are needed.75*/76void _rtld_powerpc_pltlongresolve(void);77void _rtld_powerpc_pltresolve(void);78void _rtld_powerpc_pltcall(void);7980/*81* TLS82*/8384#define round(size, align) \85(((size) + (align) - 1) & ~((align) - 1))86#define calculate_first_tls_offset(size, align, offset) \87TLS_TCB_SIZE88#define calculate_tls_offset(prev_offset, prev_size, size, align, offset) \89round(prev_offset + prev_size, align)90#define calculate_tls_post_size(align) 09192typedef struct {93unsigned long ti_module;94unsigned long ti_offset;95} tls_index;9697extern void *__tls_get_addr(tls_index* ti);9899extern void powerpc_abi_variant_hook(Elf_Auxinfo **);100#define md_abi_variant_hook(x) powerpc_abi_variant_hook(x)101102#endif103104105