Reset LOAD offset when changing SECTIONs

This would cause spurious section overflow messages, since the load offset
is added to the section's when computing its size.
This commit is contained in:
ISSOtm
2021-05-21 09:06:48 +02:00
parent e970b6d6eb
commit 69d7f84502
9 changed files with 52 additions and 9 deletions

View File

@@ -418,6 +418,7 @@ void sect_NewSection(char const *name, uint32_t type, uint32_t org,
changeSection();
curOffset = mod == SECTION_UNION ? 0 : sect->size;
loadOffset = 0; // This is still used when checking for section size overflow!
currentSection = sect;
}
@@ -989,16 +990,15 @@ void sect_PopSection(void)
if (currentLoadSection)
fatalerror("Cannot change the section within a `LOAD` block!\n");
struct SectionStackEntry *sect;
struct SectionStackEntry *entry = sectionStack;
sect = sectionStack;
changeSection();
currentSection = sect->section;
currentLoadSection = sect->loadSection;
sym_SetCurrentSymbolScope(sect->scope);
curOffset = sect->offset;
loadOffset = sect->loadOffset;
currentSection = entry->section;
currentLoadSection = entry->loadSection;
sym_SetCurrentSymbolScope(entry->scope);
curOffset = entry->offset;
loadOffset = entry->loadOffset;
sectionStack = sect->next;
free(sect);
sectionStack = entry->next;
free(entry);
}