From owner-freebsd-emulation@FreeBSD.ORG Tue Sep 12 12:54:29 2006 Return-Path: X-Original-To: emulation@freebsd.org Delivered-To: freebsd-emulation@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B76EF16A407 for ; Tue, 12 Sep 2006 12:54:29 +0000 (UTC) (envelope-from saper@SYSTEM.PL) Received: from mail01.ish.de (pip252.ish.de [80.69.98.252]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2E61E43D6A for ; Tue, 12 Sep 2006 12:54:22 +0000 (GMT) (envelope-from saper@SYSTEM.PL) Received: from [80.69.97.9] (HELO saperski.saper.info) by mail-fe-01.mail01.ish.de (CommuniGate Pro SMTP 5.0.6) with ESMTPS id 75614906 for emulation@freebsd.org; Tue, 12 Sep 2006 14:54:21 +0200 Received: from [127.0.0.1] (saperski.saper.info [127.0.0.1]) by saperski.saper.info (8.13.8/8.13.8) with ESMTP id k8CCjbDt053323 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Tue, 12 Sep 2006 14:45:45 +0200 (CEST) (envelope-from saper@SYSTEM.PL) Message-ID: <4506ABF1.6010407@SYSTEM.PL> Date: Tue, 12 Sep 2006 14:45:37 +0200 From: Marcin Cieslak User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8.0.6) Gecko/20060912 SeaMonkey/1.0.4 MIME-Version: 1.0 To: emulation@freebsd.org Content-Type: multipart/mixed; boundary="------------010009050207000304010904" X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Subject: report by LTP: "2.4+ kernel w/o ELF notes? [long] X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Sep 2006 12:54:29 -0000 This is a multi-part message in MIME format. --------------010009050207000304010904 Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit Having finally installed and run ltp I've had a look at this issue. The message comes from tools/top-LTP/proc/sysinfo.c where function init_libproc() tries to find out the number of clock ticks per second (see some discussion at http://comments.gmane.org/gmane.linux.kernel/190241). The message is a bit misleading, I think that PT_NOTE is actually something different - it's a special ELF section that provides Linux-way of doing brandelf(1). Feel free to run "elfdump -n" on any FreeBSD and Linux binary to find out the difference. Nice introduction to PT_NOTE: http://netbsd.org/Documentation/kernel/elf-notes.html On a side note I think that understanding ELF interpreter entry (elfdump -i) and notes is a key to understand ld-linux.2 vs. brandelf issue we discussed previously. Coming back to the problem with clock ticks: Number of clock ticks per second is provided in Linux via auxiliary arguments provided to the application right after its environment. The POSIX way to fetch this information in the application is sysconf(_SC_CLK_TCK). This value is currently fixed on the FreeBSD to 128. I wrote a small program to read auxiliary arguments (attached). Linux binary run under FreeBSD returns: % ./linux_t program headers for program [0x00000003], 0x08048034 size of program header entry [0x00000004], 0x00000020 number of program headers [0x00000005], 0x00000008 system page size [0x00000006], 0x00001000 flags [0x00000008], 0x00000000 entry point of program [0x00000009], 0x08048320 base address of interpreter [0x00000007], 0x48049000 real uid [0x0000000b], 0x000000a9 effective uid [0x0000000c], 0x000000a9 real gid [0x0000000d], 0x0000000a effective gid [0x0000000e], 0x0000000a Linux binary run under FC3 on sparc64 gives: arch dependent hints at CPU capabilities [0x00000010], 0x0000001f system page size [0x00000006], 0x00002000 frequency at which times() increments [0x00000011], 0x00000064 program headers for program [0x00000003], 0x00010034 size of program header entry [0x00000004], 0x00000020 number of program headers [0x00000005], 0x00000007 base address of interpreter [0x00000007], 0x70000000 flags [0x00000008], 0x00000000 entry point of program [0x00000009], 0x00010310 real uid [0x0000000b], 0x000012ad effective uid [0x0000000c], 0x000012ad real gid [0x0000000d], 0x000012ad effective gid [0x0000000e], 0x000012ad unknown [0x00000017], 0x00000000 Linux binary on 32-bit i386 on OpenSuSE 10.0: arch dependent hints at CPU capabilities [0x00000010], 0x0383fbff system page size [0x00000006], 0x00001000 frequency at which times() increments [0x00000011], 0x00000064 program headers for program [0x00000003], 0x08048034 size of program header entry [0x00000004], 0x00000020 number of program headers [0x00000005], 0x00000008 base address of interpreter [0x00000007], 0x40000000 flags [0x00000008], 0x00000000 entry point of program [0x00000009], 0x08048320 real uid [0x0000000b], 0x000003e8 effective uid [0x0000000c], 0x000003e8 real gid [0x0000000d], 0x00000064 effective gid [0x0000000e], 0x00000064 unknown [0x00000017], 0x00000000 string identifying CPU for optimizations [0x0000000f], 0xbfd4356b I guess that some CPU-optimizing programs could benefit from adding AT_PLATFORM, AT_HWCAP and AT_CLKTCK. I guess that adding AT_CLKTCK should be just something like adding one line in elf_linux_fixup() of ${arch}/linux/linux_sysvec.c. Adding "AUXARGS_ENTRY(pos, 17, 100)" before AUXARGS_ENTRY(pos, AT_NULL...) at least silences the ltp test program. Therefore we should put implementing of AT_PLATFORM, AT_HWCAP, AT_CLKTCK and possibly AT_SECURE on our TO-DO list. It may help us to deal with glibc incompatibilities. -- << Marcin Cieslak // saper@system.pl >> --------------010009050207000304010904 Content-Type: text/plain; name="t.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="t.c" #include #include "linux_elf.h" #define AT_EOF ((unsigned long)0xFFFFFFFF) struct nmap { unsigned long nm_id; const char *nm_name; } note_map[] = { {AT_NULL, "end of vector"}, {AT_IGNORE, "entry should be ignored"}, {AT_EXECFD, "file descriptor of program"}, {AT_PHDR, "program headers for program"}, {AT_PHENT, "size of program header entry"}, {AT_PHNUM, "number of program headers"}, {AT_PAGESZ, "system page size"}, {AT_BASE, "base address of interpreter"}, {AT_FLAGS, "flags"}, {AT_ENTRY, "entry point of program"}, {AT_NOTELF, "program is not ELF"}, {AT_UID, "real uid"}, {AT_EUID, "effective uid"}, {AT_GID, "real gid"}, {AT_EGID, "effective gid"}, {AT_PLATFORM, "string identifying CPU for optimizations"}, {AT_HWCAP, "arch dependent hints at CPU capabilities"}, {AT_CLKTCK, "frequency at which times() increments"}, {AT_EOF, "unknown"}, }; int main(int argc, char *argv[], char *environ[]) { unsigned long *ep = (unsigned long *) environ; struct nmap *search; int i; while(*ep++); while (*ep) { for (search = note_map; search->nm_id != AT_EOF; search ++) if (search->nm_id == ep[0]) break; printf("%s [0x%08lx], 0x%08lx\n", search->nm_name, ep[0], ep[1]); ep+=2 ; } } --------------010009050207000304010904--