simplifying symbol table scopes

Linker cannot register extern import symbols initially because
the import object files are not available until all other object files are
resolved. To work around this, we create a stub weak symbol and assign
it to each import symbol. This allows linker to proceed. Once the import
object files are generated, linker replaces the stub symbol with
the actual ones from the import objects.
This commit is contained in:
Nikita Smith authored and Ryan Fleury committed 2025-08-05 08:39:12 -07:00
1 parent dd715dacf7
commit d3dedd8bef
4 files changed
+13 -37

No files matched your search

-8
View File
@@ -8,7 +8,6 @@
typedef enum
{
LNK_SymbolScope_Defined,
LNK_SymbolScope_Import,
LNK_SymbolScope_Lib,
LNK_SymbolScope_Count
} LNK_SymbolScope;
@@ -30,18 +29,12 @@ typedef struct LNK_SymbolUndefined
struct LNK_Obj *obj;
} LNK_SymbolUndefined;
typedef struct LNK_SymbolImport
{
String8 import_header;
} LNK_SymbolImport;
typedef struct LNK_Symbol
{
String8 name;
union {
LNK_SymbolDefined defined;
LNK_SymbolLib lib;
LNK_SymbolImport imp;
LNK_SymbolUndefined undef;
} u;
} LNK_Symbol;
@@ -120,7 +113,6 @@ typedef struct
internal LNK_Symbol * lnk_make_defined_symbol(Arena *arena, String8 name, struct LNK_Obj *obj, U32 symbol_idx);
internal LNK_Symbol * lnk_make_lib_symbol(Arena *arena, String8 name, struct LNK_Lib *lib, U64 member_offset);
internal LNK_Symbol * lnk_make_undefined_symbol(Arena *arena, String8 name, struct LNK_Obj *obj);
internal LNK_Symbol * lnk_make_import_symbol(Arena *arena, String8 name, String8 import_header);
// --- Symbol Containers ------------------------------------------------------