127bd4146SNathan Whitehorn /*- 24d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3e6209940SPedro F. Giffuni * 427bd4146SNathan Whitehorn * Copyright (c) 1999, 2000 John D. Polstra. 527bd4146SNathan Whitehorn * All rights reserved. 627bd4146SNathan Whitehorn * 727bd4146SNathan Whitehorn * Redistribution and use in source and binary forms, with or without 827bd4146SNathan Whitehorn * modification, are permitted provided that the following conditions 927bd4146SNathan Whitehorn * are met: 1027bd4146SNathan Whitehorn * 1. Redistributions of source code must retain the above copyright 1127bd4146SNathan Whitehorn * notice, this list of conditions and the following disclaimer. 1227bd4146SNathan Whitehorn * 2. Redistributions in binary form must reproduce the above copyright 1327bd4146SNathan Whitehorn * notice, this list of conditions and the following disclaimer in the 1427bd4146SNathan Whitehorn * documentation and/or other materials provided with the distribution. 1527bd4146SNathan Whitehorn * 1627bd4146SNathan Whitehorn * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1727bd4146SNathan Whitehorn * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1827bd4146SNathan Whitehorn * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1927bd4146SNathan Whitehorn * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2027bd4146SNathan Whitehorn * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2127bd4146SNathan Whitehorn * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2227bd4146SNathan Whitehorn * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2327bd4146SNathan Whitehorn * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2427bd4146SNathan Whitehorn * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2527bd4146SNathan Whitehorn * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2627bd4146SNathan Whitehorn * SUCH DAMAGE. 2727bd4146SNathan Whitehorn */ 2827bd4146SNathan Whitehorn 2927bd4146SNathan Whitehorn #ifndef RTLD_MACHDEP_H 3027bd4146SNathan Whitehorn #define RTLD_MACHDEP_H 1 3127bd4146SNathan Whitehorn 3227bd4146SNathan Whitehorn #include <sys/types.h> 3327bd4146SNathan Whitehorn #include <machine/atomic.h> 348bcdb144SJohn Baldwin #include <machine/tls.h> 3527bd4146SNathan Whitehorn 3627bd4146SNathan Whitehorn struct Struct_Obj_Entry; 3727bd4146SNathan Whitehorn 38*1cd90a2cSAndrew Turner #define MD_OBJ_ENTRY \ 39*1cd90a2cSAndrew Turner Elf_Addr glink; /* GLINK PLT call stub section */ 4006db20ffSAndrew Turner 4127bd4146SNathan Whitehorn /* Return the address of the .dynamic section in the dynamic linker. */ 4227bd4146SNathan Whitehorn #define rtld_dynamic(obj) (&_DYNAMIC) 4327bd4146SNathan Whitehorn 44*1cd90a2cSAndrew Turner bool arch_digest_dynamic(struct Struct_Obj_Entry *, const Elf_Dyn *); 45dd4155beSAndrew Turner 46d8925a5fSAndrew Turner /* No architecture specific notes */ 47d8925a5fSAndrew Turner #define arch_digest_note(obj, note) false 48d8925a5fSAndrew Turner 4927bd4146SNathan Whitehorn Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target, 50e35ddbe4SKonstantin Belousov const struct Struct_Obj_Entry *defobj, const struct Struct_Obj_Entry *obj, 5127bd4146SNathan Whitehorn const Elf_Rel *rel); 52903e0ffdSAlex Richardson void reloc_non_plt_self(Elf_Dyn *dynp, Elf_Addr relocbase); 5327bd4146SNathan Whitehorn 5427bd4146SNathan Whitehorn #define make_function_pointer(def, defobj) \ 5527bd4146SNathan Whitehorn ((defobj)->relocbase + (def)->st_value) 5627bd4146SNathan Whitehorn 5727bd4146SNathan Whitehorn #define call_initfini_pointer(obj, target) \ 5827bd4146SNathan Whitehorn (((InitFunc)(target))()) 5927bd4146SNathan Whitehorn 6083aa9cc0SKonstantin Belousov #define call_init_pointer(obj, target) \ 6183aa9cc0SKonstantin Belousov (((InitArrFunc)(target))(main_argc, main_argv, environ)) 6283aa9cc0SKonstantin Belousov 6341b4ec8aSBrandon Bergren extern u_long cpu_features; /* r3 */ 6441b4ec8aSBrandon Bergren extern u_long cpu_features2; /* r4 */ 6541b4ec8aSBrandon Bergren /* r5-r10: ifunc resolver parameters reserved for future assignment. */ 664352999eSKonstantin Belousov #define call_ifunc_resolver(ptr) \ 6741b4ec8aSBrandon Bergren (((Elf_Addr (*)(uint32_t, uint32_t, uint64_t, uint64_t, uint64_t, \ 6841b4ec8aSBrandon Bergren uint64_t, uint64_t, uint64_t))ptr)((uint32_t)cpu_features, \ 6941b4ec8aSBrandon Bergren (uint32_t)cpu_features2, 0, 0, 0, 0, 0, 0)) 704352999eSKonstantin Belousov 7127bd4146SNathan Whitehorn /* 7227bd4146SNathan Whitehorn * TLS 7327bd4146SNathan Whitehorn */ 7427bd4146SNathan Whitehorn 7527bd4146SNathan Whitehorn #define round(size, align) \ 7627bd4146SNathan Whitehorn (((size) + (align) - 1) & ~((align) - 1)) 77e5c3405cSKonstantin Belousov #define calculate_first_tls_offset(size, align, offset) \ 7817fb2856SBrooks Davis TLS_TCB_SIZE 79e5c3405cSKonstantin Belousov #define calculate_tls_offset(prev_offset, prev_size, size, align, offset) \ 8027bd4146SNathan Whitehorn round(prev_offset + prev_size, align) 8117fb2856SBrooks Davis #define calculate_tls_post_size(align) 0 8227bd4146SNathan Whitehorn 8327bd4146SNathan Whitehorn typedef struct { 8427bd4146SNathan Whitehorn unsigned long ti_module; 8527bd4146SNathan Whitehorn unsigned long ti_offset; 8627bd4146SNathan Whitehorn } tls_index; 8727bd4146SNathan Whitehorn 8827bd4146SNathan Whitehorn extern void *__tls_get_addr(tls_index* ti); 8927bd4146SNathan Whitehorn 9041b4ec8aSBrandon Bergren extern void powerpc64_abi_variant_hook(Elf_Auxinfo **); 9141b4ec8aSBrandon Bergren #define md_abi_variant_hook(x) powerpc64_abi_variant_hook(x) 928fd53f45SWarner Losh 9327bd4146SNathan Whitehorn #endif 94