mirror of
https://github.com/gbdev/rgbds.git
synced 2026-09-03 12:28:39 +00:00
Avoid truncating too-large JR offset from an invalid object file
This commit is contained in:
+2
-2
@@ -588,12 +588,12 @@ static void applyFilePatches(Section §ion, Section &dataSection) {
|
|||||||
// Offset is relative to the byte *after* the operand
|
// Offset is relative to the byte *after* the operand
|
||||||
// PC as operand to `jr` is lower than reference PC by 2
|
// PC as operand to `jr` is lower than reference PC by 2
|
||||||
uint16_t address = patch.pcSection->org + patch.pcOffset + 2;
|
uint16_t address = patch.pcSection->org + patch.pcOffset + 2;
|
||||||
int16_t jumpOffset = value - address;
|
int32_t jumpOffset = value - address;
|
||||||
|
|
||||||
if (jumpOffset < -128 || jumpOffset > 127) {
|
if (jumpOffset < -128 || jumpOffset > 127) {
|
||||||
firstErrorAt(
|
firstErrorAt(
|
||||||
patch,
|
patch,
|
||||||
"`JR` target must be between -128 and 127 bytes away, not %" PRId16
|
"`JR` target must be between -128 and 127 bytes away, not %" PRId32
|
||||||
"; use `JP` instead",
|
"; use `JP` instead",
|
||||||
jumpOffset
|
jumpOffset
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user