LEFT | RIGHT |
1 // Inferno utils/5l/obj.c | 1 // Inferno utils/5l/obj.c |
2 // http://code.google.com/p/inferno-os/source/browse/utils/5l/obj.c | 2 // http://code.google.com/p/inferno-os/source/browse/utils/5l/obj.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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 break; | 622 break; |
623 | 623 |
624 case ATYPE: | 624 case ATYPE: |
625 if(skip) | 625 if(skip) |
626 goto casedef; | 626 goto casedef; |
627 pc++; | 627 pc++; |
628 goto loop; | 628 goto loop; |
629 | 629 |
630 case ANPTRS: | 630 case ANPTRS: |
631 if(skip) | 631 if(skip) |
632 » » » goto casdef; | 632 » » » goto casedef; |
| 633 » » if(cursym->nptrs != -1) { |
| 634 » » » diag("ldobj1: multiple pointer maps defined for %s", cur
sym->name); |
| 635 » » » errorexit(); |
| 636 » » } |
| 637 » » if(p->to.offset > cursym->args/PtrSize) { |
| 638 » » » diag("ldobj1: pointer map definition for %s exceeds its
argument size", cursym->name); |
| 639 » » » errorexit(); |
| 640 » » } |
633 cursym->nptrs = p->to.offset; | 641 cursym->nptrs = p->to.offset; |
634 » » cursym->ptrs = mal(cursym->nptrs*sizeof(*cursym->ptrs)); | 642 » » if(cursym->nptrs != 0) |
| 643 » » » cursym->ptrs = mal((rnd(cursym->nptrs, 32) / 32) * sizeo
f(*cursym->ptrs)); |
635 pc++; | 644 pc++; |
636 goto loop; | 645 goto loop; |
637 | 646 |
638 case APTRS: | 647 case APTRS: |
639 if(skip) | 648 if(skip) |
640 » » » goto casdef; | 649 » » » goto casedef; |
| 650 » » if(cursym->nptrs == -1 || cursym->ptrs == NULL) { |
| 651 » » » diag("ldobj1: pointer map data provided for %s without a
definition", cursym->name); |
| 652 » » » errorexit(); |
| 653 » » } |
| 654 » » if(p->from.offset*32 >= rnd(cursym->nptrs, 32)) { |
| 655 » » » diag("ldobj1: excessive pointer map data provided for %s
", cursym->name); |
| 656 » » » errorexit(); |
| 657 » » } |
641 cursym->ptrs[p->from.offset] = p->to.offset; | 658 cursym->ptrs[p->from.offset] = p->to.offset; |
642 pc++; | 659 pc++; |
643 goto loop; | 660 goto loop; |
644 | 661 |
645 case ATEXT: | 662 case ATEXT: |
646 if(cursym != nil && cursym->text) { | 663 if(cursym != nil && cursym->text) { |
647 histtoauto(); | 664 histtoauto(); |
648 cursym->autom = curauto; | 665 cursym->autom = curauto; |
649 curauto = 0; | 666 curauto = 0; |
650 } | 667 } |
(...skipping 27 matching lines...) Expand all Loading... |
678 } | 695 } |
679 etextp = s; | 696 etextp = s; |
680 p->align = 4; | 697 p->align = 4; |
681 autosize = (p->to.offset+3L) & ~3L; | 698 autosize = (p->to.offset+3L) & ~3L; |
682 p->to.offset = autosize; | 699 p->to.offset = autosize; |
683 autosize += 4; | 700 autosize += 4; |
684 s->type = STEXT; | 701 s->type = STEXT; |
685 s->text = p; | 702 s->text = p; |
686 s->value = pc; | 703 s->value = pc; |
687 s->args = p->to.offset2; | 704 s->args = p->to.offset2; |
| 705 s->nptrs = -1; |
688 lastp = p; | 706 lastp = p; |
689 p->pc = pc; | 707 p->pc = pc; |
690 pc++; | 708 pc++; |
691 break; | 709 break; |
692 | 710 |
693 case ASUB: | 711 case ASUB: |
694 if(p->from.type == D_CONST) | 712 if(p->from.type == D_CONST) |
695 if(p->from.name == D_NONE) | 713 if(p->from.name == D_NONE) |
696 if(p->from.offset < 0) { | 714 if(p->from.offset < 0) { |
697 p->from.offset = -p->from.offset; | 715 p->from.offset = -p->from.offset; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 appendp(Prog *q) | 827 appendp(Prog *q) |
810 { | 828 { |
811 Prog *p; | 829 Prog *p; |
812 | 830 |
813 p = prg(); | 831 p = prg(); |
814 p->link = q->link; | 832 p->link = q->link; |
815 q->link = p; | 833 q->link = p; |
816 p->line = q->line; | 834 p->line = q->line; |
817 return p; | 835 return p; |
818 } | 836 } |
LEFT | RIGHT |