1129204Scognet/*-
2129204Scognet * Copyright (c) 1999, 2000 John D. Polstra.
3129204Scognet * All rights reserved.
4129204Scognet *
5129204Scognet * Redistribution and use in source and binary forms, with or without
6129204Scognet * modification, are permitted provided that the following conditions
7129204Scognet * are met:
8129204Scognet * 1. Redistributions of source code must retain the above copyright
9129204Scognet *    notice, this list of conditions and the following disclaimer.
10129204Scognet * 2. Redistributions in binary form must reproduce the above copyright
11129204Scognet *    notice, this list of conditions and the following disclaimer in the
12129204Scognet *    documentation and/or other materials provided with the distribution.
13129204Scognet *
14129204Scognet * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15129204Scognet * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16129204Scognet * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17129204Scognet * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18129204Scognet * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19129204Scognet * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20129204Scognet * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21129204Scognet * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22129204Scognet * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23129204Scognet * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24129204Scognet * SUCH DAMAGE.
25129204Scognet *
26129204Scognet * $FreeBSD: stable/10/libexec/rtld-elf/arm/rtld_machdep.h 309061 2016-11-23 17:48:43Z kib $
27129204Scognet */
28129204Scognet
29129204Scognet#ifndef RTLD_MACHDEP_H
30129204Scognet#define RTLD_MACHDEP_H	1
31129204Scognet
32129204Scognet#include <sys/types.h>
33129204Scognet#include <machine/atomic.h>
34129204Scognet
35129204Scognetstruct Struct_Obj_Entry;
36129204Scognet
37129204Scognet/* Return the address of the .dynamic section in the dynamic linker. */
38129204Scognet#define rtld_dynamic(obj) (&_DYNAMIC)
39135680Scognet
40129204ScognetElf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
41129204Scognet		       const struct Struct_Obj_Entry *defobj,
42129204Scognet		       const struct Struct_Obj_Entry *obj,
43129204Scognet		       const Elf_Rel *rel);
44129204Scognet
45129204Scognet#define make_function_pointer(def, defobj) \
46129204Scognet	((defobj)->relocbase + (def)->st_value)
47129204Scognet
48129204Scognet#define call_initfini_pointer(obj, target) \
49129204Scognet	(((InitFunc)(target))())
50135680Scognet
51232831Skib#define call_init_pointer(obj, target) \
52232831Skib	(((InitArrFunc)(target))(main_argc, main_argv, environ))
53232831Skib
54309061Skib#define	call_ifunc_resolver(ptr) \
55309061Skib	(((Elf_Addr (*)(void))ptr)())
56309061Skib
57231618Sgonzo#define	TLS_TCB_SIZE	8
58135680Scognettypedef struct {
59135680Scognet	unsigned long ti_module;
60135680Scognet	unsigned long ti_offset;
61135680Scognet} tls_index;
62129204Scognet
63135680Scognet#define round(size, align) \
64231618Sgonzo    (((size) + (align) - 1) & ~((align) - 1))
65135680Scognet#define calculate_first_tls_offset(size, align) \
66231618Sgonzo    round(8, align)
67135680Scognet#define calculate_tls_offset(prev_offset, prev_size, size, align) \
68231618Sgonzo    round(prev_offset + prev_size, align)
69135680Scognet#define calculate_tls_end(off, size)    ((off) + (size))
70135680Scognet
71129204Scognet/*
72129204Scognet * Lazy binding entry point, called via PLT.
73129204Scognet */
74129204Scognetvoid _rtld_bind_start(void);
75129204Scognet
76135680Scognetextern void *__tls_get_addr(tls_index *ti);
77138023Scognet
78217851Skib#define	RTLD_DEFAULT_STACK_PF_EXEC	PF_X
79217851Skib#define	RTLD_DEFAULT_STACK_EXEC		PROT_EXEC
80217851Skib
81129204Scognet#endif
82