Put all local symbols in object/sym/map files (#774)

* Store all the local symbols in object files, not only the ones that need linker patches.
  This generates better map/sym files, and thus allows for better debugging as well.

* Add comments explaining the ->src and the (void)arg;
This commit is contained in:
daid
2021-03-03 10:59:51 +01:00
committed by GitHub
parent 365484ef18
commit a6d3df7ac9

View File

@@ -469,10 +469,12 @@ static void writeFileStackNode(struct FileStackNode const *node, FILE *f)
} }
} }
static void registerExportedSymbol(struct Symbol *symbol, void *arg) static void registerUnregisteredSymbol(struct Symbol *symbol, void *arg)
{ {
(void)arg; (void)arg; // sym_ForEach requires a void* parameter, but we are not using it.
if (sym_IsExported(symbol) && symbol->ID == -1) {
// Check for symbol->src, to skip any auto generated symbol from rgbasm
if (symbol->src && symbol->ID == -1) {
registerSymbol(symbol); registerSymbol(symbol);
} }
} }
@@ -491,8 +493,8 @@ void out_WriteObject(void)
if (!f) if (!f)
err(1, "Couldn't write file '%s'", tzObjectname); err(1, "Couldn't write file '%s'", tzObjectname);
/* Also write exported symbols that weren't written above */ /* Also write symbols that weren't written above */
sym_ForEach(registerExportedSymbol, NULL); sym_ForEach(registerUnregisteredSymbol, NULL);
fprintf(f, RGBDS_OBJECT_VERSION_STRING, RGBDS_OBJECT_VERSION_NUMBER); fprintf(f, RGBDS_OBJECT_VERSION_STRING, RGBDS_OBJECT_VERSION_NUMBER);
putlong(RGBDS_OBJECT_REV, f); putlong(RGBDS_OBJECT_REV, f);