Home | History | Annotate | Line # | Download | only in include
      1  1.5    jkoshy /* $NetBSD: elf_machdep.h,v 1.5 2022/05/30 21:18:37 jkoshy Exp $ */
      2  1.1      matt 
      3  1.1      matt /*-
      4  1.1      matt  * Copyright (c) 2014 The NetBSD Foundation, Inc.
      5  1.1      matt  * All rights reserved.
      6  1.1      matt  *
      7  1.1      matt  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1      matt  * by Matt Thomas of 3am Software Foundry.
      9  1.1      matt  *
     10  1.1      matt  * Redistribution and use in source and binary forms, with or without
     11  1.1      matt  * modification, are permitted provided that the following conditions
     12  1.1      matt  * are met:
     13  1.1      matt  * 1. Redistributions of source code must retain the above copyright
     14  1.1      matt  *    notice, this list of conditions and the following disclaimer.
     15  1.1      matt  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1      matt  *    notice, this list of conditions and the following disclaimer in the
     17  1.1      matt  *    documentation and/or other materials provided with the distribution.
     18  1.1      matt  *
     19  1.1      matt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  1.1      matt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.1      matt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.1      matt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  1.1      matt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.1      matt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.1      matt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.1      matt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.1      matt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.1      matt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.1      matt  * POSSIBILITY OF SUCH DAMAGE.
     30  1.1      matt  */
     31  1.1      matt 
     32  1.1      matt #ifndef _AARCH64_ELF_MACHDEP_H_
     33  1.1      matt #define _AARCH64_ELF_MACHDEP_H_
     34  1.1      matt 
     35  1.1      matt #ifdef __aarch64__
     36  1.1      matt 
     37  1.1      matt #if defined(__AARCH64EB__)
     38  1.1      matt #define ELF64_MACHDEP_ENDIANNESS	ELFDATA2MSB
     39  1.1      matt #define ELF32_MACHDEP_ENDIANNESS	ELFDATA2MSB
     40  1.1      matt #else
     41  1.1      matt #define ELF64_MACHDEP_ENDIANNESS	ELFDATA2LSB
     42  1.1      matt #define ELF32_MACHDEP_ENDIANNESS	ELFDATA2LSB
     43  1.1      matt #endif
     44  1.1      matt 
     45  1.1      matt /* Processor specific flags for the ELF header e_flags field.  */
     46  1.1      matt #define EF_ARM_RELEXEC		0x00000001
     47  1.1      matt #define EF_ARM_HASENTRY		0x00000002
     48  1.1      matt #define EF_ARM_INTERWORK	0x00000004 /* GNU binutils 000413 */
     49  1.1      matt #define EF_ARM_SYMSARESORTED	0x00000004 /* ARM ELF A08 */
     50  1.1      matt #define EF_ARM_APCS_26		0x00000008 /* GNU binutils 000413 */
     51  1.1      matt #define EF_ARM_DYNSYMSUSESEGIDX	0x00000008 /* ARM ELF B01 */
     52  1.1      matt #define EF_ARM_APCS_FLOAT	0x00000010 /* GNU binutils 000413 */
     53  1.1      matt #define EF_ARM_MAPSYMSFIRST	0x00000010 /* ARM ELF B01 */
     54  1.1      matt #define EF_ARM_PIC		0x00000020
     55  1.1      matt #define EF_ARM_ALIGN8		0x00000040 /* 8-bit structure alignment.  */
     56  1.1      matt #define EF_ARM_NEW_ABI		0x00000080
     57  1.1      matt #define EF_ARM_OLD_ABI		0x00000100
     58  1.1      matt #define EF_ARM_SOFT_FLOAT	0x00000200
     59  1.1      matt #define EF_ARM_BE8		0x00800000
     60  1.1      matt #define EF_ARM_EABIMASK		0xff000000
     61  1.1      matt #define	EF_ARM_EABI_VER1	0x01000000
     62  1.1      matt #define	EF_ARM_EABI_VER2	0x02000000
     63  1.1      matt #define	EF_ARM_EABI_VER3	0x03000000
     64  1.1      matt #define	EF_ARM_EABI_VER4	0x04000000
     65  1.1      matt #define	EF_ARM_EABI_VER5	0x05000000
     66  1.1      matt 
     67  1.4       ryo #define ELF32_MACHDEP_ID_CASES						\
     68  1.4       ryo 		case EM_ARM:						\
     69  1.1      matt 			break;
     70  1.1      matt 
     71  1.1      matt #define	ELF64_MACHDEP_ID_CASES						\
     72  1.1      matt 		case EM_AARCH64:					\
     73  1.1      matt 			break;
     74  1.1      matt 
     75  1.1      matt #define	ELF64_MACHDEP_ID	EM_AARCH64
     76  1.4       ryo #define ELF32_MACHDEP_ID	EM_ARM
     77  1.1      matt 
     78  1.2  christos #define	KERN_ELFSIZE		64
     79  1.1      matt #define ARCH_ELFSIZE		64	/* MD native binary size */
     80  1.1      matt 
     81  1.1      matt /* Processor specific relocation types */
     82  1.1      matt 
     83  1.1      matt #define R_AARCH64_NONE			0
     84  1.1      matt #define R_AARCH64_NONE2			256
     85  1.1      matt 
     86  1.1      matt #define	R_AARCH64_ABS64			257	/* S + A */
     87  1.1      matt #define	R_AARCH64_ABS32			258	/* S + A */
     88  1.1      matt #define	R_AARCH64_ABS16			259	/* S + A */
     89  1.1      matt #define	R_AARCH64_PREL64		260	/* S + A - P */
     90  1.1      matt #define	R_AARCH64_PREL32		261	/* S + A - P */
     91  1.1      matt #define	R_AARCH64_PREL16		262	/* S + A - P */
     92  1.1      matt #define R_AARCH64_MOVW_UABS_G0		263	/* S + A [bits 0..15] */
     93  1.1      matt #define R_AARCH64_MOVW_UABS_G0_NC	264	/* S + A [bits 0..15] */
     94  1.1      matt #define R_AARCH64_MOVW_UABS_G1		265	/* S + A [bits 16..31] */
     95  1.1      matt #define R_AARCH64_MOVW_UABS_G1_NC	266	/* S + A [bits 16..31] */
     96  1.1      matt #define R_AARCH64_MOVW_UABS_G2		267	/* S + A [bits 32..47] */
     97  1.1      matt #define R_AARCH64_MOVW_UABS_G2_NC	268	/* S + A [bits 32..47] */
     98  1.1      matt #define R_AARCH64_MOVW_UABS_G3		269	/* S + A [bits 48..63] */
     99  1.1      matt #define R_AARCH64_MOVW_SABS_G0		270	/* S + A [bits 0..15] */
    100  1.1      matt #define R_AARCH64_MOVW_SABS_G1		271	/* S + A [bits 16..31] */
    101  1.1      matt #define R_AARCH64_MOVW_SABS_G2		272	/* S + A [bits 32..47] */
    102  1.1      matt #define	R_AARCH64_LD_PREL_LO19		273	/* S + A - P */
    103  1.1      matt #define	R_AARCH64_ADR_PREL_LO21		274	/* S + A - P */
    104  1.1      matt #define	R_AARCH64_ADR_PREL_PG_HI21	275	/* Page(S + A) - Page(P) */
    105  1.1      matt #define	R_AARCH64_ADR_PREL_PG_HI21_NC	276	/* Page(S + A) - Page(P) */
    106  1.3       ryo #define R_AARCH64_ADD_ABS_LO12_NC	277	/* S + A */
    107  1.1      matt #define	R_AARCH64_LDST8_ABS_LO12_NC	278	/* S + A */
    108  1.1      matt #define R_AARCH_TSTBR14			279	/* S + A - P */
    109  1.1      matt #define R_AARCH_CONDBR19		281	/* S + A - P */
    110  1.1      matt #define R_AARCH_JUMP26			282	/* S + A - P */
    111  1.1      matt #define R_AARCH_CALL26			283	/* S + A - P */
    112  1.1      matt #define R_AARCH_LDST16_ABS_LO12_NC	284	/* S + A */
    113  1.1      matt #define R_AARCH_LDST32_ABS_LO12_NC	285	/* S + A */
    114  1.1      matt #define R_AARCH_LDST64_ABS_LO12_NC	286	/* S + A */
    115  1.1      matt #define R_AARCH64_MOVW_PREL_G0		287	/* S + A - P */
    116  1.1      matt #define R_AARCH64_MOVW_PREL_G0_NC	288	/* S + A - P */
    117  1.1      matt #define R_AARCH64_MOVW_PREL_G1		289	/* S + A - P */
    118  1.1      matt #define R_AARCH64_MOVW_PREL_G1_NC	290	/* S + A - P */
    119  1.1      matt #define R_AARCH64_MOVW_PREL_G2		291	/* S + A - P */
    120  1.1      matt #define R_AARCH64_MOVW_PREL_G2_NC	292	/* S + A - P */
    121  1.1      matt #define R_AARCH64_MOVW_PREL_G3		293	/* S + A - P */
    122  1.1      matt 
    123  1.1      matt #define R_AARCH64_LDST128_ABS_LO12_NC	299	/* S + A */
    124  1.1      matt #define R_AARCH64_MOVW_GOTOFF_G0	300	/* G(GDAT(S + A)) - GOT */
    125  1.1      matt #define R_AARCH64_MOVW_GOTOFF_G0_NC	301	/* G(GDAT(S + A)) - GOT */
    126  1.1      matt #define R_AARCH64_MOVW_GOTOFF_G1	302	/* G(GDAT(S + A)) - GOT */
    127  1.1      matt #define R_AARCH64_MOVW_GOTOFF_G1_NC	303	/* G(GDAT(S + A)) - GOT */
    128  1.1      matt #define R_AARCH64_MOVW_GOTOFF_G2	304	/* G(GDAT(S + A)) - GOT */
    129  1.1      matt #define R_AARCH64_MOVW_GOTOFF_G2_NC	305	/* G(GDAT(S + A)) - GOT */
    130  1.1      matt #define R_AARCH64_MOVW_GOTOFF_G3	306	/* G(GDAT(S + A)) - GOT */
    131  1.1      matt #define R_AARCH64_GOTREL64		307	/* S + A - GOT */
    132  1.1      matt #define R_AARCH64_GOTREL32		308	/* S + A - GOT */
    133  1.1      matt #define R_AARCH64_GOT_LD_PREL19		309	/* G(GDAT(S + A)) - P */
    134  1.1      matt #define R_AARCH64_LD64_GOTOFF_LO15	310	/* G(GDAT(S + A)) - GOT */
    135  1.1      matt #define R_AARCH64_ADR_GOT_PAGE		311	/* Page(G(GDAT(S + A))) - Page(GOT) */
    136  1.1      matt #define R_AARCH64_LD64_GOT_LO12_NC	312	/* G(GDAT(S + A)) */
    137  1.1      matt #define R_AARCH64_LD64_GOTPAGE_LO15	313	/* G(GDAT(S + A)) - Page(GOT) */
    138  1.1      matt 
    139  1.1      matt #define R_AARCH64_TLSGD_ADR_PREL21		512	/* G(GTLSIDX(S,A)) - P */
    140  1.1      matt #define R_AARCH64_TLSGD_ADR_PAGE21		513	/* Page(G(GTLSIDX(S,A))) - Page(P) */
    141  1.1      matt #define R_AARCH64_TLSGD_ADD_LO12_NC		514	/* G(GTLSIDX(S,A)) */
    142  1.1      matt #define R_AARCH64_TLSGD_MOVW_G1			515	/* G(GTLSIDX(S,A)) - GOT */
    143  1.1      matt #define R_AARCH64_TLSGD_MOVW_G0_NV		516	/* G(GTLSIDX(S,A)) - GOT */
    144  1.1      matt #define R_AARCH64_TLSLD_ADR_PREL21		517	/* G(GLDM(S,A)) - P */
    145  1.1      matt #define R_AARCH64_TLSLD_ADR_PAGE21		518	/* Page(G(GLDM(S))) - Page(P) */
    146  1.1      matt #define R_AARCH64_TLSLD_ADD_LO12_NC		519	/* G(GLDM(S)) */
    147  1.1      matt #define R_AARCH64_TLSLD_MOVW_G1			520	/* G(GLDM(S)) - GOT */
    148  1.1      matt #define R_AARCH64_TLSLD_MOVW_G0_NC		521	/* G(GLDM(S)) - GOT */
    149  1.1      matt #define R_AARCH64_TLSLD_LD_PREL21		522	/* G(GLDM(S)) - P */
    150  1.1      matt #define R_AARCH64_TLSLD_MOVW_DTPREL_G2		523	/* DTPREL(S+A) */
    151  1.1      matt #define R_AARCH64_TLSLD_MOVW_DTPREL_G1		524	/* DTPREL(S+A) */
    152  1.1      matt #define R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC	525	/* DTPREL(S+A) */
    153  1.1      matt #define R_AARCH64_TLSLD_MOVW_DTPREL_G0		526	/* DTPREL(S+A) */
    154  1.1      matt #define R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC	528	/* DTPREL(S+A) */
    155  1.1      matt #define R_AARCH64_TLSLD_ADD_DTPREL_HI12		528	/* DTPREL(S+A) */
    156  1.1      matt #define R_AARCH64_TLSLD_ADD_DTPREL_HI12		528	/* DTPREL(S+A) */
    157  1.1      matt #define R_AARCH64_TLSLD_ADD_DTPREL_LO12		529	/* DTPREL(S+A) */
    158  1.1      matt #define R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC	530	/* DTPREL(S+A) */
    159  1.1      matt #define R_AARCH64_TLSLD_LDST8_DTPREL_LO12	531	/* DTPREL(S+A) */
    160  1.1      matt #define R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC	532	/* DTPREL(S+A) */
    161  1.1      matt #define R_AARCH64_TLSLD_LDST16_DTPREL_LO12	533	/* DTPREL(S+A) */
    162  1.1      matt #define R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC	534	/* DTPREL(S+A) */
    163  1.1      matt #define R_AARCH64_TLSLD_LDST32_DTPREL_LO12	535	/* DTPREL(S+A) */
    164  1.1      matt #define R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC	536	/* DTPREL(S+A) */
    165  1.1      matt #define R_AARCH64_TLSLD_LDST64_DTPREL_LO12	537	/* DTPREL(S+A) */
    166  1.1      matt #define R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC	538	/* DTPREL(S+A) */
    167  1.1      matt #define R_AARCH64_TLSIE_MOVW_GOTTPREL_G1	539	/* G(GTPREL(S+A)) - GOT */
    168  1.1      matt #define R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC	540	/* G(GTPREL(S+A)) - GOT */
    169  1.1      matt #define R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21	541	/* Page(G(GTPREL(S+A))) - Page(P) */
    170  1.1      matt #define R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC	542	/* G(GTPREL(S+A)) */
    171  1.1      matt #define R_AARCH64_TLSIE_LD_GOTTPREL_PREL19	543	/* G(GTPREL(S+A)) - P */
    172  1.1      matt #define R_AARCH64_TLSLE_MOVW_TPREL_G2	544	/* TPREL(S+A) */
    173  1.1      matt #define R_AARCH64_MOVW_TPREL_G1		545	/* TPREL(S+A) */
    174  1.1      matt #define R_AARCH64_MOVW_TPREL_G1_NC	546	/* TPREL(S+A) */
    175  1.1      matt #define R_AARCH64_MOVW_TPREL_G0		547	/* TPREL(S+A) */
    176  1.1      matt #define R_AARCH64_MOVW_TPREL_G0_NC	548	/* TPREL(S+A) */
    177  1.1      matt #define R_AARCH64_ADD_TPREL_HI12	549	/* TPREL(S+A) */
    178  1.1      matt #define R_AARCH64_ADD_TPREL_LO12	550	/* TPREL(S+A) */
    179  1.1      matt #define R_AARCH64_ADD_TPREL_LO12_NC	551	/* TPREL(S+A) */
    180  1.1      matt #define R_AARCH64_LDST8_TPREL_LO12	552	/* TPREL(S+A) */
    181  1.1      matt #define R_AARCH64_LDST8_TPREL_LO12_NC	553	/* TPREL(S+A) */
    182  1.1      matt #define R_AARCH64_LDST16_TPREL_LO12	554	/* TPREL(S+A) */
    183  1.1      matt #define R_AARCH64_LDST16_TPREL_LO12_NC	555	/* TPREL(S+A) */
    184  1.1      matt #define R_AARCH64_LDST32_TPREL_LO12	556	/* TPREL(S+A) */
    185  1.1      matt #define R_AARCH64_LDST32_TPREL_LO12_NC	557	/* TPREL(S+A) */
    186  1.1      matt #define R_AARCH64_LDST64_TPREL_LO12	558	/* TPREL(S+A) */
    187  1.1      matt #define R_AARCH64_LDST64_TPREL_LO12_NC	559	/* TPREL(S+A) */
    188  1.1      matt #define R_AARCH64_TLSDESC_LD_PREL19	560	/* G(GTLSDESC(S+A)) - P */
    189  1.1      matt #define R_AARCH64_TLSDESC_LD_PREL21	561	/* G(GTLSDESC(S+A)) - P */
    190  1.1      matt #define R_AARCH64_TLSDESC_LD_PAGE21	562	/* Page(G(GTLSDESC(S+A))) - Page(P) */
    191  1.1      matt #define R_AARCH64_TLSDESC_LD64_LO12	563	/* G(GTLSDESC(S+A)) */
    192  1.1      matt #define R_AARCH64_TLSDESC_ADD_LO12	564	/* G(GTLSDESC(S+A)) */
    193  1.1      matt #define R_AARCH64_TLSDESC_OFF_G1	565	/* G(GTLSDESC(S+A)) - GOT */
    194  1.1      matt #define R_AARCH64_TLSDESC_OFF_G0_NC	566	/* G(GTLSDESC(S+A)) - GOT */
    195  1.1      matt #define R_AARCH64_TLSDESC_LDR		567	/* */
    196  1.1      matt #define R_AARCH64_TLSDESC_ADD		568	/* */
    197  1.1      matt #define R_AARCH64_TLSDESC_CALL		569	/* */
    198  1.1      matt #define R_AARCH64_TLSLE_LDST128_TPREL_LO12	570	/* TPREL(S+A) */
    199  1.1      matt #define R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC	571	/* TPREL(S+A) */
    200  1.1      matt #define R_AARCH64_TLSLD_LDST128_DTPREL_LO12	572	/* DTPREL(S+A) */
    201  1.5    jkoshy #define R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC	573	/* DTPREL(S+A) */
    202  1.1      matt 
    203  1.1      matt /* Dynamic Relocations */
    204  1.1      matt #define R_AARCH64_P32_COPY		180
    205  1.1      matt #define R_AARCH64_P32_GLOB_DAT		181	/* S + A */
    206  1.1      matt #define R_AARCH64_P32_JUMP_SLOT		182	/* S + A */
    207  1.1      matt #define R_AARCH64_P32_RELATIVE		183	/* Delta(S) + A */
    208  1.1      matt #define R_AARCH64_P32_TLS_DTPREL	184	/* DTPREL(S+A) */
    209  1.1      matt #define R_AARCH64_P32_TLS_DTPMOD	185	/* LBM(S) */
    210  1.1      matt #define R_AARCH64_P32_TLS_TPREL		186	/* TPREL(S+A) */
    211  1.1      matt #define R_AARCH64_P32_TLSDESC		187	/* TLSDESC(S+A) */
    212  1.1      matt #define R_AARCH64_P32_IRELATIVE		188	/* Indirect(Delta(S) + A) */
    213  1.1      matt 
    214  1.1      matt #define R_AARCH64_COPY			1024
    215  1.1      matt #define R_AARCH64_GLOB_DAT		1025	/* S + A */
    216  1.1      matt #define R_AARCH64_JUMP_SLOT		1026	/* S + A */
    217  1.1      matt #define R_AARCH64_RELATIVE		1027	/* Delta(S) + A */
    218  1.1      matt #define R_AARCH64_TLS_DTPREL64		1028	/* DTPREL(S+A) */
    219  1.1      matt #define R_AARCH64_TLS_DTPMOD64		1029	/* LBM(S) */
    220  1.1      matt #define R_AARCH64_TLS_TPREL64		1030	/* TPREL(S+A) */
    221  1.1      matt #define R_AARCH64_TLSDESC		1031	/* TLSDESC(S+A) */
    222  1.1      matt #define R_AARCH64_IRELATIVE		1032	/* Indirect(Delta(S) + A) */
    223  1.1      matt 
    224  1.1      matt #define R_TYPE(name)		R_AARCH64_ ## name
    225  1.1      matt #define R_TLS_TYPE(name)	R_AARCH64_ ## name ## 64
    226  1.1      matt 
    227  1.1      matt /* Processor specific program header types */
    228  1.1      matt #define PT_AARCH64_ARCHEXT	(PT_LOPROC + 0)
    229  1.1      matt #define PT_AARCH64_UNWIND	(PT_LOPROC + 1)
    230  1.1      matt 
    231  1.1      matt /* Processor specific section header flags */
    232  1.1      matt #define SHF_ENTRYSECT		0x10000000
    233  1.1      matt #define SHF_COMDEF		0x80000000
    234  1.1      matt 
    235  1.1      matt #define SHT_AARCH64_ATTRIBUTES	(SHT_LOPROC + 3)
    236  1.1      matt 
    237  1.1      matt #ifdef _KERNEL
    238  1.1      matt #ifdef ELFSIZE
    239  1.1      matt #define	ELF_MD_PROBE_FUNC	ELFNAME2(aarch64_netbsd,probe)
    240  1.1      matt #endif
    241  1.1      matt 
    242  1.1      matt struct exec_package;
    243  1.1      matt 
    244  1.1      matt int aarch64_netbsd_elf64_probe(struct lwp *, struct exec_package *, void *,
    245  1.1      matt 	char *, vaddr_t *);
    246  1.4       ryo int aarch64_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *,
    247  1.4       ryo 	char *, vaddr_t *);
    248  1.1      matt #endif
    249  1.1      matt 
    250  1.1      matt #elif defined(__arm__)
    251  1.1      matt 
    252  1.1      matt #include <arm/elf_machdep.h>
    253  1.1      matt 
    254  1.1      matt #endif
    255  1.1      matt 
    256  1.1      matt #endif /* _AARCH64_ELF_MACHDEP_H_ */
    257