Add more tests for unionized sections + fix bugs

Implementing those tests found a few bugs... oops
This commit is contained in:
ISSOtm
2020-03-22 01:46:10 +01:00
parent 275b8e15ff
commit 4877bb783c
28 changed files with 178 additions and 7 deletions

View File

@@ -155,6 +155,10 @@ static struct Section *getSection(char const *pzName, enum SectionType type,
if (pSect->nOrg != -1 && pSect->nOrg != org)
fail("Section \"%s\" already declared as fixed at different address $%x",
pSect->pzName, pSect->nOrg);
else if (pSect->nAlign != 0
&& ((pSect->nAlign - 1) & org))
fail("Section \"%s\" already declared as aligned to %u bytes",
pSect->pzName, pSect->nAlign);
else
/* Otherwise, just override */
pSect->nOrg = org;
@@ -207,7 +211,7 @@ static struct Section *getSection(char const *pzName, enum SectionType type,
fail("Section \"%s\" already declared as unaligned",
pSect->pzName);
else
fail("Section \"%s\" already declared as aligned to %u bits",
fail("Section \"%s\" already declared as aligned to %u bytes",
pSect->pzName, pSect->nAlign);
}
}

View File

@@ -38,6 +38,10 @@ void sect_ForEach(void (*callback)(struct Section *, void *), void *arg)
static void mergeSections(struct Section *target, struct Section *other)
{
if (target->type != other->type)
errx(1, "Section \"%s\" is defined with conflicting types %s and %s",
other->name,
typeNames[target->type], typeNames[other->type]);
if (other->isAddressFixed) {
if (target->isAddressFixed) {
if (target->org != other->org)