1e659267fSOlivier Houchard /*- 24d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 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 29e659267fSOlivier Houchard #ifndef RTLD_MACHDEP_H 30e659267fSOlivier Houchard #define RTLD_MACHDEP_H 1 31e659267fSOlivier Houchard 32e659267fSOlivier Houchard #include <sys/types.h> 33e659267fSOlivier Houchard #include <machine/atomic.h> 3408d1c5b1SWarner Losh #include <machine/acle-compat.h> 358bcdb144SJohn Baldwin #include <machine/tls.h> 36e659267fSOlivier Houchard 37e659267fSOlivier Houchard struct Struct_Obj_Entry; 38e659267fSOlivier Houchard 39e659267fSOlivier Houchard /* Return the address of the .dynamic section in the dynamic linker. */ 40e659267fSOlivier Houchard #define rtld_dynamic(obj) (&_DYNAMIC) 419ac88d19SOlivier Houchard 42d8925a5fSAndrew Turner /* No architecture specific notes */ 43d8925a5fSAndrew Turner #define arch_digest_note(obj, note) false 44d8925a5fSAndrew Turner 45e659267fSOlivier Houchard Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target, 46e35ddbe4SKonstantin Belousov const struct Struct_Obj_Entry *defobj, const struct Struct_Obj_Entry *obj, 47e659267fSOlivier Houchard const Elf_Rel *rel); 48e659267fSOlivier Houchard 49e659267fSOlivier Houchard #define make_function_pointer(def, defobj) \ 50e659267fSOlivier Houchard ((defobj)->relocbase + (def)->st_value) 51e659267fSOlivier Houchard 52e659267fSOlivier Houchard #define call_initfini_pointer(obj, target) \ 53e659267fSOlivier Houchard (((InitFunc)(target))()) 54e659267fSOlivier Houchard 5583aa9cc0SKonstantin Belousov #define call_init_pointer(obj, target) \ 5683aa9cc0SKonstantin Belousov (((InitArrFunc)(target))(main_argc, main_argv, environ)) 5783aa9cc0SKonstantin Belousov 584352999eSKonstantin Belousov #define call_ifunc_resolver(ptr) \ 594352999eSKonstantin Belousov (((Elf_Addr (*)(void))ptr)()) 604352999eSKonstantin Belousov 619ac88d19SOlivier Houchard typedef struct { 629ac88d19SOlivier Houchard unsigned long ti_module; 639ac88d19SOlivier Houchard unsigned long ti_offset; 649ac88d19SOlivier Houchard } tls_index; 659ac88d19SOlivier Houchard 669ac88d19SOlivier Houchard #define round(size, align) \ 679ac88d19SOlivier Houchard (((size) + (align) - 1) & ~((align) - 1)) 68e5c3405cSKonstantin Belousov #define calculate_first_tls_offset(size, align, offset) \ 69dc3b6c3aSOleksandr Tymoshenko round(8, align) 70e5c3405cSKonstantin Belousov #define calculate_tls_offset(prev_offset, prev_size, size, align, offset) \ 719ac88d19SOlivier Houchard round(prev_offset + prev_size, align) 7217fb2856SBrooks Davis #define calculate_tls_post_size(align) \ 7317fb2856SBrooks Davis round(TLS_TCB_SIZE, align) - TLS_TCB_SIZE 749ac88d19SOlivier Houchard 759ac88d19SOlivier Houchard extern void *__tls_get_addr(tls_index *ti); 7625a25289SOlivier Houchard 7708d1c5b1SWarner Losh #define md_abi_variant_hook(x) 788fd53f45SWarner Losh 79c6ac5bfcSOlivier Houchard #endif 80