xref: /linux/arch/x86/um/asm/elf.h (revision 6a34dfa15d6edf7e78b8118d862d2db0889cf669)
1 /*
2  * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3  * Licensed under the GPL
4  */
5 #ifndef __UM_ELF_X86_H
6 #define __UM_ELF_X86_H
7 
8 #include <asm/user.h>
9 #include <skas.h>
10 
11 #define CORE_DUMP_USE_REGSET
12 
13 #ifdef CONFIG_X86_32
14 
15 #define R_386_NONE	0
16 #define R_386_32	1
17 #define R_386_PC32	2
18 #define R_386_GOT32	3
19 #define R_386_PLT32	4
20 #define R_386_COPY	5
21 #define R_386_GLOB_DAT	6
22 #define R_386_JMP_SLOT	7
23 #define R_386_RELATIVE	8
24 #define R_386_GOTOFF	9
25 #define R_386_GOTPC	10
26 #define R_386_NUM	11
27 
28 /*
29  * This is used to ensure we don't load something for the wrong architecture.
30  */
31 #define elf_check_arch(x) \
32 	(((x)->e_machine == EM_386) || ((x)->e_machine == EM_486))
33 
34 #define ELF_CLASS	ELFCLASS32
35 #define ELF_DATA        ELFDATA2LSB
36 #define ELF_ARCH        EM_386
37 
38 #define ELF_PLAT_INIT(regs, load_addr) do { \
39 	PT_REGS_BX(regs) = 0; \
40 	PT_REGS_CX(regs) = 0; \
41 	PT_REGS_DX(regs) = 0; \
42 	PT_REGS_SI(regs) = 0; \
43 	PT_REGS_DI(regs) = 0; \
44 	PT_REGS_BP(regs) = 0; \
45 	PT_REGS_AX(regs) = 0; \
46 } while (0)
47 
48 /* Shamelessly stolen from include/asm-i386/elf.h */
49 
50 #define ELF_CORE_COPY_REGS(pr_reg, regs) do {	\
51 	pr_reg[0] = PT_REGS_BX(regs);		\
52 	pr_reg[1] = PT_REGS_CX(regs);		\
53 	pr_reg[2] = PT_REGS_DX(regs);		\
54 	pr_reg[3] = PT_REGS_SI(regs);		\
55 	pr_reg[4] = PT_REGS_DI(regs);		\
56 	pr_reg[5] = PT_REGS_BP(regs);		\
57 	pr_reg[6] = PT_REGS_AX(regs);		\
58 	pr_reg[7] = PT_REGS_DS(regs);		\
59 	pr_reg[8] = PT_REGS_ES(regs);		\
60 	/* fake once used fs and gs selectors? */	\
61 	pr_reg[9] = PT_REGS_DS(regs);		\
62 	pr_reg[10] = PT_REGS_DS(regs);		\
63 	pr_reg[11] = PT_REGS_SYSCALL_NR(regs);	\
64 	pr_reg[12] = PT_REGS_IP(regs);		\
65 	pr_reg[13] = PT_REGS_CS(regs);		\
66 	pr_reg[14] = PT_REGS_EFLAGS(regs);	\
67 	pr_reg[15] = PT_REGS_SP(regs);		\
68 	pr_reg[16] = PT_REGS_SS(regs);		\
69 } while (0);
70 
71 extern char * elf_aux_platform;
72 #define ELF_PLATFORM (elf_aux_platform)
73 
74 extern unsigned long vsyscall_ehdr;
75 extern unsigned long vsyscall_end;
76 extern unsigned long __kernel_vsyscall;
77 
78 /*
79  * This is the range that is readable by user mode, and things
80  * acting like user mode such as get_user_pages.
81  */
82 #define FIXADDR_USER_START      vsyscall_ehdr
83 #define FIXADDR_USER_END        vsyscall_end
84 
85 
86 /*
87  * Architecture-neutral AT_ values in 0-17, leave some room
88  * for more of them, start the x86-specific ones at 32.
89  */
90 #define AT_SYSINFO		32
91 #define AT_SYSINFO_EHDR		33
92 
93 #define ARCH_DLINFO						\
94 do {								\
95 	if ( vsyscall_ehdr ) {					\
96 		NEW_AUX_ENT(AT_SYSINFO,	__kernel_vsyscall);	\
97 		NEW_AUX_ENT(AT_SYSINFO_EHDR, vsyscall_ehdr);	\
98 	}							\
99 } while (0)
100 
101 #else
102 
103 /* x86-64 relocation types, taken from asm-x86_64/elf.h */
104 #define R_X86_64_NONE		0	/* No reloc */
105 #define R_X86_64_64		1	/* Direct 64 bit  */
106 #define R_X86_64_PC32		2	/* PC relative 32 bit signed */
107 #define R_X86_64_GOT32		3	/* 32 bit GOT entry */
108 #define R_X86_64_PLT32		4	/* 32 bit PLT address */
109 #define R_X86_64_COPY		5	/* Copy symbol at runtime */
110 #define R_X86_64_GLOB_DAT	6	/* Create GOT entry */
111 #define R_X86_64_JUMP_SLOT	7	/* Create PLT entry */
112 #define R_X86_64_RELATIVE	8	/* Adjust by program base */
113 #define R_X86_64_GOTPCREL	9	/* 32 bit signed pc relative
114 					   offset to GOT */
115 #define R_X86_64_32		10	/* Direct 32 bit zero extended */
116 #define R_X86_64_32S		11	/* Direct 32 bit sign extended */
117 #define R_X86_64_16		12	/* Direct 16 bit zero extended */
118 #define R_X86_64_PC16		13	/* 16 bit sign extended pc relative */
119 #define R_X86_64_8		14	/* Direct 8 bit sign extended  */
120 #define R_X86_64_PC8		15	/* 8 bit sign extended pc relative */
121 #define R_X86_64_PC64		24	/* Place relative 64-bit signed */
122 
123 /*
124  * This is used to ensure we don't load something for the wrong architecture.
125  */
126 #define elf_check_arch(x) \
127 	((x)->e_machine == EM_X86_64)
128 
129 #define ELF_CLASS	ELFCLASS64
130 #define ELF_DATA        ELFDATA2LSB
131 #define ELF_ARCH        EM_X86_64
132 
133 #define ELF_PLAT_INIT(regs, load_addr)    do { \
134 	PT_REGS_BX(regs) = 0; \
135 	PT_REGS_CX(regs) = 0; \
136 	PT_REGS_DX(regs) = 0; \
137 	PT_REGS_SI(regs) = 0; \
138 	PT_REGS_DI(regs) = 0; \
139 	PT_REGS_BP(regs) = 0; \
140 	PT_REGS_AX(regs) = 0; \
141 	PT_REGS_R8(regs) = 0; \
142 	PT_REGS_R9(regs) = 0; \
143 	PT_REGS_R10(regs) = 0; \
144 	PT_REGS_R11(regs) = 0; \
145 	PT_REGS_R12(regs) = 0; \
146 	PT_REGS_R13(regs) = 0; \
147 	PT_REGS_R14(regs) = 0; \
148 	PT_REGS_R15(regs) = 0; \
149 } while (0)
150 
151 #define ELF_CORE_COPY_REGS(pr_reg, _regs)		\
152 	(pr_reg)[0] = (_regs)->regs.gp[0];			\
153 	(pr_reg)[1] = (_regs)->regs.gp[1];			\
154 	(pr_reg)[2] = (_regs)->regs.gp[2];			\
155 	(pr_reg)[3] = (_regs)->regs.gp[3];			\
156 	(pr_reg)[4] = (_regs)->regs.gp[4];			\
157 	(pr_reg)[5] = (_regs)->regs.gp[5];			\
158 	(pr_reg)[6] = (_regs)->regs.gp[6];			\
159 	(pr_reg)[7] = (_regs)->regs.gp[7];			\
160 	(pr_reg)[8] = (_regs)->regs.gp[8];			\
161 	(pr_reg)[9] = (_regs)->regs.gp[9];			\
162 	(pr_reg)[10] = (_regs)->regs.gp[10];			\
163 	(pr_reg)[11] = (_regs)->regs.gp[11];			\
164 	(pr_reg)[12] = (_regs)->regs.gp[12];			\
165 	(pr_reg)[13] = (_regs)->regs.gp[13];			\
166 	(pr_reg)[14] = (_regs)->regs.gp[14];			\
167 	(pr_reg)[15] = (_regs)->regs.gp[15];			\
168 	(pr_reg)[16] = (_regs)->regs.gp[16];			\
169 	(pr_reg)[17] = (_regs)->regs.gp[17];			\
170 	(pr_reg)[18] = (_regs)->regs.gp[18];			\
171 	(pr_reg)[19] = (_regs)->regs.gp[19];			\
172 	(pr_reg)[20] = (_regs)->regs.gp[20];			\
173 	(pr_reg)[21] = (_regs)->regs.gp[21];			\
174 	(pr_reg)[22] = (_regs)->regs.gp[22];			\
175 	(pr_reg)[23] = 0;					\
176 	(pr_reg)[24] = 0;					\
177 	(pr_reg)[25] = 0;					\
178 	(pr_reg)[26] = 0;
179 
180 #define ELF_PLATFORM "x86_64"
181 
182 /* No user-accessible fixmap addresses, i.e. vsyscall */
183 #define FIXADDR_USER_START      0
184 #define FIXADDR_USER_END        0
185 
186 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
187 struct linux_binprm;
188 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
189 	int uses_interp);
190 
191 extern unsigned long um_vdso_addr;
192 #define AT_SYSINFO_EHDR 33
193 #define ARCH_DLINFO	NEW_AUX_ENT(AT_SYSINFO_EHDR, um_vdso_addr)
194 
195 #endif
196 
197 typedef unsigned long elf_greg_t;
198 
199 #define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
200 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
201 
202 typedef struct user_i387_struct elf_fpregset_t;
203 
204 struct task_struct;
205 
206 #define ELF_EXEC_PAGESIZE 4096
207 
208 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
209 
210 extern long elf_aux_hwcap;
211 #define ELF_HWCAP (elf_aux_hwcap)
212 
213 #define SET_PERSONALITY(ex) do {} while(0)
214 
215 #endif
216