From edwin@mavetju.org  Fri Mar  5 23:08:13 2004
Return-Path: <edwin@mavetju.org>
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 <edwin@mavetju.org>
Reply-To: Edwin Groothuis <edwin@mavetju.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: christos@astron.com, jharris@widomaker.com, obrien@freebsd.org
Subject: [patch] file(1) doesn't recognize FreeBSD 5.x executables properly
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         63830
>Category:       bin
>Synopsis:       [patch] file(1) doesn't recognize FreeBSD 5.x executables properly
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    obrien
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Mar 05 23:10:09 PST 2004
>Closed-Date:    Mon Jan 31 00:01:38 GMT 2005
>Last-Modified:  Mon Jan 31 00:01:38 GMT 2005
>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: <major><two digit minor>
+					 * <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:
Responsible-Changed-From-To: freebsd-bugs->obrien 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Wed May 12 17:00:50 PDT 2004 
Responsible-Changed-Why:  
obrien did the last import of file(1), so ask friendly if he's 
willing to fix this problem. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=63830 

From: Edwin Groothuis <edwin@mavetju.org>
To: FreeBSD Gnats Submit <freebsd-gnats-submit@freebsd.org>
Cc: obrien@freebsd.org
Subject: bin/63830: [patch] file(1) doesn't recognize FreeBSD 5.x executables properly
Date: Fri, 28 May 2004 08:52:31 +1000

 This is fixed in the last 4.0.9 release of file(1):
 
 2004-03-22 15:25  Christos Zoulas  <christos@zoulas.com>
 	* FreeBSD ELF version handling
 	  (Edwin Groothuis) <edwin@mavetju.org>
 
 -- 
 Edwin Groothuis      |            Personal website: http://www.mavetju.org
 edwin@mavetju.org    |          Weblog: http://weblog.barnet.com.au/edwin/
State-Changed-From-To: open->closed 
State-Changed-By: edwin 
State-Changed-When: Mon Jan 31 00:01:28 GMT 2005 
State-Changed-Why:  
Old PR. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=63830 
>Unformatted:
