mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 18:52:07 +00:00
Report overlapping sections whenever possible
This commit is contained in:
@@ -20,6 +20,13 @@
|
|||||||
*/
|
*/
|
||||||
void out_AddSection(struct Section const *section);
|
void out_AddSection(struct Section const *section);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds an assigned section overlapping another one.
|
||||||
|
* @param section The section that is being overlapped
|
||||||
|
* @return A section overlapping it
|
||||||
|
*/
|
||||||
|
struct Section const *out_OverlappingSection(struct Section const *section);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes all output (bin, sym, map) files.
|
* Writes all output (bin, sym, map) files.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "link/assign.h"
|
#include "link/assign.h"
|
||||||
#include "link/section.h"
|
#include "link/section.h"
|
||||||
@@ -284,32 +285,41 @@ static void placeSection(struct Section *section)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Please adjust depending on longest message below */
|
||||||
|
char where[64];
|
||||||
|
|
||||||
if (section->isBankFixed && nbbanks(section->type) != 1) {
|
if (section->isBankFixed && nbbanks(section->type) != 1) {
|
||||||
if (section->isAddressFixed)
|
if (section->isAddressFixed)
|
||||||
errx(1, "Unable to place \"%s\" (%s section) at $%02x:%04x",
|
snprintf(where, 64, "at $%02x:%04x",
|
||||||
section->name, typeNames[section->type],
|
section->bank, section->org);
|
||||||
section->bank, section->org);
|
|
||||||
else if (section->isAlignFixed)
|
else if (section->isAlignFixed)
|
||||||
errx(1, "Unable to place \"%s\" (%s section) in bank %u with align mask %x",
|
snprintf(where, 64, "in bank %02x with align mask %x",
|
||||||
section->name, typeNames[section->type],
|
section->bank, ~section->alignMask);
|
||||||
section->bank, ~section->alignMask);
|
|
||||||
else
|
else
|
||||||
errx(1, "Unable to place \"%s\" (%s section) in bank %u",
|
snprintf(where, 64, "in bank %02x", section->bank);
|
||||||
section->name, typeNames[section->type],
|
|
||||||
section->bank);
|
|
||||||
} else {
|
} else {
|
||||||
if (section->isAddressFixed)
|
if (section->isAddressFixed)
|
||||||
errx(1, "Unable to place \"%s\" (%s section) at address $%x",
|
snprintf(where, 64, "at address $%04x", section->org);
|
||||||
section->name, typeNames[section->type],
|
|
||||||
section->org);
|
|
||||||
else if (section->isAlignFixed)
|
else if (section->isAlignFixed)
|
||||||
errx(1, "Unable to place \"%s\" (%s section) with align mask %x",
|
snprintf(where, 64, "with align mask %x",
|
||||||
section->name, typeNames[section->type],
|
~section->alignMask);
|
||||||
~section->alignMask);
|
|
||||||
else
|
else
|
||||||
errx(1, "Unable to place \"%s\" (%s section) anywhere",
|
strcpy(where, "anywhere");
|
||||||
section->name, typeNames[section->type]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If a section failed to go to several places, nothing we can report */
|
||||||
|
if (!section->isBankFixed || !section->isAddressFixed)
|
||||||
|
errx(1, "Unable to place \"%s\" (%s section) %s",
|
||||||
|
section->name, typeNames[section->type], where);
|
||||||
|
/* If the section just can't fit the bank, report that */
|
||||||
|
else if (section->org + section->size > endaddr(section->type) + 1)
|
||||||
|
errx(1, "Unable to place \"%s\" (%s section) %s: section runs past end of region",
|
||||||
|
section->name, typeNames[section->type], where);
|
||||||
|
/* Otherwise there is overlap with another section */
|
||||||
|
else
|
||||||
|
errx(1, "Unable to place \"%s\" (%s section) %s: section overlaps with \"%s\"",
|
||||||
|
section->name, typeNames[section->type], where,
|
||||||
|
out_OverlappingSection(section)->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct UnassignedSection {
|
struct UnassignedSection {
|
||||||
|
|||||||
@@ -78,6 +78,20 @@ void out_AddSection(struct Section const *section)
|
|||||||
*ptr = newSection;
|
*ptr = newSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Section const *out_OverlappingSection(struct Section const *section)
|
||||||
|
{
|
||||||
|
struct SortedSection *ptr =
|
||||||
|
sections[section->type].banks[section->bank].sections;
|
||||||
|
|
||||||
|
while (ptr) {
|
||||||
|
if (ptr->section->org < section->org + section->size
|
||||||
|
&& section->org < ptr->section->org + ptr->section->size)
|
||||||
|
return ptr->section;
|
||||||
|
ptr = ptr->next;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs sanity checks on the overlay file.
|
* Performs sanity checks on the overlay file.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user