[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[lintian] 07/08: h/c/objdump-info-helper: Only emit the sections we use



This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository lintian.

commit 3fd98d97a9a5c6f6be7043ad672c4b54925ec59e
Author: Niels Thykier <niels@thykier.net>
Date:   Mon Jan 25 20:42:15 2016 +0000

    h/c/objdump-info-helper: Only emit the sections we use
    
    With this, the objdump member for
    linux-image-4.4.0-trunk-rt-686-pae/4.4-1~exp is reduced to 2MB (down
    from 7MB).  The total "cache" memory usage is approaching 1/3 of the
    original for that package.
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 helpers/coll/objdump-info-helper | 20 ++++++++++++++++----
 lib/Lintian/Collect/Binary.pm    | 12 ++++++++----
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/helpers/coll/objdump-info-helper b/helpers/coll/objdump-info-helper
index 8786736..eea246d 100755
--- a/helpers/coll/objdump-info-helper
+++ b/helpers/coll/objdump-info-helper
@@ -36,6 +36,12 @@ my %program_headers;
 my $bin;
 my $truncated = 0;
 my $section = '';
+# List of named sections, which are collected
+my %COLLECT_SECTIONS = map { $_ => 1 } qw(
+  .comment
+  .note
+);
+my $COLLECT_SECTIONS_REGEX = qr/^\.z?debug_/;
 
 # it would have been nice to do open '-|', "readelf ... 2>&1" but
 # then we have to escape the args and that puts us over the
@@ -147,19 +153,25 @@ while (my $line = <$readelf>) {
 
     } elsif ($line =~ m/^\s*\[\s*(\d+)\] (\S+)(?:\s|\Z)/
         and $section eq 'SH') {
-        $sections[$1] = $2;
+        my $section = $2;
+        $sections[$1] = $section;
         # We need sections as well (e.g. for incomplete stripping)
-        print " $1 $2\n";
+        print " $section\n"
+          if exists($COLLECT_SECTIONS{$section})
+          or$section =~ $COLLECT_SECTIONS_REGEX;
     } elsif ($line =~ m/^\s*0x(?:[0-9A-F]+)\s+\((.*?)\)\s+(\S.*)\Z/i
         and $section eq 'DS') {
         my ($type, $value) = ($1, $2);
+        my $keep = 0;
 
         if ($type eq 'RPATH') {
             $value =~ s/.*\[//;
             $value =~ s/\]\s*$//;
+            $keep = 1;
         }
-        $value =~ s/^(?:Shared library|Library soname): \[(.*)\]/$1/;
-        print "  $type   $value\n";
+        $keep = 1
+          if $value =~ s/^(?:Shared library|Library soname): \[(.*)\]/$1/;
+        print "  $type   $value\n" if $keep;
     } elsif ($line =~ m/^\s*[0-9a-f]+: \s* \S+ \s* (?:\(\S+\))? (?:\s|\Z)/xi
         and $section eq 'VS') {
         while ($line =~ m/([0-9a-f]+h?)\s*(?:\((\S+)\))?(?:\s|\Z)/gci) {
diff --git a/lib/Lintian/Collect/Binary.pm b/lib/Lintian/Collect/Binary.pm
index cca6f34..5ca929d 100644
--- a/lib/Lintian/Collect/Binary.pm
+++ b/lib/Lintian/Collect/Binary.pm
@@ -29,7 +29,7 @@ use Lintian::Relation;
 use Carp qw(croak);
 use Parse::DebianChangelog;
 
-use Lintian::Util qw(fail open_gz parse_dpkg_control get_file_checksum);
+use Lintian::Util qw(fail open_gz parse_dpkg_control get_file_checksum strip);
 
 =head1 NAME
 
@@ -385,9 +385,13 @@ sub objdump_info {
                 push @{ $info{'SYMBOLS'} }, [$sec, $ver, $sym];
             }
         }
-        foreach my $data (split m/\s*\n\s*/, $pg->{'section-headers'}//'') {
-            next unless $data;
-            my (undef, $section) = split m/\s++/, $data;
+        foreach my $section (split m/\s*\n\s*/, $pg->{'section-headers'}//'') {
+            next unless $section;
+            # NB: helpers/coll/objdump-info-helper discards most
+            # sections.  If you are missing a section name for a
+            # check, please update helpers/coll/objdump-info-helper to
+            # retrain the section name you need.
+            strip($section);
             $info{'SH'}{$section} = 1;
         }
         foreach my $data (split m/\s*\n\s*/, $pg->{'program-headers'}//'') {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: