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