Re: Determine FreeBSD version of binary

2007-11-08 Thread Yuri Pankov
On Thu, Nov 08, 2007 at 06:01:40PM +0100, John Smith wrote:
 Hi,
 
 
 
 I was wondering if it was possible to determine for what version of
 FreeBSD a binary was compiled, purely by examining the binary?
 
 
 Any and all help and suggestions are greatly appreciated,
 
 
 
 Thanks,
 
 
 john Smith

May be not entirely correct, but close:

ldd binary | grep libc.so

libc.so.4 - 4.x, libc.so.5 - 5.x, libc.so.6 - 6x, libc.so.7 - 7.x (and
8-CURRENT at the moment).


HTH,
Yuri
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


RE: Determine FreeBSD version of binary

2007-11-08 Thread Chris Haulmark


 
 Hi,
 
 
 
 I was wondering if it was possible to determine for what version of
 FreeBSD a binary was compiled, purely by examining the binary?

Try using strings to examine the binary file for clues.

Chris

 
 
 Any and all help and suggestions are greatly appreciated,
 
 
 
 Thanks,
 
 
 john Smith
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to freebsd-questions-
 [EMAIL PROTECTED]
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Determine FreeBSD version of binary

2007-11-08 Thread John Smith
On Nov 8, 2007 6:45 PM, Chris Haulmark [EMAIL PROTECTED] wrote:

 Try using strings to examine the binary file for clues.


Thanks, but... exactly what kind of 'clues' should I be looking for ?
Is there anything in particular that could be helpful or give me some
kind of hint ?


Regards,


John Smith
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Determine FreeBSD version of binary

2007-11-08 Thread Chuck Robey

John Smith wrote:


I was wondering if it was possible to determine for what version of
FreeBSD a binary was compiled, purely by examining the binary?


As a suggestion, use the 'ldd' command to see what version of the libc 
is linked in with the binary.  You didn['t mention if the binary was 
linked shared or not (if it's statically linked, well, you're out of 
luck with this particular method).Depending on how it's linked, you 
might even have probnlems using ldd, I think, then you'd have to use the 
objdump utility, along with grep, like this:


objdump -x whateverfile | grep NEEDED | grep libc

and get the version of libc from there.  It's the version of libc that 
you're after with all this song and dance.  I've been gone from FreeBSD 
for a longish while (more than about 2 years) so I couldn't give you 
exact libc version versus date info, but if you post that to this list, 
most likely someone would have that right to hand.






Any and all help and suggestions are greatly appreciated,



Thanks,


john Smith
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Determine FreeBSD version of binary

2007-11-08 Thread John Smith
On Nov 8, 2007 6:59 PM, Yuri Pankov [EMAIL PROTECTED] wrote:

 May be not entirely correct, but close:

 ldd binary | grep libc.so


Yes, that helps somewhat. At least I now know that it's FreeBSD 4.x.
And before I again forget something I forgot to mention earlier on: I
also have a file called 'kernel'. Could that somehow give somewhat
more detailed information about exactly which 4.x kernel it is, and if
so, how would I go about doing that ?


Regards,

John Smith
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Determine FreeBSD version of binary

2007-11-08 Thread Erik Osterholm
On Thu, Nov 08, 2007 at 03:47:54PM -0600, Dan Nelson wrote:
 In the last episode (Nov 08), John Smith said:
  On Nov 8, 2007 6:59 PM, Yuri Pankov [EMAIL PROTECTED] wrote:
   May be not entirely correct, but close:
  
   ldd binary | grep libc.so
  
  Yes, that helps somewhat. At least I now know that it's FreeBSD 4.x.
  And before I again forget something I forgot to mention earlier on: I
  also have a file called 'kernel'. Could that somehow give somewhat
  more detailed information about exactly which 4.x kernel it is, and
  if so, how would I go about doing that ?
 
 Run strings /kernel | tail on it.
 
 There's also a better way to determine the FreeBSD version an
 executable was built for.  As long as you didn't build world with -O2,
 the file command can print it.  Note that you will need to run a 5.x
 or newer version of file, since even though 4.x puts the version in
 each binary, its file command doesn't print it.
 
 $ file /bin/ls
 /bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD), for 
 FreeBSD 7.0 (700052), dynamically linked (uses shared libs), FreeBSD-style, 
 stripped
 $ file /mnt/oldsystem/bin/ls
 /mnt/oldsystem/bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1, for 
 FreeBSD 4.2, statically linked, stripped
 
 If you like building with -O2, apply the patch in PR 101590.

Interesting.  Does 6.2/amd64 build with -O2 by default?

