mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Sanity check fixed address of sections in RGBLINK
This could otherwise cause segfaults while reporting errors (!) during placement
This commit is contained in:
@@ -134,7 +134,7 @@ static void doSanityChecks(struct Section *section, void *ptr)
|
|||||||
|
|
||||||
/* Check if section has a chance to be placed */
|
/* Check if section has a chance to be placed */
|
||||||
if (section->size > maxsize[section->type])
|
if (section->size > maxsize[section->type])
|
||||||
errx(1, "Section \"%s\" is bigger than the max size for that type: %#X > %#X",
|
errx(1, "Section \"%s\" is bigger than the max size for that type: %#x > %#x",
|
||||||
section->size, maxsize[section->type]);
|
section->size, maxsize[section->type]);
|
||||||
|
|
||||||
/* Translate loose constraints to strong ones when they're equivalent */
|
/* Translate loose constraints to strong ones when they're equivalent */
|
||||||
@@ -160,6 +160,20 @@ static void doSanityChecks(struct Section *section, void *ptr)
|
|||||||
section->isAddressFixed = true;
|
section->isAddressFixed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (section->isAddressFixed) {
|
||||||
|
/* Ensure the target address is valid */
|
||||||
|
if (section->org < startaddr[section->type]
|
||||||
|
|| section->org > endaddr(section->type))
|
||||||
|
errx(1, "Section \"%s\"'s fixed address %#x is outside of range [%#x; %#x]",
|
||||||
|
section->name, section->org,
|
||||||
|
startaddr[section->type], endaddr(section->type));
|
||||||
|
|
||||||
|
if (section->org + section->size > endaddr(section->type) + 1)
|
||||||
|
errx(1, "Section \"%s\"'s end address %#x is greater than last address %#x",
|
||||||
|
section->name, section->org + section->size,
|
||||||
|
endaddr(section->type) + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sect_DoSanityChecks(void)
|
void sect_DoSanityChecks(void)
|
||||||
|
|||||||
Reference in New Issue
Block a user