Mercurial > hg-old > index.cgi
comparison lwasm/lwasm.c @ 381:1624a36f12a3
Properly support 32 bit relocations
author | lost@starbug |
---|---|
date | Mon, 26 Apr 2010 19:56:10 -0600 |
parents | 91c0fe026940 |
children | eacdae8a1575 |
comparison
equal
deleted
inserted
replaced
380:cc154dc614fe | 381:1624a36f12a3 |
---|---|
629 if (l -> as -> output_format == OUTPUT_OBJ) | 629 if (l -> as -> output_format == OUTPUT_OBJ) |
630 { | 630 { |
631 reloctab_t *re; | 631 reloctab_t *re; |
632 lw_expr_t te; | 632 lw_expr_t te; |
633 | 633 |
634 // add "expression" record to section table | 634 if (size == 4) |
635 re = lw_alloc(sizeof(reloctab_t)); | 635 { |
636 re -> next = l -> csect -> reloctab; | 636 // create a two part reference because lwlink doesn't |
637 l -> csect -> reloctab = re; | 637 // support 32 bit references |
638 te = lw_expr_build(lw_expr_type_int, l -> outputl); | 638 lw_expr_t te2; |
639 re -> offset = lw_expr_build(lw_expr_type_oper, lw_expr_oper_plus, l -> addr, te); | 639 te = lw_expr_build(lw_expr_type_int, 0x10000); |
640 lw_expr_destroy(te); | 640 te2 = lw_expr_build(lw_expr_type_oper, lw_expr_oper_divide, expr, te); |
641 lwasm_reduce_expr(l -> as, re -> offset); | 641 lw_expr_destroy(te); |
642 re -> size = size; | 642 |
643 re -> expr = lw_expr_copy(expr); | 643 re = lw_alloc(sizeof(reloctab_t)); |
644 | 644 re -> next = l -> csect -> reloctab; |
645 l -> csect -> reloctab = re; | |
646 te = lw_expr_build(lw_expr_type_int, l -> outputl); | |
647 re -> offset = lw_expr_build(lw_expr_type_oper, lw_expr_oper_plus, l -> addr, te); | |
648 lw_expr_destroy(te); | |
649 lwasm_reduce_expr(l -> as, re -> offset); | |
650 re -> expr = te2; | |
651 re -> size = 2; | |
652 | |
653 te = lw_expr_build(lw_expr_type_int, 0xFFFF); | |
654 te2 = lw_expr_build(lw_expr_type_oper, lw_expr_oper_bwand, expr, te); | |
655 lw_expr_destroy(te); | |
656 | |
657 re = lw_alloc(sizeof(reloctab_t)); | |
658 re -> next = l -> csect -> reloctab; | |
659 l -> csect -> reloctab = re; | |
660 te = lw_expr_build(lw_expr_type_int, l -> outputl + 2); | |
661 re -> offset = lw_expr_build(lw_expr_type_oper, lw_expr_oper_plus, l -> addr, te); | |
662 lw_expr_destroy(te); | |
663 lwasm_reduce_expr(l -> as, re -> offset); | |
664 re -> expr = te2; | |
665 re -> size = 2; | |
666 } | |
667 else | |
668 { | |
669 // add "expression" record to section table | |
670 re = lw_alloc(sizeof(reloctab_t)); | |
671 re -> next = l -> csect -> reloctab; | |
672 l -> csect -> reloctab = re; | |
673 te = lw_expr_build(lw_expr_type_int, l -> outputl); | |
674 re -> offset = lw_expr_build(lw_expr_type_oper, lw_expr_oper_plus, l -> addr, te); | |
675 lw_expr_destroy(te); | |
676 lwasm_reduce_expr(l -> as, re -> offset); | |
677 re -> size = size; | |
678 re -> expr = lw_expr_copy(expr); | |
679 } | |
645 for (v = 0; v < size; v++) | 680 for (v = 0; v < size; v++) |
646 lwasm_emit(l, 0); | 681 lwasm_emit(l, 0); |
647 return 0; | 682 return 0; |
648 } | 683 } |
649 lwasm_register_error(l -> as, l, "Expression not fully resolved"); | 684 lwasm_register_error(l -> as, l, "Expression not fully resolved"); |