Path: blob/main/libexec/rtld-elf/powerpc64/rtld_machdep.h
34923 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) false4748Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target,49const struct Struct_Obj_Entry *defobj, const struct Struct_Obj_Entry *obj,50const Elf_Rel *rel);51void reloc_non_plt_self(Elf_Dyn *dynp, Elf_Addr relocbase);5253#define make_function_pointer(def, defobj) \54((defobj)->relocbase + (def)->st_value)5556#define call_initfini_pointer(obj, target) \57(((InitFunc)(target))())5859#define call_init_pointer(obj, target) \60(((InitArrFunc)(target))(main_argc, main_argv, environ))6162extern u_long cpu_features; /* r3 */63extern u_long cpu_features2; /* r4 */64/* r5-r10: ifunc resolver parameters reserved for future assignment. */65#define call_ifunc_resolver(ptr) \66(((Elf_Addr (*)(uint32_t, uint32_t, uint64_t, uint64_t, uint64_t, \67uint64_t, uint64_t, uint64_t))ptr)((uint32_t)cpu_features, \68(uint32_t)cpu_features2, 0, 0, 0, 0, 0, 0))6970/*71* TLS72*/7374#define round(size, align) \75(((size) + (align) - 1) & ~((align) - 1))76#define calculate_first_tls_offset(size, align, offset) \77TLS_TCB_SIZE78#define calculate_tls_offset(prev_offset, prev_size, size, align, offset) \79round(prev_offset + prev_size, align)80#define calculate_tls_post_size(align) 08182typedef struct {83unsigned long ti_module;84unsigned long ti_offset;85} tls_index;8687extern void *__tls_get_addr(tls_index* ti);8889extern void powerpc64_abi_variant_hook(Elf_Auxinfo **);90#define md_abi_variant_hook(x) powerpc64_abi_variant_hook(x)9192#endif939495