Improve cygwin rebase behaviour
authorReini Urban <rurban@x-ray.at>
Tue, 14 Sep 2010 15:54:15 +0000 (17:54 +0200)
committerJesse Vincent <jesse@bestpractical.com>
Tue, 4 Jan 2011 08:42:17 +0000 (16:42 +0800)
If a dll is updated on cygwin reuse the old imagebase address.
This solves most rebase errors, esp when updating on core dll's.
See http://www.tishler.net/jason/software/rebase/rebase-2.4.2.README

cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_Cygwin.pm

index d1de9d2..19aab84 100644 (file)
@@ -116,6 +116,29 @@ sub maybe_command {
     return $self->SUPER::maybe_command($file);
 }
 
+=item dynamic_lib
+
+Use the default to produce the *.dll's.
+But for new archdir dll's use the same rebase address if the old exists.
+
+=cut
+
+sub dynamic_lib {
+    my($self, %attribs) = @_;
+    my $s = ExtUtils::MM_Unix::dynamic_lib($self, %attribs);
+    my $ori = "$self->{INSTALLARCHLIB}/auto/$self->{FULLEXT}/$self->{BASEEXT}.$self->{DLEXT}";
+    if (-e $ori) {
+        my $imagebase = `/bin/objdump -p $ori | /bin/grep ImageBase | /bin/cut -c12-`;
+        chomp $imagebase;
+        if ($imagebase gt "40000000") {
+            my $LDDLFLAGS = $self->{LDDLFLAGS};
+            $LDDLFLAGS =~ s/-Wl,--enable-auto-image-base/-Wl,--image-base=0x$imagebase/;
+            $s =~ s/ \$\(LDDLFLAGS\) / $LDDLFLAGS /m;
+        }
+    }
+    $s;
+}
+
 =back
 
 =cut