Observation for ALL maintainers who provide dlls (was Re:question for perl maintainer)

Pierre A. Humblet pierre@phumblet.no-ip.org
Tue Jul 12 04:40:00 GMT 2005


At 11:47 PM 7/11/2005 -0400, Christopher Faylor wrote:
>On Mon, Jul 11, 2005 at 08:33:15PM -0700, Brian Dessent wrote:
>>"Pierre A. Humblet" wrote:
>>
>>> The attached script takes the name of a .exe or .dll,
>>> uses cygcheck to find the dll dependence and checks for conflicts.
>>> 
>>> This will allow you to check your favorite applications or dlls,
>>> seeing if --enable-auto-image-base works for you.
>>
>>I was under the impression that relocations at startup-time (i.e. all
>>DLL base addresses set to 0x10000000) was fine and doesn't cause the
>>remap issue, since the windows loader apparently will always choose the
>>same layout for the DLLs for a given .exe every time.
>
>Relocations of standard "statically loaded" dlls can fail on fork the
>same way that dynamically loaded dlls do.  Windows doesn't guarantee
>that the base address will be the same in the "forker" and "forkee" and
>it seems like something in the forked process throws off windows so that
>it chooses a different location for some dlls.

I have extended the tool (attached) so that it takes a variable number
of arguments. You can check a program and all the dll's it might ever
load dynamically, or all the dll's in /bin, or whatever. 
cygcheck will search the PATH if necessary.

Pierre
-------------- next part --------------
#! /bin/bash

# Checks for conflicts between all dll's that are loaded by the programs or dlls given as arguments.
# cygcheck searches PATH to find arguments that are not absolute pathnames.
 
final_dec=0
final_guard_dec=0
guard=0x10000

#set -x

cygcheck "$@" |
while read -r file
do
 [ -n "$file" ] && [ "$file" = "${file#Found:}" ] && objdump -p "$file" | 
   sed -n -e '2 {s:\\:/:g; s/^/ /; s/: .*$//; h}' -e '/ImageBase/ {s/ImageBase/ /; G; h}' -e '/SizeOfImage/ {s/SizeOfImage//; G; s/[\t\n]//gp; Q}'
done |
sort -f -u -k 2 |
while read size base name
do
  conflict=""
  base_dec=$(( 0x$base ))
  if [ "$final_dec" -ge "$base_dec" ] 
  then
    conflict="CONFLICT End: $final_dec Start:$base_dec"
  else
    [ "$final_guard_dec" -ge "$base_dec" ] && conflict="GUARD CONFLICT End: $final_dec Start:$base_dec"
  fi
  echo $name $base $size $conflict
  final_dec=$(( 0x$base + 0x$size  ))
  final_guard_dec=$(( $final_dec + $guard ))
done


More information about the Cygwin-apps mailing list