1d5b537d0SJohn Polstra /*- 2630df077SJohn Polstra * Copyright (c) 1999, 2000 John D. Polstra. 3d5b537d0SJohn Polstra * All rights reserved. 4d5b537d0SJohn Polstra * 5d5b537d0SJohn Polstra * Redistribution and use in source and binary forms, with or without 6d5b537d0SJohn Polstra * modification, are permitted provided that the following conditions 7d5b537d0SJohn Polstra * are met: 8d5b537d0SJohn Polstra * 1. Redistributions of source code must retain the above copyright 9d5b537d0SJohn Polstra * notice, this list of conditions and the following disclaimer. 10d5b537d0SJohn Polstra * 2. Redistributions in binary form must reproduce the above copyright 11d5b537d0SJohn Polstra * notice, this list of conditions and the following disclaimer in the 12d5b537d0SJohn Polstra * documentation and/or other materials provided with the distribution. 13d5b537d0SJohn Polstra * 14d5b537d0SJohn Polstra * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15d5b537d0SJohn Polstra * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16d5b537d0SJohn Polstra * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17d5b537d0SJohn Polstra * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18d5b537d0SJohn Polstra * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19d5b537d0SJohn Polstra * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20d5b537d0SJohn Polstra * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21d5b537d0SJohn Polstra * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22d5b537d0SJohn Polstra * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23d5b537d0SJohn Polstra * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24d5b537d0SJohn Polstra * SUCH DAMAGE. 25d5b537d0SJohn Polstra * 267f3dea24SPeter Wemm * $FreeBSD$ 27d5b537d0SJohn Polstra */ 28d5b537d0SJohn Polstra 29d5b537d0SJohn Polstra #ifndef RTLD_MACHDEP_H 30d5b537d0SJohn Polstra #define RTLD_MACHDEP_H 1 31d5b537d0SJohn Polstra 326d5d786fSAlexander Kabaev #include <sys/types.h> 336d5d786fSAlexander Kabaev #include <machine/atomic.h> 346d5d786fSAlexander Kabaev 35b5393d9fSDoug Rabson struct Struct_Obj_Entry; 36b5393d9fSDoug Rabson 37d5b537d0SJohn Polstra /* Return the address of the .dynamic section in the dynamic linker. */ 38d5b537d0SJohn Polstra #define rtld_dynamic(obj) \ 39d5b537d0SJohn Polstra ((const Elf_Dyn *)((obj)->relocbase + (Elf_Addr)&_DYNAMIC)) 40d5b537d0SJohn Polstra 41*e35ddbe4SKonstantin Belousov Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target, 42*e35ddbe4SKonstantin Belousov const struct Struct_Obj_Entry *obj, const struct Struct_Obj_Entry *refobj, 43*e35ddbe4SKonstantin Belousov const Elf_Rel *rel); 44b5393d9fSDoug Rabson 45b5393d9fSDoug Rabson #define make_function_pointer(def, defobj) \ 46b5393d9fSDoug Rabson ((defobj)->relocbase + (def)->st_value) 47962fdc46SJohn Polstra 4814a55adfSPeter Wemm #define call_initfini_pointer(obj, target) \ 4914a55adfSPeter Wemm (((InitFunc)(target))()) 5014a55adfSPeter Wemm 5183aa9cc0SKonstantin Belousov #define call_init_pointer(obj, target) \ 5283aa9cc0SKonstantin Belousov (((InitArrFunc)(target))(main_argc, main_argv, environ)) 5383aa9cc0SKonstantin Belousov 544352999eSKonstantin Belousov extern uint32_t cpu_feature; 554352999eSKonstantin Belousov extern uint32_t cpu_feature2; 564352999eSKonstantin Belousov extern uint32_t cpu_stdext_feature; 574352999eSKonstantin Belousov extern uint32_t cpu_stdext_feature2; 584352999eSKonstantin Belousov #define call_ifunc_resolver(ptr) \ 594352999eSKonstantin Belousov (((Elf_Addr (*)(uint32_t, uint32_t, uint32_t, uint32_t))ptr)( \ 604352999eSKonstantin Belousov cpu_feature, cpu_feature2, cpu_stdext_feature, cpu_stdext_feature2)) 614352999eSKonstantin Belousov 62017246d0SDoug Rabson #define round(size, align) \ 63017246d0SDoug Rabson (((size) + (align) - 1) & ~((align) - 1)) 64017246d0SDoug Rabson #define calculate_first_tls_offset(size, align) \ 65017246d0SDoug Rabson round(size, align) 66017246d0SDoug Rabson #define calculate_tls_offset(prev_offset, prev_size, size, align) \ 67017246d0SDoug Rabson round((prev_offset) + (size), align) 68017246d0SDoug Rabson #define calculate_tls_end(off, size) (off) 69017246d0SDoug Rabson 70017246d0SDoug Rabson typedef struct { 71017246d0SDoug Rabson unsigned long ti_module; 72017246d0SDoug Rabson unsigned long ti_offset; 73017246d0SDoug Rabson } tls_index; 74017246d0SDoug Rabson 750c4f9ecdSKonstantin Belousov void *___tls_get_addr(tls_index *ti) __attribute__((__regparm__(1))) __exported; 760c4f9ecdSKonstantin Belousov void *__tls_get_addr(tls_index *ti) __exported; 77017246d0SDoug Rabson 78cb38d494SKonstantin Belousov #define RTLD_DEFAULT_STACK_PF_EXEC PF_X 79cb38d494SKonstantin Belousov #define RTLD_DEFAULT_STACK_EXEC PROT_EXEC 80cb38d494SKonstantin Belousov 818fd53f45SWarner Losh #define md_abi_variant_hook(x) 828fd53f45SWarner Losh 83d5b537d0SJohn Polstra #endif 84