mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Print location information in linker errors where viable
This commit is contained in:
@@ -15,7 +15,7 @@ void sym_Init(void);
|
|||||||
void sym_CreateSymbol(char *tzName, int32_t nValue, int32_t nBank,
|
void sym_CreateSymbol(char *tzName, int32_t nValue, int32_t nBank,
|
||||||
char *tzObjFileName, char *tzFileName,
|
char *tzObjFileName, char *tzFileName,
|
||||||
uint32_t nFileLine);
|
uint32_t nFileLine);
|
||||||
int32_t sym_GetValue(char *tzName);
|
int32_t sym_GetValue(struct sPatch *pPatch, char *tzName);
|
||||||
int32_t sym_GetBank(char *tzName);
|
int32_t sym_GetBank(struct sPatch *pPatch, char *tzName);
|
||||||
|
|
||||||
#endif /* RGBDS_LINK_SYMBOL_H */
|
#endif /* RGBDS_LINK_SYMBOL_H */
|
||||||
|
|||||||
@@ -35,13 +35,13 @@ static int32_t rpnpop(void)
|
|||||||
return rpnstack[rpnp];
|
return rpnstack[rpnp];
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t getsymvalue(int32_t symid)
|
static int32_t getsymvalue(struct sPatch *pPatch, int32_t symid)
|
||||||
{
|
{
|
||||||
const struct sSymbol *tSymbol = pCurrentSection->tSymbols[symid];
|
const struct sSymbol *tSymbol = pCurrentSection->tSymbols[symid];
|
||||||
|
|
||||||
switch (tSymbol->Type) {
|
switch (tSymbol->Type) {
|
||||||
case SYM_IMPORT:
|
case SYM_IMPORT:
|
||||||
return sym_GetValue(tSymbol->pzName);
|
return sym_GetValue(pPatch, tSymbol->pzName);
|
||||||
|
|
||||||
case SYM_EXPORT:
|
case SYM_EXPORT:
|
||||||
case SYM_LOCAL:
|
case SYM_LOCAL:
|
||||||
@@ -75,14 +75,14 @@ static int32_t getrealbankfrominternalbank(int32_t n)
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t getsymbank(int32_t symid)
|
static int32_t getsymbank(struct sPatch *pPatch, int32_t symid)
|
||||||
{
|
{
|
||||||
int32_t nBank;
|
int32_t nBank;
|
||||||
const struct sSymbol *tSymbol = pCurrentSection->tSymbols[symid];
|
const struct sSymbol *tSymbol = pCurrentSection->tSymbols[symid];
|
||||||
|
|
||||||
switch (tSymbol->Type) {
|
switch (tSymbol->Type) {
|
||||||
case SYM_IMPORT:
|
case SYM_IMPORT:
|
||||||
nBank = sym_GetBank(tSymbol->pzName);
|
nBank = sym_GetBank(pPatch, tSymbol->pzName);
|
||||||
break;
|
break;
|
||||||
case SYM_EXPORT:
|
case SYM_EXPORT:
|
||||||
case SYM_LOCAL:
|
case SYM_LOCAL:
|
||||||
@@ -209,8 +209,8 @@ int32_t calcrpn(struct sPatch *pPatch)
|
|||||||
t |= (*rpn++) << 8;
|
t |= (*rpn++) << 8;
|
||||||
t |= (*rpn++) << 16;
|
t |= (*rpn++) << 16;
|
||||||
t |= (*rpn++) << 24;
|
t |= (*rpn++) << 24;
|
||||||
rpnpush(getsymvalue(t));
|
rpnpush(getsymvalue(pPatch, t));
|
||||||
pPatch->oRelocPatch |= (getsymbank(t) != -1);
|
pPatch->oRelocPatch |= (getsymbank(pPatch, t) != -1);
|
||||||
size -= 4;
|
size -= 4;
|
||||||
break;
|
break;
|
||||||
case RPN_BANK_SYM:
|
case RPN_BANK_SYM:
|
||||||
@@ -219,7 +219,7 @@ int32_t calcrpn(struct sPatch *pPatch)
|
|||||||
t |= (*rpn++) << 8;
|
t |= (*rpn++) << 8;
|
||||||
t |= (*rpn++) << 16;
|
t |= (*rpn++) << 16;
|
||||||
t |= (*rpn++) << 24;
|
t |= (*rpn++) << 24;
|
||||||
rpnpush(getsymbank(t));
|
rpnpush(getsymbank(pPatch, t));
|
||||||
size -= 4;
|
size -= 4;
|
||||||
break;
|
break;
|
||||||
case RPN_BANK_SECT:
|
case RPN_BANK_SECT:
|
||||||
@@ -229,7 +229,9 @@ int32_t calcrpn(struct sPatch *pPatch)
|
|||||||
struct sSection *pSection = GetSectionByName(name);
|
struct sSection *pSection = GetSectionByName(name);
|
||||||
|
|
||||||
if (pSection == NULL) {
|
if (pSection == NULL) {
|
||||||
errx(1, "Requested BANK() of section \"%s\", which was not found.\n",
|
errx(1,
|
||||||
|
"%s(%ld) : Requested BANK() of section \"%s\", which was not found.\n",
|
||||||
|
pPatch->pzFilename, pPatch->nLineNo,
|
||||||
name);
|
name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include "link/main.h"
|
#include "link/main.h"
|
||||||
#include "link/patch.h"
|
#include "link/patch.h"
|
||||||
|
#include "link/mylink.h"
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
@@ -53,7 +54,7 @@ void sym_Init(void)
|
|||||||
tHash[i] = NULL;
|
tHash[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t sym_GetValue(char *tzName)
|
int32_t sym_GetValue(struct sPatch *pPatch, char *tzName)
|
||||||
{
|
{
|
||||||
if (strcmp(tzName, "@") == 0)
|
if (strcmp(tzName, "@") == 0)
|
||||||
return nPC;
|
return nPC;
|
||||||
@@ -68,10 +69,13 @@ int32_t sym_GetValue(char *tzName)
|
|||||||
return ((*ppSym)->nValue);
|
return ((*ppSym)->nValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
errx(1, "Unknown symbol '%s'", tzName);
|
errx(1,
|
||||||
|
"%s(%ld) : Unknown symbol '%s'",
|
||||||
|
pPatch->pzFilename, pPatch->nLineNo,
|
||||||
|
tzName);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t sym_GetBank(char *tzName)
|
int32_t sym_GetBank(struct sPatch *pPatch, char *tzName)
|
||||||
{
|
{
|
||||||
struct ISymbol **ppSym;
|
struct ISymbol **ppSym;
|
||||||
|
|
||||||
@@ -83,7 +87,10 @@ int32_t sym_GetBank(char *tzName)
|
|||||||
return ((*ppSym)->nBank);
|
return ((*ppSym)->nBank);
|
||||||
}
|
}
|
||||||
|
|
||||||
errx(1, "Unknown symbol '%s'", tzName);
|
errx(1,
|
||||||
|
"%s(%ld) : Unknown symbol '%s'",
|
||||||
|
pPatch->pzFilename, pPatch->nLineNo,
|
||||||
|
tzName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sym_CreateSymbol(char *tzName, int32_t nValue, int32_t nBank,
|
void sym_CreateSymbol(char *tzName, int32_t nValue, int32_t nBank,
|
||||||
|
|||||||
Reference in New Issue
Block a user