From: Jan Kratochvil Date: Fri, 4 Sep 2020 20:48:30 +0000 (+0200) Subject: dtneededsize: +SYMLINK X-Git-Url: http://git.jankratochvil.net/?p=massrebuild.git;a=commitdiff_plain;h=cd952a82538c21d1d2db61fceee5ea2012c0e8ed dtneededsize: +SYMLINK --- diff --git a/dtneededsize b/dtneededsize index 7a7120e..da07789 100755 --- a/dtneededsize +++ b/dtneededsize @@ -47,11 +47,28 @@ chdir "dtneeded.out" or die "dtneeded.out: $!"; my %F; my %SONAME; my @DEBUG; +my %SYMLINK; find { "no_chdir"=>1, "wanted"=>sub { die $File::Find::dir if $File::Find::dir=~m{/$}; my $binfn=$File::Find::name; + if (-l $binfn) { + my $target=readlink $binfn or die $binfn; + $binfn=~s{^[.]}{}; + my $ref=\$SYMLINK{$binfn}; + die if $$ref; + if ($target=~m{^/}) { + $$ref=$target; +#warn "$binfn,target=rel=$$ref\n"; + } else { + my $base=dirname(".$binfn"); + my $abs=File::Spec->rel2abs($target,$base); + $$ref="/".File::Spec->abs2rel($abs); +#warn "$binfn,base=$base,target=$target,abs=$abs,rel=$$ref\n"; + } + return; + } return if !-f $binfn; die $binfn if $binfn!~m{^[.]/}; my $bin=readfile $binfn; @@ -69,6 +86,7 @@ find { }; $h->{"rpath"}=$rpath if $rpath; $F{$binfn}=$h; +#warn "$binfn=".Dumper($h)."\n" if $binfn=~/libc.so.6/; # my $total=keys %F; warn "$total...\n" if 0==$total%1000; if ($soname) { my $sonamefn=$File::Find::dir."/".$soname; @@ -81,11 +99,16 @@ find { }, },"."; +#while (my($src,$target)=each %SYMLINK) { +# die "$src->$target" if exists $SYMLINK{$target}; +#} + my $dwzsizeall=0; my $dtsizeall=0; my $computed=0; BINFN: for my $binfn (@DEBUG) { # warn "$binfn...\n".Dumper([sort @{$F{$binfn}{"needed"}}]); + die $binfn if exists $SYMLINK{$binfn}; my @l=$binfn; my %l=($binfn=>1); while (@l) { @@ -94,6 +117,7 @@ BINFN: for my $binfn (@DEBUG) { for my $needed (@{$h->{"needed"}}) { my $found; if ($needed=~m{^/}) { + $needed=$SYMLINK{$needed} while exists $SYMLINK{$needed}; $found=$needed; } else { # die "$binfn: $l: $needed" if $needed=~m{/}; @@ -107,6 +131,7 @@ BINFN: for my $binfn (@DEBUG) { next; } my $fn="$rpath/$needed"; + $fn=$SYMLINK{$fn} while exists $SYMLINK{$fn}; next if !$SONAME{$fn}; $found=$fn; last;