rtld_machdep.h revision 115396
18156Sphk/*- 28156Sphk * Copyright (c) 1999, 2000 John D. Polstra. 38156Sphk * All rights reserved. 48156Sphk * 58156Sphk * Redistribution and use in source and binary forms, with or without 68156Sphk * modification, are permitted provided that the following conditions 78156Sphk * are met: 88156Sphk * 1. Redistributions of source code must retain the above copyright 98158Sphk * notice, this list of conditions and the following disclaimer. 108156Sphk * 2. Redistributions in binary form must reproduce the above copyright 118156Sphk * notice, this list of conditions and the following disclaimer in the 128153Sphk * documentation and/or other materials provided with the distribution. 138158Sphk * 148158Sphk * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 158158Sphk * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 168153Sphk * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 178156Sphk * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 188153Sphk * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 198157Sphk * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 208153Sphk * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 218153Sphk * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 228153Sphk * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 238153Sphk * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 248156Sphk * SUCH DAMAGE. 258156Sphk * 268153Sphk * $FreeBSD: head/libexec/rtld-elf/amd64/rtld_machdep.h 115396 2003-05-29 22:58:26Z kan $ 278153Sphk */ 288153Sphk 298153Sphk#ifndef RTLD_MACHDEP_H 308153Sphk#define RTLD_MACHDEP_H 1 318153Sphk 328158Sphk#include <sys/types.h> 338158Sphk#include <machine/atomic.h> 348158Sphk 358153Sphk#define CACHE_LINE_SIZE 32 368153Sphk 378153Sphkstruct Struct_Obj_Entry; 388153Sphk 398153Sphk/* Return the address of the .dynamic section in the dynamic linker. */ 408153Sphk#define rtld_dynamic(obj) \ 418153Sphk ((const Elf_Dyn *)((obj)->relocbase + (Elf_Addr)&_DYNAMIC)) 428153Sphk 438153Sphk/* Fixup the jump slot at "where" to transfer control to "target". */ 448153Sphkstatic inline Elf_Addr 458153Sphkreloc_jmpslot(Elf_Addr *where, Elf_Addr target, 468153Sphk const struct Struct_Obj_Entry *obj, 478156Sphk const struct Struct_Obj_Entry *refobj, const Elf_Rel *rel) 488156Sphk{ 498156Sphk dbg("reloc_jmpslot: *%p = %p", (void *)(where), 508153Sphk (void *)(target)); 518156Sphk (*(Elf_Addr *)(where) = (Elf_Addr)(target)); 528156Sphk return target; 538156Sphk} 548156Sphk 558156Sphk#define make_function_pointer(def, defobj) \ 568156Sphk ((defobj)->relocbase + (def)->st_value) 578156Sphk 588156Sphk#define call_initfini_pointer(obj, target) \ 598156Sphk (((InitFunc)(target))()) 608153Sphk 618153Sphk#endif 628156Sphk