chiark / gitweb /
dpkg (1.18.25) stretch; urgency=medium
[dpkg] / scripts / t / Dpkg_Shlibs / spacesyms-o-map.pl
1 #!/usr/bin/perl
2 #
3 # spacesyms-o-map.pl INPUT OUTPUT
4 #
5 # Copy the object file INPUT to OUTPUT, redefining any symbol in INPUT that
6 # contains "SPACE" in its name to contain "SPA CE" instead.
7
8 use strict;
9 use warnings;
10
11 my ($input, $output) = @ARGV;
12 my @cmds = ('objcopy');
13
14 open my $nm, '-|', 'nm', $input or die "cannot run nm: $!";
15 while (<$nm>) {
16     next if not m/SPACE/;
17     chomp;
18     my $x = (split / /, $_, 3)[2];
19     my $y = $x =~ s/SPACE/SPA CE/r;
20     push @cmds, "--redefine-sym=$x=$y";
21 }
22 close $nm;
23
24 push @cmds, $input, $output;
25 exec @cmds;