Allow specifying offset in addition to alignment

This commit is contained in:
ISSOtm
2020-04-08 00:40:41 +02:00
parent e82ad21704
commit b0ec8468e6
16 changed files with 154 additions and 44 deletions

View File

@@ -48,21 +48,28 @@ static void mergeSections(struct Section *target, struct Section *other)
errx(1, "Section \"%s\" is defined with conflicting addresses $%x and $%x",
other->name, target->org, other->org);
} else if (target->isAlignFixed) {
if (other->org & target->alignMask)
errx(1, "Section \"%s\" is defined with conflicting %u-byte alignment and address $%x",
if ((other->org - target->alignOfs) & target->alignMask)
errx(1, "Section \"%s\" is defined with conflicting %u-byte alignment (offset %u) and address $%x",
other->name, target->alignMask + 1,
other->org);
target->alignOfs, other->org);
}
target->isAddressFixed = true;
target->org = other->org;
} else if (other->isAlignFixed) {
if (target->isAddressFixed) {
if (target->org & other->alignMask)
errx(1, "Section \"%s\" is defined with conflicting address $%x and %u-byte alignment",
if ((target->org - other->alignOfs) & other->alignMask)
errx(1, "Section \"%s\" is defined with conflicting address $%x and %u-byte alignment (offset %u)",
other->name, target->org,
other->alignMask + 1);
other->alignMask + 1, other->alignOfs);
} else if (target->isAlignFixed
&& (other->alignMask & target->alignOfs)
!= (target->alignMask & other->alignOfs)) {
errx(1, "Section \"%s\" is defined with conflicting %u-byte alignment (offset %u) and %u-byte alignment (offset %u)",
other->name, target->alignMask + 1,
target->alignOfs, other->alignMask + 1,
other->alignOfs);
} else if (!target->isAlignFixed
|| other->alignMask > target->alignMask) {
|| (other->alignMask > target->alignMask)) {
target->isAlignFixed = true;
target->alignMask = other->alignMask;
}