Files
qemu/linux-user/alpha/target_elf.h
Matt Turner 7a2e863f9d linux-user/alpha: populate AT_HWCAP from env->amask
Alpha has never set AT_HWCAP in linux-user emulation, so getauxval(AT_HWCAP)
always returned 0 regardless of the emulated CPU model.

The Linux kernel computes ELF_HWCAP as ~amask(-1), i.e. the set of ISA
extension bits that the amask instruction reports as supported (cleared in
its output).  env->amask stores exactly those bits with the same layout
(BWX=0x1, FIX=0x2, CIX=0x4, MVI=0x100, TRAP=0x200, PREFETCH=0x1000), so
returning it directly from get_elf_hwcap matches the kernel convention.

Add HAVE_ELF_HWCAP to target_elf.h and implement get_elf_hwcap() in
elfload.c to expose the emulated CPU's capability mask to user-space
programs via the auxiliary vector.

Without this fix, programs using getauxval(AT_HWCAP) to detect BWX/FIX/CIX
(such as glibc's memcpy or JIT compilers targeting Alpha) incorrectly
concluded that no extensions were available even when emulating ev56+.

Signed-off-by: Matt Turner <mattst88@gmail.com>
Cc: qemu-stable@nongnu.org
Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Helge Deller <deller@gmx.de>
2026-07-13 16:16:31 +02:00

29 lines
933 B
C

/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation, or (at your option) any
* later version. See the COPYING file in the top-level directory.
*/
#ifndef ALPHA_TARGET_ELF_H
#define ALPHA_TARGET_ELF_H
#define ELF_CLASS ELFCLASS64
#define ELF_MACHINE EM_ALPHA
#define HAVE_ELF_CORE_DUMP 1
#define HAVE_ELF_HWCAP 1
/*
* Matches the kernel's elf_gregset_t (ELF_NGREG = 33):
* r0-r30 at indices 0-30, pc at 31, ps at 32.
* r31 (hardwired zero) is not stored; pc occupies index 31.
*/
typedef struct target_elf_gregset_t {
abi_ulong regs[31]; /* integer registers r0-r30 [0..30] */
abi_ulong pc; /* program counter [31] */
abi_ulong unique; /* thread's UNIQUE field [32] */
} target_elf_gregset_t;
#endif