0001
0002
0003
0004
0005 #ifndef __ASM_ELF_H
0006 #define __ASM_ELF_H
0007
0008 #include <asm/hwcap.h>
0009
0010
0011
0012
0013 #include <asm/ptrace.h>
0014 #include <asm/user.h>
0015
0016
0017
0018
0019
0020
0021 #define R_ARM_NONE 0
0022 #define R_AARCH64_NONE 256
0023
0024
0025 #define R_AARCH64_ABS64 257
0026 #define R_AARCH64_ABS32 258
0027 #define R_AARCH64_ABS16 259
0028 #define R_AARCH64_PREL64 260
0029 #define R_AARCH64_PREL32 261
0030 #define R_AARCH64_PREL16 262
0031
0032
0033 #define R_AARCH64_MOVW_UABS_G0 263
0034 #define R_AARCH64_MOVW_UABS_G0_NC 264
0035 #define R_AARCH64_MOVW_UABS_G1 265
0036 #define R_AARCH64_MOVW_UABS_G1_NC 266
0037 #define R_AARCH64_MOVW_UABS_G2 267
0038 #define R_AARCH64_MOVW_UABS_G2_NC 268
0039 #define R_AARCH64_MOVW_UABS_G3 269
0040
0041 #define R_AARCH64_MOVW_SABS_G0 270
0042 #define R_AARCH64_MOVW_SABS_G1 271
0043 #define R_AARCH64_MOVW_SABS_G2 272
0044
0045 #define R_AARCH64_LD_PREL_LO19 273
0046 #define R_AARCH64_ADR_PREL_LO21 274
0047 #define R_AARCH64_ADR_PREL_PG_HI21 275
0048 #define R_AARCH64_ADR_PREL_PG_HI21_NC 276
0049 #define R_AARCH64_ADD_ABS_LO12_NC 277
0050 #define R_AARCH64_LDST8_ABS_LO12_NC 278
0051
0052 #define R_AARCH64_TSTBR14 279
0053 #define R_AARCH64_CONDBR19 280
0054 #define R_AARCH64_JUMP26 282
0055 #define R_AARCH64_CALL26 283
0056 #define R_AARCH64_LDST16_ABS_LO12_NC 284
0057 #define R_AARCH64_LDST32_ABS_LO12_NC 285
0058 #define R_AARCH64_LDST64_ABS_LO12_NC 286
0059 #define R_AARCH64_LDST128_ABS_LO12_NC 299
0060
0061 #define R_AARCH64_MOVW_PREL_G0 287
0062 #define R_AARCH64_MOVW_PREL_G0_NC 288
0063 #define R_AARCH64_MOVW_PREL_G1 289
0064 #define R_AARCH64_MOVW_PREL_G1_NC 290
0065 #define R_AARCH64_MOVW_PREL_G2 291
0066 #define R_AARCH64_MOVW_PREL_G2_NC 292
0067 #define R_AARCH64_MOVW_PREL_G3 293
0068
0069 #define R_AARCH64_RELATIVE 1027
0070
0071
0072
0073
0074 #define ELF_CLASS ELFCLASS64
0075 #ifdef __AARCH64EB__
0076 #define ELF_DATA ELFDATA2MSB
0077 #else
0078 #define ELF_DATA ELFDATA2LSB
0079 #endif
0080 #define ELF_ARCH EM_AARCH64
0081
0082
0083
0084
0085
0086
0087 #define ELF_PLATFORM_SIZE 16
0088 #ifdef __AARCH64EB__
0089 #define ELF_PLATFORM ("aarch64_be")
0090 #else
0091 #define ELF_PLATFORM ("aarch64")
0092 #endif
0093
0094
0095
0096
0097 #define elf_check_arch(x) ((x)->e_machine == EM_AARCH64)
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120 #define compat_elf_read_implies_exec(ex, stk) (stk == EXSTACK_DEFAULT)
0121
0122 #define CORE_DUMP_USE_REGSET
0123 #define ELF_EXEC_PAGESIZE PAGE_SIZE
0124
0125
0126
0127
0128
0129
0130 #ifdef CONFIG_ARM64_FORCE_52BIT
0131 #define ELF_ET_DYN_BASE (2 * TASK_SIZE_64 / 3)
0132 #else
0133 #define ELF_ET_DYN_BASE (2 * DEFAULT_MAP_WINDOW_64 / 3)
0134 #endif
0135
0136 #ifndef __ASSEMBLY__
0137
0138 #include <uapi/linux/elf.h>
0139 #include <linux/bug.h>
0140 #include <linux/errno.h>
0141 #include <linux/fs.h>
0142 #include <linux/types.h>
0143 #include <asm/processor.h> /* for signal_minsigstksz, used by ARCH_DLINFO */
0144
0145 typedef unsigned long elf_greg_t;
0146
0147 #define ELF_NGREG (sizeof(struct user_pt_regs) / sizeof(elf_greg_t))
0148 #define ELF_CORE_COPY_REGS(dest, regs) \
0149 *(struct user_pt_regs *)&(dest) = (regs)->user_regs;
0150
0151 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
0152 typedef struct user_fpsimd_state elf_fpregset_t;
0153
0154
0155
0156
0157
0158
0159 #define ELF_PLAT_INIT(_r, load_addr) (_r)->regs[0] = 0
0160
0161 #define SET_PERSONALITY(ex) \
0162 ({ \
0163 clear_thread_flag(TIF_32BIT); \
0164 current->personality &= ~READ_IMPLIES_EXEC; \
0165 })
0166
0167
0168 #define ARCH_DLINFO \
0169 do { \
0170 NEW_AUX_ENT(AT_SYSINFO_EHDR, \
0171 (elf_addr_t)current->mm->context.vdso); \
0172 \
0173
0174
0175
0176
0177 \
0178 if (likely(signal_minsigstksz)) \
0179 NEW_AUX_ENT(AT_MINSIGSTKSZ, signal_minsigstksz); \
0180 else \
0181 NEW_AUX_ENT(AT_IGNORE, 0); \
0182 } while (0)
0183
0184 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES
0185 struct linux_binprm;
0186 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
0187 int uses_interp);
0188
0189
0190 #ifdef CONFIG_COMPAT
0191 #define STACK_RND_MASK (test_thread_flag(TIF_32BIT) ? \
0192 0x7ff >> (PAGE_SHIFT - 12) : \
0193 0x3ffff >> (PAGE_SHIFT - 12))
0194 #else
0195 #define STACK_RND_MASK (0x3ffff >> (PAGE_SHIFT - 12))
0196 #endif
0197
0198 #ifdef __AARCH64EB__
0199 #define COMPAT_ELF_PLATFORM ("v8b")
0200 #else
0201 #define COMPAT_ELF_PLATFORM ("v8l")
0202 #endif
0203
0204 #ifdef CONFIG_COMPAT
0205
0206
0207 #define COMPAT_ELF_ET_DYN_BASE 0x000400000UL
0208
0209
0210 #define COMPAT_ELF_NGREG 18
0211 typedef unsigned int compat_elf_greg_t;
0212 typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG];
0213
0214
0215 #define EF_ARM_EABI_MASK 0xff000000
0216 int compat_elf_check_arch(const struct elf32_hdr *);
0217 #define compat_elf_check_arch compat_elf_check_arch
0218 #define compat_start_thread compat_start_thread
0219
0220
0221
0222
0223
0224 #define COMPAT_SET_PERSONALITY(ex) \
0225 ({ \
0226 set_thread_flag(TIF_32BIT); \
0227 })
0228 #ifdef CONFIG_COMPAT_VDSO
0229 #define COMPAT_ARCH_DLINFO \
0230 do { \
0231
0232
0233
0234
0235
0236 \
0237 NEW_AUX_ENT(AT_SYSINFO_EHDR, \
0238 (Elf64_Off)current->mm->context.vdso); \
0239 } while (0)
0240 #else
0241 #define COMPAT_ARCH_DLINFO
0242 #endif
0243 extern int aarch32_setup_additional_pages(struct linux_binprm *bprm,
0244 int uses_interp);
0245 #define compat_arch_setup_additional_pages \
0246 aarch32_setup_additional_pages
0247
0248 #endif
0249
0250 struct arch_elf_state {
0251 int flags;
0252 };
0253
0254 #define ARM64_ELF_BTI (1 << 0)
0255
0256 #define INIT_ARCH_ELF_STATE { \
0257 .flags = 0, \
0258 }
0259
0260 static inline int arch_parse_elf_property(u32 type, const void *data,
0261 size_t datasz, bool compat,
0262 struct arch_elf_state *arch)
0263 {
0264
0265 if (IS_ENABLED(CONFIG_COMPAT) && compat)
0266 return 0;
0267
0268 if (type == GNU_PROPERTY_AARCH64_FEATURE_1_AND) {
0269 const u32 *p = data;
0270
0271 if (datasz != sizeof(*p))
0272 return -ENOEXEC;
0273
0274 if (system_supports_bti() &&
0275 (*p & GNU_PROPERTY_AARCH64_FEATURE_1_BTI))
0276 arch->flags |= ARM64_ELF_BTI;
0277 }
0278
0279 return 0;
0280 }
0281
0282 static inline int arch_elf_pt_proc(void *ehdr, void *phdr,
0283 struct file *f, bool is_interp,
0284 struct arch_elf_state *state)
0285 {
0286 return 0;
0287 }
0288
0289 static inline int arch_check_elf(void *ehdr, bool has_interp,
0290 void *interp_ehdr,
0291 struct arch_elf_state *state)
0292 {
0293 return 0;
0294 }
0295
0296 #endif
0297
0298 #endif