From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ebeyj-0007Az-Ds for qemu-devel@nongnu.org; Mon, 14 Nov 2005 09:06:37 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ebeyi-0007AJ-Fu for qemu-devel@nongnu.org; Mon, 14 Nov 2005 09:06:36 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ebeyh-0007A5-Vi for qemu-devel@nongnu.org; Mon, 14 Nov 2005 09:06:36 -0500 Received: from [84.14.106.134] (helo=office.mandriva.com) by monty-python.gnu.org with esmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1Ebeyh-00049w-Ij for qemu-devel@nongnu.org; Mon, 14 Nov 2005 09:06:35 -0500 Received: from gauss.mandriva.com (gauss.mandriva.com [192.168.100.68]) by office.mandriva.com (Postfix) with ESMTP id 17A8754990 for ; Mon, 14 Nov 2005 15:06:33 +0100 (CET) Date: Mon, 14 Nov 2005 15:07:04 +0100 (CET) From: Gwenole Beauchesne Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: [Qemu-devel] [PATCH] more auxv entries for x86 Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Hi, The inlined patch hereunder adds more auxv entries, namely AT_PLATFORM and AT_HWCAP. This e.g. makes it possible to use Mandriva Linux provided glibc libraries. Plain patch available at: 2005-10-23 Gwenole Beauchesne * linux-user/elfload.c (create_elf_tables): Add AT_PLATFORM and AT_HWCAP entries to auxiliary vector. * linux-user/main.c (main): setup global_env earlier for elf_exec. --- qemu/linux-user/elfload.c.auxv 2005-09-05 10:26:06.000000000 +0200 +++ qemu/linux-user/elfload.c 2005-10-24 14:39:20.000000000 +0200 @@ -25,6 +25,26 @@ #ifdef TARGET_I386 +#define ELF_PLATFORM get_elf_platform() + +static const char *get_elf_platform(void) +{ + static char elf_platform[] = "i386"; + int family = (global_env->cpuid_version >> 8) & 0xff; + if (family > 6) + family = 6; + if (family >= 3) + elf_platform[1] = '0' + family; + return elf_platform; +} + +#define ELF_HWCAP get_elf_hwcap() + +static uint32_t get_elf_hwcap(void) +{ + return global_env->cpuid_features; +} + #define ELF_START_MMAP 0x80000000 /* @@ -211,6 +231,14 @@ static inline void init_thread(struct ta #endif +#ifndef ELF_PLATFORM +#define ELF_PLATFORM (NULL) +#endif + +#ifndef ELF_HWCAP +#define ELF_HWCAP 0 +#endif + #include "elf.h" /* @@ -292,7 +320,7 @@ struct exec #define INTERPRETER_AOUT 1 #define INTERPRETER_ELF 2 -#define DLINFO_ITEMS 11 +#define DLINFO_ITEMS 12 static inline void memcpy_fromfs(void * to, const void * from, unsigned long n) { @@ -624,14 +652,26 @@ static unsigned int * create_elf_tables( { target_ulong *argv, *envp; target_ulong *sp, *csp; + target_ulong *u_platform; + const char *k_platform; int v; /* * Force 16 byte _final_ alignment here for generality. */ sp = (unsigned int *) (~15UL & (unsigned long) p); + u_platform = NULL; + k_platform = ELF_PLATFORM; + if (k_platform) { + size_t len = strlen(k_platform) + 1; + sp -= len; + u_platform = (target_ulong *)sp; + __copy_to_user(u_platform, k_platform, len); + } csp = sp; csp -= (DLINFO_ITEMS + 1) * 2; + if (k_platform) + csp -= 2; #ifdef DLINFO_ARCH_ITEMS csp -= DLINFO_ARCH_ITEMS*2; #endif @@ -659,6 +699,9 @@ static unsigned int * create_elf_tables( NEW_AUX_ENT(AT_EUID, (target_ulong) geteuid()); NEW_AUX_ENT(AT_GID, (target_ulong) getgid()); NEW_AUX_ENT(AT_EGID, (target_ulong) getegid()); + NEW_AUX_ENT(AT_HWCAP, (target_ulong) ELF_HWCAP); + if (k_platform) + NEW_AUX_ENT(AT_PLATFORM, (target_ulong) u_platform); #ifdef ARCH_DLINFO /* * ARCH_DLINFO must come last so platform specific code can enforce --- qemu/linux-user/main.c.auxv 2005-08-07 08:39:17.000000000 +0200 +++ qemu/linux-user/main.c 2005-10-24 14:38:44.000000000 +0200 @@ -1095,6 +1095,7 @@ int main(int argc, char **argv) /* NOTE: we need to init the CPU at this stage to get qemu_host_page_size */ env = cpu_init(); + global_env = env; if (elf_exec(filename, argv+optind, environ, regs, info) != 0) { printf("Error loading %s\n", filename); @@ -1117,8 +1118,6 @@ int main(int argc, char **argv) syscall_init(); signal_init(); - global_env = env; - /* build Task State */ memset(ts, 0, sizeof(TaskState)); env->opaque = ts;