zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 691090f3429b8625252dd5cfec101f2a9e171463 (tree)
parent e17c4a497ff77a9da11393886a86a216705eb687
Author: Jakub Konka <kubkon@jakubkonka.com>
Date:   Mon, 22 Nov 2021 14:15:46 +0100

zld: parse ObjC ivars and eh_types in tapi v3 and v4

Diffstat:
Msrc/link/MachO/Dylib.zig | 60++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/link/tapi.zig | 8++++++++
2 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/src/link/MachO/Dylib.zig b/src/link/MachO/Dylib.zig @@ -255,6 +255,18 @@ fn addObjCClassSymbol(self: *Dylib, allocator: *Allocator, sym_name: []const u8) } } +fn addObjCIVarSymbol(self: *Dylib, allocator: *Allocator, sym_name: []const u8) !void { + const expanded = try std.fmt.allocPrint(allocator, "_OBJC_IVAR_$_{s}", .{sym_name}); + if (self.symbols.contains(expanded)) return; + try self.symbols.putNoClobber(allocator, expanded, .{}); +} + +fn addObjCEhTypeSymbol(self: *Dylib, allocator: *Allocator, sym_name: []const u8) !void { + const expanded = try std.fmt.allocPrint(allocator, "_OBJC_EHTYPE_$_{s}", .{sym_name}); + if (self.symbols.contains(expanded)) return; + try self.symbols.putNoClobber(allocator, expanded, .{}); +} + fn addSymbol(self: *Dylib, allocator: *Allocator, sym_name: []const u8) !void { if (self.symbols.contains(sym_name)) return; try self.symbols.putNoClobber(allocator, try allocator.dupe(u8, sym_name), {}); @@ -385,6 +397,18 @@ pub fn parseFromStub(self: *Dylib, allocator: *Allocator, target: std.Target, li } } + if (exp.objc_ivars) |objc_ivars| { + for (objc_ivars) |ivar| { + try self.addObjCIVarSymbol(allocator, ivar); + } + } + + if (exp.objc_eh_types) |objc_eh_types| { + for (objc_eh_types) |eht| { + try self.addObjCEhTypeSymbol(allocator, eht); + } + } + // TODO track which libs were already parsed in different steps if (exp.re_exports) |re_exports| { for (re_exports) |lib| { @@ -415,6 +439,18 @@ pub fn parseFromStub(self: *Dylib, allocator: *Allocator, target: std.Target, li try self.addObjCClassSymbol(allocator, sym_name); } } + + if (exp.objc_ivars) |objc_ivars| { + for (objc_ivars) |ivar| { + try self.addObjCIVarSymbol(allocator, ivar); + } + } + + if (exp.objc_eh_types) |objc_eh_types| { + for (objc_eh_types) |eht| { + try self.addObjCEhTypeSymbol(allocator, eht); + } + } } } @@ -433,6 +469,18 @@ pub fn parseFromStub(self: *Dylib, allocator: *Allocator, target: std.Target, li try self.addObjCClassSymbol(allocator, sym_name); } } + + if (reexp.objc_ivars) |objc_ivars| { + for (objc_ivars) |ivar| { + try self.addObjCIVarSymbol(allocator, ivar); + } + } + + if (reexp.objc_eh_types) |objc_eh_types| { + for (objc_eh_types) |eht| { + try self.addObjCEhTypeSymbol(allocator, eht); + } + } } } @@ -441,6 +489,18 @@ pub fn parseFromStub(self: *Dylib, allocator: *Allocator, target: std.Target, li try self.addObjCClassSymbol(allocator, sym_name); } } + + if (stub.objc_ivars) |objc_ivars| { + for (objc_ivars) |ivar| { + try self.addObjCIVarSymbol(allocator, ivar); + } + } + + if (stub.objc_eh_types) |objc_eh_types| { + for (objc_eh_types) |eht| { + try self.addObjCEhTypeSymbol(allocator, eht); + } + } }, } } diff --git a/src/link/tapi.zig b/src/link/tapi.zig @@ -27,6 +27,8 @@ pub const TbdV3 = struct { re_exports: ?[]const []const u8, symbols: ?[]const []const u8, objc_classes: ?[]const []const u8, + objc_ivars: ?[]const []const u8, + objc_eh_types: ?[]const []const u8, }, }; @@ -52,17 +54,23 @@ pub const TbdV4 = struct { targets: []const []const u8, symbols: ?[]const []const u8, objc_classes: ?[]const []const u8, + objc_ivars: ?[]const []const u8, + objc_eh_types: ?[]const []const u8, }, reexports: ?[]const struct { targets: []const []const u8, symbols: ?[]const []const u8, objc_classes: ?[]const []const u8, + objc_ivars: ?[]const []const u8, + objc_eh_types: ?[]const []const u8, }, allowable_clients: ?[]const struct { targets: []const []const u8, clients: []const []const u8, }, objc_classes: ?[]const []const u8, + objc_ivars: ?[]const []const u8, + objc_eh_types: ?[]const []const u8, }; pub const Tbd = union(enum) {