Add new filter mechanism: Exclude list of function symbols

This commit is contained in:
2026-08-05 19:05:47 +02:00
parent 68a86206d7
commit e067310dce
2 changed files with 100 additions and 5 deletions
+48
View File
@@ -188,6 +188,54 @@ sub elf_sym_addr {
return hex($1);
}
# Determine the address range of a function symbol
sub elf_sym_range {
my ( $elffile, $sym ) = @_;
my @lines = qx{nm -nS "$elffile" 2>/dev/null};
return () unless @lines;
for my $i ( 0 .. $#lines ) {
my $line = $lines[$i];
# With size: "0010eefe 000001fe T aot_invoke_native"
# Without size: "001298fe T invokeNative"
next
unless $line =~ /^([0-9a-f]+)(?:\s+([0-9a-f]+))?\s+\S\s+(\S+)\s*$/i;
my ( $addr, $size, $name ) = ( $1, $2, $3 );
next unless $name eq $sym;
my $start = hex($addr);
if ( defined $size ) {
return ( $start, $start + hex($size) );
}
# Those don't have sizes, skip them.
# They appear inside invokeNative_ia32.s
my %ELF_INTERNAL_LABELS = (
stack_aligned => 1,
skip_push_args => 1,
);
# No size -> take next symbol whose address is > $start.
for my $j ( $i + 1 .. $#lines ) {
next
unless $lines[$j] =~
/^([0-9a-f]+)(?:\s+[0-9a-f]+)?\s+\S\s+(\S+)\s*$/i;
my ( $next_addr, $next_name ) = ( hex($1), $2 );
next if $next_addr <= $start;
next if $ELF_INTERNAL_LABELS{$next_name};
return ( $start, $next_addr );
}
# No next symbol, don't know size
return ();
}
return ();
}
sub elf_read_sections {
my ($elffile) = @_;