GNU Linux-libre 4.14.332-gnu1
[releases.git] / arch / metag / include / asm / elf.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_METAG_ELF_H
3 #define __ASM_METAG_ELF_H
4
5 #define EM_METAG      174
6
7 /* Meta relocations */
8 #define R_METAG_HIADDR16                 0
9 #define R_METAG_LOADDR16                 1
10 #define R_METAG_ADDR32                   2
11 #define R_METAG_NONE                     3
12 #define R_METAG_RELBRANCH                4
13 #define R_METAG_GETSETOFF                5
14
15 /* Backward compatibility */
16 #define R_METAG_REG32OP1                 6
17 #define R_METAG_REG32OP2                 7
18 #define R_METAG_REG32OP3                 8
19 #define R_METAG_REG16OP1                 9
20 #define R_METAG_REG16OP2                10
21 #define R_METAG_REG16OP3                11
22 #define R_METAG_REG32OP4                12
23
24 #define R_METAG_HIOG                    13
25 #define R_METAG_LOOG                    14
26
27 /* GNU */
28 #define R_METAG_GNU_VTINHERIT           30
29 #define R_METAG_GNU_VTENTRY             31
30
31 /* PIC relocations */
32 #define R_METAG_HI16_GOTOFF             32
33 #define R_METAG_LO16_GOTOFF             33
34 #define R_METAG_GETSET_GOTOFF           34
35 #define R_METAG_GETSET_GOT              35
36 #define R_METAG_HI16_GOTPC              36
37 #define R_METAG_LO16_GOTPC              37
38 #define R_METAG_HI16_PLT                38
39 #define R_METAG_LO16_PLT                39
40 #define R_METAG_RELBRANCH_PLT           40
41 #define R_METAG_GOTOFF                  41
42 #define R_METAG_PLT                     42
43 #define R_METAG_COPY                    43
44 #define R_METAG_JMP_SLOT                44
45 #define R_METAG_RELATIVE                45
46 #define R_METAG_GLOB_DAT                46
47
48 /*
49  * ELF register definitions.
50  */
51
52 #include <asm/page.h>
53 #include <asm/processor.h>
54 #include <asm/ptrace.h>
55 #include <asm/user.h>
56
57 typedef unsigned long elf_greg_t;
58
59 #define ELF_NGREG (sizeof(struct user_gp_regs) / sizeof(elf_greg_t))
60 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
61
62 typedef unsigned long elf_fpregset_t;
63
64 /*
65  * This is used to ensure we don't load something for the wrong architecture.
66  */
67 #define elf_check_arch(x) ((x)->e_machine == EM_METAG)
68
69 /*
70  * These are used to set parameters in the core dumps.
71  */
72 #define ELF_CLASS       ELFCLASS32
73 #define ELF_DATA        ELFDATA2LSB
74 #define ELF_ARCH        EM_METAG
75
76 #define ELF_PLAT_INIT(_r, load_addr)    \
77         do { _r->ctx.AX[0].U0 = 0; } while (0)
78
79 #define USE_ELF_CORE_DUMP
80 #define CORE_DUMP_USE_REGSET
81 #define ELF_EXEC_PAGESIZE       PAGE_SIZE
82
83 /* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
84    use of this is to invoke "./ld.so someprog" to test out a new version of
85    the loader.  We need to make sure that it is out of the way of the program
86    that it will "exec", and that there is sufficient room for the brk.  */
87
88 #define ELF_ET_DYN_BASE         0x08000000UL
89
90 #define ELF_CORE_COPY_REGS(_dest, _regs)                        \
91         memcpy((char *)&_dest, (char *)_regs, sizeof(struct pt_regs));
92
93 /* This yields a mask that user programs can use to figure out what
94    instruction set this cpu supports.  */
95
96 #define ELF_HWCAP       (0)
97
98 /* This yields a string that ld.so will use to load implementation
99    specific libraries for optimization.  This is more specific in
100    intent than poking at uname or /proc/cpuinfo.  */
101
102 #define ELF_PLATFORM  (NULL)
103
104 #define STACK_RND_MASK (0)
105
106 #ifdef CONFIG_METAG_USER_TCM
107
108 struct elf32_phdr;
109 struct file;
110
111 unsigned long __metag_elf_map(struct file *filep, unsigned long addr,
112                               struct elf32_phdr *eppnt, int prot, int type,
113                               unsigned long total_size);
114
115 static inline unsigned long metag_elf_map(struct file *filep,
116                                           unsigned long addr,
117                                           struct elf32_phdr *eppnt, int prot,
118                                           int type, unsigned long total_size)
119 {
120         return __metag_elf_map(filep, addr, eppnt, prot, type, total_size);
121 }
122 #define elf_map metag_elf_map
123
124 #endif
125
126 #endif