Fix overflow detection for R_ARM_CALL, R_ARM_PC24, R_ARM_JUMP24 and R_ARM_PLT32 relocations on ARM. 26 bits means 25 bits for positive and negative offsets !
Unified · Split
| @@ -613,14 +613,14 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s) · 612 unmodified lines | ||
| 613 | 613 | x += val - addr; |
| 614 | 614 | h = x & 2; |
| 615 | 615 | #ifndef TCC_TARGET_PE |
| 616 | − if ((x & 3) || x >= 0x4000000 || x < -0x4000000) | |
| 616 | + if ((x & 3) || x >= 0x2000000 || x < -0x2000000) | |
| 617 | 617 | if (!(x & 3) || !blx_avail || !is_call) |
| 618 | 618 | if (s1->output_type == TCC_OUTPUT_MEMORY) { |
| 619 | 619 | x += add_jmp_table(s1, val) - val; /* add veneer */ |
| 620 | 620 | is_thumb = 0; /* Veneer uses ARM instructions */ |
| 621 | 621 | } |
| 622 | 622 | #endif |
| 623 | − if ((x & 3) || x >= 0x4000000 || x < -0x4000000) | |
| 623 | + if ((x & 3) || x >= 0x2000000 || x < -0x2000000) | |
| 624 | 624 | if (!(x & 3) || !blx_avail || !is_call) |
| 625 | 625 | tcc_error("can't relocate value at %x",addr); |
| 626 | 626 | x >>= 2; |