1*95e1ffb1Schristos /* $NetBSD: reloc.h,v 1.7 2005/12/11 12:19:06 christos Exp $ */ 2274a9076Sderaadt 34588caefSderaadt /* 44588caefSderaadt * Copyright (c) 1992, 1993 54588caefSderaadt * The Regents of the University of California. All rights reserved. 64588caefSderaadt * 74588caefSderaadt * This software was developed by the Computer Systems Engineering group 84588caefSderaadt * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 94588caefSderaadt * contributed to Berkeley. 104588caefSderaadt * 114588caefSderaadt * All advertising materials mentioning features or use of this software 124588caefSderaadt * must display the following acknowledgement: 134588caefSderaadt * This product includes software developed by the University of 144588caefSderaadt * California, Lawrence Berkeley Laboratory. 154588caefSderaadt * 164588caefSderaadt * Redistribution and use in source and binary forms, with or without 174588caefSderaadt * modification, are permitted provided that the following conditions 184588caefSderaadt * are met: 194588caefSderaadt * 1. Redistributions of source code must retain the above copyright 204588caefSderaadt * notice, this list of conditions and the following disclaimer. 214588caefSderaadt * 2. Redistributions in binary form must reproduce the above copyright 224588caefSderaadt * notice, this list of conditions and the following disclaimer in the 234588caefSderaadt * documentation and/or other materials provided with the distribution. 24aad01611Sagc * 3. Neither the name of the University nor the names of its contributors 254588caefSderaadt * may be used to endorse or promote products derived from this software 264588caefSderaadt * without specific prior written permission. 274588caefSderaadt * 284588caefSderaadt * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 294588caefSderaadt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 304588caefSderaadt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 314588caefSderaadt * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 324588caefSderaadt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 334588caefSderaadt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 344588caefSderaadt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 354588caefSderaadt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 364588caefSderaadt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 374588caefSderaadt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 384588caefSderaadt * SUCH DAMAGE. 394588caefSderaadt * 404588caefSderaadt * @(#)reloc.h 8.1 (Berkeley) 6/11/93 414588caefSderaadt */ 424588caefSderaadt 434588caefSderaadt /* 444588caefSderaadt * SPARC relocations. The linker has, unfortunately, a large number 4548fcc1a2Smrg * of link types. 464588caefSderaadt */ 474588caefSderaadt enum reloc_type { 484588caefSderaadt /* architecturally-required types */ 494588caefSderaadt RELOC_8, /* 8-bit absolute */ 504588caefSderaadt RELOC_16, /* 16-bit absolute */ 514588caefSderaadt RELOC_32, /* 32-bit absolute */ 524588caefSderaadt RELOC_DISP8, /* 8-bit pc-relative */ 534588caefSderaadt RELOC_DISP16, /* 16-bit pc-relative */ 544588caefSderaadt RELOC_DISP32, /* 32-bit pc-relative */ 554588caefSderaadt RELOC_WDISP30, /* 30-bit pc-relative signed word */ 564588caefSderaadt RELOC_WDISP22, /* 22-bit pc-relative signed word */ 574588caefSderaadt RELOC_HI22, /* 22-bit `%hi' (ie, sethi %hi(X),%l0) */ 584588caefSderaadt RELOC_22, /* 22-bit non-%hi (i.e., sethi X,%l0) */ 594588caefSderaadt RELOC_13, /* 13-bit absolute */ 604588caefSderaadt RELOC_LO10, /* 10-bit `%lo' */ 614588caefSderaadt 624588caefSderaadt /* gnu ld understands some of these, but I do not */ 634588caefSderaadt RELOC_SFA_BASE, /* ? */ 644588caefSderaadt RELOC_SFA_OFF13, /* ? */ 654588caefSderaadt RELOC_BASE10, /* ? */ 664588caefSderaadt RELOC_BASE13, /* ? */ 674588caefSderaadt RELOC_BASE22, /* ? */ 684588caefSderaadt 694588caefSderaadt /* gnu ld does not use these but Sun linker does */ 704588caefSderaadt /* we define them anyway (note that they are included 714588caefSderaadt in the freely-available gas sources!) */ 7248fcc1a2Smrg /* actually, newer gnu ld does generate some of these. */ 734588caefSderaadt RELOC_PC10, /* ? */ 744588caefSderaadt RELOC_PC22, /* ? */ 754588caefSderaadt RELOC_JMP_TBL, /* ? */ 764588caefSderaadt RELOC_SEGOFF16, /* ? */ 774588caefSderaadt RELOC_GLOB_DAT, /* ? */ 784588caefSderaadt RELOC_JMP_SLOT, /* ? */ 794588caefSderaadt RELOC_RELATIVE, /* ? */ 8048fcc1a2Smrg RELOC_UA_32, /* unaligned 32bit relocation */ 81ce0e1deaSmrg 82ce0e1deaSmrg /* The following are LP64 relocations */ 83ce0e1deaSmrg 84ce0e1deaSmrg RELOC_PLT32, 85ce0e1deaSmrg RELOC_HIPLT22, 86ce0e1deaSmrg RELOC_LOPLT10, 87ce0e1deaSmrg RELOC_PCPLT32, 883a5765c0Sskrll RELOC_PCPLT22, 893a5765c0Sskrll RELOC_PCPLT10, 90ce0e1deaSmrg 91ce0e1deaSmrg RELOC_10, 92ce0e1deaSmrg RELOC_11, 93ce0e1deaSmrg RELOC_64, 94ce0e1deaSmrg RELOC_OLO10, 95ce0e1deaSmrg RELOC_HH22, 96ce0e1deaSmrg 97ce0e1deaSmrg RELOC_HM10, 98ce0e1deaSmrg RELOC_LM22, 99ce0e1deaSmrg RELOC_PC_HH22, 100ce0e1deaSmrg RELOC_PC_HM10, 101ce0e1deaSmrg RELOC_PC_LM22, 102ce0e1deaSmrg 103ce0e1deaSmrg RELOC_WDISP16, 104ce0e1deaSmrg RELOC_WDISP19, 105ce0e1deaSmrg RELOC_GLOB_JMP, 106ce0e1deaSmrg RELOC_7, 107ce0e1deaSmrg RELOC_5, 108ce0e1deaSmrg RELOC_6 1094588caefSderaadt }; 1104588caefSderaadt 1114588caefSderaadt /* 1124588caefSderaadt * SPARC relocation info. 1134588caefSderaadt * 1144588caefSderaadt * Symbol-relative relocation is done by: 1154588caefSderaadt * 1. locating the appropriate symbol 1164588caefSderaadt * 2. if defined, adding (value + r_addend), subtracting pc if pc-rel, 1174588caefSderaadt * and then shifting down 2 or 10 or 13 if necessary. 1184588caefSderaadt * The resulting value is then to be stuffed into the appropriate bits 1194588caefSderaadt * in the object (the low 22, or the high 30, or ..., etc). 1204588caefSderaadt */ 1214588caefSderaadt struct reloc_info_sparc { 1224588caefSderaadt u_long r_address; /* relocation addr (offset in segment) */ 1234588caefSderaadt u_int r_index:24, /* segment (r_extern==0) or symbol index */ 1244588caefSderaadt r_extern:1, /* if set, r_index is symbol index */ 1254588caefSderaadt :2; /* unused */ 1264588caefSderaadt enum reloc_type r_type:5; /* relocation type, from above */ 1274588caefSderaadt long r_addend; /* value to add to symbol value */ 1284588caefSderaadt }; 129