1#! /usr/bin/perl 2eval "exec /usr/bin/env perl -w -S $0 $@" 3 if 0; 4# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Red Hat, Inc. 5# Written by Ulrich Drepper <drepper@redhat.com>, 2000. 6 7# This program is free software; you can redistribute it and/or modify 8# it under the terms of the GNU General Public License version 2 as 9# published by the Free Software Foundation. 10# 11# This program is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15# 16# You should have received a copy of the GNU General Public License 17# along with this program; if not, see <http://www.gnu.org/licenses/>. 18 19for ($cnt = 0; $cnt <= $#ARGV; ++$cnt) { 20 $relent = 0; 21 $relsz = 0; 22 $relcount = 0; 23 $pltrelsz = 0; 24 $extplt = 0; 25 $users = 0; 26 27 open (READLINK, "readlink -f $ARGV[$cnt] |") || die "cannot open readlink"; 28 while (<READLINK>) { 29 chop; 30 $fullpath = $_; 31 } 32 close (READLINK); 33 34 open (READELF, "eu-readelf -d $ARGV[$cnt] |") || die "cannot open $ARGV[$cnt]"; 35 while (<READELF>) { 36 chop; 37 if (/.* RELA?ENT *([0-9]*).*/) { 38 $relent = $1 + 0; 39 } elsif (/.* RELA?SZ *([0-9]*).*/) { 40 $relsz = $1 + 0; 41 } elsif (/.* RELA?COUNT *([0-9]*).*/) { 42 $relcount = $1 + 0; 43 } elsif (/.* PLTRELSZ *([0-9]*).*/) { 44 $pltrelsz = $1 + 0; 45 } 46 } 47 close (READELF); 48 49 open (READELF, "eu-readelf -r $ARGV[$cnt] | sed '/'.gnu.conflict'/,/^\$/d' |") || die "cannot open $ARGV[$cnt]"; 50 while (<READELF>) { 51 chop; 52 if (/.*JU?MP_SLOT *0+ .*/) { 53 ++$extplt; 54 } 55 } 56 close (READELF); 57 58 if (open (PRELINK, "/usr/sbin/prelink -p 2>/dev/null | fgrep \"$fullpath\" |")) { 59 while (<PRELINK>) { 60 ++$users; 61 } 62 close(PRELINK); 63 } else { 64 $users = -1; 65 } 66 67 printf ("%s: %d relocations, %d relative (%d%%), %d PLT entries, %d for local syms (%d%%)", 68 $ARGV[$cnt], $relent == 0 ? 0 : $relsz / $relent, $relcount, 69 $relent == 0 ? 0 : ($relcount * 100) / ($relsz / $relent), 70 $relent == 0 ? 0 : $pltrelsz / $relent, 71 $relent == 0 ? 0 : $pltrelsz / $relent - $extplt, 72 $relent == 0 ? 0 : (($pltrelsz / $relent - $extplt) * 100) / ($pltrelsz / $relent)); 73 if ($users >= 0) { 74 printf(", %d users", $users); 75 } 76 printf("\n"); 77} 78