]>
sourceware.org Git - newlib-cygwin.git/blob - winsup/cygwin/mkimport
3 use File
::Temp qw
'tempdir';
6 my $dir = tempdir
(CLEANUP
=> 1);
8 my ($ar, $as, $nm, $objcopy, %replace);
9 GetOptions
('ar=s'=>\
$ar, 'as=s'=>\
$as,'nm=s'=>\
$nm, 'objcopy=s'=>\
$objcopy, 'replace=s'=>\
%replace);
12 # 1) import lib to create
14 # 3...) extra objects to add
16 $_ = File
::Spec-
>rel2abs($_) for @ARGV;
21 open my $nm_fd, '-|', $nm, '-Apg', '--defined-only', $inpdll;
27 my ($fn, $type, $sym) = /^$inpdll:(.*?):\S+\s+(\S)\s+(\S+)$/o;
29 $text{$fn} = $sym if $type eq 'T';
30 $import{$fn} = $sym if $type eq 'I';
33 close $nm_fd or exit 1;
35 for my $sym (keys %replace) {
37 my $_sym = '_' . $sym;
38 if (!defined($fn = $symfile{$_sym})) {
42 my $imp_sym = '__imp__' . $replace{$sym};
43 $import{$fn} = $imp_sym;
46 for my $f (keys %text) {
47 my $imp_sym = delete $import{$f};
48 my $glob_sym = $text{$f};
49 if (!defined $imp_sym) {
51 } elsif ($imp_sym eq '__imp__') {
55 open my $as_fd, '|-', $as, '-o', "$dir/t-$f", "-";
63 close $as_fd or exit 1;
67 chdir $dir or die "$0: couldn't cd to $dir - $!\n";
68 system $ar, 'x', $inpdll;
71 for my $f (keys %text) {
75 system $objcopy, '-R', '.text', $f and exit 1;
76 system $objcopy, '-R', '.bss', '-R', '.data', "t-$f" and exit 1;
81 system $ar, 'crus', $libdll, glob('*.o'), @ARGV;
86 chdir '/tmp'; # Allow $dir directory removal on Windows
This page took 0.043744 seconds and 5 git commands to generate.