1e659267fSOlivier Houchard /*- 2e6209940SPedro F. Giffuni * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3e6209940SPedro F. Giffuni * 4e659267fSOlivier Houchard * Copyright (c) 1999, 2000 John D. Polstra. 5e659267fSOlivier Houchard * All rights reserved. 6e659267fSOlivier Houchard * 7e659267fSOlivier Houchard * Redistribution and use in source and binary forms, with or without 8e659267fSOlivier Houchard * modification, are permitted provided that the following conditions 9e659267fSOlivier Houchard * are met: 10e659267fSOlivier Houchard * 1. Redistributions of source code must retain the above copyright 11e659267fSOlivier Houchard * notice, this list of conditions and the following disclaimer. 12e659267fSOlivier Houchard * 2. Redistributions in binary form must reproduce the above copyright 13e659267fSOlivier Houchard * notice, this list of conditions and the following disclaimer in the 14e659267fSOlivier Houchard * documentation and/or other materials provided with the distribution. 15e659267fSOlivier Houchard * 16e659267fSOlivier Houchard * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17e659267fSOlivier Houchard * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18e659267fSOlivier Houchard * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19e659267fSOlivier Houchard * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20e659267fSOlivier Houchard * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21e659267fSOlivier Houchard * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22e659267fSOlivier Houchard * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23e659267fSOlivier Houchard * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24e659267fSOlivier Houchard * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25e659267fSOlivier Houchard * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26e659267fSOlivier Houchard * SUCH DAMAGE. 27e659267fSOlivier Houchard * 28e659267fSOlivier Houchard * $FreeBSD$ 29e659267fSOlivier Houchard */ 30e659267fSOlivier Houchard 31e659267fSOlivier Houchard #ifndef RTLD_MACHDEP_H 32e659267fSOlivier Houchard #define RTLD_MACHDEP_H 1 33e659267fSOlivier Houchard 34e659267fSOlivier Houchard #include <sys/types.h> 35e659267fSOlivier Houchard #include <machine/atomic.h> 3608d1c5b1SWarner Losh #include <machine/acle-compat.h> 378bcdb144SJohn Baldwin #include <machine/tls.h> 38e659267fSOlivier Houchard 39e659267fSOlivier Houchard struct Struct_Obj_Entry; 40e659267fSOlivier Houchard 41e659267fSOlivier Houchard /* Return the address of the .dynamic section in the dynamic linker. */ 42e659267fSOlivier Houchard #define rtld_dynamic(obj) (&_DYNAMIC) 439ac88d19SOlivier Houchard 44e659267fSOlivier Houchard Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target, 45e35ddbe4SKonstantin Belousov const struct Struct_Obj_Entry *defobj, const struct Struct_Obj_Entry *obj, 46e659267fSOlivier Houchard const Elf_Rel *rel); 47e659267fSOlivier Houchard 48e659267fSOlivier Houchard #define make_function_pointer(def, defobj) \ 49e659267fSOlivier Houchard ((defobj)->relocbase + (def)->st_value) 50e659267fSOlivier Houchard 51e659267fSOlivier Houchard #define call_initfini_pointer(obj, target) \ 52e659267fSOlivier Houchard (((InitFunc)(target))()) 53e659267fSOlivier Houchard 5483aa9cc0SKonstantin Belousov #define call_init_pointer(obj, target) \ 5583aa9cc0SKonstantin Belousov (((InitArrFunc)(target))(main_argc, main_argv, environ)) 5683aa9cc0SKonstantin Belousov 574352999eSKonstantin Belousov #define call_ifunc_resolver(ptr) \ 584352999eSKonstantin Belousov (((Elf_Addr (*)(void))ptr)()) 594352999eSKonstantin Belousov 609ac88d19SOlivier Houchard typedef struct { 619ac88d19SOlivier Houchard unsigned long ti_module; 629ac88d19SOlivier Houchard unsigned long ti_offset; 639ac88d19SOlivier Houchard } tls_index; 649ac88d19SOlivier Houchard 659ac88d19SOlivier Houchard #define round(size, align) \ 669ac88d19SOlivier Houchard (((size) + (align) - 1) & ~((align) - 1)) 67e5c3405cSKonstantin Belousov #define calculate_first_tls_offset(size, align, offset) \ 68dc3b6c3aSOleksandr Tymoshenko round(8, align) 69e5c3405cSKonstantin Belousov #define calculate_tls_offset(prev_offset, prev_size, size, align, offset) \ 709ac88d19SOlivier Houchard round(prev_offset + prev_size, align) 7117fb2856SBrooks Davis #define calculate_tls_post_size(align) \ 7217fb2856SBrooks Davis round(TLS_TCB_SIZE, align) - TLS_TCB_SIZE 739ac88d19SOlivier Houchard 749ac88d19SOlivier Houchard extern void *__tls_get_addr(tls_index *ti); 7525a25289SOlivier Houchard 76cb38d494SKonstantin Belousov #define RTLD_DEFAULT_STACK_PF_EXEC PF_X 77cb38d494SKonstantin Belousov #define RTLD_DEFAULT_STACK_EXEC PROT_EXEC 78cb38d494SKonstantin Belousov 798fd53f45SWarner Losh extern void arm_abi_variant_hook(Elf_Auxinfo **); 808fd53f45SWarner Losh 8108d1c5b1SWarner Losh #ifdef __ARM_FP 828fd53f45SWarner Losh #define md_abi_variant_hook(x) arm_abi_variant_hook(x) 8308d1c5b1SWarner Losh #else 8408d1c5b1SWarner Losh #define md_abi_variant_hook(x) 8508d1c5b1SWarner Losh #endif 868fd53f45SWarner Losh 87c6ac5bfcSOlivier Houchard #endif 88