^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #ifndef __ASM_CSKY_ELF_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #define __ASM_CSKY_ELF_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <asm/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <abi/regdef.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #define ELF_ARCH EM_CSKY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define EM_CSKY_OLD 39
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) /* CSKY Relocations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #define R_CSKY_NONE 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #define R_CSKY_32 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define R_CSKY_PCIMM8BY4 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define R_CSKY_PCIMM11BY2 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define R_CSKY_PCIMM4BY2 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define R_CSKY_PC32 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define R_CSKY_PCRELJSR_IMM11BY2 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define R_CSKY_GNU_VTINHERIT 7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define R_CSKY_GNU_VTENTRY 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define R_CSKY_RELATIVE 9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define R_CSKY_COPY 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define R_CSKY_GLOB_DAT 11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define R_CSKY_JUMP_SLOT 12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define R_CSKY_ADDR_HI16 24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define R_CSKY_ADDR_LO16 25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define R_CSKY_PCRELJSR_IMM26BY2 40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) typedef unsigned long elf_greg_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) typedef struct user_fp elf_fpregset_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * In gdb/bfd elf32-csky.c, csky_elf_grok_prstatus() use fixed size of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * elf_prstatus. It's 148 for abiv1 and 220 for abiv2, the size is enough
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * for coredump and no need full sizeof(struct pt_regs).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define ELF_NGREG ((sizeof(struct pt_regs) / sizeof(elf_greg_t)) - 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) typedef elf_greg_t elf_gregset_t[ELF_NGREG];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * This is used to ensure we don't load something for the wrong architecture.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define elf_check_arch(x) (((x)->e_machine == ELF_ARCH) || \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) ((x)->e_machine == EM_CSKY_OLD))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * These are used to set parameters in the core dumps.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #define USE_ELF_CORE_DUMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #define ELF_EXEC_PAGESIZE 4096
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define ELF_CLASS ELFCLASS32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #define ELF_PLAT_INIT(_r, load_addr) { _r->a0 = 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #ifdef __cskyBE__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #define ELF_DATA ELFDATA2MSB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define ELF_DATA ELFDATA2LSB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * This is the location that an ET_DYN program is loaded if exec'ed. Typical
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * use of this is to invoke "./ld.so someprog" to test out a new version of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * the loader. We need to make sure that it is out of the way of the program
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * that it will "exec", and that there is sufficient room for the brk.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) #define ELF_ET_DYN_BASE 0x0UL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #include <abi/elf.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /* Similar, but for a thread other than current. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) struct task_struct;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) extern int dump_task_regs(struct task_struct *tsk, elf_gregset_t *elf_regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #define ELF_HWCAP (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * This yields a string that ld.so will use to load implementation specific
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * libraries for optimization. This is more specific in intent than poking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * at uname or /proc/cpuinfo.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #define ELF_PLATFORM (NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #define SET_PERSONALITY(ex) set_personality(PER_LINUX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) struct linux_binprm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) extern int arch_setup_additional_pages(struct linux_binprm *bprm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) int uses_interp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) #endif /* __ASM_CSKY_ELF_H */