bin/63830: [patch] file(1) doesn't recognize FreeBSD 5.x executables properly

Edwin Groothuis edwin at mavetju.org
Fri Mar 5 23:10:11 PST 2004


>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 at 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:
>Unformatted:


More information about the freebsd-bugs mailing list