From nobody@FreeBSD.org  Mon Jul 29 00:14:02 2002
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 382A237B400
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 29 Jul 2002 00:14:02 -0700 (PDT)
Received: from www.freebsd.org (www.FreeBSD.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id D4D3243E31
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 29 Jul 2002 00:14:01 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.4/8.12.4) with ESMTP id g6T7E0OT002729
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 29 Jul 2002 00:14:00 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.4/8.12.4/Submit) id g6T7E0Uc002727;
	Mon, 29 Jul 2002 00:14:00 -0700 (PDT)
Message-Id: <200207290714.g6T7E0Uc002727@www.freebsd.org>
Date: Mon, 29 Jul 2002 00:14:00 -0700 (PDT)
From: Miguel Angel Vicente Serrano <miguelangel@cic.es>
To: freebsd-gnats-submit@FreeBSD.org
Subject: file(1) command shows incorrect data (signal #) when working with core files
X-Send-Pr-Version: www-1.0

>Number:         41107
>Category:       misc
>Synopsis:       file(1) command shows incorrect data (signal #) when working with core files
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jul 29 00:20:02 PDT 2002
>Closed-Date:    Sat Jul 12 18:03:57 PDT 2003
>Last-Modified:  Sat Jul 12 18:03:57 PDT 2003
>Originator:     Miguel Angel Vicente Serrano
>Release:        4.5 RELEASE
>Organization:
CICSA (Spain)
>Environment:
FreeBSD personal.sistemas.com 4.5-RELEASE FreeBSD 4.5-RELEASE #0: Mon Jan 28 14:31:56 GMT 2002     murray@builder.freebsdmall.com:/usr/src/sys/compile/GENERIC  i386

>Description:
when we run "file corefile" we get an incorrect information about signal number which caused the core (always shows the number 4477762).
/usr/share/misc/magic file has information about the offset of the signal and the name of the program in the core file. Perhaps these offsets are wrong in the case of FreeBSD's core files, but are good for Linux's cores.
    
>How-To-Repeat:
we can create some core files, for instance:
sleep 300 &
kill -3 $!

we have sleep.core file (the signal can be 3, 4, 5, 6, 7, 8, 10, 11 or 12)

we run "file sleep.core" and get this:

sleep.core: ELF 32-bit LSB core file (signal 4477762), Intel 80386, version 1 (FreeBSD), from 'sleep'

as you can see the signal number is wrong (must be 3, the one used with kill)
>Fix:
we create a temporal copy of "magic" file in /tmp directory:

cd /tmp
cp /usr/share/misc/magic .

we work with this temporal copy of "magic" file
we must change two lines, so the offsets of the signal and the program are right

replace the line #6752
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: kris 
State-Changed-When: Sat Jul 12 18:02:30 PDT 2003 
State-Changed-Why:  
Thanks for reporting this, but file is maintained externally 
to FreeBSD.  Please submit this to 
Christos Zoulas <christos@zoulas.com> instead. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41107 
>Unformatted:
 >>>(0x38+0xcc) string	>\0		of '%s'
 
 with this one
 >>>(0x38+0x15c) string	>\0		of '%s'
 
 replace the line #6753
 >>>(0x38+0x10) lelong	>0		(signal %d),
 
 with this one
 >>>(0x38+0x28) lelong	>0		(signal %d),
 
 we write a magic.mgc file:
 file -C -m magic
 
 we install the new pre-parsed version of magic file:
 mv /usr/share/misc/magic.mgc /usr/share/misc/magic.mgc.old
 mv magic.mgc /usr/share/misc
 
 we run "file sleep.core" and get this:
 
 sleep.core: ELF 32-bit LSB core file of 'sleep' (signal 3), Intel 80386, version 1 (FreeBSD), from 'sleep'
 
 as you can see the signal number is right (the one used with kill) and the name of the program is shown (LSB core file of 'sleep')
 
