rtld_machdep.h revision 293066
1148211Sanholt/*-
2148211Sanholt * Copyright (c) 1999, 2000 John D. Polstra.
3148211Sanholt * Copyright (c) 2014 the FreeBSD Foundation
4148211Sanholt * All rights reserved.
5148211Sanholt *
6148211Sanholt * Portions of this software were developed by Andrew Turner
7148211Sanholt * under sponsorship from the FreeBSD Foundation.
8148211Sanholt *
9148211Sanholt * Redistribution and use in source and binary forms, with or without
10148211Sanholt * modification, are permitted provided that the following conditions
11148211Sanholt * are met:
12148211Sanholt * 1. Redistributions of source code must retain the above copyright
13148211Sanholt *    notice, this list of conditions and the following disclaimer.
14148211Sanholt * 2. Redistributions in binary form must reproduce the above copyright
15148211Sanholt *    notice, this list of conditions and the following disclaimer in the
16148211Sanholt *    documentation and/or other materials provided with the distribution.
17148211Sanholt *
18148211Sanholt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19148211Sanholt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20148211Sanholt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21148211Sanholt * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22148211Sanholt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23148211Sanholt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24148211Sanholt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25148211Sanholt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26152909Sanholt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27152909Sanholt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28148211Sanholt * SUCH DAMAGE.
29182080Srnoland *
30182080Srnoland * $FreeBSD: head/libexec/rtld-elf/aarch64/rtld_machdep.h 293066 2016-01-03 04:32:02Z imp $
31148211Sanholt */
32148211Sanholt
33148211Sanholt#ifndef RTLD_MACHDEP_H
34148211Sanholt#define	RTLD_MACHDEP_H	1
35148211Sanholt
36148211Sanholt#include <sys/types.h>
37148211Sanholt#include <machine/atomic.h>
38148211Sanholt
39148211Sanholtstruct Struct_Obj_Entry;
40148211Sanholt
41148211Sanholt/* Return the address of the .dynamic section in the dynamic linker. */
42148211Sanholt#define	rtld_dynamic(obj)						\
43148211Sanholt({									\
44148211Sanholt	Elf_Addr _dynamic_addr;						\
45148211Sanholt	asm volatile("adr	%0, _DYNAMIC" : "=&r"(_dynamic_addr));	\
46148211Sanholt	(const Elf_Dyn *)_dynamic_addr;					\
47148211Sanholt})
48148211Sanholt#define	RTLD_IS_DYNAMIC() (1)
49148211Sanholt
50148211SanholtElf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
51148211Sanholt		       const struct Struct_Obj_Entry *defobj,
52148211Sanholt		       const struct Struct_Obj_Entry *obj,
53148211Sanholt		       const Elf_Rel *rel);
54148211Sanholt
55148211Sanholt#define	make_function_pointer(def, defobj) \
56182080Srnoland	((defobj)->relocbase + (def)->st_value)
57182080Srnoland
58182080Srnoland#define	call_initfini_pointer(obj, target) \
59182080Srnoland	(((InitFunc)(target))())
60182080Srnoland
61182080Srnoland#define	call_init_pointer(obj, target) \
62148211Sanholt	(((InitArrFunc)(target))(main_argc, main_argv, environ))
63148211Sanholt
64148211Sanholt#define	round(size, align) \
65148211Sanholt	(((size) + (align) - 1) & ~((align) - 1))
66148211Sanholt#define	calculate_first_tls_offset(size, align) \
67148211Sanholt	round(16, align)
68148211Sanholt#define	calculate_tls_offset(prev_offset, prev_size, size, align) \
69148211Sanholt	round(prev_offset + prev_size, align)
70148211Sanholt#define	calculate_tls_end(off, size) 	((off) + (size))
71182080Srnoland
72182080Srnoland#define	TLS_TCB_SIZE	16
73182080Srnolandtypedef struct {
74182080Srnoland    unsigned long ti_module;
75182080Srnoland    unsigned long ti_offset;
76182080Srnoland} tls_index;
77182080Srnoland
78182080Srnolandextern void *__tls_get_addr(tls_index *ti);
79182080Srnoland
80148211Sanholt#define	RTLD_DEFAULT_STACK_PF_EXEC	PF_X
81182080Srnoland#define	RTLD_DEFAULT_STACK_EXEC		PROT_EXEC
82182080Srnoland
83182080Srnoland#define md_abi_variant_hook(x)
84182080Srnoland
85182080Srnoland#endif
86182080Srnoland