Home | History | Annotate | Line # | Download | only in include
      1  1.16       uwe /*	$NetBSD: elf_machdep.h,v 1.16 2019/12/08 21:46:03 uwe Exp $	*/
      2  1.10      matt 
      3  1.10      matt #ifndef _POWERPC_ELF_MACHDEP_H_
      4  1.10      matt #define _POWERPC_ELF_MACHDEP_H_
      5   1.1   thorpej 
      6   1.3    kleink #define	ELF32_MACHDEP_ENDIANNESS	ELFDATA2MSB
      7   1.1   thorpej #define	ELF32_MACHDEP_ID_CASES						\
      8   1.3    kleink 		case EM_PPC:						\
      9   1.1   thorpej 			break;
     10   1.1   thorpej 
     11   1.6      ross #define	ELF64_MACHDEP_ENDIANNESS	ELFDATA2MSB
     12   1.1   thorpej #define	ELF64_MACHDEP_ID_CASES						\
     13   1.6      ross 		case EM_PPC64:						\
     14   1.6      ross 			break;
     15   1.5   thorpej 
     16   1.5   thorpej #define	ELF32_MACHDEP_ID	EM_PPC
     17   1.6      ross #define	ELF64_MACHDEP_ID	EM_PPC64
     18   1.4   minoura 
     19  1.14  christos 
     20   1.6      ross #ifdef _LP64
     21  1.15  christos #define KERN_ELFSIZE		64
     22   1.6      ross #define ARCH_ELFSIZE		64	/* MD native binary size */
     23   1.6      ross #else
     24  1.15  christos #define KERN_ELFSIZE		32
     25   1.4   minoura #define ARCH_ELFSIZE		32	/* MD native binary size */
     26   1.6      ross #endif
     27   1.1   thorpej 
     28   1.9      matt /* Specify the value of _GLOBAL_OFFSET_TABLE_ */
     29   1.9      matt #define	DT_PPC_GOT		DT_LOPROC
     30  1.11      matt #define	DT_PPC64_GLINK		(DT_LOPROC + 0)
     31  1.11      matt #define	DT_PPC64_OPD		(DT_LOPROC + 1)
     32  1.11      matt #define	DT_PPC64_OPDSZ		(DT_LOPROC + 2)
     33  1.11      matt #define	DT_PPC64_TLSOPT		(DT_LOPROC + 3)
     34   1.9      matt 
     35  1.10      matt // A = the addend used to compute the value of relocatable field
     36  1.10      matt // B = the base address of the shared object
     37  1.10      matt // G = offset into the global offset table
     38  1.10      matt // L = section offset or address of the procedure link table entry for the
     39  1.10      matt //     symbol + addend
     40  1.10      matt // M = similar to G except the address which is stored may be the address of
     41  1.10      matt //     the procedure linkage table entry for the symbol
     42  1.10      matt // P = the place (section offset or address) of the storage unit being
     43  1.10      matt //     relocated (computed using r_offset)
     44  1.10      matt // R = the offset of the symbol with the section in which the symbol is defined
     45  1.10      matt // S = the value of the symbol whose index resides in the relocation entry
     46  1.10      matt //
     47  1.10      matt // @dtpmod
     48  1.10      matt //   Computes the load module index of the load module that contains the
     49  1.10      matt //   definition of sym.  The addend, if present, is ignored.
     50  1.10      matt // @dtprel
     51  1.10      matt //   Computes a dtv-relative displacement, the difference between the value of
     52  1.10      matt //   S + A and the base address of the thread-local storage block that contains
     53  1.10      matt //   the definition of the symbol, minus 0x8000.
     54  1.10      matt // @tprel
     55  1.10      matt //   Computes a tp-relative displacement, the difference between the value of
     56  1.10      matt //   S + A and the value of the thread pointer (r13).
     57  1.10      matt // @got@tlsgd
     58  1.10      matt //   Allocates two contiguous entries in the GOT to hold a tls_index structure,
     59  1.10      matt //   with values @dtpmod and @dtprel, and computes the offset to the first
     60  1.10      matt //   entry relative to the TOC base (r2).
     61  1.10      matt // @got@tlsld
     62  1.10      matt //   Allocates two contiguous entries in the GOT to hold a tls_index structure,
     63  1.10      matt //   with values @dtpmod and zero, and computes the offset to the first entry
     64  1.10      matt //   relative to the TOC base (r2).
     65  1.10      matt // @got@dtprel
     66  1.10      matt //   Allocates an entry in the GOT with value @dtprel, and computes the offset
     67  1.10      matt //   to the entry relative to the TOC base (r2).
     68  1.10      matt // @got@tprel
     69  1.10      matt //   Allocates an entry in the GOT with value @tprel, and computes the offset
     70  1.10      matt //   to the entry relative to the TOC base (r2).
     71  1.10      matt //
     72  1.10      matt // #lo(x) = (x & 0xffff)
     73  1.10      matt // #hi(x) = ((x >> 16) & 0xffff)
     74  1.16       uwe // #ha(x) = (((x >> 16) + ((x & 0x8000) == 0x8000)) & 0xffff)
     75  1.10      matt // #higher(x) = ((x >> 32) & 0xffff)
     76  1.10      matt // #highera(x) =
     77  1.10      matt //    (((x >> 32) + ((x & 0xffff8000) == 0xffff8000)) & 0xffff)
     78  1.10      matt // #highest(x) = ((x >> 48) & 0xffff)
     79  1.10      matt // #highesta(x) =
     80  1.10      matt //    (((x >> 48) + ((x & 0xffffffff8000) == 0xffffffff8000)) & 0xffff)
     81  1.10      matt // .TOC. = base TOC base of TOC section for object being relocated
     82  1.10      matt 
     83   1.7     freza #define	R_PPC_NONE 		0
     84  1.10      matt #define	R_PPC_ADDR32 		1	// S + A
     85  1.10      matt #define	R_PPC_ADDR24 		2	// (S + A) >> 2
     86  1.10      matt #define	R_PPC_ADDR16 		3	// S + A
     87  1.10      matt #define	R_PPC_ADDR16_LO 	4	// #lo(S + A)
     88  1.10      matt #define	R_PPC_ADDR16_HI 	5	// #hi(S + A)
     89  1.10      matt #define	R_PPC_ADDR16_HA 	6	// #ha(S + A)
     90  1.10      matt #define	R_PPC_ADDR14 		7	// (S + A) >> 2
     91  1.10      matt #define	R_PPC_ADDR14_TAKEN 	8	// (S + A) >> 2
     92  1.10      matt #define	R_PPC_ADDR14_NTAKEN 	9	// (S + A) >> 2
     93  1.10      matt #define	R_PPC_REL24 		10 	// (S + A - P) >> 2
     94  1.10      matt #define	R_PPC_REL14 		11	// (S + A - P) >> 2
     95  1.10      matt #define	R_PPC_REL14_TAKEN 	12	// (S + A - P) >> 2
     96  1.10      matt #define	R_PPC_REL14_NTAKEN 	13	// (S + A - P) >> 2
     97  1.10      matt #define	R_PPC_GOT16 		14	// G + A
     98  1.10      matt #define	R_PPC_GOT16_LO 		15	// #lo(G + A)
     99  1.10      matt #define	R_PPC_GOT16_HI 		16	// #hi(G + A)
    100  1.10      matt #define	R_PPC_GOT16_HA 		17	// #ha(G + A)
    101  1.10      matt #define	R_PPC_PLTREL24 		18	// (L + A - P) >> 2
    102  1.10      matt #define	R_PPC_COPY 		19	// none
    103  1.10      matt #define	R_PPC_GLOB_DAT 		20	// S + A
    104   1.7     freza #define	R_PPC_JMP_SLOT 		21
    105  1.10      matt #define	R_PPC_RELATIVE 		22	// B + A
    106  1.10      matt #define	R_PPC_LOCAL24PC 	23	// (see R_PPC_REL24)
    107  1.10      matt #define	R_PPC_UADDR32 		24	// S + A
    108  1.10      matt #define	R_PPC_UADDR16 		25	// S + A
    109  1.10      matt #define	R_PPC_REL32 		26	// S + A - P
    110  1.10      matt #define	R_PPC_PLT32 		27	// L
    111  1.10      matt #define	R_PPC_PLTREL 		28	// L - P
    112  1.10      matt #define	R_PPC_PLT16_LO 		29	// #lo(L)
    113  1.10      matt #define	R_PPC_PLT16_HI 		30	// #hi(L)
    114  1.10      matt #define	R_PPC_PLT16_HA 		31	// #ha(L)
    115  1.10      matt #define	R_PPC_SDAREL16 		32	// S + A - _SDA_BASE_
    116  1.10      matt #define	R_PPC_SECTOFF 		33	// R + A
    117  1.10      matt #define	R_PPC_SECTOFF_LO 	34	// #lo(R + A)
    118  1.10      matt #define	R_PPC_SECTOFF_HI	35	// #lo(R + A)
    119  1.10      matt #define	R_PPC_SECTOFF_HA	36	// #ha(R + A)
    120  1.10      matt #define	R_PPC_ADDR30 		37	// (S + A - P) >> 2
    121  1.10      matt /* PPC64 relocations */
    122  1.10      matt #define R_PPC_ADDR64		38	// S + A
    123  1.10      matt #define R_PPC_ADDR16_HIGHER	39	// #higher(S + A)
    124  1.10      matt #define R_PPC_ADDR16_HIGHERA	40	// #highera(S + A)
    125  1.10      matt #define R_PPC_ADDR16_HIGHEST	41	// #highest(S + A)
    126  1.10      matt #define R_PPC_ADDR16_HIGHESTA	42	// #highesta(S + A)
    127  1.10      matt #define R_PPC_UADDR64		43	// S + A
    128  1.10      matt #define R_PPC_REL64		44	// S + A - P
    129  1.10      matt #define R_PPC_PLT64		45	// L
    130  1.10      matt #define R_PPC_PLTREL4		46	// L - P
    131  1.10      matt #define	R_PPC_TOC16 		47	// S + A - .TOC.
    132  1.10      matt #define	R_PPC_TOC16_LO 		48	// #lo(S + A - .TOC.)
    133  1.10      matt #define	R_PPC_TOC16_HI		49	// #lo(S + A - .TOC.)
    134  1.10      matt #define	R_PPC_TOC16_HA		50	// #ha(S + A - .TOC.)
    135  1.10      matt #define R_PPC_TOC		51	// .TOC.
    136  1.10      matt #define	R_PPC_PLTGOT16 		52	// M
    137  1.10      matt #define	R_PPC_PLTGOT16_LO 	53	// #lo(M)
    138  1.10      matt #define	R_PPC_PLTGOT16_HI	54	// #lo(M)
    139  1.10      matt #define	R_PPC_PLTGOT16_HA	55	// #ha(M)
    140  1.10      matt #define	R_PPC_ADDR16_DS		56	// (S + A) >> 2
    141  1.10      matt #define	R_PPC_ADDR16_LO_DS 	57	// #lo(S + A) >> 2
    142  1.10      matt #define	R_PPC_GOT16_DS 		58	// G >> 2
    143  1.10      matt #define	R_PPC_GOT16_LO_DS 	59	// #lo(G) >> 2
    144  1.10      matt #define	R_PPC_PLT16_LO_DS 	60	// #lo(L) >> 2
    145  1.10      matt #define	R_PPC_SECTOFF16_DS	61	// (R + A) >> 2
    146  1.10      matt #define	R_PPC_SECTOFF16_LO_DS 	62	// #lo(R + A) >> 2
    147  1.10      matt #define	R_PPC_TOC16_DS		63	// (S + A - .TOC.) >> 2
    148  1.10      matt #define	R_PPC_TOC16_LO_DS 	64	// #lo(S + A - .TOC.) >> 2
    149  1.10      matt #define	R_PPC_PLTGOT16_DS	65	// M >> 2
    150  1.10      matt #define	R_PPC_PLTGOT16_LO_DS 	66	// #lo(M) >> 2
    151   1.2    tsubai 
    152   1.8     skrll /* TLS relocations */
    153  1.10      matt #define	R_PPC_TLS		67	// none
    154   1.8     skrll 
    155  1.10      matt #define	R_PPC_DTPMOD		68
    156  1.10      matt #define	R_PPC_TPREL16		69	// @tprel
    157  1.10      matt #define	R_PPC_TPREL16_LO	70	// #lo(@tprel)
    158  1.10      matt #define	R_PPC_TPREL16_HI	71	// #hi(@tprel)
    159  1.10      matt #define	R_PPC_TPREL16_HA	72	// #ha(@tprel)
    160  1.10      matt #define	R_PPC_TPREL		73	// @tprel
    161  1.10      matt #define	R_PPC_DTPREL16		74	// @got@dtprel
    162  1.10      matt #define	R_PPC_DTPREL16_LO	75	// #lo(@dtprel)
    163  1.10      matt #define	R_PPC_DTPREL16_HI	76	// #hi(@dtprel)
    164  1.10      matt #define	R_PPC_DTPREL16_HA	77	// #ha(@dtprel)
    165  1.10      matt #define	R_PPC_DTPREL		78	// @dtprel
    166  1.10      matt 
    167  1.10      matt #define	R_PPC_GOT_TLSGD16	79	// @got@tlsgd
    168  1.10      matt #define	R_PPC_GOT_TLSGD16_LO	80	// #lo(@got@tlsgd)
    169  1.10      matt #define	R_PPC_GOT_TLSGD16_HI	81	// #hi(@got@tlsgd)
    170  1.10      matt #define	R_PPC_GOT_TLSGD16_HA	82	// #ha(@got@tlsgd)
    171  1.10      matt #define	R_PPC_GOT_TLSLD16	83	// @got@tlsld
    172  1.10      matt #define	R_PPC_GOT_TLSLD16_LO	84	// #lo(@got@tlsld)
    173  1.10      matt #define	R_PPC_GOT_TLSLD16_HI	85	// #hi(@got@tlsld)
    174  1.10      matt #define	R_PPC_GOT_TLSLD16_HA	86	// #ha(@got@tlsld)
    175  1.10      matt 
    176  1.10      matt #define	R_PPC_GOT_TPREL16	87	// @got@tprel
    177  1.10      matt #define	R_PPC_GOT_TPREL16_LO	88	// #lo(@got@tprel)
    178  1.10      matt #define	R_PPC_GOT_TPREL16_HI	89	// #hi(@got@tprel)
    179  1.10      matt #define	R_PPC_GOT_TPREL16_HA	90	// #ha(@got@tprel)
    180  1.10      matt #define	R_PPC_GOT_DTPREL16	91	// @got@dtprel
    181  1.10      matt #define	R_PPC_GOT_DTPREL16_LO	92	// #lo(@got@dtprel)
    182  1.10      matt #define	R_PPC_GOT_DTPREL16_HI	93	// #hi(@got@dtprel)
    183  1.10      matt #define	R_PPC_GOT_DTPREL16_HA	94	// #ha(@got@dtprel)
    184   1.8     skrll #define	R_PPC_TLSGD		95
    185   1.8     skrll #define	R_PPC_TLSLD		96
    186   1.8     skrll 
    187  1.10      matt /* PPC64 relocations */
    188  1.10      matt #define	R_PPC_TPREL16_DS	95	// @tprel
    189  1.10      matt #define	R_PPC_TPREL16_LO_DS	96	// #lo(@tprel)
    190  1.10      matt #define	R_PPC_TPREL16_HIGHER	97	// #higher(@tprel)
    191  1.10      matt #define	R_PPC_TPREL16_HIGHERA	98	// #highera(@tprel)
    192  1.10      matt #define	R_PPC_TPREL16_HIGHEST	99	// #highest(@tprel)
    193  1.10      matt #define	R_PPC_TPREL16_HIGHESTA	100	// #highesta(@tprel)
    194  1.10      matt 
    195  1.10      matt #define	R_PPC_DTPREL16_DS	101	// @dtprel
    196  1.10      matt #define	R_PPC_DTPREL16_LO_DS	102	// #lo(@dtprel)
    197  1.10      matt #define	R_PPC_DTPREL16_HIGHER	103	// #higher(@dtprel)
    198  1.10      matt #define	R_PPC_DTPREL16_HIGHERA	104	// #highera(@dtprel)
    199  1.10      matt #define	R_PPC_DTPREL16_HIGHEST	105	// #highest(@dtprel)
    200  1.10      matt #define	R_PPC_DTPREL16_HIGHESTA	106	// #highesta(@dtprel)
    201  1.10      matt 
    202  1.13     joerg /* Indirect-function support */
    203  1.13     joerg #define	R_PPC_IRELATIVE		248
    204  1.13     joerg 
    205   1.9      matt /* Used for the secure-plt PIC code sequences */
    206  1.10      matt #define	R_PPC_REL16		249	// S + A - P
    207  1.10      matt #define	R_PPC_REL16_LO		250	// #lo(S + A - P)
    208  1.10      matt #define	R_PPC_REL16_HI		251	// #hi(S + A - P)
    209  1.10      matt #define	R_PPC_REL16_HA		252	// #ha(S + A - P)
    210   1.9      matt 
    211   1.7     freza #define R_TYPE(name) 		__CONCAT(R_PPC_,name)
    212  1.10      matt 
    213  1.10      matt #endif /* _POWERPC_ELF_MACHDEP_H_ */
    214