mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Merge pull request #146 from AntonioND/an/same-name
Prohibit sections from having the same name
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