lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | #! /usr/bin/perl |
| 2 | eval "exec /usr/bin/perl -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, write to the Free Software Foundation, |
| 18 | # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
| 19 | |
| 20 | for ($cnt = 0; $cnt <= $#ARGV; ++$cnt) { |
| 21 | $relent = 0; |
| 22 | $relsz = 0; |
| 23 | $relcount = 0; |
| 24 | $pltrelsz = 0; |
| 25 | $extplt = 0; |
| 26 | $users = 0; |
| 27 | |
| 28 | open (READLINK, "readlink -f $ARGV[$cnt] |") || die "cannot open readlink"; |
| 29 | while (<READLINK>) { |
| 30 | chop; |
| 31 | $fullpath = $_; |
| 32 | } |
| 33 | close (READLINK); |
| 34 | |
| 35 | open (READELF, "eu-readelf -d $ARGV[$cnt] |") || die "cannot open $ARGV[$cnt]"; |
| 36 | while (<READELF>) { |
| 37 | chop; |
| 38 | if (/.* RELA?ENT *([0-9]*).*/) { |
| 39 | $relent = $1 + 0; |
| 40 | } elsif (/.* RELA?SZ *([0-9]*).*/) { |
| 41 | $relsz = $1 + 0; |
| 42 | } elsif (/.* RELA?COUNT *([0-9]*).*/) { |
| 43 | $relcount = $1 + 0; |
| 44 | } elsif (/.* PLTRELSZ *([0-9]*).*/) { |
| 45 | $pltrelsz = $1 + 0; |
| 46 | } |
| 47 | } |
| 48 | close (READELF); |
| 49 | |
| 50 | open (READELF, "eu-readelf -r $ARGV[$cnt] | sed '/'.gnu.conflict'/,/^\$/d' |") || die "cannot open $ARGV[$cnt]"; |
| 51 | while (<READELF>) { |
| 52 | chop; |
| 53 | if (/.*JU?MP_SLOT *0+ .*/) { |
| 54 | ++$extplt; |
| 55 | } |
| 56 | } |
| 57 | close (READELF); |
| 58 | |
| 59 | if (open (PRELINK, "/usr/sbin/prelink -p 2>/dev/null | fgrep \"$fullpath\" |")) { |
| 60 | while (<PRELINK>) { |
| 61 | ++$users; |
| 62 | } |
| 63 | close(PRELINK); |
| 64 | } else { |
| 65 | $users = -1; |
| 66 | } |
| 67 | |
| 68 | printf ("%s: %d relocations, %d relative (%d%%), %d PLT entries, %d for local syms (%d%%)", |
| 69 | $ARGV[$cnt], $relent == 0 ? 0 : $relsz / $relent, $relcount, |
| 70 | $relent == 0 ? 0 : ($relcount * 100) / ($relsz / $relent), |
| 71 | $relent == 0 ? 0 : $pltrelsz / $relent, |
| 72 | $relent == 0 ? 0 : $pltrelsz / $relent - $extplt, |
| 73 | $relent == 0 ? 0 : (($pltrelsz / $relent - $extplt) * 100) / ($pltrelsz / $relent)); |
| 74 | if ($users >= 0) { |
| 75 | printf(", %d users", $users); |
| 76 | } |
| 77 | printf("\n"); |
| 78 | } |