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 committed 2021-05-21 09:37:17 +02:00
1 parent e970b6d6eb
commit 69d7f84502
9 files changed
+52 -9

No files matched your search

+9 -9
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);
}