Cannot start a new section that's already on the stack

This is only relevant for FRAGMENT or UNION sections, since
normal ones would fail with "Section already defined previously".

Fixes #730
This commit is contained in:
Rangi
2021-02-12 15:54:15 -05:00
committed by Eldred Habert
parent a919f922a1
commit dddff0f450
4 changed files with 15 additions and 6 deletions

View File

@@ -87,15 +87,10 @@ static inline void reserveSpace(uint32_t delta_size)
struct Section *out_FindSectionByName(const char *name)
{
struct Section *sect = pSectionList;
while (sect) {
for (struct Section *sect = pSectionList; sect; sect = sect->next) {
if (strcmp(name, sect->name) == 0)
return sect;
sect = sect->next;
}
return NULL;
}
@@ -376,6 +371,11 @@ void out_NewSection(char const *name, uint32_t type, uint32_t org,
if (currentLoadSection)
fatalerror("Cannot change the section within a `LOAD` block\n");
for (struct SectionStackEntry *stack = sectionStack; stack; stack = stack->next) {
if (stack->section && !strcmp(name, stack->section->name))
fatalerror("Section '%s' is already on the stack\n", name);
}
struct Section *sect = getSection(name, type, org, attribs, mod);
changeSection();