Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 // Inferno utils/6l/obj.c | 1 // Inferno utils/6l/obj.c |
2 // http://code.google.com/p/inferno-os/source/browse/utils/6l/obj.c | 2 // http://code.google.com/p/inferno-os/source/browse/utils/6l/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 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
612 ········ | 612 ········ |
613 case ATYPE: | 613 case ATYPE: |
614 if(skip) | 614 if(skip) |
615 goto casdef; | 615 goto casdef; |
616 pc++; | 616 pc++; |
617 goto loop; | 617 goto loop; |
618 | 618 |
619 case ANPTRS: | 619 case ANPTRS: |
620 if(skip) | 620 if(skip) |
621 goto casdef; | 621 goto casdef; |
622 if(cursym->nptrs != -1) { | |
623 diag("ldobj1: multiple pointer maps defined for %s", cur sym->name); | |
624 errorexit(); | |
625 } | |
626 if(p->to.offset > cursym->args/PtrSize) { | |
627 diag("ldobj1: pointer map definition for %s exceeds its argument size", cursym->name); | |
628 errorexit(); | |
629 } | |
622 cursym->nptrs = p->to.offset; | 630 cursym->nptrs = p->to.offset; |
623 » » cursym->ptrs = mal(cursym->nptrs*sizeof(*cursym->ptrs)); | 631 » » if(cursym->nptrs != 0) |
632 » » » cursym->ptrs = mal((rnd(cursym->nptrs, 32) / 32) * sizeo f(*cursym->ptrs)); | |
624 pc++; | 633 pc++; |
625 goto loop; | 634 goto loop; |
626 | 635 |
627 case APTRS: | 636 case APTRS: |
628 if(skip) | 637 if(skip) |
629 goto casdef; | 638 goto casdef; |
639 if(cursym->nptrs == -1 || cursym->ptrs == NULL) { | |
640 diag("ldobj1: pointer map data provided for %s without a definition", cursym->name); | |
641 errorexit(); | |
642 } | |
643 if(p->from.offset*32 >= rnd(cursym->nptrs, 32)) { | |
644 diag("ldobj1: excessive pointer map data provided for %s ", cursym->name); | |
645 errorexit(); | |
646 } | |
630 cursym->ptrs[p->from.offset] = p->to.offset; | 647 cursym->ptrs[p->from.offset] = p->to.offset; |
iant
2013/05/22 00:41:00
Check for p->from.offset >= cursym->nptrs.
cshapiro1
2013/05/22 06:35:21
Ditto.
| |
631 pc++; | 648 pc++; |
632 goto loop; | 649 goto loop; |
633 | 650 |
634 case ATEXT: | 651 case ATEXT: |
635 s = p->from.sym; | 652 s = p->from.sym; |
636 if(s->text != nil) { | 653 if(s->text != nil) { |
637 if(p->from.scale & DUPOK) { | 654 if(p->from.scale & DUPOK) { |
638 skip = 1; | 655 skip = 1; |
639 goto casdef; | 656 goto casdef; |
640 } | 657 } |
(...skipping 27 matching lines...) Expand all Loading... | |
668 diag("%s: redefinition: %s\n%P", pn, s->name, p); | 685 diag("%s: redefinition: %s\n%P", pn, s->name, p); |
669 } | 686 } |
670 if(fromgotype) { | 687 if(fromgotype) { |
671 if(s->gotype && s->gotype != fromgotype) | 688 if(s->gotype && s->gotype != fromgotype) |
672 diag("%s: type mismatch for %s", pn, s->name); | 689 diag("%s: type mismatch for %s", pn, s->name); |
673 s->gotype = fromgotype; | 690 s->gotype = fromgotype; |
674 } | 691 } |
675 s->type = STEXT; | 692 s->type = STEXT; |
676 s->value = pc; | 693 s->value = pc; |
677 s->args = p->to.offset >> 32; | 694 s->args = p->to.offset >> 32; |
695 s->nptrs = -1; | |
678 lastp = p; | 696 lastp = p; |
679 p->pc = pc++; | 697 p->pc = pc++; |
680 goto loop; | 698 goto loop; |
681 | 699 |
682 case AMODE: | 700 case AMODE: |
683 if(p->from.type == D_CONST || p->from.type == D_INDIR+D_NONE){ | 701 if(p->from.type == D_CONST || p->from.type == D_INDIR+D_NONE){ |
684 switch((int)p->from.offset){ | 702 switch((int)p->from.offset){ |
685 case 16: case 32: case 64: | 703 case 16: case 32: case 64: |
686 mode = p->from.offset; | 704 mode = p->from.offset; |
687 break; | 705 break; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
806 { | 824 { |
807 Prog *p; | 825 Prog *p; |
808 | 826 |
809 p = prg(); | 827 p = prg(); |
810 p->link = q->link; | 828 p->link = q->link; |
811 q->link = p; | 829 q->link = p; |
812 p->line = q->line; | 830 p->line = q->line; |
813 p->mode = q->mode; | 831 p->mode = q->mode; |
814 return p; | 832 return p; |
815 } | 833 } |
LEFT | RIGHT |