Path: blob/main/libexec/rtld-elf/amd64/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_ENTRY3839/* Return the address of the .dynamic section in the dynamic linker. */40Elf_Dyn *rtld_dynamic_addr(void);41#define rtld_dynamic(obj) rtld_dynamic_addr()4243/* No arch-specific dynamic tags */44#define arch_digest_dynamic(obj, dynp) false4546/* No architecture specific notes */47#define arch_digest_note(obj, note) false4849Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target,50const struct Struct_Obj_Entry *obj, const struct Struct_Obj_Entry *refobj,51const Elf_Rel *rel);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 uint32_t cpu_feature;63extern uint32_t cpu_feature2;64extern uint32_t cpu_stdext_feature;65extern uint32_t cpu_stdext_feature2;66#define call_ifunc_resolver(ptr) \67(((Elf_Addr (*)(uint32_t, uint32_t, uint32_t, uint32_t))ptr)( \68cpu_feature, cpu_feature2, cpu_stdext_feature, cpu_stdext_feature2))6970typedef struct {71unsigned long ti_module;72unsigned long ti_offset;73} tls_index;7475void *__tls_get_addr(tls_index *ti) __exported;7677#define md_abi_variant_hook(x)7879size_t calculate_first_tls_offset(size_t size, size_t align, size_t offset);80size_t calculate_tls_offset(size_t prev_offset, size_t prev_size, size_t size,81size_t align, size_t offset);82#endif838485