1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_H8300_ELF_H
3 #define __ASM_H8300_ELF_H
4 
5 /*
6  * ELF register definitions..
7  */
8 
9 #include <asm/ptrace.h>
10 #include <asm/user.h>
11 
12 typedef unsigned long elf_greg_t;
13 
14 #define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
15 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
16 typedef unsigned long elf_fpregset_t;
17 
18 /*
19  * This is used to ensure we don't load something for the wrong architecture.
20  */
21 #define elf_check_arch(x) ((x)->e_machine == EM_H8_300)
22 
23 /*
24  * These are used to set parameters in the core dumps.
25  */
26 #define ELF_CLASS	ELFCLASS32
27 #define ELF_DATA	ELFDATA2MSB
28 #define ELF_ARCH	EM_H8_300
29 #if defined(CONFIG_CPU_H8300H)
30 #define ELF_CORE_EFLAGS 0x810000
31 #endif
32 #if defined(CONFIG_CPU_H8S)
33 #define ELF_CORE_EFLAGS 0x820000
34 #endif
35 
36 #define ELF_PLAT_INIT(_r) do { (_r)->er1 = 0; } while (0)
37 
38 #define ELF_EXEC_PAGESIZE	4096
39 
40 /* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
41    use of this is to invoke "./ld.so someprog" to test out a new version of
42    the loader.  We need to make sure that it is out of the way of the program
43    that it will "exec", and that there is sufficient room for the brk.  */
44 
45 #define ELF_ET_DYN_BASE         0xD0000000UL
46 
47 /* This yields a mask that user programs can use to figure out what
48    instruction set this cpu supports.  */
49 
50 #define ELF_HWCAP	(0)
51 
52 /* This yields a string that ld.so will use to load implementation
53    specific libraries for optimization.  This is more specific in
54    intent than poking at uname or /proc/cpuinfo.  */
55 
56 #define ELF_PLATFORM  (NULL)
57 
58 #define R_H8_NONE       0
59 #define R_H8_DIR32      1
60 #define R_H8_DIR32_28   2
61 #define R_H8_DIR32_24   3
62 #define R_H8_DIR32_16   4
63 #define R_H8_DIR32U     6
64 #define R_H8_DIR32U_28  7
65 #define R_H8_DIR32U_24  8
66 #define R_H8_DIR32U_20  9
67 #define R_H8_DIR32U_16 10
68 #define R_H8_DIR24     11
69 #define R_H8_DIR24_20  12
70 #define R_H8_DIR24_16  13
71 #define R_H8_DIR24U    14
72 #define R_H8_DIR24U_20 15
73 #define R_H8_DIR24U_16 16
74 #define R_H8_DIR16     17
75 #define R_H8_DIR16U    18
76 #define R_H8_DIR16S_32 19
77 #define R_H8_DIR16S_28 20
78 #define R_H8_DIR16S_24 21
79 #define R_H8_DIR16S_20 22
80 #define R_H8_DIR16S    23
81 #define R_H8_DIR8      24
82 #define R_H8_DIR8U     25
83 #define R_H8_DIR8Z_32  26
84 #define R_H8_DIR8Z_28  27
85 #define R_H8_DIR8Z_24  28
86 #define R_H8_DIR8Z_20  29
87 #define R_H8_DIR8Z_16  30
88 #define R_H8_PCREL16   31
89 #define R_H8_PCREL8    32
90 #define R_H8_BPOS      33
91 #define R_H8_PCREL32   34
92 #define R_H8_GOT32O    35
93 #define R_H8_GOT16O    36
94 #define R_H8_DIR16A8   59
95 #define R_H8_DIR16R8   60
96 #define R_H8_DIR24A8   61
97 #define R_H8_DIR24R8   62
98 #define R_H8_DIR32A16  63
99 #define R_H8_ABS32     65
100 #define R_H8_ABS32A16 127
101 
102 #endif
103