From: Raphael Hertzog Date: Tue, 14 Aug 2007 12:38:16 +0000 (+0200) Subject: Add new attributes (local, global, visibility) to Dpkg::Shlibs::Objdump's symbols X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb437163ca96a0df0e98e50852412e42030add54;p=dpkg Add new attributes (local, global, visibility) to Dpkg::Shlibs::Objdump's symbols Those new attributes are needed for further changes in dpkg-gensymbols behaviour. Update the test suite to include the new attributes. --- diff --git a/scripts/Dpkg/Shlibs/Objdump.pm b/scripts/Dpkg/Shlibs/Objdump.pm index cd51f427..19a38f47 100644 --- a/scripts/Dpkg/Shlibs/Objdump.pm +++ b/scripts/Dpkg/Shlibs/Objdump.pm @@ -224,14 +224,20 @@ sub _parse { sub parse_dynamic_symbol { my ($self, $line) = @_; - my $vis = '(?:\.protected|\.hidden|\.internal|0x\S+)'; - if ($line =~ /^[0-9a-f]+ (.{7})\s+(\S+)\s+[0-9a-f]+\s+(\S+)?(?:(?:\s+$vis)?\s+(\S+))/) { + my $vis_re = '(\.protected|\.hidden|\.internal|0x\S+)'; + if ($line =~ /^[0-9a-f]+ (.{7})\s+(\S+)\s+[0-9a-f]+\s+(\S+)?(?:(?:\s+$vis_re)?\s+(\S+))/) { - my ($flags, $sect, $ver, $name) = ($1, $2, $3, $4); + my ($flags, $sect, $ver, $vis, $name) = ($1, $2, $3, $4, $5); # Special case if version is missing but extra visibility # attribute replaces it in the match - $ver = '' if defined($ver) and $ver =~ /^$vis$/; + if (defined($ver) and $ver =~ /^$vis_re$/) { + $vis = $ver; + $ver = ''; + } + + # Cleanup visibility field + $vis =~ s/^\.// if defined($vis); my $symbol = { name => $name, @@ -241,6 +247,9 @@ sub parse_dynamic_symbol { debug => substr($flags, 5, 1) eq "d", type => substr($flags, 6, 1), weak => substr($flags, 1, 1) eq "w", + local => substr($flags, 0, 1) eq "l", + global => substr($flags, 0, 1) eq "g", + visibility => defined($vis) ? $vis : '', hidden => '', defined => $sect ne '*UND*' }; diff --git a/scripts/Dpkg/Shlibs/SymbolFile.pm b/scripts/Dpkg/Shlibs/SymbolFile.pm index f8a09425..329f763a 100644 --- a/scripts/Dpkg/Shlibs/SymbolFile.pm +++ b/scripts/Dpkg/Shlibs/SymbolFile.pm @@ -122,7 +122,7 @@ sub load { }; $self->{objects}{$object}{syms}{$2} = $sym; } elsif (/^#/) { - # Skip possible comments + # Skip possible comments } elsif (/^\|\s*(.*)$/) { # Alternative dependency template push @{$self->{objects}{$object}{deps}}, "$1"; diff --git a/scripts/t/200_Dpkg_Shlibs.t b/scripts/t/200_Dpkg_Shlibs.t index f19f83dd..ec12a8c8 100644 --- a/scripts/t/200_Dpkg_Shlibs.t +++ b/scripts/t/200_Dpkg_Shlibs.t @@ -37,11 +37,13 @@ my $sym = $obj->get_symbol('_sys_nerr@GLIBC_2.3'); is_deeply( $sym, { name => '_sys_nerr', version => 'GLIBC_2.3', soname => 'libc.so.6', section => '.rodata', dynamic => 1, debug => '', type => 'O', weak => '', + local => '', global => 1, visibility => '', hidden => 1, defined => 1 }, 'Symbol' ); $sym = $obj->get_symbol('_IO_stdin_used'); is_deeply( $sym, { name => '_IO_stdin_used', version => '', soname => 'libc.so.6', section => '*UND*', dynamic => 1, debug => '', type => ' ', weak => 1, + local => '', global => '', visibility => '', hidden => '', defined => '' }, 'Symbol 2' ); my @syms = $obj->get_exported_dynamic_symbols; @@ -132,6 +134,7 @@ $sym = $obj->get_symbol('IA__g_free'); is_deeply( $sym, { name => 'IA__g_free', version => '', soname => 'libglib-2.0.so.0', section => '.text', dynamic => 1, debug => '', type => 'F', weak => '', + local => 1, global => '', visibility => 'hidden', hidden => '', defined => 1 }, 'symbol with visibility without version' );