Skip to content

Instantly share code, notes, and snippets.

@dakkar
Created May 16, 2017 16:21
Show Gist options
  • Select an option

  • Save dakkar/d7aed24c04d959ee201a54583307cbc7 to your computer and use it in GitHub Desktop.

Select an option

Save dakkar/d7aed24c04d959ee201a54583307cbc7 to your computer and use it in GitHub Desktop.
Check what C libraries get loaded when loading a Perl module
#!/usr/bin/env perl
use strict;
use warnings;
sub maps {
open my $fh, '<', '/proc/self/maps';
my @lines = <$fh>;
my %ret = map {
m{\ {10}(/.+)$} ? ($1,$_) : ()
} @lines;
return \%ret;
}
my $before_maps = maps();
my $target = shift;
eval "require $target" or die "Can't load $target: $@\n";
my $after_maps = maps();
delete @{$after_maps}{keys %{$before_maps}};
local $\="\n";
print for sort keys %{$after_maps};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment