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,
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*'
};
};
$self->{objects}{$object}{syms}{$2} = $sym;
} elsif (/^#/) {
- # Skip possible comments
+ # Skip possible comments
} elsif (/^\|\s*(.*)$/) {
# Alternative dependency template
push @{$self->{objects}{$object}{deps}}, "$1";
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;
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' );