162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci 362306a36Sopenharmony_ci#ifndef __ASM_CSKY_ELF_H 462306a36Sopenharmony_ci#define __ASM_CSKY_ELF_H 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#include <asm/ptrace.h> 762306a36Sopenharmony_ci#include <abi/regdef.h> 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#define ELF_ARCH EM_CSKY 1062306a36Sopenharmony_ci#define EM_CSKY_OLD 39 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci/* CSKY Relocations */ 1362306a36Sopenharmony_ci#define R_CSKY_NONE 0 1462306a36Sopenharmony_ci#define R_CSKY_32 1 1562306a36Sopenharmony_ci#define R_CSKY_PCIMM8BY4 2 1662306a36Sopenharmony_ci#define R_CSKY_PCIMM11BY2 3 1762306a36Sopenharmony_ci#define R_CSKY_PCIMM4BY2 4 1862306a36Sopenharmony_ci#define R_CSKY_PC32 5 1962306a36Sopenharmony_ci#define R_CSKY_PCRELJSR_IMM11BY2 6 2062306a36Sopenharmony_ci#define R_CSKY_GNU_VTINHERIT 7 2162306a36Sopenharmony_ci#define R_CSKY_GNU_VTENTRY 8 2262306a36Sopenharmony_ci#define R_CSKY_RELATIVE 9 2362306a36Sopenharmony_ci#define R_CSKY_COPY 10 2462306a36Sopenharmony_ci#define R_CSKY_GLOB_DAT 11 2562306a36Sopenharmony_ci#define R_CSKY_JUMP_SLOT 12 2662306a36Sopenharmony_ci#define R_CSKY_ADDR_HI16 24 2762306a36Sopenharmony_ci#define R_CSKY_ADDR_LO16 25 2862306a36Sopenharmony_ci#define R_CSKY_PCRELJSR_IMM26BY2 40 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_citypedef unsigned long elf_greg_t; 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_citypedef struct user_fp elf_fpregset_t; 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci/* 3562306a36Sopenharmony_ci * In gdb/bfd elf32-csky.c, csky_elf_grok_prstatus() use fixed size of 3662306a36Sopenharmony_ci * elf_prstatus. It's 148 for abiv1 and 220 for abiv2, the size is enough 3762306a36Sopenharmony_ci * for coredump and no need full sizeof(struct pt_regs). 3862306a36Sopenharmony_ci */ 3962306a36Sopenharmony_ci#define ELF_NGREG ((sizeof(struct pt_regs) / sizeof(elf_greg_t)) - 2) 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_citypedef elf_greg_t elf_gregset_t[ELF_NGREG]; 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci/* 4462306a36Sopenharmony_ci * This is used to ensure we don't load something for the wrong architecture. 4562306a36Sopenharmony_ci */ 4662306a36Sopenharmony_ci#define elf_check_arch(x) (((x)->e_machine == ELF_ARCH) || \ 4762306a36Sopenharmony_ci ((x)->e_machine == EM_CSKY_OLD)) 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci/* 5062306a36Sopenharmony_ci * These are used to set parameters in the core dumps. 5162306a36Sopenharmony_ci */ 5262306a36Sopenharmony_ci#define ELF_EXEC_PAGESIZE 4096 5362306a36Sopenharmony_ci#define ELF_CLASS ELFCLASS32 5462306a36Sopenharmony_ci#define ELF_PLAT_INIT(_r, load_addr) { _r->a0 = 0; } 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci#ifdef __cskyBE__ 5762306a36Sopenharmony_ci#define ELF_DATA ELFDATA2MSB 5862306a36Sopenharmony_ci#else 5962306a36Sopenharmony_ci#define ELF_DATA ELFDATA2LSB 6062306a36Sopenharmony_ci#endif 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci/* 6362306a36Sopenharmony_ci * This is the location that an ET_DYN program is loaded if exec'ed. Typical 6462306a36Sopenharmony_ci * use of this is to invoke "./ld.so someprog" to test out a new version of 6562306a36Sopenharmony_ci * the loader. We need to make sure that it is out of the way of the program 6662306a36Sopenharmony_ci * that it will "exec", and that there is sufficient room for the brk. 6762306a36Sopenharmony_ci */ 6862306a36Sopenharmony_ci#define ELF_ET_DYN_BASE 0x0UL 6962306a36Sopenharmony_ci#include <abi/elf.h> 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci/* Similar, but for a thread other than current. */ 7262306a36Sopenharmony_cistruct task_struct; 7362306a36Sopenharmony_ciextern int dump_task_regs(struct task_struct *tsk, elf_gregset_t *elf_regs); 7462306a36Sopenharmony_ci#define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs) 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci#define ELF_HWCAP (0) 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci/* 7962306a36Sopenharmony_ci * This yields a string that ld.so will use to load implementation specific 8062306a36Sopenharmony_ci * libraries for optimization. This is more specific in intent than poking 8162306a36Sopenharmony_ci * at uname or /proc/cpuinfo. 8262306a36Sopenharmony_ci */ 8362306a36Sopenharmony_ci#define ELF_PLATFORM (NULL) 8462306a36Sopenharmony_ci#define SET_PERSONALITY(ex) set_personality(PER_LINUX) 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 8762306a36Sopenharmony_cistruct linux_binprm; 8862306a36Sopenharmony_ciextern int arch_setup_additional_pages(struct linux_binprm *bprm, 8962306a36Sopenharmony_ci int uses_interp); 9062306a36Sopenharmony_ci#endif /* __ASM_CSKY_ELF_H */ 91