162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef _ASM_IA64_ELF_H
362306a36Sopenharmony_ci#define _ASM_IA64_ELF_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci/*
662306a36Sopenharmony_ci * ELF-specific definitions.
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci * Copyright (C) 1998-1999, 2002-2004 Hewlett-Packard Co
962306a36Sopenharmony_ci *	David Mosberger-Tang <davidm@hpl.hp.com>
1062306a36Sopenharmony_ci */
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#include <asm/fpu.h>
1462306a36Sopenharmony_ci#include <asm/page.h>
1562306a36Sopenharmony_ci#include <asm/auxvec.h>
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci/*
1862306a36Sopenharmony_ci * This is used to ensure we don't load something for the wrong architecture.
1962306a36Sopenharmony_ci */
2062306a36Sopenharmony_ci#define elf_check_arch(x) ((x)->e_machine == EM_IA_64)
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci/*
2362306a36Sopenharmony_ci * These are used to set parameters in the core dumps.
2462306a36Sopenharmony_ci */
2562306a36Sopenharmony_ci#define ELF_CLASS	ELFCLASS64
2662306a36Sopenharmony_ci#define ELF_DATA	ELFDATA2LSB
2762306a36Sopenharmony_ci#define ELF_ARCH	EM_IA_64
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci#define CORE_DUMP_USE_REGSET
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci/* Least-significant four bits of ELF header's e_flags are OS-specific.  The bits are
3262306a36Sopenharmony_ci   interpreted as follows by Linux: */
3362306a36Sopenharmony_ci#define EF_IA_64_LINUX_EXECUTABLE_STACK	0x1	/* is stack (& heap) executable by default? */
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci#define ELF_EXEC_PAGESIZE	PAGE_SIZE
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci/*
3862306a36Sopenharmony_ci * This is the location that an ET_DYN program is loaded if exec'ed.
3962306a36Sopenharmony_ci * Typical use of this is to invoke "./ld.so someprog" to test out a
4062306a36Sopenharmony_ci * new version of the loader.  We need to make sure that it is out of
4162306a36Sopenharmony_ci * the way of the program that it will "exec", and that there is
4262306a36Sopenharmony_ci * sufficient room for the brk.
4362306a36Sopenharmony_ci */
4462306a36Sopenharmony_ci#define ELF_ET_DYN_BASE		(TASK_UNMAPPED_BASE + 0x800000000UL)
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci#define PT_IA_64_UNWIND		0x70000001
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci/* IA-64 relocations: */
4962306a36Sopenharmony_ci#define R_IA64_NONE		0x00	/* none */
5062306a36Sopenharmony_ci#define R_IA64_IMM14		0x21	/* symbol + addend, add imm14 */
5162306a36Sopenharmony_ci#define R_IA64_IMM22		0x22	/* symbol + addend, add imm22 */
5262306a36Sopenharmony_ci#define R_IA64_IMM64		0x23	/* symbol + addend, mov imm64 */
5362306a36Sopenharmony_ci#define R_IA64_DIR32MSB		0x24	/* symbol + addend, data4 MSB */
5462306a36Sopenharmony_ci#define R_IA64_DIR32LSB		0x25	/* symbol + addend, data4 LSB */
5562306a36Sopenharmony_ci#define R_IA64_DIR64MSB		0x26	/* symbol + addend, data8 MSB */
5662306a36Sopenharmony_ci#define R_IA64_DIR64LSB		0x27	/* symbol + addend, data8 LSB */
5762306a36Sopenharmony_ci#define R_IA64_GPREL22		0x2a	/* @gprel(sym+add), add imm22 */
5862306a36Sopenharmony_ci#define R_IA64_GPREL64I		0x2b	/* @gprel(sym+add), mov imm64 */
5962306a36Sopenharmony_ci#define R_IA64_GPREL32MSB	0x2c	/* @gprel(sym+add), data4 MSB */
6062306a36Sopenharmony_ci#define R_IA64_GPREL32LSB	0x2d	/* @gprel(sym+add), data4 LSB */
6162306a36Sopenharmony_ci#define R_IA64_GPREL64MSB	0x2e	/* @gprel(sym+add), data8 MSB */
6262306a36Sopenharmony_ci#define R_IA64_GPREL64LSB	0x2f	/* @gprel(sym+add), data8 LSB */
6362306a36Sopenharmony_ci#define R_IA64_LTOFF22		0x32	/* @ltoff(sym+add), add imm22 */
6462306a36Sopenharmony_ci#define R_IA64_LTOFF64I		0x33	/* @ltoff(sym+add), mov imm64 */
6562306a36Sopenharmony_ci#define R_IA64_PLTOFF22		0x3a	/* @pltoff(sym+add), add imm22 */
6662306a36Sopenharmony_ci#define R_IA64_PLTOFF64I	0x3b	/* @pltoff(sym+add), mov imm64 */
6762306a36Sopenharmony_ci#define R_IA64_PLTOFF64MSB	0x3e	/* @pltoff(sym+add), data8 MSB */
6862306a36Sopenharmony_ci#define R_IA64_PLTOFF64LSB	0x3f	/* @pltoff(sym+add), data8 LSB */
6962306a36Sopenharmony_ci#define R_IA64_FPTR64I		0x43	/* @fptr(sym+add), mov imm64 */
7062306a36Sopenharmony_ci#define R_IA64_FPTR32MSB	0x44	/* @fptr(sym+add), data4 MSB */
7162306a36Sopenharmony_ci#define R_IA64_FPTR32LSB	0x45	/* @fptr(sym+add), data4 LSB */
7262306a36Sopenharmony_ci#define R_IA64_FPTR64MSB	0x46	/* @fptr(sym+add), data8 MSB */
7362306a36Sopenharmony_ci#define R_IA64_FPTR64LSB	0x47	/* @fptr(sym+add), data8 LSB */
7462306a36Sopenharmony_ci#define R_IA64_PCREL60B		0x48	/* @pcrel(sym+add), brl */
7562306a36Sopenharmony_ci#define R_IA64_PCREL21B		0x49	/* @pcrel(sym+add), ptb, call */
7662306a36Sopenharmony_ci#define R_IA64_PCREL21M		0x4a	/* @pcrel(sym+add), chk.s */
7762306a36Sopenharmony_ci#define R_IA64_PCREL21F		0x4b	/* @pcrel(sym+add), fchkf */
7862306a36Sopenharmony_ci#define R_IA64_PCREL32MSB	0x4c	/* @pcrel(sym+add), data4 MSB */
7962306a36Sopenharmony_ci#define R_IA64_PCREL32LSB	0x4d	/* @pcrel(sym+add), data4 LSB */
8062306a36Sopenharmony_ci#define R_IA64_PCREL64MSB	0x4e	/* @pcrel(sym+add), data8 MSB */
8162306a36Sopenharmony_ci#define R_IA64_PCREL64LSB	0x4f	/* @pcrel(sym+add), data8 LSB */
8262306a36Sopenharmony_ci#define R_IA64_LTOFF_FPTR22	0x52	/* @ltoff(@fptr(s+a)), imm22 */
8362306a36Sopenharmony_ci#define R_IA64_LTOFF_FPTR64I	0x53	/* @ltoff(@fptr(s+a)), imm64 */
8462306a36Sopenharmony_ci#define R_IA64_LTOFF_FPTR32MSB	0x54	/* @ltoff(@fptr(s+a)), 4 MSB */
8562306a36Sopenharmony_ci#define R_IA64_LTOFF_FPTR32LSB	0x55	/* @ltoff(@fptr(s+a)), 4 LSB */
8662306a36Sopenharmony_ci#define R_IA64_LTOFF_FPTR64MSB	0x56	/* @ltoff(@fptr(s+a)), 8 MSB */
8762306a36Sopenharmony_ci#define R_IA64_LTOFF_FPTR64LSB	0x57	/* @ltoff(@fptr(s+a)), 8 LSB */
8862306a36Sopenharmony_ci#define R_IA64_SEGREL32MSB	0x5c	/* @segrel(sym+add), data4 MSB */
8962306a36Sopenharmony_ci#define R_IA64_SEGREL32LSB	0x5d	/* @segrel(sym+add), data4 LSB */
9062306a36Sopenharmony_ci#define R_IA64_SEGREL64MSB	0x5e	/* @segrel(sym+add), data8 MSB */
9162306a36Sopenharmony_ci#define R_IA64_SEGREL64LSB	0x5f	/* @segrel(sym+add), data8 LSB */
9262306a36Sopenharmony_ci#define R_IA64_SECREL32MSB	0x64	/* @secrel(sym+add), data4 MSB */
9362306a36Sopenharmony_ci#define R_IA64_SECREL32LSB	0x65	/* @secrel(sym+add), data4 LSB */
9462306a36Sopenharmony_ci#define R_IA64_SECREL64MSB	0x66	/* @secrel(sym+add), data8 MSB */
9562306a36Sopenharmony_ci#define R_IA64_SECREL64LSB	0x67	/* @secrel(sym+add), data8 LSB */
9662306a36Sopenharmony_ci#define R_IA64_REL32MSB		0x6c	/* data 4 + REL */
9762306a36Sopenharmony_ci#define R_IA64_REL32LSB		0x6d	/* data 4 + REL */
9862306a36Sopenharmony_ci#define R_IA64_REL64MSB		0x6e	/* data 8 + REL */
9962306a36Sopenharmony_ci#define R_IA64_REL64LSB		0x6f	/* data 8 + REL */
10062306a36Sopenharmony_ci#define R_IA64_LTV32MSB		0x74	/* symbol + addend, data4 MSB */
10162306a36Sopenharmony_ci#define R_IA64_LTV32LSB		0x75	/* symbol + addend, data4 LSB */
10262306a36Sopenharmony_ci#define R_IA64_LTV64MSB		0x76	/* symbol + addend, data8 MSB */
10362306a36Sopenharmony_ci#define R_IA64_LTV64LSB		0x77	/* symbol + addend, data8 LSB */
10462306a36Sopenharmony_ci#define R_IA64_PCREL21BI	0x79	/* @pcrel(sym+add), ptb, call */
10562306a36Sopenharmony_ci#define R_IA64_PCREL22		0x7a	/* @pcrel(sym+add), imm22 */
10662306a36Sopenharmony_ci#define R_IA64_PCREL64I		0x7b	/* @pcrel(sym+add), imm64 */
10762306a36Sopenharmony_ci#define R_IA64_IPLTMSB		0x80	/* dynamic reloc, imported PLT, MSB */
10862306a36Sopenharmony_ci#define R_IA64_IPLTLSB		0x81	/* dynamic reloc, imported PLT, LSB */
10962306a36Sopenharmony_ci#define R_IA64_COPY		0x84	/* dynamic reloc, data copy */
11062306a36Sopenharmony_ci#define R_IA64_SUB		0x85	/* -symbol + addend, add imm22 */
11162306a36Sopenharmony_ci#define R_IA64_LTOFF22X		0x86	/* LTOFF22, relaxable.  */
11262306a36Sopenharmony_ci#define R_IA64_LDXMOV		0x87	/* Use of LTOFF22X.  */
11362306a36Sopenharmony_ci#define R_IA64_TPREL14		0x91	/* @tprel(sym+add), add imm14 */
11462306a36Sopenharmony_ci#define R_IA64_TPREL22		0x92	/* @tprel(sym+add), add imm22 */
11562306a36Sopenharmony_ci#define R_IA64_TPREL64I		0x93	/* @tprel(sym+add), add imm64 */
11662306a36Sopenharmony_ci#define R_IA64_TPREL64MSB	0x96	/* @tprel(sym+add), data8 MSB */
11762306a36Sopenharmony_ci#define R_IA64_TPREL64LSB	0x97	/* @tprel(sym+add), data8 LSB */
11862306a36Sopenharmony_ci#define R_IA64_LTOFF_TPREL22	0x9a	/* @ltoff(@tprel(s+a)), add imm22 */
11962306a36Sopenharmony_ci#define R_IA64_DTPMOD64MSB	0xa6	/* @dtpmod(sym+add), data8 MSB */
12062306a36Sopenharmony_ci#define R_IA64_DTPMOD64LSB	0xa7	/* @dtpmod(sym+add), data8 LSB */
12162306a36Sopenharmony_ci#define R_IA64_LTOFF_DTPMOD22	0xaa	/* @ltoff(@dtpmod(s+a)), imm22 */
12262306a36Sopenharmony_ci#define R_IA64_DTPREL14		0xb1	/* @dtprel(sym+add), imm14 */
12362306a36Sopenharmony_ci#define R_IA64_DTPREL22		0xb2	/* @dtprel(sym+add), imm22 */
12462306a36Sopenharmony_ci#define R_IA64_DTPREL64I	0xb3	/* @dtprel(sym+add), imm64 */
12562306a36Sopenharmony_ci#define R_IA64_DTPREL32MSB	0xb4	/* @dtprel(sym+add), data4 MSB */
12662306a36Sopenharmony_ci#define R_IA64_DTPREL32LSB	0xb5	/* @dtprel(sym+add), data4 LSB */
12762306a36Sopenharmony_ci#define R_IA64_DTPREL64MSB	0xb6	/* @dtprel(sym+add), data8 MSB */
12862306a36Sopenharmony_ci#define R_IA64_DTPREL64LSB	0xb7	/* @dtprel(sym+add), data8 LSB */
12962306a36Sopenharmony_ci#define R_IA64_LTOFF_DTPREL22	0xba	/* @ltoff(@dtprel(s+a)), imm22 */
13062306a36Sopenharmony_ci
13162306a36Sopenharmony_ci/* IA-64 specific section flags: */
13262306a36Sopenharmony_ci#define SHF_IA_64_SHORT		0x10000000	/* section near gp */
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci/*
13562306a36Sopenharmony_ci * We use (abuse?) this macro to insert the (empty) vm_area that is
13662306a36Sopenharmony_ci * used to map the register backing store.  I don't see any better
13762306a36Sopenharmony_ci * place to do this, but we should discuss this with Linus once we can
13862306a36Sopenharmony_ci * talk to him...
13962306a36Sopenharmony_ci */
14062306a36Sopenharmony_ciextern void ia64_init_addr_space (void);
14162306a36Sopenharmony_ci#define ELF_PLAT_INIT(_r, load_addr)	ia64_init_addr_space()
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci/* ELF register definitions.  This is needed for core dump support.  */
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_ci/*
14662306a36Sopenharmony_ci * elf_gregset_t contains the application-level state in the following order:
14762306a36Sopenharmony_ci *	r0-r31
14862306a36Sopenharmony_ci *	NaT bits (for r0-r31; bit N == 1 iff rN is a NaT)
14962306a36Sopenharmony_ci *	predicate registers (p0-p63)
15062306a36Sopenharmony_ci *	b0-b7
15162306a36Sopenharmony_ci *	ip cfm psr
15262306a36Sopenharmony_ci *	ar.rsc ar.bsp ar.bspstore ar.rnat
15362306a36Sopenharmony_ci *	ar.ccv ar.unat ar.fpsr ar.pfs ar.lc ar.ec ar.csd ar.ssd
15462306a36Sopenharmony_ci */
15562306a36Sopenharmony_ci#define ELF_NGREG	128	/* we really need just 72 but let's leave some headroom... */
15662306a36Sopenharmony_ci#define ELF_NFPREG	128	/* f0 and f1 could be omitted, but so what... */
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ci/* elf_gregset_t register offsets */
15962306a36Sopenharmony_ci#define ELF_GR_0_OFFSET     0
16062306a36Sopenharmony_ci#define ELF_NAT_OFFSET     (32 * sizeof(elf_greg_t))
16162306a36Sopenharmony_ci#define ELF_PR_OFFSET      (33 * sizeof(elf_greg_t))
16262306a36Sopenharmony_ci#define ELF_BR_0_OFFSET    (34 * sizeof(elf_greg_t))
16362306a36Sopenharmony_ci#define ELF_CR_IIP_OFFSET  (42 * sizeof(elf_greg_t))
16462306a36Sopenharmony_ci#define ELF_CFM_OFFSET     (43 * sizeof(elf_greg_t))
16562306a36Sopenharmony_ci#define ELF_CR_IPSR_OFFSET (44 * sizeof(elf_greg_t))
16662306a36Sopenharmony_ci#define ELF_GR_OFFSET(i)   (ELF_GR_0_OFFSET + i * sizeof(elf_greg_t))
16762306a36Sopenharmony_ci#define ELF_BR_OFFSET(i)   (ELF_BR_0_OFFSET + i * sizeof(elf_greg_t))
16862306a36Sopenharmony_ci#define ELF_AR_RSC_OFFSET  (45 * sizeof(elf_greg_t))
16962306a36Sopenharmony_ci#define ELF_AR_BSP_OFFSET  (46 * sizeof(elf_greg_t))
17062306a36Sopenharmony_ci#define ELF_AR_BSPSTORE_OFFSET (47 * sizeof(elf_greg_t))
17162306a36Sopenharmony_ci#define ELF_AR_RNAT_OFFSET (48 * sizeof(elf_greg_t))
17262306a36Sopenharmony_ci#define ELF_AR_CCV_OFFSET  (49 * sizeof(elf_greg_t))
17362306a36Sopenharmony_ci#define ELF_AR_UNAT_OFFSET (50 * sizeof(elf_greg_t))
17462306a36Sopenharmony_ci#define ELF_AR_FPSR_OFFSET (51 * sizeof(elf_greg_t))
17562306a36Sopenharmony_ci#define ELF_AR_PFS_OFFSET  (52 * sizeof(elf_greg_t))
17662306a36Sopenharmony_ci#define ELF_AR_LC_OFFSET   (53 * sizeof(elf_greg_t))
17762306a36Sopenharmony_ci#define ELF_AR_EC_OFFSET   (54 * sizeof(elf_greg_t))
17862306a36Sopenharmony_ci#define ELF_AR_CSD_OFFSET  (55 * sizeof(elf_greg_t))
17962306a36Sopenharmony_ci#define ELF_AR_SSD_OFFSET  (56 * sizeof(elf_greg_t))
18062306a36Sopenharmony_ci#define ELF_AR_END_OFFSET  (57 * sizeof(elf_greg_t))
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_citypedef unsigned long elf_greg_t;
18362306a36Sopenharmony_citypedef elf_greg_t elf_gregset_t[ELF_NGREG];
18462306a36Sopenharmony_ci
18562306a36Sopenharmony_citypedef struct ia64_fpreg elf_fpreg_t;
18662306a36Sopenharmony_citypedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
18762306a36Sopenharmony_ci
18862306a36Sopenharmony_ci
18962306a36Sopenharmony_ci
19062306a36Sopenharmony_cistruct pt_regs;	/* forward declaration... */
19162306a36Sopenharmony_ciextern void ia64_elf_core_copy_regs (struct pt_regs *src, elf_gregset_t dst);
19262306a36Sopenharmony_ci#define ELF_CORE_COPY_REGS(_dest,_regs)	ia64_elf_core_copy_regs(_regs, _dest);
19362306a36Sopenharmony_ci
19462306a36Sopenharmony_ci/* This macro yields a bitmask that programs can use to figure out
19562306a36Sopenharmony_ci   what instruction set this CPU supports.  */
19662306a36Sopenharmony_ci#define ELF_HWCAP 	0
19762306a36Sopenharmony_ci
19862306a36Sopenharmony_ci/* This macro yields a string that ld.so will use to load
19962306a36Sopenharmony_ci   implementation specific libraries for optimization.  Not terribly
20062306a36Sopenharmony_ci   relevant until we have real hardware to play with... */
20162306a36Sopenharmony_ci#define ELF_PLATFORM	NULL
20262306a36Sopenharmony_ci
20362306a36Sopenharmony_ci#define elf_read_implies_exec(ex, executable_stack)					\
20462306a36Sopenharmony_ci	((executable_stack!=EXSTACK_DISABLE_X) && ((ex).e_flags & EF_IA_64_LINUX_EXECUTABLE_STACK) != 0)
20562306a36Sopenharmony_ci
20662306a36Sopenharmony_cistruct task_struct;
20762306a36Sopenharmony_ci
20862306a36Sopenharmony_ci#define GATE_EHDR	((const struct elfhdr *) GATE_ADDR)
20962306a36Sopenharmony_ci
21062306a36Sopenharmony_ci/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */
21162306a36Sopenharmony_ci#define ARCH_DLINFO								\
21262306a36Sopenharmony_cido {										\
21362306a36Sopenharmony_ci	extern char __kernel_syscall_via_epc[];					\
21462306a36Sopenharmony_ci	NEW_AUX_ENT(AT_SYSINFO, (unsigned long) __kernel_syscall_via_epc);	\
21562306a36Sopenharmony_ci	NEW_AUX_ENT(AT_SYSINFO_EHDR, (unsigned long) GATE_EHDR);		\
21662306a36Sopenharmony_ci} while (0)
21762306a36Sopenharmony_ci
21862306a36Sopenharmony_ci/*
21962306a36Sopenharmony_ci * format for entries in the Global Offset Table
22062306a36Sopenharmony_ci */
22162306a36Sopenharmony_cistruct got_entry {
22262306a36Sopenharmony_ci	uint64_t val;
22362306a36Sopenharmony_ci};
22462306a36Sopenharmony_ci
22562306a36Sopenharmony_ci/*
22662306a36Sopenharmony_ci * Layout of the Function Descriptor
22762306a36Sopenharmony_ci */
22862306a36Sopenharmony_cistruct fdesc {
22962306a36Sopenharmony_ci	uint64_t addr;
23062306a36Sopenharmony_ci	uint64_t gp;
23162306a36Sopenharmony_ci};
23262306a36Sopenharmony_ci
23362306a36Sopenharmony_ci#endif /* _ASM_IA64_ELF_H */
234