Browse Source

Bugfix in Dpkg::Shlibs::Objdump parsing of flags returned by objdump -f

The parser was not working as expected due to a wrong regexp.
Added a non-regression test case to avoid this in the future.
Raphael Hertzog 19 years ago
parent
commit
4a34d81475
2 changed files with 6 additions and 3 deletions
  1. 4 2
      scripts/Dpkg/Shlibs/Objdump.pm
  2. 2 1
      scripts/t/200_Dpkg_Shlibs.t

+ 4 - 2
scripts/Dpkg/Shlibs/Objdump.pm

@@ -190,12 +190,14 @@ sub _parse {
 	} elsif ($section eq "none") {
 	    if (/^\s*\S+:\s*file\s+format\s+(\S+)\s*$/) {
 		$self->{format} = $1;
-	    } elsif (/^architecture:\s*\S+,\s*flags:\s*\S+\s*$/) {
+	    } elsif (/^architecture:\s*\S+,\s*flags\s*\S+:\s*$/) {
 		# Parse 2 lines of "-f"
 		# architecture: i386, flags 0x00000112:
 		# EXEC_P, HAS_SYMS, D_PAGED
 		# start address 0x08049b50
-		$self->{flags}{$_} = 1 foreach (split(/,\s*/, <$fh>));
+		$_ = <$fh>;
+		chomp;
+		$self->{flags}{$_} = 1 foreach (split(/,\s*/));
 	    }
 	}
     }

+ 2 - 1
scripts/t/200_Dpkg_Shlibs.t

@@ -1,6 +1,6 @@
 # -*- mode: cperl;-*-
 
-use Test::More tests => 26;
+use Test::More tests => 27;
 
 use strict;
 use warnings;
@@ -30,6 +30,7 @@ is($obj->{SONAME}, 'libc.so.6', 'SONAME');
 is($obj->{HASH}, '0x13d99c', 'HASH');
 is($obj->{GNU_HASH}, '0x194', 'GNU_HASH');
 is($obj->{format}, 'elf32-i386', 'format');
+is_deeply($obj->{flags}, { DYNAMIC => 1, HAS_SYMS => 1, D_PAGED => 1 }, 'flags');
 is_deeply($obj->{NEEDED}, [ 'ld-linux.so.2' ], 'NEEDED');
 is_deeply([ $obj->get_needed_libraries ], [ 'ld-linux.so.2' ], 'NEEDED');