185004Sdfr/*-
285004Sdfr * Copyright (c) 1999, 2000 John D. Polstra.
385004Sdfr * All rights reserved.
485004Sdfr *
585004Sdfr * Redistribution and use in source and binary forms, with or without
685004Sdfr * modification, are permitted provided that the following conditions
785004Sdfr * are met:
885004Sdfr * 1. Redistributions of source code must retain the above copyright
985004Sdfr *    notice, this list of conditions and the following disclaimer.
1085004Sdfr * 2. Redistributions in binary form must reproduce the above copyright
1185004Sdfr *    notice, this list of conditions and the following disclaimer in the
1285004Sdfr *    documentation and/or other materials provided with the distribution.
1385004Sdfr *
1485004Sdfr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1585004Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1685004Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1785004Sdfr * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1885004Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1985004Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2085004Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2185004Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2285004Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2385004Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2485004Sdfr * SUCH DAMAGE.
2585004Sdfr *
2685004Sdfr * $FreeBSD$
2785004Sdfr */
2885004Sdfr
2985004Sdfr#ifndef RTLD_MACHDEP_H
3085004Sdfr#define RTLD_MACHDEP_H	1
3185004Sdfr
32115396Skan#include <sys/types.h>
33115396Skan#include <machine/atomic.h>
34115396Skan
3585004Sdfr/*
3685004Sdfr * Macros for cracking ia64 function pointers.
3785004Sdfr */
3885004Sdfrstruct fptr {
3985004Sdfr	Elf_Addr	target;
4085004Sdfr	Elf_Addr	gp;
4185004Sdfr};
4285004Sdfr
4385004Sdfr#define FPTR_TARGET(f)	(((struct fptr *) (f))->target)
4485004Sdfr#define FPTR_GP(f)	(((struct fptr *) (f))->gp)
4585004Sdfr
4685004Sdfr/* Return the address of the .dynamic section in the dynamic linker. */
4785004Sdfr#define rtld_dynamic(obj)	(&_DYNAMIC)
4885004Sdfr
4985004Sdfrstruct Struct_Obj_Entry;
5085004Sdfr
51107071StmmElf_Addr reloc_jmpslot(Elf_Addr *, Elf_Addr, const struct Struct_Obj_Entry *,
52107071Stmm		       const struct Struct_Obj_Entry *, const Elf_Rel *);
5385004Sdfrvoid *make_function_pointer(const Elf_Sym *, const struct Struct_Obj_Entry *);
5485677Spetervoid call_initfini_pointer(const struct Struct_Obj_Entry *, Elf_Addr);
55232831Skibvoid call_init_pointer(const struct Struct_Obj_Entry *, Elf_Addr);
5685004Sdfr
57161783Smarcel#define	TLS_TCB_SIZE	16
58161783Smarcel
59133063Sdfr#define round(size, align) \
60133063Sdfr	(((size) + (align) - 1) & ~((align) - 1))
61133063Sdfr#define calculate_first_tls_offset(size, align) \
62161783Smarcel	round(TLS_TCB_SIZE, align)
63133063Sdfr#define calculate_tls_offset(prev_offset, prev_size, size, align) \
64133063Sdfr	round(prev_offset + prev_size, align)
65133063Sdfr#define calculate_tls_end(off, size) 	((off) + (size))
66133063Sdfr
67133063Sdfrextern void *__tls_get_addr(unsigned long module, unsigned long offset);
68133063Sdfr
69217851Skib#define	RTLD_DEFAULT_STACK_PF_EXEC	0
70217851Skib#define	RTLD_DEFAULT_STACK_EXEC		0
71217851Skib
7285004Sdfr#endif
73