spacesyms-o-map.pl 552 B

1234567891011121314151617181920212223242526
  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. use strict;
  8. use warnings;
  9. my ($input, $output) = @ARGV;
  10. my @cmds = ('objcopy');
  11. open my $nm, '-|', 'nm', $input or die "cannot run nm: $!";
  12. while (<$nm>) {
  13. next if not m/SPACE/;
  14. chomp;
  15. my $x = (split / /, $_, 3)[2];
  16. my $y = $x =~ s/SPACE/SPA CE/r;
  17. push @cmds, "--redefine-sym=$x=$y";
  18. }
  19. close $nm;
  20. push @cmds, $input, $output;
  21. exec @cmds;