Path: blob/main/libexec/rtld-elf/powerpc64/rtld_machdep.h
105194 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 glink; /* GLINK PLT call stub section */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-r10: ifunc resolver parameters reserved for future assignment. */67#define call_ifunc_resolver(ptr) \68(((Elf_Addr (*)(uint32_t, uint32_t, uint64_t, uint64_t, uint64_t, \69uint64_t, uint64_t, uint64_t))ptr)((uint32_t)cpu_features, \70(uint32_t)cpu_features2, 0, 0, 0, 0, 0, 0))7172/*73* TLS74*/7576#define round(size, align) \77(((size) + (align) - 1) & ~((align) - 1))78#define calculate_first_tls_offset(size, align, offset) \79TLS_TCB_SIZE80#define calculate_tls_offset(prev_offset, prev_size, size, align, offset) \81round(prev_offset + prev_size, align)82#define calculate_tls_post_size(align) 08384typedef struct {85unsigned long ti_module;86unsigned long ti_offset;87} tls_index;8889extern void *__tls_get_addr(tls_index* ti);9091extern void powerpc64_abi_variant_hook(Elf_Auxinfo **);92#define md_abi_variant_hook(x) powerpc64_abi_variant_hook(x)9394#endif959697