aboutsummaryrefslogtreecommitdiff
path: root/src/link.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2022-07-06 17:11:39 +0200
committerJakub Konka <kubkon@jakubkonka.com>2022-07-22 16:58:20 +0200
commit9eb7e5182b963366da9415ff7efe7c0fa5b1ad62 (patch)
tree8f93fc1156cdc5e9480519c1db0eafbae545fab0 /src/link.zig
parent843701d0feb683810f6be3cb5d6406eddb5539d0 (diff)
downloadzig-9eb7e5182b963366da9415ff7efe7c0fa5b1ad62.tar.gz
zig-9eb7e5182b963366da9415ff7efe7c0fa5b1ad62.zip
macho: rework symbol handling to match zld/ELF
Now, each object file will store a mutable table of symbols that it defines. Upon symbol resolution between object files, the symbol will be updated with a globally allocated section ordinal and address in virtual memory. If the object defines a globally available symbol, its location only (comprising of the symbol index and object index) will be stored in the globals map for easy access when relocating, etc. This approach cleans up the symbol management significantly, and matches the status quo used in zld/ELF. Additionally, this makes scoping symbol stabs easier too as they are now naturally contained within each object file.
Diffstat (limited to 'src/link.zig')
-rw-r--r--src/link.zig7
1 files changed, 1 insertions, 6 deletions
diff --git a/src/link.zig b/src/link.zig
index aa37589ff5..a69dcc4c6e 100644
--- a/src/link.zig
+++ b/src/link.zig
@@ -544,12 +544,7 @@ pub const File = struct {
switch (base.tag) {
.coff => return @fieldParentPtr(Coff, "base", base).allocateDeclIndexes(decl_index),
.elf => return @fieldParentPtr(Elf, "base", base).allocateDeclIndexes(decl_index),
- .macho => return @fieldParentPtr(MachO, "base", base).allocateDeclIndexes(decl_index) catch |err| switch (err) {
- // remap this error code because we are transitioning away from
- // `allocateDeclIndexes`.
- error.Overflow => return error.OutOfMemory,
- error.OutOfMemory => return error.OutOfMemory,
- },
+ .macho => return @fieldParentPtr(MachO, "base", base).allocateDeclIndexes(decl_index),
.wasm => return @fieldParentPtr(Wasm, "base", base).allocateDeclIndexes(decl_index),
.plan9 => return @fieldParentPtr(Plan9, "base", base).allocateDeclIndexes(decl_index),
.c, .spirv, .nvptx => {},