From owner-freebsd-bugs@FreeBSD.ORG Fri Mar 5 23:10:11 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2BD0216A4CE for ; Fri, 5 Mar 2004 23:10:11 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 10BCB43D1F for ; Fri, 5 Mar 2004 23:10:11 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i267A9bv073677 for ; Fri, 5 Mar 2004 23:10:09 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i267A9L1073676; Fri, 5 Mar 2004 23:10:09 -0800 (PST) (envelope-from gnats) Resent-Date: Fri, 5 Mar 2004 23:10:09 -0800 (PST) Resent-Message-Id: <200403060710.i267A9L1073676@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Edwin Groothuis Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BE6AF16A4CE; Fri, 5 Mar 2004 23:08:13 -0800 (PST) Received: from mailout2.barnet.com.au (mailout2.barnet.com.au [218.185.88.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0B98743D2D; Fri, 5 Mar 2004 23:08:13 -0800 (PST) (envelope-from edwin@mavetju.org) Received: by mailout2.barnet.com.au (Postfix, from userid 27) id 85F32AA61E7; Sat, 6 Mar 2004 18:08:11 +1100 (EST) Received: from mail2-auth.barnet.com.au (localhost [127.0.0.1]) by mail2.barnet.com.au (Postfix) with ESMTP id B3CCCB29D0D; Sat, 6 Mar 2004 18:08:10 +1100 (EST) Received: from k7.mavetju (edwin.adsl.barnet.com.au [203.111.122.2]) by mail2-auth.barnet.com.au (Postfix) with ESMTP id 33C0519328; Sat, 6 Mar 2004 18:08:09 +1100 (EST) Received: by k7.mavetju (Postfix, from userid 1001) id ED5306184; Sat, 6 Mar 2004 18:08:50 +1100 (EST) Message-Id: <20040306070850.ED5306184@k7.mavetju> Date: Sat, 6 Mar 2004 18:08:50 +1100 (EST) From: Edwin Groothuis To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 cc: christos@astron.com cc: jharris@widomaker.com cc: obrien@FreeBSD.org Subject: bin/63830: [patch] file(1) doesn't recognize FreeBSD 5.x executables properly X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Edwin Groothuis List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Mar 2004 07:10:11 -0000 >Number: 63830 >Category: bin >Synopsis: [patch] file(1) doesn't recognize FreeBSD 5.x executables properly >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Mar 05 23:10:09 PST 2004 >Closed-Date: >Last-Modified: >Originator: Edwin Groothuis >Release: FreeBSD 5.2.1-RELEASE i386 >Organization: - >Environment: System: FreeBSD k7.mavetju 5.2.1-RELEASE FreeBSD 5.2.1-RELEASE #3: Fri Feb 27 13:54:29 EST 2004 edwin@k7.mavetju:/usr/src/sys/i386/compile/k7 i386 >Description: While trying to figure out if a binary was staticly or dynamicly linked, my eye fell on... /usr/X11R6/bin/linphone: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD), for FreeBSD 5.0.2, dynamically linked (uses shared libs), stripped That should be 5.2.1 >How-To-Repeat: Run file /usr/bin/file on a FreeBSD 5.x machine >Fix: This is a patch against readelf.c of 3.41. I wasn't able to figure out how to use file_printf properly. Maybe the maintainer of sysutils/file could have a look at it? Informed author of file. Informed maintainer of port. Informed importer of file in the FreeBSD base system. --- readelf.c.orig Sat Mar 6 17:43:56 2004 +++ readelf.c Sat Mar 6 17:55:21 2004 @@ -280,17 +280,31 @@ * Contents is __FreeBSD_version, * whose relation to OS versions is * defined by a huge table in the - * Porters' Handbook. Happily, the - * first three digits are the version - * number, at least in versions of - * FreeBSD that use this note. + * Porters' Handbook. + * For up to 5.x, the first three + * digits are the version number. + * For 5.x and higher, the scheme + * is: + * <0 if release branch, otherwise 1>xx */ - printf(" %d.%d", desc / 100000, - desc / 10000 % 10); - if (desc / 1000 % 10 > 0) + if (desc / 100000 < 5) { + printf(" %d.%d", desc / 100000, + desc / 10000 % 10); + if (desc / 1000 % 10 > 0) printf(".%d", desc / 1000 % 10); + } else { + printf(" %d.%d", desc / 100000, + desc / 1000 % 100); + desc %= 1000; + if (desc > 100 ) + printf("-CURRENT (rev %d)", + desc % 100 ); + else if (desc != 0) + printf(".%d", + desc / 10); + } } if (nh_namesz == 8 && >Release-Note: >Audit-Trail: >Unformatted: