Check for unsatisfiable alignment constraints

Fixes #493
This commit is contained in:
ISSOtm
2020-03-22 11:54:57 +01:00
parent 062fa5392b
commit df2c0dc2f9
2 changed files with 10 additions and 0 deletions

View File

@@ -108,6 +108,9 @@ static struct Section *getSection(char const *pzName, enum SectionType type,
yyerror("Section \"%s\"'s fixed address doesn't match its alignment",
pzName);
alignment = 1; /* Ignore it if it's satisfied */
} else if (startaddr[type] & mask) {
yyerror("Section \"%s\"'s alignment cannot be attained in %s",
pzName, typeNames[type]);
}
}

View File

@@ -161,6 +161,13 @@ static void doSanityChecks(struct Section *section, void *ptr)
if (section->isAlignFixed && section->alignMask == 1)
section->isAlignFixed = false;
/* Too large an alignment may not be satisfiable */
if (section->isAlignFixed
&& (section->alignMask & startaddr[section->type]))
fail("%s: %s sections cannot be aligned to $%x bytes",
section->name, typeNames[section->type],
section->alignMask + 1);
uint32_t minbank = bankranges[section->type][0],
maxbank = bankranges[section->type][1];