rtld_machdep.h revision 133063
165862Sbrian/*-
265862Sbrian * Copyright (c) 1999, 2000 John D. Polstra.
365862Sbrian * All rights reserved.
465862Sbrian *
565862Sbrian * Redistribution and use in source and binary forms, with or without
665862Sbrian * modification, are permitted provided that the following conditions
765862Sbrian * are met:
865862Sbrian * 1. Redistributions of source code must retain the above copyright
965862Sbrian *    notice, this list of conditions and the following disclaimer.
1065862Sbrian * 2. Redistributions in binary form must reproduce the above copyright
1165862Sbrian *    notice, this list of conditions and the following disclaimer in the
1265862Sbrian *    documentation and/or other materials provided with the distribution.
1365862Sbrian *
1465862Sbrian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1565862Sbrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1665862Sbrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1765862Sbrian * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1865862Sbrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1965862Sbrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2065862Sbrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2165862Sbrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2265862Sbrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2365862Sbrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2465862Sbrian * SUCH DAMAGE.
2565862Sbrian *
2665862Sbrian * $FreeBSD: head/libexec/rtld-elf/sparc64/rtld_machdep.h 133063 2004-08-03 08:51:00Z dfr $
2765862Sbrian */
2865862Sbrian
2965862Sbrian#ifndef RTLD_MACHDEP_H
3065862Sbrian#define RTLD_MACHDEP_H	1
3165862Sbrian
3265862Sbrian#include <sys/types.h>
3365862Sbrian#include <machine/atomic.h>
3465862Sbrian
3565862Sbrian#define CACHE_LINE_SIZE		128
3665862Sbrian
3765862Sbrianstruct Struct_Obj_Entry;
3865862Sbrian
3965862Sbrian/* Return the address of the .dynamic section in the dynamic linker. */
4065862SbrianElf_Dyn *rtld_dynamic_addr();
4165862Sbrian#define	rtld_dynamic(obj)	rtld_dynamic_addr()
4265862Sbrian#define	RTLD_IS_DYNAMIC()	(rtld_dynamic_addr() != NULL)
4365862Sbrian
4465862SbrianElf_Addr reloc_jmpslot(Elf_Addr *, Elf_Addr,
4565862Sbrian		       const struct Struct_Obj_Entry *,
4665862Sbrian		       const struct Struct_Obj_Entry *,
4765862Sbrian		       const Elf_Rel *);
4865862Sbrian
4965862Sbrian#define make_function_pointer(def, defobj) \
5065862Sbrian	((defobj)->relocbase + (def)->st_value)
5165862Sbrian
5265862Sbrian#define call_initfini_pointer(obj, target) \
5365862Sbrian	(((InitFunc)(target))())
5465862Sbrian
5565862Sbrian#define round(size, align) \
5665862Sbrian	(((size) + (align) - 1) & ~((align) - 1))
5765862Sbrian#define calculate_first_tls_offset(size, align) \
5865862Sbrian	round(size, align)
5965862Sbrian#define calculate_tls_offset(prev_offset, prev_size, size, align) \
6065862Sbrian	round((prev_offset) + (size), align)
6165862Sbrian#define calculate_tls_end(off, size) 	((off) + (size))
6265863Sbrian
6365863Sbriantypedef struct {
6465862Sbrian    unsigned long ti_module;
6565862Sbrian    unsigned long ti_offset;
6665862Sbrian} tls_index;
6765862Sbrian
6865862Sbrianextern void *__tls_get_addr(tls_index *ti);
6965862Sbrian
7065862Sbrian#endif
71134789Sbrian