delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/09/09/14:58:59

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <022501c37704$6276c030$a62d8751@starfruit>
From: "Max Bowsher" <maxb AT ukf DOT net>
To: <sds AT gnu DOT org>, <cygwin AT cygwin DOT com>
References: <uoextu8i3 DOT fsf AT gnu DOT org>
Subject: Re: package _version_ check
Date: Tue, 9 Sep 2003 19:58:39 +0100
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Note-from-DJ: This may be spam

------=_NextPart_000_0222_01C3770C.C3374CC0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Sam Steingold wrote:
> how do I check that the installed package foo was built against cygwin
> 1.5 and not 1.3?

I've attached a perl script (CVID - Cygwin Version IDentify) that I wrote,
which you can run on an .exe or .dll.
It examines "objdump -p" output (so requires binutils), and deduces the API
based on which functions the the exe/dll imports from cygwin1.dll.

new = 1.5.x
old = 1.3.x
mixed = the peculiar brokenness early in the 1.5.x series
immune = *Possibly* independent of the changed datatype. Investigate all
dependent DLLs.

Max.

------=_NextPart_000_0222_01C3770C.C3374CC0
Content-Type: application/octet-stream;
	name="cvid.pl"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="cvid.pl"

#!/usr/bin/perl=0A=
=0A=
use strict;=0A=
use warnings 'all' =3D> 'FATAL';=0A=
use diagnostics;=0A=
=0A=
my @oldfuncs =3D qw( open acl aclcheck aclfrommode aclfrompbits =
aclfromtext aclsort acltomode acltopbits acltotext chown facl fchown =
fdopen fgetpos fopen freopen fseeko fsetpos fstat ftello ftruncate =
getegid geteuid getgid getgrent getgrgid getgrnam getgroups getpwuid =
getpwuid_r getuid initgroups lchown lseek lstat mknod mmap seekdir =
setegid seteuid setgid setgroups setregid setreuid setuid stat telldir =
truncate );=0A=
my @newfuncs =3D qw( _open64 _acl32 _aclcheck32 _aclfrommode32 =
_aclfrompbits32 _aclfromtext32 _aclsort32 _acltomode32 _acltopbits32 =
_acltotext32 _chown32 _facl32 _fchown32 _fdopen64 _fgetpos64 _fopen64 =
_freopen64 _fseeko64 _fsetpos64 _fstat64 _ftello64 _ftruncate64 =
_getegid32 _geteuid32 _getgid32 _getgrent32 _getgrgid32 _getgrnam32 =
_getgroups32 _getpwuid32 _getpwuid_r32 _getuid32 _initgroups32 _lchown32 =
_lseek64 _lstat64 _mknod32 _mmap64 _seekdir64 _setegid32 _seteuid32 =
_setgid32 _setgroups32 _setregid32 _setreuid32 _setuid32 _stat64 =
_telldir64 _truncate64 );=0A=
my (%is_old, %is_new);=0A=
@is_old{ @oldfuncs } =3D (1) x @oldfuncs;=0A=
@is_new{ @newfuncs } =3D (1) x @newfuncs;=0A=
=0A=
sub idver($)=0A=
{=0A=
  -f($_) or return "ERR";=0A=
=0A=
  undef $/;=0A=
  open(FH, "objdump -p \"".$_[0]."\" |") or die;=0A=
  my $odmp =3D <FH>;=0A=
  close(FH);=0A=
=0A=
  $odmp =3D~ m/(^The Import Tables.*?)(^\S|\Z)/ms or die;=0A=
  $odmp =3D $1;=0A=
  $odmp =3D~ m/^\s*DLL Name: cygwin1\.dll$(.*?)^\s*$/ms or return =
"non-cyg";=0A=
=0A=
  my @imps =3D split /\n/, $1;=0A=
  $_ =3D shift @imps; m/^\s*$/ or die "Unexpected: \'$_\'\n";=0A=
  $_ =3D shift @imps; m/vma: / or die "Unexpected: \'$_\'\n";=0A=
=0A=
  my ($has_old, $has_new);=0A=
=0A=
  foreach (@imps)=0A=
  {=0A=
    m/^\s*(\S+)\s+(\S+)\s+(\S+)\s*$/ or die;=0A=
    $has_old =3D 1 if $is_old{$3};=0A=
    $has_new =3D 1 if $is_new{$3};=0A=
  }=0A=
=0A=
  my $type;=0A=
  if ($has_old and $has_new) { $type =3D "mixed"; }=0A=
  elsif ($has_old) { $type =3D "old"; }=0A=
  elsif ($has_new) { $type =3D "new"; }=0A=
  else { $type =3D "immune"; }=0A=
=0A=
  my @dlls =3D grep { m/^\s*DLL Name: (?!cygwin1)/ } split(/\n/, $odmp);=0A=
  @dlls =3D map { m/^\s*DLL Name: (?:cyg)?(.*?)(?:\.dll|\.DLL)?$/; $1; } =
@dlls;=0A=
  my %dlls;=0A=
  @dlls{@dlls} =3D (1)x AT dlls;=0A=
  for (qw(=0A=
ADVAPI32=0A=
COMCTL32=0A=
COMDLG32=0A=
GDI32=0A=
IMM32=0A=
KERNEL32=0A=
NETAPI32=0A=
OLE32=0A=
SHELL32=0A=
USER32=0A=
WINSPOOL.DRV=0A=
    )) { delete $dlls{$_}; }=0A=
  @dlls =3D keys %dlls;=0A=
=0A=
  return $type . " (" . join(' ', @dlls).")";=0A=
};=0A=
=0A=
for (@ARGV)=0A=
{=0A=
  print $_.": ".idver($_)."\n";=0A=
}=0A=
=0A=


------=_NextPart_000_0222_01C3770C.C3374CC0
Content-Type: text/plain; charset=us-ascii

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/
------=_NextPart_000_0222_01C3770C.C3374CC0--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019