annotate bin/cell_fixpic.pl @ 776:922c0133c61c draft

heap corruption in TaskArray1
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 05 Mar 2010 10:12:49 +0900
parents c5f283bd88af
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
471
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #!/usr/bin/perl
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 # Author: Shinji KONO <kono@ie.u-ryukyu.ac.jp>
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 # v.0.1 Sat May 30 04:41:18 JST 2009
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 #
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 # fix spu-gcc assembler soruce for DMA loadable PIC code
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 #
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 #$(OVLOBJS): %.o : %.cc
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 # $(SPECC) $(SPECFLAGS) -c $< -S -o $(<:.cc=.s)
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 # perl spe/fixpic.pl $(<:.cc=.s) | $(SPECC) $(SPECFLAGS) -x assembler -c -o $@ -
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 use strict;
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 my %global;
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 my %local;
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 my %weak;
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 my @line;
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 # Basically SPU code is PIC. But linked library is in the fixed
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 # address space.
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 #
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 # rewrite relative to absolute for global branch address
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 # Target instruction
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 # hbrr -> hbra
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 # br -> bra
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 # brsl -> brasl
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 # brnz cannot be global
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 # lqr -> li (for global)
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 # ila global -> a $0,.LC0-.,$1
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 while(<>) {
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 push(@line,$_);
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 if(/\.global\s+([^\s]+)/) {
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 $global{$1} = 1;
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 }
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 if(/\.weak\s+([^\s]+)/) {
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 $weak{$1} = 1;
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 next;
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 }
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 if(/^([^\s]+):/) {
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 $local{$1} = 1;
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 }
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 }
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 for(@line) {
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 if (! /^#/) {
474
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 471
diff changeset
49 next if (/\.section\s+\.rodata/);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 471
diff changeset
50 if (/\s(brsl|hbrr|br)\s+[^\s]+,\s*(\d+[fb])/) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 471
diff changeset
51 } elsif(/\s(br)\s+([^\s]+)/||/\s(brsl|hbrr)\s+[^\s]+,\s*([^\s]+)/) {
471
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 my $name = $2;
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 if (! defined $local{$name} || defined $weak{$name} ) {
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 s/hbrr/hbra/ ||
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 s/brsl/brasl/ ||
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 s/br/bra/ ;
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 }
474
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 471
diff changeset
58 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 471
diff changeset
59
471
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 # } elsif(/\s(lqr)\s+(\$\d+),([^\s]+)/) {
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 # my $name = $2;
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 # if (! defined $local{$name} || defined $weak{$name} ) {
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 # s/lqr/lqd/;
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 # }
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 # } elsif(/\s(ila)\s+(\$\d+),([^\s]+)/) {
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 # my $name = $3;
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 # if (! defined $local{$name} || defined $weak{$name} ) {
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 # $_ = $_;
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 # } else {
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 # $_ = "\tai\t$2,\$0,$3-.\n";
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 # }
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 }
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 print ;
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 }
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75
e95d1047d15c add library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 # end