153007Sbostic /*- 2*63217Sbostic * Copyright (c) 1992, 1993 3*63217Sbostic * The Regents of the University of California. All rights reserved. 453007Sbostic * 553007Sbostic * %sccs.include.redist.c% 653007Sbostic * 7*63217Sbostic * @(#)reloc.h 8.1 (Berkeley) 06/10/93 857870Sralph * 957870Sralph * from: $Header: reloc.h,v 1.6 92/06/20 09:59:37 torek Exp $ 1053007Sbostic */ 1153007Sbostic 1253007Sbostic /* 1357870Sralph * MIPS relocation types. 1453007Sbostic */ 1557870Sralph enum reloc_type { 1657870Sralph MIPS_RELOC_32, /* 32-bit absolute */ 1757870Sralph MIPS_RELOC_JMP, /* 26-bit absolute << 2 | high 4 bits of pc */ 1857870Sralph MIPS_RELOC_WDISP16, /* 16-bit signed pc-relative << 2 */ 1957870Sralph MIPS_RELOC_HI16, /* 16-bit absolute << 16 */ 2057870Sralph MIPS_RELOC_HI16_S, /* 16-bit absolute << 16 (+1 if needed) */ 2157870Sralph MIPS_RELOC_LO16, /* 16-bit absolute */ 2257870Sralph }; 2357870Sralph 2457870Sralph /* 2557870Sralph * MIPS relocation info. 2657870Sralph * 2757870Sralph * Symbol-relative relocation is done by: 2857870Sralph * 1. start with the value r_addend, 2957870Sralph * 2. locate the appropriate symbol and if defined, add symbol value, 3057870Sralph * 3. if pc relative, subtract pc, 3157870Sralph * 4. if the reloc_type is MIPS_RELOC_HI16_S and the result bit 15 is set, 3257870Sralph * add 0x00010000, 3357870Sralph * 5. shift down 2 or 16 if necessary. 3457870Sralph * The resulting value is then to be stuffed into the appropriate bits 3557870Sralph * in the object (the low 16, or the low 26 bits). 3657870Sralph */ 3757870Sralph struct reloc_info_mips { 3857870Sralph u_long r_address; /* relocation addr (offset in segment) */ 3957870Sralph u_int r_index:24, /* segment (r_extern==0) or symbol index */ 4057870Sralph r_extern:1, /* if set, r_index is symbol index */ 4157870Sralph :2; /* unused */ 4257870Sralph enum reloc_type r_type:5; /* relocation type, from above */ 4357870Sralph long r_addend; /* value to add to symbol value */ 4457870Sralph }; 45