aboutsummaryrefslogtreecommitdiff
path: root/src/link/MachO/Symbol.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2024-01-28 00:07:01 +0100
committerJakub Konka <kubkon@jakubkonka.com>2024-01-28 00:40:50 +0100
commit6337ce16ae76977b2444b5c07f3c436db4d5ece7 (patch)
treef462496a8adce12d5535ab9a0490a2b45ecf1bbb /src/link/MachO/Symbol.zig
parent190ea02e0d0c939c0b558927b63a03e30af4749a (diff)
downloadzig-6337ce16ae76977b2444b5c07f3c436db4d5ece7.tar.gz
zig-6337ce16ae76977b2444b5c07f3c436db4d5ece7.zip
macho: do not allocate input files in full
Diffstat (limited to 'src/link/MachO/Symbol.zig')
-rw-r--r--src/link/MachO/Symbol.zig12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/link/MachO/Symbol.zig b/src/link/MachO/Symbol.zig
index e8a8a561b7..a61e6f9579 100644
--- a/src/link/MachO/Symbol.zig
+++ b/src/link/MachO/Symbol.zig
@@ -55,7 +55,12 @@ pub fn weakRef(symbol: Symbol, macho_file: *MachO) bool {
}
pub fn getName(symbol: Symbol, macho_file: *MachO) [:0]const u8 {
- return macho_file.strings.getAssumeExists(symbol.name);
+ if (symbol.flags.global) return macho_file.strings.getAssumeExists(symbol.name);
+ return switch (symbol.getFile(macho_file).?) {
+ .dylib => unreachable, // There are no local symbols for dylibs
+ .zig_object => |x| x.strtab.getAssumeExists(symbol.name),
+ inline else => |x| x.getString(symbol.name),
+ };
}
pub fn getAtom(symbol: Symbol, macho_file: *MachO) ?*Atom {
@@ -341,6 +346,11 @@ pub const Flags = packed struct {
/// Whether the symbol is exported at runtime.
@"export": bool = false,
+ /// Whether the symbol is effectively an extern and takes part in global
+ /// symbol resolution. Then, its name will be saved in global string interning
+ /// table.
+ global: bool = false,
+
/// Whether this symbol is weak.
weak: bool = false,