Index: head/sys/arm64/include/elf.h =================================================================== --- head/sys/arm64/include/elf.h (revision 353435) +++ head/sys/arm64/include/elf.h (revision 353436) @@ -1,120 +1,124 @@ /*- * Copyright (c) 1996-1997 John D. Polstra. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #ifndef _MACHINE_ELF_H_ #define _MACHINE_ELF_H_ /* * ELF definitions for the AArch64 architecture. */ #include /* Definitions common to all 32 bit architectures. */ #include /* Definitions common to all 64 bit architectures. */ #ifndef __ELF_WORD_SIZE #define __ELF_WORD_SIZE 64 /* Used by */ #endif #include /* * Auxiliary vector entries for passing information to the interpreter. */ typedef struct { /* Auxiliary vector entry on initial stack */ int a_type; /* Entry type. */ union { int a_val; /* Integer value. */ } a_un; } Elf32_Auxinfo; typedef struct { /* Auxiliary vector entry on initial stack */ long a_type; /* Entry type. */ union { long a_val; /* Integer value. */ void *a_ptr; /* Address. */ void (*a_fcn)(void); /* Function pointer (not used). */ } a_un; } Elf64_Auxinfo; __ElfType(Auxinfo); +#ifdef _MACHINE_ELF_WANT_32BIT +#define ELF_ARCH EM_ARM +#else #define ELF_ARCH EM_AARCH64 +#endif #define ELF_MACHINE_OK(x) ((x) == (ELF_ARCH)) /* Define "machine" characteristics */ #if __ELF_WORD_SIZE == 64 #define ELF_TARG_CLASS ELFCLASS64 #define ELF_TARG_DATA ELFDATA2LSB #define ELF_TARG_MACH EM_AARCH64 #define ELF_TARG_VER 1 #else #define ELF_TARG_CLASS ELFCLASS32 #define ELF_TARG_DATA ELFDATA2LSB #define ELF_TARG_MACH EM_ARM #define ELF_TARG_VER 1 #endif #if __ELF_WORD_SIZE == 32 #define ET_DYN_LOAD_ADDR 0x12000 #else #define ET_DYN_LOAD_ADDR 0x100000 #endif /* HWCAP */ #define HWCAP_FP 0x00000001 #define HWCAP_ASIMD 0x00000002 #define HWCAP_EVTSTRM 0x00000004 #define HWCAP_AES 0x00000008 #define HWCAP_PMULL 0x00000010 #define HWCAP_SHA1 0x00000020 #define HWCAP_SHA2 0x00000040 #define HWCAP_CRC32 0x00000080 #define HWCAP_ATOMICS 0x00000100 #define HWCAP_FPHP 0x00000200 #define HWCAP_CPUID 0x00000400 #define HWCAP_ASIMDRDM 0x00000800 #define HWCAP_JSCVT 0x00001000 #define HWCAP_FCMA 0x00002000 #define HWCAP_LRCPC 0x00004000 #define HWCAP_DCPOP 0x00008000 #define HWCAP_SHA3 0x00010000 #define HWCAP_SM3 0x00020000 #define HWCAP_SM4 0x00040000 #define HWCAP_ASIMDDP 0x00080000 #define HWCAP_SHA512 0x00100000 #define HWCAP_SVE 0x00200000 #define HWCAP_ASIMDFHM 0x00400000 #define HWCAP_DIT 0x00800000 #define HWCAP_USCAT 0x01000000 #define HWCAP_ILRCPC 0x02000000 #define HWCAP_FLAGM 0x04000000 #endif /* !_MACHINE_ELF_H_ */ Index: head/usr.bin/gcore/Makefile =================================================================== --- head/usr.bin/gcore/Makefile (revision 353435) +++ head/usr.bin/gcore/Makefile (revision 353436) @@ -1,14 +1,14 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ PROG= gcore SRCS= elfcore.c gcore.c LIBADD= sbuf util -.if ${MACHINE_ARCH} == "amd64" +.if ${MACHINE_ARCH} == "aarch64" || ${MACHINE_ARCH} == "amd64" SRCS+= elf32core.c .endif WARNS?= 1 .include Index: head/usr.bin/gcore/elf32core.c =================================================================== --- head/usr.bin/gcore/elf32core.c (revision 353435) +++ head/usr.bin/gcore/elf32core.c (revision 353436) @@ -1,88 +1,98 @@ /* $FreeBSD$ */ #ifndef __LP64__ #error "this file must be compiled for LP64." #endif #define __ELF_WORD_SIZE 32 #define _MACHINE_ELF_WANT_32BIT #define _WANT_LWPINFO32 #include #define ELFCORE_COMPAT_32 1 #include "elfcore.c" static void elf_convert_gregset(elfcore_gregset_t *rd, struct reg *rs) { #ifdef __amd64__ rd->r_gs = rs->r_gs; rd->r_fs = rs->r_fs; rd->r_es = rs->r_es; rd->r_ds = rs->r_ds; rd->r_edi = rs->r_rdi; rd->r_esi = rs->r_rsi; rd->r_ebp = rs->r_rbp; rd->r_ebx = rs->r_rbx; rd->r_edx = rs->r_rdx; rd->r_ecx = rs->r_rcx; rd->r_eax = rs->r_rax; rd->r_eip = rs->r_rip; rd->r_cs = rs->r_cs; rd->r_eflags = rs->r_rflags; rd->r_esp = rs->r_rsp; rd->r_ss = rs->r_ss; -#else +#elif defined(__aarch64__) + int i; + + for (i = 0; i < 13; i++) + rd->r[i] = rs->x[i]; + rd->r_sp = rs->x[13]; + rd->r_lr = rs->x[14]; + rd->r_pc = rs->elr; + rd->r_cpsr = rs->spsr; #error Unsupported architecture #endif } static void elf_convert_fpregset(elfcore_fpregset_t *rd, struct fpreg *rs) { #ifdef __amd64__ /* XXX this is wrong... */ memcpy(rd, rs, sizeof(*rd)); +#elif defined(__aarch64__) + /* ARM64TODO */ #else #error Unsupported architecture #endif } static void elf_convert_siginfo(struct siginfo32 *sid, siginfo_t *sis) { bzero(sid, sizeof(*sid)); sid->si_signo = sis->si_signo; sid->si_errno = sis->si_errno; sid->si_code = sis->si_code; sid->si_pid = sis->si_pid; sid->si_uid = sis->si_uid; sid->si_status = sis->si_status; sid->si_addr = (uintptr_t)sis->si_addr; #if _BYTE_ORDER == _BIG_ENDIAN if (sis->si_value.sival_int == 0) sid->si_value.sival_ptr = (uintptr_t)sis->si_value.sival_ptr; else #endif sid->si_value.sival_int = sis->si_value.sival_int; sid->si_timerid = sis->si_timerid; sid->si_overrun = sis->si_overrun; } static void elf_convert_lwpinfo(struct ptrace_lwpinfo32 *pld, struct ptrace_lwpinfo *pls) { pld->pl_lwpid = pls->pl_lwpid; pld->pl_event = pls->pl_event; pld->pl_flags = pls->pl_flags; pld->pl_sigmask = pls->pl_sigmask; pld->pl_siglist = pls->pl_siglist; elf_convert_siginfo(&pld->pl_siginfo, &pls->pl_siginfo); memcpy(pld->pl_tdname, pls->pl_tdname, sizeof(pld->pl_tdname)); pld->pl_child_pid = pls->pl_child_pid; pld->pl_syscall_code = pls->pl_syscall_code; pld->pl_syscall_narg = pls->pl_syscall_narg; }