aboutsummaryrefslogtreecommitdiff
path: root/src/link/MachO/Symbol.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2021-07-07 10:36:41 +0200
committerJakub Konka <kubkon@jakubkonka.com>2021-07-15 18:49:47 +0200
commit555b66c25567ab23402e3792bdbe81b7a4e98803 (patch)
tree7f4dab9ab3c66caf1c4057b46d5dc068f1104bbc /src/link/MachO/Symbol.zig
parentdbd2eb7c7f9267e8ae508d0995c1d4c5a3b46309 (diff)
downloadzig-555b66c25567ab23402e3792bdbe81b7a4e98803.tar.gz
zig-555b66c25567ab23402e3792bdbe81b7a4e98803.zip
zld: move should_rebase logic into Symbol
Diffstat (limited to 'src/link/MachO/Symbol.zig')
-rw-r--r--src/link/MachO/Symbol.zig21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/link/MachO/Symbol.zig b/src/link/MachO/Symbol.zig
index 16cd0c9ecc..5f437dc209 100644
--- a/src/link/MachO/Symbol.zig
+++ b/src/link/MachO/Symbol.zig
@@ -2,6 +2,7 @@ const Symbol = @This();
const std = @import("std");
const assert = std.debug.assert;
+const commands = @import("commands.zig");
const macho = std.macho;
const mem = std.mem;
@@ -57,6 +58,8 @@ pub const Regular = struct {
local_sym_index: u32 = 0,
+ should_rebase: bool = false,
+
pub const Linkage = enum {
translation_unit,
linkage_unit,
@@ -74,6 +77,9 @@ pub const Regular = struct {
if (self.weak_ref) {
try std.fmt.format(writer, ".weak_ref, ", .{});
}
+ if (self.should_rebase) {
+ try std.fmt.format(writer, ".should_rebase, ", .{});
+ }
if (self.file) |file| {
try std.fmt.format(writer, ".file = {s}, ", .{file.name.?});
}
@@ -108,8 +114,8 @@ pub const Proxy = struct {
/// Dynamic binding info - spots within the final
/// executable where this proxy is referenced from.
bind_info: std.ArrayListUnmanaged(struct {
- segment_id: u16,
- address: u64,
+ local_sym_index: u32,
+ offset: u32,
}) = .{},
/// Dylib where to locate this symbol.
@@ -198,6 +204,17 @@ pub fn isTemp(symbol: Symbol) bool {
return false;
}
+pub fn needsTlvOffset(self: Symbol, zld: *Zld) bool {
+ if (self.payload != .regular) return false;
+
+ const reg = self.payload.regular;
+ const seg = zld.load_command.items[reg.segment_id].Segment;
+ const sect = seg.sections.items[reg.section_id];
+ const sect_type = commands.sectionType(sect);
+
+ return sect_type == macho.S_THREAD_LOCAL_VARIABLES;
+}
+
pub fn asNlist(symbol: *Symbol, strtab: *StringTable) !macho.nlist_64 {
const n_strx = try strtab.getOrPut(symbol.name);
const nlist = nlist: {