1 #include <linux/export.h>
2 #include <linux/sched.h>
3 #include <linux/personality.h>
4 #include <linux/binfmts.h>
6 #include <asm/system_info.h>
8 int elf_check_arch(const struct elf32_hdr
*x
)
12 /* Make sure it's an ARM executable */
13 if (x
->e_machine
!= EM_ARM
)
16 /* Make sure the entry address is reasonable */
18 if (!(elf_hwcap
& HWCAP_THUMB
))
20 } else if (x
->e_entry
& 3)
24 if ((eflags
& EF_ARM_EABI_MASK
) == EF_ARM_EABI_UNKNOWN
) {
27 /* APCS26 is only allowed if the CPU supports it */
28 if ((eflags
& EF_ARM_APCS_26
) && !(elf_hwcap
& HWCAP_26BIT
))
31 flt_fmt
= eflags
& (EF_ARM_VFP_FLOAT
| EF_ARM_SOFT_FLOAT
);
33 /* VFP requires the supporting code */
34 if (flt_fmt
== EF_ARM_VFP_FLOAT
&& !(elf_hwcap
& HWCAP_VFP
))
39 EXPORT_SYMBOL(elf_check_arch
);
41 void elf_set_personality(const struct elf32_hdr
*x
)
43 unsigned int eflags
= x
->e_flags
;
44 unsigned int personality
= current
->personality
& ~PER_MASK
;
47 * We only support Linux ELF executables, so always set the
48 * personality to LINUX.
50 personality
|= PER_LINUX
;
53 * APCS-26 is only valid for OABI executables
55 if ((eflags
& EF_ARM_EABI_MASK
) == EF_ARM_EABI_UNKNOWN
&&
56 (eflags
& EF_ARM_APCS_26
))
57 personality
&= ~ADDR_LIMIT_32BIT
;
59 personality
|= ADDR_LIMIT_32BIT
;
61 set_personality(personality
);
64 * Since the FPA coprocessor uses CP1 and CP2, and iWMMXt uses CP0
65 * and CP1, we only enable access to the iWMMXt coprocessor if the
66 * binary is EABI or softfloat (and thus, guaranteed not to use
69 if (elf_hwcap
& HWCAP_IWMMXT
&&
70 eflags
& (EF_ARM_EABI_MASK
| EF_ARM_SOFT_FLOAT
)) {
71 set_thread_flag(TIF_USING_IWMMXT
);
73 clear_thread_flag(TIF_USING_IWMMXT
);
76 EXPORT_SYMBOL(elf_set_personality
);
79 * Set READ_IMPLIES_EXEC if:
80 * - the binary requires an executable stack
81 * - we're running on a CPU which doesn't support NX.
83 int arm_elf_read_implies_exec(const struct elf32_hdr
*x
, int executable_stack
)
85 if (executable_stack
!= EXSTACK_DISABLE_X
)
87 if (cpu_architecture() < CPU_ARCH_ARMv6
)
91 EXPORT_SYMBOL(arm_elf_read_implies_exec
);