1*6206Sab196087 /* 2*6206Sab196087 * CDDL HEADER START 3*6206Sab196087 * 4*6206Sab196087 * The contents of this file are subject to the terms of the 5*6206Sab196087 * Common Development and Distribution License (the "License"). 6*6206Sab196087 * You may not use this file except in compliance with the License. 7*6206Sab196087 * 8*6206Sab196087 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*6206Sab196087 * or http://www.opensolaris.org/os/licensing. 10*6206Sab196087 * See the License for the specific language governing permissions 11*6206Sab196087 * and limitations under the License. 12*6206Sab196087 * 13*6206Sab196087 * When distributing Covered Code, include this CDDL HEADER in each 14*6206Sab196087 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*6206Sab196087 * If applicable, add the following below this CDDL HEADER, with the 16*6206Sab196087 * fields enclosed by brackets "[]" replaced with your own identifying 17*6206Sab196087 * information: Portions Copyright [yyyy] [name of copyright owner] 18*6206Sab196087 * 19*6206Sab196087 * CDDL HEADER END 20*6206Sab196087 */ 21*6206Sab196087 22*6206Sab196087 /* 23*6206Sab196087 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24*6206Sab196087 * Use is subject to license terms. 25*6206Sab196087 */ 26*6206Sab196087 27*6206Sab196087 #ifndef _RELOC_DEFS_DOT_H 28*6206Sab196087 #define _RELOC_DEFS_DOT_H 29*6206Sab196087 30*6206Sab196087 #pragma ident "%Z%%M% %I% %E% SMI" 31*6206Sab196087 32*6206Sab196087 #include <sys/machelf.h> 33*6206Sab196087 34*6206Sab196087 #ifdef __cplusplus 35*6206Sab196087 extern "C" { 36*6206Sab196087 #endif 37*6206Sab196087 38*6206Sab196087 /* 39*6206Sab196087 * Definitions used by the relocation common code. 40*6206Sab196087 */ 41*6206Sab196087 42*6206Sab196087 43*6206Sab196087 /* 44*6206Sab196087 * Structure used to build the reloc_table[] 45*6206Sab196087 */ 46*6206Sab196087 typedef struct { 47*6206Sab196087 Xword re_mask; /* mask to apply to reloc (sparc only) */ 48*6206Sab196087 Word re_flags; /* relocation attributes */ 49*6206Sab196087 uchar_t re_fsize; /* field size (in bytes) */ 50*6206Sab196087 uchar_t re_bshift; /* number of bits to shift (sparc only) */ 51*6206Sab196087 uchar_t re_sigbits; /* number of significant bits */ 52*6206Sab196087 } Rel_entry; 53*6206Sab196087 54*6206Sab196087 /* 55*6206Sab196087 * Flags for reloc_entry->re_flags 56*6206Sab196087 */ 57*6206Sab196087 #define FLG_RE_NOTREL 0x00000000 58*6206Sab196087 #define FLG_RE_GOTADD 0x00000001 /* create a GOT entry */ 59*6206Sab196087 #define FLG_RE_GOTREL 0x00000002 /* GOT based */ 60*6206Sab196087 #define FLG_RE_GOTPC 0x00000004 /* GOT - P */ 61*6206Sab196087 #define FLG_RE_GOTOPINS 0x00000008 /* GOTOP instruction */ 62*6206Sab196087 #define FLG_RE_PCREL 0x00000010 63*6206Sab196087 #define FLG_RE_PLTREL 0x00000020 64*6206Sab196087 #define FLG_RE_VERIFY 0x00000040 /* verify value fits */ 65*6206Sab196087 #define FLG_RE_UNALIGN 0x00000080 /* offset is not aligned */ 66*6206Sab196087 #define FLG_RE_WDISP16 0x00000100 /* funky sparc DISP16 rel */ 67*6206Sab196087 #define FLG_RE_SIGN 0x00000200 /* value is signed */ 68*6206Sab196087 #define FLG_RE_ADDRELATIVE 0x00000400 /* RELATIVE relocation */ 69*6206Sab196087 /* required for non- */ 70*6206Sab196087 /* fixed objects */ 71*6206Sab196087 #define FLG_RE_EXTOFFSET 0x00000800 /* extra offset required */ 72*6206Sab196087 #define FLG_RE_REGISTER 0x00001000 /* relocation initializes */ 73*6206Sab196087 /* a REGISTER by OLO10 */ 74*6206Sab196087 #define FLG_RE_SIZE 0x00002000 /* symbol size required */ 75*6206Sab196087 76*6206Sab196087 #define FLG_RE_NOTSUP 0x00010000 /* relocation not supported */ 77*6206Sab196087 78*6206Sab196087 #define FLG_RE_SEGREL 0x00040000 /* segment relative */ 79*6206Sab196087 #define FLG_RE_SECREL 0x00080000 /* section relative */ 80*6206Sab196087 81*6206Sab196087 #define FLG_RE_TLSGD 0x00200000 /* TLS GD relocation */ 82*6206Sab196087 #define FLG_RE_TLSLD 0x00400000 /* TLS LD relocation */ 83*6206Sab196087 #define FLG_RE_TLSIE 0x00800000 /* TLS IE relocation */ 84*6206Sab196087 #define FLG_RE_TLSLE 0x01000000 /* TLS LE relocation */ 85*6206Sab196087 #define FLG_RE_LOCLBND 0x02000000 /* relocation must bind */ 86*6206Sab196087 /* locally */ 87*6206Sab196087 88*6206Sab196087 /* 89*6206Sab196087 * Relocation table and macros for testing relocation table flags. 90*6206Sab196087 */ 91*6206Sab196087 92*6206Sab196087 #define RELTAB_IS_PLT(X, _reltab) \ 93*6206Sab196087 ((_reltab[(X)].re_flags & FLG_RE_PLTREL) != 0) 94*6206Sab196087 95*6206Sab196087 #define RELTAB_IS_GOT_RELATIVE(X, _reltab) \ 96*6206Sab196087 ((_reltab[(X)].re_flags & FLG_RE_GOTADD) != 0) 97*6206Sab196087 98*6206Sab196087 #define RELTAB_IS_GOT_PC(X, _reltab) \ 99*6206Sab196087 ((_reltab[(X)].re_flags & FLG_RE_GOTPC) != 0) 100*6206Sab196087 101*6206Sab196087 #define RELTAB_IS_GOTPCREL(X, _reltab) \ 102*6206Sab196087 ((_reltab[(X)].re_flags & (FLG_RE_GOTPC | FLG_RE_GOTADD)) == \ 103*6206Sab196087 (FLG_RE_GOTPC | FLG_RE_GOTADD)) 104*6206Sab196087 105*6206Sab196087 #define RELTAB_IS_GOT_BASED(X, _reltab) \ 106*6206Sab196087 ((_reltab[(X)].re_flags & FLG_RE_GOTREL) != 0) 107*6206Sab196087 108*6206Sab196087 #define RELTAB_IS_GOT_OPINS(X, _reltab) \ 109*6206Sab196087 ((_reltab[(X)].re_flags & FLG_RE_GOTOPINS) != 0) 110*6206Sab196087 111*6206Sab196087 #define RELTAB_IS_GOT_REQUIRED(X, _reltab) \ 112*6206Sab196087 ((_reltab[(X)].re_flags & (FLG_RE_GOTADD | FLG_RE_GOTREL | \ 113*6206Sab196087 FLG_RE_GOTPC | FLG_RE_GOTOPINS)) != 0) 114*6206Sab196087 115*6206Sab196087 #define RELTAB_IS_PC_RELATIVE(X, _reltab) \ 116*6206Sab196087 ((_reltab[(X)].re_flags & FLG_RE_PCREL) != 0) 117*6206Sab196087 118*6206Sab196087 #define RELTAB_IS_ADD_RELATIVE(X, _reltab) \ 119*6206Sab196087 ((_reltab[(X)].re_flags & FLG_RE_ADDRELATIVE) != 0) 120*6206Sab196087 121*6206Sab196087 #define RELTAB_IS_REGISTER(X, _reltab) \ 122*6206Sab196087 ((_reltab[(X)].re_flags & FLG_RE_REGISTER) != 0) 123*6206Sab196087 124*6206Sab196087 #define RELTAB_IS_NOTSUP(X, _reltab) \ 125*6206Sab196087 ((_reltab[(X)].re_flags & FLG_RE_NOTSUP) != 0) 126*6206Sab196087 127*6206Sab196087 #define RELTAB_IS_SEG_RELATIVE(X, _reltab) \ 128*6206Sab196087 ((_reltab[(X)].re_flags & FLG_RE_SEGREL) != 0) 129*6206Sab196087 130*6206Sab196087 #define RELTAB_IS_EXTOFFSET(X, _reltab) \ 131*6206Sab196087 ((_reltab[(X)].re_flags & FLG_RE_EXTOFFSET) != 0) 132*6206Sab196087 133*6206Sab196087 #define RELTAB_IS_SEC_RELATIVE(X, _reltab) \ 134*6206Sab196087 ((_reltab[(X)].re_flags & FLG_RE_SECREL) != 0) 135*6206Sab196087 136*6206Sab196087 #define RELTAB_IS_TLS_INS(X, _reltab) \ 137*6206Sab196087 ((_reltab[(X)].re_flags & \ 138*6206Sab196087 (FLG_RE_TLSGD | FLG_RE_TLSLD | FLG_RE_TLSIE | FLG_RE_TLSLE)) != 0) 139*6206Sab196087 140*6206Sab196087 #define RELTAB_IS_TLS_GD(X, _reltab) \ 141*6206Sab196087 ((_reltab[(X)].re_flags & FLG_RE_TLSGD) != 0) 142*6206Sab196087 143*6206Sab196087 #define RELTAB_IS_TLS_LD(X, _reltab) \ 144*6206Sab196087 ((_reltab[(X)].re_flags & FLG_RE_TLSLD) != 0) 145*6206Sab196087 146*6206Sab196087 #define RELTAB_IS_TLS_IE(X, _reltab) \ 147*6206Sab196087 ((_reltab[(X)].re_flags & FLG_RE_TLSIE) != 0) 148*6206Sab196087 149*6206Sab196087 #define RELTAB_IS_TLS_LE(X, _reltab) \ 150*6206Sab196087 ((_reltab[(X)].re_flags & FLG_RE_TLSLE) != 0) 151*6206Sab196087 152*6206Sab196087 #define RELTAB_IS_LOCALBND(X, _reltab) \ 153*6206Sab196087 ((_reltab[(X)].re_flags & FLG_RE_LOCLBND) != 0) 154*6206Sab196087 155*6206Sab196087 #define RELTAB_IS_SIZE(X, _reltab) \ 156*6206Sab196087 ((_reltab[(X)].re_flags & FLG_RE_SIZE) != 0) 157*6206Sab196087 158*6206Sab196087 #ifdef __cplusplus 159*6206Sab196087 } 160*6206Sab196087 #endif 161*6206Sab196087 162*6206Sab196087 #endif /* _RELOC_DEFS_DOT_H */ 163