This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Eliminate pre-5.9.x conditional code for PERL_PACK_CAN_BYTEORDER
[perl5.git] / symbian / find_writeable_data.pl
CommitLineData
a0fd4948
JH
1#!/usr/bin/perl -w
2
3#
4# find_writeable_data - find non-const data in Symbian object files
5#
6# Use this when PETRAN tells you "dll has (un)initialised data".
7# Expects to find the Symbian (GNU) nm in the executable path.
8#
9# Copyright (c) 2004-2005 Nokia. All rights reserved.
10#
11# This utility is licensed under the same terms as Perl itself.
12#
13
14use strict;
15
16BEGIN {
17 unless (exists $ENV{EPOCROOT}) {
18 die "$0: EPOCROOT unset\n";
19 }
20 if (open(my $fh, "nm --version |")) {
21 unless (<$fh> =~ /^GNU nm .*-psion-.*/) {
22 die "$0: Cannot find the GNU nm from Symbian\n";
23 }
24 close($fh);
25 } else {
26 die "$0: Cannot find any nm in the executable path: $!\n";
27 }
28 unless (@ARGV && $ARGV[0] =~ /\.mmp$/i) {
29 die "$0: Must specify target mmp as the first argument\n";
30 }
31}
32
33use Cwd;
34use File::Basename;
35
36my $dir = lc(getcwd());
5c271e25 37my $tgt = basename(shift(@ARGV), ".mmp");
a0fd4948
JH
38
39$dir =~ s!/!\\!g;
40$dir =~ s!^c:!c:$ENV{EPOCROOT}epoc32\\build!;
41$dir .= "\\$tgt\\thumb\\urel";
42
43print $dir, "\n";
44
45unless (-d $dir) {
46 die "$0: No directory $dir\n";
47}
48
49my @o = glob("$dir\\*.o");
50
51unless (@o) {
52 die "$0: No objects in $dir\n";
53}
54
55for my $o (@o) {
56 if (open(my $fh, "nm $o |")) {
57 my @d;
58 while (<$fh>) {
59 next if / [TURtr] /;
60 push @d, $_;
61 }
62 close($fh);
63 if (@d) {
64 $o =~ s!^\Q$dir\E\\!!;
65 print "$o:\n";
66 print @d;
67 }
68 } else {
69 warn "$0: nm $o failed: $!\n";
70 }
71}
72
73exit(0);