Save object file name of each symbol in linker

This is useful to generate error messages when there is a symbol that
appears in more than one object file.

Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
This commit is contained in:
Antonio Niño Díaz
2017-07-22 15:16:38 +01:00
parent 4e2a035838
commit 92449a4fe4
5 changed files with 34 additions and 17 deletions

View File

@@ -116,7 +116,7 @@ AllocSection(void)
*/
struct sSymbol *
obj_ReadSymbol(FILE * f)
obj_ReadSymbol(FILE * f, char *tzObjectfile)
{
struct sSymbol *pSym;
@@ -128,6 +128,8 @@ obj_ReadSymbol(FILE * f)
readasciiz(&pSym->pzName, f);
pSym->Type = (enum eSymbolType)fgetc(f);
pSym->pzObjFileName = tzObjectfile;
if (pSym->Type != SYM_IMPORT) {
readasciiz(&pSym->pzFileName, f);
pSym->nFileLine = readlong(f);
@@ -268,7 +270,7 @@ obj_ReadRGBSection(FILE * f)
}
void
obj_ReadRGB(FILE * pObjfile)
obj_ReadRGB(FILE * pObjfile, char *tzObjectfile)
{
struct sSection *pFirstSection;
SLONG nNumberOfSymbols, nNumberOfSections, i;
@@ -285,7 +287,7 @@ obj_ReadRGB(FILE * pObjfile)
}
for (i = 0; i < nNumberOfSymbols; i += 1)
tSymbols[i] = obj_ReadSymbol(pObjfile);
tSymbols[i] = obj_ReadSymbol(pObjfile, tzObjectfile);
} else
tSymbols = (struct sSymbol **) & dummymem;
@@ -337,7 +339,7 @@ obj_ReadOpenFile(FILE * pObjfile, char *tzObjectfile)
if (strncmp(tzHeader, "RGB", 3) == 0) {
switch (tzHeader[3]) {
case '5':
obj_ReadRGB(pObjfile);
obj_ReadRGB(pObjfile, tzObjectfile);
break;
default:
errx(1, "'%s' uses an unsupported object file version (%s). Please reassemble it.", tzObjectfile, tzHeader);