1 /* 2 * Copyright (c) 1992 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This software was developed by the Computer Systems Engineering group 6 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 7 * contributed to Berkeley. 8 * 9 * %sccs.include.redist.c% 10 * 11 * @(#)reloc.h 7.1 (Berkeley) 07/13/92 12 * 13 * from: $Header: reloc.h,v 1.6 92/06/20 09:59:37 torek Exp $ 14 */ 15 16 /* 17 * SPARC relocations. The linker has, unfortunately, a large number 18 * of link types. We do not do dynamic linking (yet?) but we define 19 * the dynamic link types. 20 */ 21 enum reloc_type { 22 /* architecturally-required types */ 23 RELOC_8, /* 8-bit absolute */ 24 RELOC_16, /* 16-bit absolute */ 25 RELOC_32, /* 32-bit absolute */ 26 RELOC_DISP8, /* 8-bit pc-relative */ 27 RELOC_DISP16, /* 16-bit pc-relative */ 28 RELOC_DISP32, /* 32-bit pc-relative */ 29 RELOC_WDISP30, /* 30-bit pc-relative signed word */ 30 RELOC_WDISP22, /* 22-bit pc-relative signed word */ 31 RELOC_HI22, /* 22-bit `%hi' (ie, sethi %hi(X),%l0) */ 32 RELOC_22, /* 22-bit non-%hi (i.e., sethi X,%l0) */ 33 RELOC_13, /* 13-bit absolute */ 34 RELOC_LO10, /* 10-bit `%lo' */ 35 36 /* gnu ld understands some of these, but I do not */ 37 RELOC_SFA_BASE, /* ? */ 38 RELOC_SFA_OFF13, /* ? */ 39 RELOC_BASE10, /* ? */ 40 RELOC_BASE13, /* ? */ 41 RELOC_BASE22, /* ? */ 42 43 /* gnu ld does not use these but Sun linker does */ 44 /* we define them anyway (note that they are included 45 in the freely-available gas sources!) */ 46 RELOC_PC10, /* ? */ 47 RELOC_PC22, /* ? */ 48 RELOC_JMP_TBL, /* ? */ 49 RELOC_SEGOFF16, /* ? */ 50 RELOC_GLOB_DAT, /* ? */ 51 RELOC_JMP_SLOT, /* ? */ 52 RELOC_RELATIVE, /* ? */ 53 }; 54 55 /* 56 * SPARC relocation info. 57 * 58 * Symbol-relative relocation is done by: 59 * 1. locating the appropriate symbol 60 * 2. if defined, adding (value + r_addend), subtracting pc if pc-rel, 61 * and then shifting down 2 or 10 or 13 if necessary. 62 * The resulting value is then to be stuffed into the appropriate bits 63 * in the object (the low 22, or the high 30, or ..., etc). 64 */ 65 struct reloc_info_sparc { 66 u_long r_address; /* relocation addr (offset in segment) */ 67 u_int r_index:24, /* segment (r_extern==0) or symbol index */ 68 r_extern:1, /* if set, r_index is symbol index */ 69 :2; /* unused */ 70 enum reloc_type r_type:5; /* relocation type, from above */ 71 long r_addend; /* value to add to symbol value */ 72 }; 73