Linux 3.11-rc3
[cris-mirror.git] / arch / hexagon / include / asm / elf.h
blobe1b933a0e121ee92c38d48d93044a431a8d33bd0
1 /*
2 * ELF definitions for the Hexagon architecture
4 * Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 and
8 * only version 2 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA.
21 #ifndef __ASM_ELF_H
22 #define __ASM_ELF_H
24 #include <asm/ptrace.h>
25 #include <asm/user.h>
28 * This should really be in linux/elf-em.h.
30 #define EM_HEXAGON 164 /* QUALCOMM Hexagon */
32 struct elf32_hdr;
35 * ELF header e_flags defines.
38 /* should have stuff like "CPU type" and maybe "ABI version", etc */
40 /* Hexagon relocations */
41 /* V2 */
42 #define R_HEXAGON_NONE 0
43 #define R_HEXAGON_B22_PCREL 1
44 #define R_HEXAGON_B15_PCREL 2
45 #define R_HEXAGON_B7_PCREL 3
46 #define R_HEXAGON_LO16 4
47 #define R_HEXAGON_HI16 5
48 #define R_HEXAGON_32 6
49 #define R_HEXAGON_16 7
50 #define R_HEXAGON_8 8
51 #define R_HEXAGON_GPREL16_0 9
52 #define R_HEXAGON_GPREL16_1 10
53 #define R_HEXAGON_GPREL16_2 11
54 #define R_HEXAGON_GPREL16_3 12
55 #define R_HEXAGON_HL16 13
56 /* V3 */
57 #define R_HEXAGON_B13_PCREL 14
58 /* V4 */
59 #define R_HEXAGON_B9_PCREL 15
60 /* V4 (extenders) */
61 #define R_HEXAGON_B32_PCREL_X 16
62 #define R_HEXAGON_32_6_X 17
63 /* V4 (extended) */
64 #define R_HEXAGON_B22_PCREL_X 18
65 #define R_HEXAGON_B15_PCREL_X 19
66 #define R_HEXAGON_B13_PCREL_X 20
67 #define R_HEXAGON_B9_PCREL_X 21
68 #define R_HEXAGON_B7_PCREL_X 22
69 #define R_HEXAGON_16_X 23
70 #define R_HEXAGON_12_X 24
71 #define R_HEXAGON_11_X 25
72 #define R_HEXAGON_10_X 26
73 #define R_HEXAGON_9_X 27
74 #define R_HEXAGON_8_X 28
75 #define R_HEXAGON_7_X 29
76 #define R_HEXAGON_6_X 30
77 /* V2 PIC */
78 #define R_HEXAGON_32_PCREL 31
79 #define R_HEXAGON_COPY 32
80 #define R_HEXAGON_GLOB_DAT 33
81 #define R_HEXAGON_JMP_SLOT 34
82 #define R_HEXAGON_RELATIVE 35
83 #define R_HEXAGON_PLT_B22_PCREL 36
84 #define R_HEXAGON_GOTOFF_LO16 37
85 #define R_HEXAGON_GOTOFF_HI16 38
86 #define R_HEXAGON_GOTOFF_32 39
87 #define R_HEXAGON_GOT_LO16 40
88 #define R_HEXAGON_GOT_HI16 41
89 #define R_HEXAGON_GOT_32 42
90 #define R_HEXAGON_GOT_16 43
93 * ELF register definitions..
95 typedef unsigned long elf_greg_t;
97 typedef struct user_regs_struct elf_gregset_t;
98 #define ELF_NGREG (sizeof(elf_gregset_t)/sizeof(unsigned long))
100 /* Placeholder */
101 typedef unsigned long elf_fpregset_t;
104 * Bypass the whole "regsets" thing for now and use the define.
107 #if CONFIG_HEXAGON_ARCH_VERSION >= 4
108 #define CS_COPYREGS(DEST,REGS) \
109 do {\
110 DEST.cs0 = REGS->cs0;\
111 DEST.cs1 = REGS->cs1;\
112 } while (0)
113 #else
114 #define CS_COPYREGS(DEST,REGS)
115 #endif
117 #define ELF_CORE_COPY_REGS(DEST, REGS) \
118 do { \
119 DEST.r0 = REGS->r00; \
120 DEST.r1 = REGS->r01; \
121 DEST.r2 = REGS->r02; \
122 DEST.r3 = REGS->r03; \
123 DEST.r4 = REGS->r04; \
124 DEST.r5 = REGS->r05; \
125 DEST.r6 = REGS->r06; \
126 DEST.r7 = REGS->r07; \
127 DEST.r8 = REGS->r08; \
128 DEST.r9 = REGS->r09; \
129 DEST.r10 = REGS->r10; \
130 DEST.r11 = REGS->r11; \
131 DEST.r12 = REGS->r12; \
132 DEST.r13 = REGS->r13; \
133 DEST.r14 = REGS->r14; \
134 DEST.r15 = REGS->r15; \
135 DEST.r16 = REGS->r16; \
136 DEST.r17 = REGS->r17; \
137 DEST.r18 = REGS->r18; \
138 DEST.r19 = REGS->r19; \
139 DEST.r20 = REGS->r20; \
140 DEST.r21 = REGS->r21; \
141 DEST.r22 = REGS->r22; \
142 DEST.r23 = REGS->r23; \
143 DEST.r24 = REGS->r24; \
144 DEST.r25 = REGS->r25; \
145 DEST.r26 = REGS->r26; \
146 DEST.r27 = REGS->r27; \
147 DEST.r28 = REGS->r28; \
148 DEST.r29 = pt_psp(REGS); \
149 DEST.r30 = REGS->r30; \
150 DEST.r31 = REGS->r31; \
151 DEST.sa0 = REGS->sa0; \
152 DEST.lc0 = REGS->lc0; \
153 DEST.sa1 = REGS->sa1; \
154 DEST.lc1 = REGS->lc1; \
155 DEST.m0 = REGS->m0; \
156 DEST.m1 = REGS->m1; \
157 DEST.usr = REGS->usr; \
158 DEST.p3_0 = REGS->preds; \
159 DEST.gp = REGS->gp; \
160 DEST.ugp = REGS->ugp; \
161 CS_COPYREGS(DEST,REGS); \
162 DEST.pc = pt_elr(REGS); \
163 DEST.cause = pt_cause(REGS); \
164 DEST.badva = pt_badva(REGS); \
165 } while (0);
168 * This is used to ensure we don't load something for the wrong architecture.
169 * Checks the machine and ABI type.
171 #define elf_check_arch(hdr) ((hdr)->e_machine == EM_HEXAGON)
174 * These are used to set parameters in the core dumps.
176 #define ELF_CLASS ELFCLASS32
177 #define ELF_DATA ELFDATA2LSB
178 #define ELF_ARCH EM_HEXAGON
180 #if CONFIG_HEXAGON_ARCH_VERSION == 2
181 #define ELF_CORE_EFLAGS 0x1
182 #endif
184 #if CONFIG_HEXAGON_ARCH_VERSION == 3
185 #define ELF_CORE_EFLAGS 0x2
186 #endif
188 #if CONFIG_HEXAGON_ARCH_VERSION == 4
189 #define ELF_CORE_EFLAGS 0x3
190 #endif
193 * Some architectures have ld.so set up a pointer to a function
194 * to be registered using atexit, to facilitate cleanup. So that
195 * static executables will be well-behaved, we would null the register
196 * in question here, in the pt_regs structure passed. For now,
197 * leave it a null macro.
199 #define ELF_PLAT_INIT(regs, load_addr) do { } while (0)
201 #define USE_ELF_CORE_DUMP
202 #define CORE_DUMP_USE_REGSET
204 /* Hrm is this going to cause problems for changing PAGE_SIZE? */
205 #define ELF_EXEC_PAGESIZE 4096
208 * This is the location that an ET_DYN program is loaded if exec'ed. Typical
209 * use of this is to invoke "./ld.so someprog" to test out a new version of
210 * the loader. We need to make sure that it is out of the way of the program
211 * that it will "exec", and that there is sufficient room for the brk.
213 #define ELF_ET_DYN_BASE 0x08000000UL
216 * This yields a mask that user programs can use to figure out what
217 * instruction set this cpu supports.
219 #define ELF_HWCAP (0)
222 * This yields a string that ld.so will use to load implementation
223 * specific libraries for optimization. This is more specific in
224 * intent than poking at uname or /proc/cpuinfo.
226 #define ELF_PLATFORM (NULL)
228 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
229 struct linux_binprm;
230 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
231 int uses_interp);
234 #endif