diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2021-06-20 12:45:51 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2021-06-24 14:45:45 +0200 |
| commit | bc78b02c04143b7e1b32aceacdcf44130026a7a7 (patch) | |
| tree | d0d20c362872c1dea62a50f694e309ca7c685645 /src/link/MachO/Symbol.zig | |
| parent | 09b46198ff8d64c9884a0cf13788855b4d4bbe2d (diff) | |
| download | zig-bc78b02c04143b7e1b32aceacdcf44130026a7a7.tar.gz zig-bc78b02c04143b7e1b32aceacdcf44130026a7a7.zip | |
zld: introduce Stub.zig which represents parsed stub file
Instead of trying to fit a stub file into the frame of a Dylib struct,
I think it makes more sense to keep them as separate entities with
possibly shared interface (which would be added in the future).
This cleaned up a lot of logic in Dylib as well as Stub. Also, while
here I've made creating actual *Symbols lazy in the sense Dylib and
Stub only store hash maps of symbol names that they expose but we
defer create and referencing given dylib/stub until link time when
a symbol is actually referenced. This should reduce memory usage
and speed things up a bit.
Diffstat (limited to 'src/link/MachO/Symbol.zig')
| -rw-r--r-- | src/link/MachO/Symbol.zig | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/link/MachO/Symbol.zig b/src/link/MachO/Symbol.zig index 35656852ea..2286b1ea93 100644 --- a/src/link/MachO/Symbol.zig +++ b/src/link/MachO/Symbol.zig @@ -7,6 +7,7 @@ const mem = std.mem; const Allocator = mem.Allocator; const Dylib = @import("Dylib.zig"); const Object = @import("Object.zig"); +const Stub = @import("Stub.zig"); pub const Type = enum { regular, @@ -84,11 +85,22 @@ pub const Regular = struct { pub const Proxy = struct { base: Symbol, - /// Dylib where to locate this symbol. + /// Dylib or stub where to locate this symbol. /// null means self-reference. - dylib: ?*Dylib = null, + file: ?union(enum) { + dylib: *Dylib, + stub: *Stub, + } = null, pub const base_type: Symbol.Type = .proxy; + + pub fn dylibOrdinal(proxy: *Proxy) u16 { + const file = proxy.file orelse return 0; + return switch (file) { + .dylib => |dylib| dylib.ordinal.?, + .stub => |stub| stub.ordinal.?, + }; + } }; pub const Unresolved = struct { |
