153007Sbostic /*- 253007Sbostic * Copyright (c) 1992 The Regents of the University of California. 353007Sbostic * All rights reserved. 453007Sbostic * 553007Sbostic * %sccs.include.redist.c% 653007Sbostic * 7*57870Sralph * @(#)reloc.h 7.2 (Berkeley) 02/04/93 8*57870Sralph * 9*57870Sralph * from: $Header: reloc.h,v 1.6 92/06/20 09:59:37 torek Exp $ 1053007Sbostic */ 1153007Sbostic 1253007Sbostic /* 13*57870Sralph * MIPS relocation types. 1453007Sbostic */ 15*57870Sralph enum reloc_type { 16*57870Sralph MIPS_RELOC_32, /* 32-bit absolute */ 17*57870Sralph MIPS_RELOC_JMP, /* 26-bit absolute << 2 | high 4 bits of pc */ 18*57870Sralph MIPS_RELOC_WDISP16, /* 16-bit signed pc-relative << 2 */ 19*57870Sralph MIPS_RELOC_HI16, /* 16-bit absolute << 16 */ 20*57870Sralph MIPS_RELOC_HI16_S, /* 16-bit absolute << 16 (+1 if needed) */ 21*57870Sralph MIPS_RELOC_LO16, /* 16-bit absolute */ 22*57870Sralph }; 23*57870Sralph 24*57870Sralph /* 25*57870Sralph * MIPS relocation info. 26*57870Sralph * 27*57870Sralph * Symbol-relative relocation is done by: 28*57870Sralph * 1. start with the value r_addend, 29*57870Sralph * 2. locate the appropriate symbol and if defined, add symbol value, 30*57870Sralph * 3. if pc relative, subtract pc, 31*57870Sralph * 4. if the reloc_type is MIPS_RELOC_HI16_S and the result bit 15 is set, 32*57870Sralph * add 0x00010000, 33*57870Sralph * 5. shift down 2 or 16 if necessary. 34*57870Sralph * The resulting value is then to be stuffed into the appropriate bits 35*57870Sralph * in the object (the low 16, or the low 26 bits). 36*57870Sralph */ 37*57870Sralph struct reloc_info_mips { 38*57870Sralph u_long r_address; /* relocation addr (offset in segment) */ 39*57870Sralph u_int r_index:24, /* segment (r_extern==0) or symbol index */ 40*57870Sralph r_extern:1, /* if set, r_index is symbol index */ 41*57870Sralph :2; /* unused */ 42*57870Sralph enum reloc_type r_type:5; /* relocation type, from above */ 43*57870Sralph long r_addend; /* value to add to symbol value */ 44*57870Sralph }; 45