$ file /bin/ls
/bin/ls: ELF 64-bit LSB executable, AMD x86-64, version 1 (FreeBSD),
dynamically linked (uses shared libs), stripped


This was after a buildworld with no special options added, and nothing
affecting the kernel in make.conf.

Erik

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Determine FreeBSD version of binary

2007-11-08 Thread Roland Smith
On Thu, Nov 08, 2007 at 10:16:38PM +0100, John Smith wrote:
 On Nov 8, 2007 6:59 PM, Yuri Pankov [EMAIL PROTECTED] wrote:
 
  May be not entirely correct, but close:
 
  ldd binary | grep libc.so
 
 
 Yes, that helps somewhat. At least I now know that it's FreeBSD 4.x.
 And before I again forget something I forgot to mention earlier on: I
 also have a file called 'kernel'. Could that somehow give somewhat
 more detailed information about exactly which 4.x kernel it is, and if
 so, how would I go about doing that ?

The command 'strings kernel | grep ^@(#)FreeBSD' should do the trick.

Roland
-- 
R.F.Smith   http://www.xs4all.nl/~rsmith/
[plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated]
pgp: 1A2B 477F 9970 BA3C 2914  B7CE 1277 EFB0 C321 A725 (KeyID: C321A725)


pgpv32tvv1jVK.pgp
Description: PGP signature


Re: Determine FreeBSD version of binary

2007-11-08 Thread Dan Nelson
In the last episode (Nov 08), John Smith said:
 On Nov 8, 2007 6:59 PM, Yuri Pankov [EMAIL PROTECTED] wrote:
  May be not entirely correct, but close:
 
  ldd binary | grep libc.so
 
 Yes, that helps somewhat. At least I now know that it's FreeBSD 4.x.
 And before I again forget something I forgot to mention earlier on: I
 also have a file called 'kernel'. Could that somehow give somewhat
 more detailed information about exactly which 4.x kernel it is, and
 if so, how would I go about doing that ?

Run strings /kernel | tail on it.

There's also a better way to determine the FreeBSD version an
executable was built for.  As long as you didn't build world with -O2,
the file command can print it.  Note that you will need to run a 5.x
or newer version of file, since even though 4.x puts the version in
each binary, its file command doesn't print it.

$ file /bin/ls
/bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD), for 
FreeBSD 7.0 (700052), dynamically linked (uses shared libs), FreeBSD-style, 
stripped
$ file /mnt/oldsystem/bin/ls
/mnt/oldsystem/bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1, for 
FreeBSD 4.2, statically linked, stripped

If you like building with -O2, apply the patch in PR 101590.

-- 
Dan Nelson
[EMAIL PROTECTED]
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Determine FreeBSD version of binary

2007-11-08 Thread Dan Nelson
In the last episode (Nov 08), Erik Osterholm said:
 On Thu, Nov 08, 2007 at 03:47:54PM -0600, Dan Nelson wrote:
  In the last episode (Nov 08), John Smith said:
   On Nov 8, 2007 6:59 PM, Yuri Pankov [EMAIL PROTECTED] wrote:
May be not entirely correct, but close:
   
ldd binary | grep libc.so
   
   Yes, that helps somewhat. At least I now know that it's FreeBSD
   4.x. And before I again forget something I forgot to mention
   earlier on: I also have a file called 'kernel'. Could that
   somehow give somewhat more detailed information about exactly
   which 4.x kernel it is, and if so, how would I go about doing
   that ?
  
  Run strings /kernel | tail on it.
  
  There's also a better way to determine the FreeBSD version an
  executable was built for.  As long as you didn't build world with
  -O2, the file command can print it.  Note that you will need to
  run a 5.x or newer version of file, since even though 4.x puts the
  version in each binary, its file command doesn't print it.
  
  $ file /bin/ls
  /bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD), for 
  FreeBSD 7.0 (700052), dynamically linked (uses shared libs), FreeBSD-style, 
  stripped
  $ file /mnt/oldsystem/bin/ls
  /mnt/oldsystem/bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1, 
  for FreeBSD 4.2, statically linked, stripped
  
  If you like building with -O2, apply the patch in PR 101590.
 
 Interesting.  Does 6.2/amd64 build with -O2 by default?

The default was switched from -O to -O2 in src/share/mk/sys.mk r1.81,
which was before 6.x was branched, so none of the 6.x releases have
versions in their executables.
 
 $ file /bin/ls
 /bin/ls: ELF 64-bit LSB executable, AMD x86-64, version 1 (FreeBSD), 
 dynamically linked (uses shared libs), stripped
 
 This was after a buildworld with no special options added, and
 nothing affecting the kernel in make.conf.

-- 
Dan Nelson
[EMAIL PROTECTED]
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]