mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Prohibit sections from having the same name
To make the behaviour of the linkerscript consistent, every section read from an object file must have an unique name. This is needed as the linkerscript uses the name of sections to place them and it expects every section to have a different name. This doesn't break compatibility with the old behaviour that allowed to continue sections if they had the same name, bank number and starting address. That's still allowed because `rgbasm` outputs a single section if this functionality is used, it is transparent to `rgblink`. Signed-off-by: AntonioND <antonio_nd@outlook.com>
This commit is contained in:
@@ -35,6 +35,9 @@ extern void CreateSymbolTable(void);
|
|||||||
extern SLONG MaxBankUsed;
|
extern SLONG MaxBankUsed;
|
||||||
extern SLONG MaxAvail[MAXBANKS];
|
extern SLONG MaxAvail[MAXBANKS];
|
||||||
|
|
||||||
|
int
|
||||||
|
IsSectionNameInUse(const char *name);
|
||||||
|
|
||||||
void
|
void
|
||||||
SetLinkerscriptName(char *tzLinkerscriptFile);
|
SetLinkerscriptName(char *tzLinkerscriptFile);
|
||||||
|
|
||||||
|
|||||||
@@ -216,6 +216,23 @@ FindLargestSection(enum eSectionType type, bool bankFixed)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
IsSectionNameInUse(const char *name)
|
||||||
|
{
|
||||||
|
struct sSection *pSection;
|
||||||
|
|
||||||
|
pSection = pSections;
|
||||||
|
while (pSection) {
|
||||||
|
if (strcmp(pSection->pzName, name) == 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
pSection = pSection->pNext;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
IsSectionSameTypeBankAndFloating(const char *name, enum eSectionType type, int bank)
|
IsSectionSameTypeBankAndFloating(const char *name, enum eSectionType type, int bank)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "extern/err.h"
|
#include "extern/err.h"
|
||||||
|
#include "link/assign.h"
|
||||||
#include "link/mylink.h"
|
#include "link/mylink.h"
|
||||||
#include "link/main.h"
|
#include "link/main.h"
|
||||||
|
|
||||||
@@ -288,14 +289,19 @@ obj_ReadRGBSection(FILE * f, enum ObjectFileContents contents)
|
|||||||
{
|
{
|
||||||
struct sSection *pSection;
|
struct sSection *pSection;
|
||||||
|
|
||||||
pSection = AllocSection();
|
char * pzName;
|
||||||
|
|
||||||
if (contents & CONTAINS_SECTION_NAME) {
|
if (contents & CONTAINS_SECTION_NAME) {
|
||||||
readasciiz(&pSection->pzName, f);
|
readasciiz(&pzName, f);
|
||||||
|
if (IsSectionNameInUse(pzName))
|
||||||
|
errx(1, "Section name \"%s\" is already in use.", pzName);
|
||||||
} else {
|
} else {
|
||||||
pSection->pzName = "";
|
pzName = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pSection = AllocSection();
|
||||||
|
pSection->pzName = pzName;
|
||||||
|
|
||||||
pSection->nByteSize = readlong(f);
|
pSection->nByteSize = readlong(f);
|
||||||
pSection->Type = (enum eSectionType) fgetc(f);
|
pSection->Type = (enum eSectionType) fgetc(f);
|
||||||
pSection->nOrg = readlong(f);
|
pSection->nOrg = readlong(f);
|
||||||
|
|||||||
Reference in New Issue
Block a user