* Merge in cygwin-64bit-branch.
This commit is contained in:
@@ -5,8 +5,8 @@ use File::Spec;
|
||||
use Getopt::Long;
|
||||
my $dir = tempdir(CLEANUP => 1);
|
||||
|
||||
my ($ar, $as, $nm, $objcopy, %replace);
|
||||
GetOptions('ar=s'=>\$ar, 'as=s'=>\$as,'nm=s'=>\$nm, 'objcopy=s'=>\$objcopy, 'replace=s'=>\%replace);
|
||||
my ($cpu, $ar, $as, $nm, $objcopy, %replace);
|
||||
GetOptions('cpu=s'=>\$cpu, 'ar=s'=>\$ar, 'as=s'=>\$as,'nm=s'=>\$nm, 'objcopy=s'=>\$objcopy, 'replace=s'=>\%replace);
|
||||
|
||||
# Args::
|
||||
# 1) import lib to create
|
||||
@@ -22,6 +22,10 @@ open my $nm_fd, '-|', $nm, '-Apg', '--defined-only', $inpdll;
|
||||
my %text = ();
|
||||
my %import = ();
|
||||
my %symfile = ();
|
||||
|
||||
my $is64bit = ($cpu eq 'x86_64' ? 1 : 0);
|
||||
my $sym_prefix = ($is64bit ? '' : '_');
|
||||
|
||||
while (<$nm_fd>) {
|
||||
chomp;
|
||||
my ($fn, $type, $sym) = /^$inpdll:(.*?):\S+\s+(\S)\s+(\S+)$/o;
|
||||
@@ -34,12 +38,12 @@ close $nm_fd or exit 1;
|
||||
|
||||
for my $sym (keys %replace) {
|
||||
my $fn;
|
||||
my $_sym = '_' . $sym;
|
||||
my $_sym = $sym_prefix . $sym;
|
||||
if (!defined($fn = $symfile{$_sym})) {
|
||||
$fn = "$sym.o";
|
||||
$text{$fn} = $_sym;
|
||||
}
|
||||
my $imp_sym = '__imp__' . $replace{$sym};
|
||||
my $imp_sym = '__imp_' . $sym_prefix . $replace{$sym};
|
||||
$import{$fn} = $imp_sym;
|
||||
}
|
||||
|
||||
@@ -48,18 +52,28 @@ for my $f (keys %text) {
|
||||
my $glob_sym = $text{$f};
|
||||
if (!defined $imp_sym) {
|
||||
delete $text{$f};
|
||||
} elsif ($imp_sym eq '__imp__') {
|
||||
} elsif ($imp_sym eq '__imp_' . $sym_prefix) {
|
||||
$text{$f} = 0;
|
||||
} else {
|
||||
$text{$f} = 1;
|
||||
open my $as_fd, '|-', $as, '-o', "$dir/t-$f", "-";
|
||||
print $as_fd <<EOF;
|
||||
if ($is64bit) {
|
||||
print $as_fd <<EOF;
|
||||
.text
|
||||
.extern $imp_sym
|
||||
.global $glob_sym
|
||||
$glob_sym:
|
||||
jmp *$imp_sym(%rip)
|
||||
EOF
|
||||
} else {
|
||||
print $as_fd <<EOF;
|
||||
.text
|
||||
.extern $imp_sym
|
||||
.global $glob_sym
|
||||
$glob_sym:
|
||||
jmp *$imp_sym
|
||||
EOF
|
||||
}
|
||||
close $as_fd or exit 1;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user