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