mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 10:42:07 +00:00
Make linkerscript errors report file names
This commit is contained in:
@@ -195,6 +195,8 @@ static struct LinkerScriptToken const *nextToken(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
token.type = TOKEN_INVALID;
|
token.type = TOKEN_INVALID;
|
||||||
|
|
||||||
|
/* Try to match a command */
|
||||||
for (enum LinkerScriptCommand i = 0; i < COMMAND_INVALID; i++) {
|
for (enum LinkerScriptCommand i = 0; i < COMMAND_INVALID; i++) {
|
||||||
if (!strcmp(commands[i], str)) {
|
if (!strcmp(commands[i], str)) {
|
||||||
token.type = TOKEN_COMMAND;
|
token.type = TOKEN_COMMAND;
|
||||||
@@ -204,6 +206,7 @@ static struct LinkerScriptToken const *nextToken(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (token.type == TOKEN_INVALID) {
|
if (token.type == TOKEN_INVALID) {
|
||||||
|
/* Try to match a bank specifier */
|
||||||
for (enum SectionType type = 0; type < SECTTYPE_INVALID;
|
for (enum SectionType type = 0; type < SECTTYPE_INVALID;
|
||||||
type++) {
|
type++) {
|
||||||
if (!strcmp(typeNames[type], str)) {
|
if (!strcmp(typeNames[type], str)) {
|
||||||
@@ -248,8 +251,8 @@ static void processCommand(enum LinkerScriptCommand command, uint16_t arg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (arg < *pc)
|
if (arg < *pc)
|
||||||
errx(1, "Linkerscript line %u: `%s` cannot be used to go backwards",
|
errx(1, "%s(%u): `%s` cannot be used to go backwards",
|
||||||
lineNo, commands[command]);
|
linkerScriptName, lineNo, commands[command]);
|
||||||
*pc = arg;
|
*pc = arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,13 +299,13 @@ struct SectionPlacement *script_NextSection(void)
|
|||||||
|
|
||||||
if (type != SECTTYPE_INVALID) {
|
if (type != SECTTYPE_INVALID) {
|
||||||
if (curaddr[type][bankID] > endaddr(type) + 1)
|
if (curaddr[type][bankID] > endaddr(type) + 1)
|
||||||
errx(1, "Linkerscript line %u: PC overflowed (%u > %u)",
|
errx(1, "%s(%u): PC overflowed (%u > %u)",
|
||||||
lineNo, curaddr[type][bankID],
|
linkerScriptName, lineNo,
|
||||||
endaddr(type));
|
curaddr[type][bankID], endaddr(type));
|
||||||
if (curaddr[type][bankID] < startaddr[type])
|
if (curaddr[type][bankID] < startaddr[type])
|
||||||
errx(1, "Linkerscript line %u: PC underflowed (%u < %u)",
|
errx(1, "%s(%u): PC underflowed (%u < %u)",
|
||||||
lineNo, curaddr[type][bankID],
|
linkerScriptName, lineNo,
|
||||||
startaddr[type]);
|
curaddr[type][bankID], startaddr[type]);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (parserState) {
|
switch (parserState) {
|
||||||
@@ -318,8 +321,8 @@ struct SectionPlacement *script_NextSection(void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
case TOKEN_NUMBER:
|
case TOKEN_NUMBER:
|
||||||
errx(1, "Linkerscript line %u: stray number",
|
errx(1, "%s(%u): stray number",
|
||||||
lineNo);
|
linkerScriptName, lineNo);
|
||||||
|
|
||||||
case TOKEN_NEWLINE:
|
case TOKEN_NEWLINE:
|
||||||
lineNo++;
|
lineNo++;
|
||||||
@@ -329,8 +332,8 @@ struct SectionPlacement *script_NextSection(void)
|
|||||||
parserState = PARSER_LINEEND;
|
parserState = PARSER_LINEEND;
|
||||||
|
|
||||||
if (type == SECTTYPE_INVALID)
|
if (type == SECTTYPE_INVALID)
|
||||||
errx(1, "Linkerscript line %u: Didn't specify a location before the section",
|
errx(1, "%s(%u): Didn't specify a location before the section",
|
||||||
lineNo);
|
linkerScriptName, lineNo);
|
||||||
|
|
||||||
section.section =
|
section.section =
|
||||||
sect_GetSection(token->attr.string);
|
sect_GetSection(token->attr.string);
|
||||||
@@ -360,11 +363,11 @@ struct SectionPlacement *script_NextSection(void)
|
|||||||
|
|
||||||
if (tokType == TOKEN_COMMAND) {
|
if (tokType == TOKEN_COMMAND) {
|
||||||
if (type == SECTTYPE_INVALID)
|
if (type == SECTTYPE_INVALID)
|
||||||
errx(1, "Linkerscript line %u: Didn't specify a location before the command",
|
errx(1, "%s(%u): Didn't specify a location before the command",
|
||||||
lineNo);
|
linkerScriptName, lineNo);
|
||||||
if (!hasArg)
|
if (!hasArg)
|
||||||
errx(1, "Linkerscript line %u: Command specified without an argument",
|
errx(1, "%s(%u): Command specified without an argument",
|
||||||
lineNo);
|
linkerScriptName, lineNo);
|
||||||
|
|
||||||
processCommand(attr.command, arg,
|
processCommand(attr.command, arg,
|
||||||
&curaddr[type][bankID]);
|
&curaddr[type][bankID]);
|
||||||
@@ -375,18 +378,18 @@ struct SectionPlacement *script_NextSection(void)
|
|||||||
* specifying the number is optional.
|
* specifying the number is optional.
|
||||||
*/
|
*/
|
||||||
if (!hasArg && nbbanks(type) != 1)
|
if (!hasArg && nbbanks(type) != 1)
|
||||||
errx(1, "Linkerscript line %u: Didn't specify a bank number",
|
errx(1, "%s(%u): Didn't specify a bank number",
|
||||||
lineNo);
|
linkerScriptName, lineNo);
|
||||||
else if (!hasArg)
|
else if (!hasArg)
|
||||||
arg = bankranges[type][0];
|
arg = bankranges[type][0];
|
||||||
else if (arg < bankranges[type][0])
|
else if (arg < bankranges[type][0])
|
||||||
errx(1, "Linkerscript line %u: specified bank number is too low (%u < %u)",
|
errx(1, "%s(%u): specified bank number is too low (%u < %u)",
|
||||||
lineNo, arg,
|
linkerScriptName, lineNo,
|
||||||
bankranges[type][0]);
|
arg, bankranges[type][0]);
|
||||||
else if (arg > bankranges[type][1])
|
else if (arg > bankranges[type][1])
|
||||||
errx(1, "Linkerscript line %u: specified bank number is too high (%u > %u)",
|
errx(1, "%s(%u): specified bank number is too high (%u > %u)",
|
||||||
lineNo, arg,
|
linkerScriptName, lineNo,
|
||||||
bankranges[type][1]);
|
arg, bankranges[type][1]);
|
||||||
bank = arg;
|
bank = arg;
|
||||||
bankID = arg - bankranges[type][0];
|
bankID = arg - bankranges[type][0];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user