OLD | NEW |
1 // Inferno utils/6l/span.c | 1 // Inferno utils/6l/span.c |
2 // http://code.google.com/p/inferno-os/source/browse/utils/6l/span.c | 2 // http://code.google.com/p/inferno-os/source/browse/utils/6l/span.c |
3 // | 3 // |
4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. | 4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. |
5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) | 5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) |
6 // Portions Copyright © 1997-1999 Vita Nuova Limited | 6 // Portions Copyright © 1997-1999 Vita Nuova Limited |
7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuov
a.com) | 7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuov
a.com) |
8 // Portions Copyright © 2004,2006 Bruce Ellis | 8 // Portions Copyright © 2004,2006 Bruce Ellis |
9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) | 9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) |
10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others | 10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 void | 40 void |
41 span1(Sym *s) | 41 span1(Sym *s) |
42 { | 42 { |
43 Prog *p, *q; | 43 Prog *p, *q; |
44 int32 c, v, loop; | 44 int32 c, v, loop; |
45 uchar *bp; | 45 uchar *bp; |
46 int n, m, i; | 46 int n, m, i; |
47 | 47 |
48 cursym = s; | 48 cursym = s; |
| 49 ········ |
| 50 if(s->p != nil) |
| 51 return; |
49 | 52 |
50 for(p = s->text; p != P; p = p->link) { | 53 for(p = s->text; p != P; p = p->link) { |
51 p->back = 2; // use short branches first time through | 54 p->back = 2; // use short branches first time through |
52 if((q = p->pcond) != P && (q->back & 2)) | 55 if((q = p->pcond) != P && (q->back & 2)) |
53 p->back |= 1; // backward jump | 56 p->back |= 1; // backward jump |
54 | 57 |
55 if(p->as == AADJSP) { | 58 if(p->as == AADJSP) { |
56 p->to.type = D_SP; | 59 p->to.type = D_SP; |
57 v = -p->from.offset; | 60 v = -p->from.offset; |
58 p->from.offset = v; | 61 p->from.offset = v; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 vlong c; | 141 vlong c; |
139 int n; | 142 int n; |
140 Section *sect; | 143 Section *sect; |
141 | 144 |
142 if(debug['v']) | 145 if(debug['v']) |
143 Bprint(&bso, "%5.2f span\n", cputime()); | 146 Bprint(&bso, "%5.2f span\n", cputime()); |
144 | 147 |
145 // NOTE(rsc): If we get rid of the globals we should | 148 // NOTE(rsc): If we get rid of the globals we should |
146 // be able to parallelize these iterations. | 149 // be able to parallelize these iterations. |
147 for(cursym = textp; cursym != nil; cursym = cursym->next) { | 150 for(cursym = textp; cursym != nil; cursym = cursym->next) { |
| 151 if(cursym->p != nil) |
| 152 continue; |
148 // TODO: move into span1 | 153 // TODO: move into span1 |
149 for(p = cursym->text; p != P; p = p->link) { | 154 for(p = cursym->text; p != P; p = p->link) { |
150 n = 0; | 155 n = 0; |
151 if(p->to.type == D_BRANCH) | 156 if(p->to.type == D_BRANCH) |
152 if(p->pcond == P) | 157 if(p->pcond == P) |
153 p->pcond = p; | 158 p->pcond = p; |
154 if((q = p->pcond) != P) | 159 if((q = p->pcond) != P) |
155 if(q->back != 2) | 160 if(q->back != 2) |
156 n = 1; | 161 n = 1; |
157 p->back = n; | 162 p->back = n; |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 r->siz = 8; | 669 r->siz = 8; |
665 r->off = p->pc + andptr - and; | 670 r->off = p->pc + andptr - and; |
666 } | 671 } |
667 put8(v); | 672 put8(v); |
668 } | 673 } |
669 */ | 674 */ |
670 | 675 |
671 vlong | 676 vlong |
672 symaddr(Sym *s) | 677 symaddr(Sym *s) |
673 { | 678 { |
674 » switch(s->type) { | 679 » if(!s->reachable) |
675 » case SMACHO: | 680 » » diag("unreachable symbol in symaddr - %s", s->name); |
676 » » return segdata.vaddr + segdata.filelen - dynptrsize + s->value; | 681 » return s->value; |
677 | |
678 » default: | |
679 » » if(!s->reachable) | |
680 » » » diag("unreachable symbol in symaddr - %s", s->name); | |
681 » » return s->value; | |
682 » } | |
683 } | 682 } |
684 | 683 |
685 static vlong | 684 static vlong |
686 vaddr(Adr *a, Reloc *r) | 685 vaddr(Adr *a, Reloc *r) |
687 { | 686 { |
688 int t; | 687 int t; |
689 vlong v; | 688 vlong v; |
690 Sym *s; | 689 Sym *s; |
691 ········ | 690 ········ |
692 if(r != nil) | 691 if(r != nil) |
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1749 for(r=cursym->r+cursym->nr; r-- > cursym->r; ) { | 1748 for(r=cursym->r+cursym->nr; r-- > cursym->r; ) { |
1750 if(r->off < p->pc) | 1749 if(r->off < p->pc) |
1751 break; | 1750 break; |
1752 r->off++; | 1751 r->off++; |
1753 } | 1752 } |
1754 memmove(and+np+1, and+np, n-np); | 1753 memmove(and+np+1, and+np, n-np); |
1755 and[np] = 0x40 | rexflag; | 1754 and[np] = 0x40 | rexflag; |
1756 andptr++; | 1755 andptr++; |
1757 } | 1756 } |
1758 } | 1757 } |
OLD | NEW |