Unified · Split
| @@ -739,25 +739,28 @@ static void gadd_sp(int val) · 738 unmodified lines | |||
| 739 | static void gcall_or_jmp(int is_jmp) | 739 | static void gcall_or_jmp(int is_jmp) |
| 740 | { | 740 | { |
| 741 | int r; | 741 | int r; |
| 742 | uint32_t x; | ||
| 742 | if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) { | 743 | if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) { |
| 743 | uint32_t x; | ||
| 744 | /* constant case */ | 744 | /* constant case */ |
| 745 | x=encbranch(ind,ind+vtop->c.i,0); | 745 | if(vtop->r & VT_SYM){ |
| 746 | if(x) { | 746 | x=encbranch(ind,ind+vtop->c.i,0); |
| 747 | if (vtop->r & VT_SYM) { | 747 | if(x) { |
| 748 | /* relocation case */ | 748 | /* relocation case */ |
| 749 | greloc(cur_text_section, vtop->sym, ind, R_ARM_PC24); | 749 | greloc(cur_text_section, vtop->sym, ind, R_ARM_PC24); |
| 750 | } else | 750 | o(x|(is_jmp?0xE0000000:0xE1000000)); |
| 751 | put_elf_reloc(symtab_section, cur_text_section, ind, R_ARM_PC24, 0); | 751 | } else { |
| 752 | o(x|(is_jmp?0xE0000000:0xE1000000)); | 752 | if(!is_jmp) |
| 753 | } else { | 753 | o(0xE28FE004); // add lr,pc,#4 |
| 754 | if(!is_jmp) | 754 | o(0xE51FF004); // ldr pc,[pc,#-4] |
| 755 | o(0xE28FE004); // add lr,pc,#4 | 755 | greloc(cur_text_section, vtop->sym, ind, R_ARM_ABS32); |
| 756 | o(0xE51FF004); // ldr pc,[pc,#-4] | 756 | o(vtop->c.i); |
| 757 | if (vtop->r & VT_SYM) | 757 | } |
| 758 | greloc(cur_text_section, vtop->sym, ind, R_ARM_ABS32); | 758 | }else{ |
| 759 | o(vtop->c.i); | 759 | if(!is_jmp) |
| 760 | } | 760 | o(0xE28FE004); // add lr,pc,#4 |
| 761 | o(0xE51FF004); // ldr pc,[pc,#-4] | ||
| 762 | o(vtop->c.i); | ||
| 763 | } | ||
| 761 | } else { | 764 | } else { |
| 762 | /* otherwise, indirect call */ | 765 | /* otherwise, indirect call */ |
| 763 | r = gv(RC_INT); | 766 | r = gv(RC_INT); |