Bug 146387 - file(1) command on sparc64 doesn't interpret sparc64 (V9) executables
Summary: file(1) command on sparc64 doesn't interpret sparc64 (V9) executables
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: sparc64 (show other bugs)
Version: 8.0-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-sparc64 (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-08 05:50 UTC by yuri
Modified: 2010-07-08 09:30 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description yuri 2010-05-08 05:50:01 UTC
On sparc64:
> file `which file`
/usr/bin/file: ERROR: ELF 64-bit MSB executable, SPARC V9, relaxed memory ordering, version 1 (FreeBSD), statically linkederror reading (File too large)

But when I try 'file' from i386 it correctly recognizes sparc64 executables.
Comment 1 Nathan Whitehorn freebsd_committer freebsd_triage 2010-05-08 23:19:49 UTC
Yuri wrote:
> Description:
>   
> On sparc64:
>   
>> file `which file`
>>     
> /usr/bin/file: ERROR: ELF 64-bit MSB executable, SPARC V9, relaxed memory ordering, version 1 (FreeBSD), statically linkederror reading (File too large)
>
> But when I try 'file' from i386 it correctly recognizes sparc64 executables.
>   
This same thing happens on 64-bit PowerPC, and on all big-endian systems 
(32 or 64 bit) when running file on 64-bit big-endian ELF files. It 
looks like an endian bug in libmagic.
-Nathan
Comment 2 marius 2010-05-11 20:12:18 UTC
On Sat, May 08, 2010 at 10:20:03PM +0000, Nathan Whitehorn wrote:
> The following reply was made to PR sparc64/146387; it has been noted by GNATS.
> 
> From: Nathan Whitehorn <nwhitehorn@freebsd.org>
> To: Yuri <yuri@tsoft.com>
> Cc: freebsd-gnats-submit@FreeBSD.org
> Subject: Re: sparc64/146387: 'file' command on sparc64 doesn't interpret sparc64
>  (V9) executables
> Date: Sat, 08 May 2010 18:19:49 -0400
> 
>  Yuri wrote:
>  > Description:
>  >   
>  > On sparc64:
>  >   
>  >> file `which file`
>  >>     
>  > /usr/bin/file: ERROR: ELF 64-bit MSB executable, SPARC V9, relaxed memory ordering, version 1 (FreeBSD), statically linkederror reading (File too large)
>  >
>  > But when I try 'file' from i386 it correctly recognizes sparc64 executables.
>  >   
>  This same thing happens on 64-bit PowerPC, and on all big-endian systems 
>  (32 or 64 bit) when running file on 64-bit big-endian ELF files. It 
>  looks like an endian bug in libmagic.

Actually, it appears that the problem is the way the base file/libmagic
is built as the port version doesn't exhibit such problems:
v215# file -v 
file-5.03
magic file from /usr/share/misc/magic
v215# file `which file`
/usr/bin/file: ELF 64-bit MSB executable, SPARC V9, relaxed memory ordering, version 1 (FreeBSD), statically linked, stripped
v215# /usr/local/bin/file -v
file-5.03
magic file from /usr/local/share/file/magic
v215# /usr/local/bin/file `which file`
/usr/bin/file: ELF 64-bit MSB executable, SPARC V9, relaxed memory ordering, version 1 (FreeBSD), dynamically linked (uses shared libs), for FreeBSD 9.0 (900005), stripped

Marius
Comment 3 marius 2010-05-15 23:40:35 UTC
> >  Yuri wrote:
> >  > Description:
> >  >   
> >  > On sparc64:
> >  >   
> >  >> file `which file`
> >  >>     
> >  > /usr/bin/file: ERROR: ELF 64-bit MSB executable, SPARC V9, relaxed memory ordering, version 1 (FreeBSD), statically linkederror reading (File too large)
> >  >
> >  > But when I try 'file' from i386 it correctly recognizes sparc64 executables.
> >  >   

Could you please try with file and libmagic rebuilt with the following
patch?
http://people.freebsd.org/~marius/libmagic_config.h_5.03.diff

I can't reproduce the exact same problem but the issues I have with
file(1) and ELF binaries are fixed with it.

Marius
Comment 4 dfilter service freebsd_committer freebsd_triage 2010-05-20 09:57:00 UTC
Author: marius
Date: Thu May 20 08:56:50 2010
New Revision: 208341
URL: http://svn.freebsd.org/changeset/base/208341

Log:
  Update to a config.h created by a file 5.03 configure script. This causes
  file.1 to contain the correct version number and SIZEOF_LONG_LONG to be
  defined as appropriate, which is crucial for 64-bit big-endian ELF files
  to be handled correctly on big-endian systems.
  
  PR:		146387
  Reviewed by:	delphij
  MFC after:	3 days

Modified:
  head/lib/libmagic/config.h

Modified: head/lib/libmagic/config.h
==============================================================================
--- head/lib/libmagic/config.h	Thu May 20 08:51:01 2010	(r208340)
+++ head/lib/libmagic/config.h	Thu May 20 08:56:50 2010	(r208341)
@@ -1,18 +1,18 @@
 /* $FreeBSD$ */
 
 /* config.h.  Generated from config.h.in by configure.  */
-/* config.h.in.  Generated from configure.in by autoheader.  */
+/* config.h.in.  Generated from configure.ac by autoheader.  */
 
-/* Use the builtin ELF recognition code */
+/* Define in built-in ELF support is used */
 #define BUILTIN_ELF 1
 
-/* Recognize ELF core files */
+/* Define for ELF core file support */
 #define ELFCORE 1
 
 /* Define to 1 if you have the `asprintf' function. */
 #define HAVE_ASPRINTF 1
 
-/* */
+/* HAVE_DAYLIGHT */
 /* #undef HAVE_DAYLIGHT */
 
 /* Define to 1 if you have the <dlfcn.h> header file. */
@@ -51,9 +51,6 @@
 /* Define to 1 if you have the <locale.h> header file. */
 #define HAVE_LOCALE_H 1
 
-/* */
-#define HAVE_LONG_LONG 1
-
 /* Define to 1 if you have the `mbrtowc' function. */
 #define HAVE_MBRTOWC 1
 
@@ -69,9 +66,6 @@
 /* Define to 1 if you have the `mmap' function. */
 #define HAVE_MMAP 1
 
-/* Define to 1 if you have the `snprintf' function. */
-#define HAVE_SNPRINTF 1
-
 /* Define to 1 if you have the <stdint.h> header file. */
 #define HAVE_STDINT_H 1
 
@@ -102,13 +96,12 @@
 /* Define to 1 if you have the `strtoul' function. */
 #define HAVE_STRTOUL 1
 
+/* HAVE_STRUCT_OPTION */
+#define HAVE_STRUCT_OPTION 1
+
 /* Define to 1 if `st_rdev' is member of `struct stat'. */
 #define HAVE_STRUCT_STAT_ST_RDEV 1
 
-/* Define to 1 if your `struct stat' has `st_rdev'. Deprecated, use
-   `HAVE_STRUCT_STAT_ST_RDEV' instead. */
-#define HAVE_ST_RDEV 1
-
 /* Define to 1 if `tm_gmtoff' is member of `struct tm'. */
 #define HAVE_STRUCT_TM_TM_GMTOFF 1
 
@@ -133,7 +126,7 @@
 /* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
 #define HAVE_SYS_WAIT_H 1
 
-/* */
+/* HAVE_TM_ISDST */
 #define HAVE_TM_ISDST 1
 
 /* HAVE_TM_ZONE */
@@ -169,9 +162,6 @@
 /* Define to 1 if you have the `vasprintf' function. */
 #define HAVE_VASPRINTF 1
 
-/* Define to 1 if you have the `vsnprintf' function. */
-#define HAVE_VSNPRINTF 1
-
 /* Define to 1 if you have the <wchar.h> header file. */
 #define HAVE_WCHAR_H 1
 
@@ -199,34 +189,22 @@
 #define PACKAGE "file"
 
 /* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT ""
+#define PACKAGE_BUGREPORT "christos@astron.com"
 
 /* Define to the full name of this package. */
-#define PACKAGE_NAME ""
+#define PACKAGE_NAME "file"
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING ""
+#define PACKAGE_STRING "file 5.03"
 
 /* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME ""
+#define PACKAGE_TARNAME "file"
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION VERSION
-
-/* */
-#define SIZEOF_INT64_T 8
+#define PACKAGE_VERSION "5.03"
 
-/* */
-#define SIZEOF_UINT16_T 2
-
-/* */
-#define SIZEOF_UINT32_T 4
-
-/* */
-#define SIZEOF_UINT64_T 8
-
-/* */
-#define SIZEOF_UINT8_T 1
+/* The size of `long long', as computed by sizeof. */
+#define SIZEOF_LONG_LONG 8
 
 /* Define to 1 if you have the ANSI C header files. */
 #define STDC_HEADERS 1
@@ -235,7 +213,7 @@
 /* #undef TM_IN_SYS_TIME */
 
 /* Version number of package */
-#define VERSION "5.00"
+#define VERSION "5.03"
 
 /* Number of bits in a file offset, on hosts where this is settable. */
 /* #undef _FILE_OFFSET_BITS */
@@ -247,8 +225,49 @@
 #endif
 #endif
 
+/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
+/* #undef _LARGEFILE_SOURCE */
+
 /* Define for large files, on AIX-style hosts. */
 /* #undef _LARGE_FILES */
 
 /* Define to empty if `const' does not conform to ANSI C. */
 /* #undef const */
+
+/* Define to a type if <wchar.h> does not define. */
+/* #undef mbstate_t */
+
+/* Define to `long int' if <sys/types.h> does not define. */
+/* #undef off_t */
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* #undef size_t */
+
+
+#ifndef HAVE_UINT8_T
+typedef unsigned char uint8_t;
+#endif
+#ifndef HAVE_UINT16_T
+typedef unsigned short uint16_t;
+#endif
+#ifndef HAVE_UINT32_T
+typedef unsigned int uint32_t;
+#endif
+#ifndef HAVE_INT32_T
+typedef int int32_t;
+#endif
+#ifndef HAVE_UINT64_T
+#if SIZEOF_LONG_LONG == 8
+typedef unsigned long long uint64_t;
+#else
+typedef unsigned long uint64_t;
+#endif
+#endif
+#ifndef HAVE_INT64_T
+#if SIZEOF_LONG_LONG == 8
+typedef long long int64_t;
+#else
+typedef long int64_t;
+#endif
+#endif
+
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 5 dfilter service freebsd_committer freebsd_triage 2010-05-23 12:18:26 UTC
Author: marius
Date: Sun May 23 11:18:05 2010
New Revision: 208444
URL: http://svn.freebsd.org/changeset/base/208444

Log:
  MFC: r208341
  
  Update to a config.h created by a file 5.03 configure script. This causes
  file.1 to contain the correct version number and SIZEOF_LONG_LONG to be
  defined as appropriate, which is crucial for 64-bit big-endian ELF files
  to be handled correctly on big-endian systems.
  
  PR:		146387
  Reviewed by:	delphij

Modified:
  stable/8/lib/libmagic/config.h
Directory Properties:
  stable/8/lib/libmagic/   (props changed)

Modified: stable/8/lib/libmagic/config.h
==============================================================================
--- stable/8/lib/libmagic/config.h	Sun May 23 10:13:11 2010	(r208443)
+++ stable/8/lib/libmagic/config.h	Sun May 23 11:18:05 2010	(r208444)
@@ -1,18 +1,18 @@
 /* $FreeBSD$ */
 
 /* config.h.  Generated from config.h.in by configure.  */
-/* config.h.in.  Generated from configure.in by autoheader.  */
+/* config.h.in.  Generated from configure.ac by autoheader.  */
 
-/* Use the builtin ELF recognition code */
+/* Define in built-in ELF support is used */
 #define BUILTIN_ELF 1
 
-/* Recognize ELF core files */
+/* Define for ELF core file support */
 #define ELFCORE 1
 
 /* Define to 1 if you have the `asprintf' function. */
 #define HAVE_ASPRINTF 1
 
-/* */
+/* HAVE_DAYLIGHT */
 /* #undef HAVE_DAYLIGHT */
 
 /* Define to 1 if you have the <dlfcn.h> header file. */
@@ -51,9 +51,6 @@
 /* Define to 1 if you have the <locale.h> header file. */
 #define HAVE_LOCALE_H 1
 
-/* */
-#define HAVE_LONG_LONG 1
-
 /* Define to 1 if you have the `mbrtowc' function. */
 #define HAVE_MBRTOWC 1
 
@@ -69,9 +66,6 @@
 /* Define to 1 if you have the `mmap' function. */
 #define HAVE_MMAP 1
 
-/* Define to 1 if you have the `snprintf' function. */
-#define HAVE_SNPRINTF 1
-
 /* Define to 1 if you have the <stdint.h> header file. */
 #define HAVE_STDINT_H 1
 
@@ -102,13 +96,12 @@
 /* Define to 1 if you have the `strtoul' function. */
 #define HAVE_STRTOUL 1
 
+/* HAVE_STRUCT_OPTION */
+#define HAVE_STRUCT_OPTION 1
+
 /* Define to 1 if `st_rdev' is member of `struct stat'. */
 #define HAVE_STRUCT_STAT_ST_RDEV 1
 
-/* Define to 1 if your `struct stat' has `st_rdev'. Deprecated, use
-   `HAVE_STRUCT_STAT_ST_RDEV' instead. */
-#define HAVE_ST_RDEV 1
-
 /* Define to 1 if `tm_gmtoff' is member of `struct tm'. */
 #define HAVE_STRUCT_TM_TM_GMTOFF 1
 
@@ -133,7 +126,7 @@
 /* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
 #define HAVE_SYS_WAIT_H 1
 
-/* */
+/* HAVE_TM_ISDST */
 #define HAVE_TM_ISDST 1
 
 /* HAVE_TM_ZONE */
@@ -169,9 +162,6 @@
 /* Define to 1 if you have the `vasprintf' function. */
 #define HAVE_VASPRINTF 1
 
-/* Define to 1 if you have the `vsnprintf' function. */
-#define HAVE_VSNPRINTF 1
-
 /* Define to 1 if you have the <wchar.h> header file. */
 #define HAVE_WCHAR_H 1
 
@@ -199,34 +189,22 @@
 #define PACKAGE "file"
 
 /* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT ""
+#define PACKAGE_BUGREPORT "christos@astron.com"
 
 /* Define to the full name of this package. */
-#define PACKAGE_NAME ""
+#define PACKAGE_NAME "file"
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING ""
+#define PACKAGE_STRING "file 5.03"
 
 /* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME ""
+#define PACKAGE_TARNAME "file"
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION VERSION
-
-/* */
-#define SIZEOF_INT64_T 8
+#define PACKAGE_VERSION "5.03"
 
-/* */
-#define SIZEOF_UINT16_T 2
-
-/* */
-#define SIZEOF_UINT32_T 4
-
-/* */
-#define SIZEOF_UINT64_T 8
-
-/* */
-#define SIZEOF_UINT8_T 1
+/* The size of `long long', as computed by sizeof. */
+#define SIZEOF_LONG_LONG 8
 
 /* Define to 1 if you have the ANSI C header files. */
 #define STDC_HEADERS 1
@@ -235,7 +213,7 @@
 /* #undef TM_IN_SYS_TIME */
 
 /* Version number of package */
-#define VERSION "5.00"
+#define VERSION "5.03"
 
 /* Number of bits in a file offset, on hosts where this is settable. */
 /* #undef _FILE_OFFSET_BITS */
@@ -247,8 +225,49 @@
 #endif
 #endif
 
+/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
+/* #undef _LARGEFILE_SOURCE */
+
 /* Define for large files, on AIX-style hosts. */
 /* #undef _LARGE_FILES */
 
 /* Define to empty if `const' does not conform to ANSI C. */
 /* #undef const */
+
+/* Define to a type if <wchar.h> does not define. */
+/* #undef mbstate_t */
+
+/* Define to `long int' if <sys/types.h> does not define. */
+/* #undef off_t */
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* #undef size_t */
+
+
+#ifndef HAVE_UINT8_T
+typedef unsigned char uint8_t;
+#endif
+#ifndef HAVE_UINT16_T
+typedef unsigned short uint16_t;
+#endif
+#ifndef HAVE_UINT32_T
+typedef unsigned int uint32_t;
+#endif
+#ifndef HAVE_INT32_T
+typedef int int32_t;
+#endif
+#ifndef HAVE_UINT64_T
+#if SIZEOF_LONG_LONG == 8
+typedef unsigned long long uint64_t;
+#else
+typedef unsigned long uint64_t;
+#endif
+#endif
+#ifndef HAVE_INT64_T
+#if SIZEOF_LONG_LONG == 8
+typedef long long int64_t;
+#else
+typedef long int64_t;
+#endif
+#endif
+
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 6 Marius Strobl freebsd_committer freebsd_triage 2010-05-23 14:06:37 UTC
State Changed
From-To: open->patched

mark as patched, awaiting feedback whether the reported case is also fixed
Comment 7 Marius Strobl freebsd_committer freebsd_triage 2010-07-08 09:29:18 UTC
State Changed
From-To: patched->closed

close; feedback timeout