void arm_netbsd_elf32_coredump_setup(struct lwp *l, void *arg) { #if defined(__ARMEB__) || defined(__ARM_EABI__) || defined(COMPAT_NETBSD32) Elf_Ehdr * const eh = arg; #if defined(__ARM_EABI__) || defined(COMPAT_NETBSD32) struct proc * const p = l->l_proc; #ifdef __ARM_EABI__ if (p->p_emul == &emul_netbsd) { eh->e_flags |= EF_ARM_EABI_VER5; } #elif defined(COMPAT_NETBSD32) if (p->p_emul == &emul_netbsd32) { eh->e_flags |= EF_ARM_EABI_VER5; } #endif #endif /* __ARM_EABI__ || COMPAT_NETBSD32 */ #ifdef __ARMEB__ if (CPU_IS_ARMV7_P() || (CPU_IS_ARMV6_P() && (armreg_sctrl_read() & CPU_CONTROL_BEND_ENABLE) == 0)) { eh->e_flags |= EF_ARM_BE8; } #endif #endif }
int arm_netbsd_elf32_probe(struct lwp *l, struct exec_package *epp, void *eh0, char *itp, vaddr_t *start_p) { const char *itp_suffix = NULL; const Elf_Ehdr * const eh = eh0; const bool elf_aapcs_p = (eh->e_flags & EF_ARM_EABIMASK) >= EF_ARM_EABI_VER4; #ifdef COMPAT_NETBSD32 const bool netbsd32_p = (epp->ep_esch->es_emul == &emul_netbsd32); #else const bool netbsd32_p = false; #endif #ifdef __ARM_EABI__ const bool aapcs_p = true; #else const bool aapcs_p = false; #endif #ifdef __ARMEB__ const bool be8_p = (eh->e_flags & EF_ARM_BE8) != 0; /* * If the BE-8 model is supported, CPSR[7] will be clear. * If the BE-32 model is supported, CPSR[7] will be set. */ register_t ctl = armreg_sctrl_read(); if (((ctl & CPU_CONTROL_BEND_ENABLE) != 0) == be8_p) return ENOEXEC; #endif /* __ARMEB__ */ /* * This is subtle. If we are netbsd32, then we don't want to match the * same ABI as the kernel. If we aren't (netbsd32 == false), then we * don't want to be different from the kernel's ABI. * true true true ENOEXEC * true false true 0 * true true false 0 * true false false ENOEXEC * false true true 0 * false false true ENOEXEC * false true false ENOEXEC * false false false 0 */ if (netbsd32_p ^ elf_aapcs_p ^ aapcs_p) return ENOEXEC; if (netbsd32_p) itp_suffix = (elf_aapcs_p) ? "eabi" : "oabi"; if (itp_suffix != NULL) (void)compat_elf_check_interp(epp, itp, itp_suffix); /* * Copy (if any) the machine_arch of the executable to the proc. */ if (epp->ep_machine_arch[0] != 0) { strlcpy(l->l_proc->p_md.md_march, epp->ep_machine_arch, sizeof(l->l_proc->p_md.md_march)); } /* * If we are AAPCS (EABI) and armv6/armv7, we want alignment faults * be off. */ if (aapcs_p && (CPU_IS_ARMV7_P() || CPU_IS_ARMV6_P())) { l->l_md.md_flags |= MDLWP_NOALIGNFLT; } return 0; }