Put undefined symbols in separate table.

Even though all regression tests pass, it feels better to do the
undefined symbols similar to the implicit globals.
This commit is contained in:
Olaf Seibert
2021-05-30 13:11:50 +02:00
parent 652c047711
commit d2d143dd9b
5 changed files with 32 additions and 4 deletions

View File

@@ -213,8 +213,9 @@ void implicit_gbl(
/* Either make the undefined symbol into an implicit global */
add_sym(value->data.symbol->label, 0, SYMBOLFLAG_GLOBAL, &absolute_section, &implicit_st);
} else {
/* or add it to the symbol table, purely for listing purposes. */
add_sym(value->data.symbol->label, 0, SYMBOLFLAG_UNDEFINED, &absolute_section, &symbol_st);
/* or add it to the undefined symbol table,
purely for listing purposes. */
add_sym(value->data.symbol->label, 0, SYMBOLFLAG_UNDEFINED, &absolute_section, &undefined_st);
}
}
}
@@ -265,6 +266,28 @@ void migrate_implicit(
}
}
/* Done between second pass and listing */
/* Migrates the symbols from the "undefined" table into the main table. */
void migrate_undefined(
void)
{
SYMBOL_ITER iter;
SYMBOL *isym,
*sym;
for (isym = first_sym(&undefined_st, &iter); isym != NULL; isym = next_sym(&undefined_st, &iter)) {
sym = lookup_sym(isym->label, &symbol_st);
if (sym) {
continue; /* It's already in there. Great. */
}
isym->flags |= SYMBOLFLAG_UNDEFINED; /* Just in case */
sym = add_sym(isym->label, isym->value, isym->flags, isym->section, &symbol_st);
/* Just one other thing - migrate the stmtno */
sym->stmtno = isym->stmtno;
}
}
int express_sym_offset(
EX_TREE *value,
SYMBOL **sym,

View File

@@ -85,7 +85,7 @@ void write_globals(
FILE *obj);
void migrate_implicit(
void);
void migrate_undefined(
void);
#endif

View File

@@ -417,6 +417,7 @@ int main(
fprintf(stderr, "%d Errors\n", errcount);
if (lstfile) {
migrate_undefined(); /* Migrate the undefined symbols */
list_symbol_table();
}

View File

@@ -30,6 +30,8 @@ SYMBOL_TABLE macro_st; /* Macros */
SYMBOL_TABLE implicit_st; /* The symbols which may be implicit globals */
SYMBOL_TABLE undefined_st; /* The symbols which may be undefined */
void list_section(SECTION *sec);

View File

@@ -370,6 +370,8 @@ extern SYMBOL_TABLE macro_st; /* Macros */
extern SYMBOL_TABLE implicit_st; /* The symbols which may be implicit globals */
extern SYMBOL_TABLE undefined_st; /* The symbols which may be undefined */
#endif
int hash_name(