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