ref: df2c0dc2f9a0d6a096080058e4460d18e52bd336
parent: 062fa5392b32c7901bdbe5093ade905500536eb9
author: ISSOtm <[email protected]>
date: Sun Mar 22 07:54:57 EDT 2020
Check for unsatisfiable alignment constraints Fixes #493
--- a/src/asm/section.c
+++ b/src/asm/section.c
@@ -108,6 +108,9 @@
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]);
}
}
--- a/src/link/section.c
+++ b/src/link/section.c
@@ -161,6 +161,13 @@
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];