rtld_machdep.h revision 115396
145501Sjdp/*-
262801Sjdp * Copyright (c) 1999, 2000 John D. Polstra.
345501Sjdp * All rights reserved.
445501Sjdp *
545501Sjdp * Redistribution and use in source and binary forms, with or without
645501Sjdp * modification, are permitted provided that the following conditions
745501Sjdp * are met:
845501Sjdp * 1. Redistributions of source code must retain the above copyright
945501Sjdp *    notice, this list of conditions and the following disclaimer.
1045501Sjdp * 2. Redistributions in binary form must reproduce the above copyright
1145501Sjdp *    notice, this list of conditions and the following disclaimer in the
1245501Sjdp *    documentation and/or other materials provided with the distribution.
1345501Sjdp *
1445501Sjdp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1545501Sjdp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1645501Sjdp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1745501Sjdp * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1845501Sjdp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1945501Sjdp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2045501Sjdp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2145501Sjdp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2245501Sjdp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2345501Sjdp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2445501Sjdp * SUCH DAMAGE.
2545501Sjdp *
2650476Speter * $FreeBSD: head/libexec/rtld-elf/i386/rtld_machdep.h 115396 2003-05-29 22:58:26Z kan $
2745501Sjdp */
2845501Sjdp
2945501Sjdp#ifndef RTLD_MACHDEP_H
3045501Sjdp#define RTLD_MACHDEP_H	1
3145501Sjdp
32115396Skan#include <sys/types.h>
33115396Skan#include <machine/atomic.h>
34115396Skan
35115396Skan#define	CACHE_LINE_SIZE		32
36115396Skan
3785004Sdfrstruct Struct_Obj_Entry;
3885004Sdfr
3945501Sjdp/* Return the address of the .dynamic section in the dynamic linker. */
4045501Sjdp#define rtld_dynamic(obj) \
4145501Sjdp    ((const Elf_Dyn *)((obj)->relocbase + (Elf_Addr)&_DYNAMIC))
4245501Sjdp
4348205Sjdp/* Fixup the jump slot at "where" to transfer control to "target". */
4485004Sdfrstatic inline Elf_Addr
4585004Sdfrreloc_jmpslot(Elf_Addr *where, Elf_Addr target,
46107071Stmm	      const struct Struct_Obj_Entry *obj,
47107071Stmm	      const struct Struct_Obj_Entry *refobj, const Elf_Rel *rel)
4885004Sdfr{
4985004Sdfr    dbg("reloc_jmpslot: *%p = %p", (void *)(where),
5085004Sdfr	(void *)(target));
5185004Sdfr    (*(Elf_Addr *)(where) = (Elf_Addr)(target));
5285004Sdfr    return target;
5385004Sdfr}
5448205Sjdp
5585004Sdfr#define make_function_pointer(def, defobj) \
5685004Sdfr	((defobj)->relocbase + (def)->st_value)
5785004Sdfr
5885677Speter#define call_initfini_pointer(obj, target) \
5985677Speter	(((InitFunc)(target))())
6085677Speter
6145501Sjdp#endif
62