| ... | @@ -255,6 +255,18 @@ fn addObjCClassSymbol(self: *Dylib, allocator: *Allocator, sym_name: []const u8) | ... | @@ -255,6 +255,18 @@ fn addObjCClassSymbol(self: *Dylib, allocator: *Allocator, sym_name: []const u8) |
| 255 | } | 255 | } |
| 256 | } | 256 | } |
| 257 | | 257 | |
| | 258 | fn addObjCIVarSymbol(self: *Dylib, allocator: *Allocator, sym_name: []const u8) !void { |
| | 259 | const expanded = try std.fmt.allocPrint(allocator, "_OBJC_IVAR_$_{s}", .{sym_name}); |
| | 260 | if (self.symbols.contains(expanded)) return; |
| | 261 | try self.symbols.putNoClobber(allocator, expanded, .{}); |
| | 262 | } |
| | 263 | |
| | 264 | fn addObjCEhTypeSymbol(self: *Dylib, allocator: *Allocator, sym_name: []const u8) !void { |
| | 265 | const expanded = try std.fmt.allocPrint(allocator, "_OBJC_EHTYPE_$_{s}", .{sym_name}); |
| | 266 | if (self.symbols.contains(expanded)) return; |
| | 267 | try self.symbols.putNoClobber(allocator, expanded, .{}); |
| | 268 | } |
| | 269 | |
| 258 | fn addSymbol(self: *Dylib, allocator: *Allocator, sym_name: []const u8) !void { | 270 | fn addSymbol(self: *Dylib, allocator: *Allocator, sym_name: []const u8) !void { |
| 259 | if (self.symbols.contains(sym_name)) return; | 271 | if (self.symbols.contains(sym_name)) return; |
| 260 | try self.symbols.putNoClobber(allocator, try allocator.dupe(u8, sym_name), {}); | 272 | 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 | ... | @@ -385,6 +397,18 @@ pub fn parseFromStub(self: *Dylib, allocator: *Allocator, target: std.Target, li |
| 385 | } | 397 | } |
| 386 | } | 398 | } |
| 387 | | 399 | |
| | 400 | if (exp.objc_ivars) |objc_ivars| { |
| | 401 | for (objc_ivars) |ivar| { |
| | 402 | try self.addObjCIVarSymbol(allocator, ivar); |
| | 403 | } |
| | 404 | } |
| | 405 | |
| | 406 | if (exp.objc_eh_types) |objc_eh_types| { |
| | 407 | for (objc_eh_types) |eht| { |
| | 408 | try self.addObjCEhTypeSymbol(allocator, eht); |
| | 409 | } |
| | 410 | } |
| | 411 | |
| 388 | // TODO track which libs were already parsed in different steps | 412 | // TODO track which libs were already parsed in different steps |
| 389 | if (exp.re_exports) |re_exports| { | 413 | if (exp.re_exports) |re_exports| { |
| 390 | for (re_exports) |lib| { | 414 | for (re_exports) |lib| { |
| ... | @@ -415,6 +439,18 @@ pub fn parseFromStub(self: *Dylib, allocator: *Allocator, target: std.Target, li | ... | @@ -415,6 +439,18 @@ pub fn parseFromStub(self: *Dylib, allocator: *Allocator, target: std.Target, li |
| 415 | try self.addObjCClassSymbol(allocator, sym_name); | 439 | try self.addObjCClassSymbol(allocator, sym_name); |
| 416 | } | 440 | } |
| 417 | } | 441 | } |
| | 442 | |
| | 443 | if (exp.objc_ivars) |objc_ivars| { |
| | 444 | for (objc_ivars) |ivar| { |
| | 445 | try self.addObjCIVarSymbol(allocator, ivar); |
| | 446 | } |
| | 447 | } |
| | 448 | |
| | 449 | if (exp.objc_eh_types) |objc_eh_types| { |
| | 450 | for (objc_eh_types) |eht| { |
| | 451 | try self.addObjCEhTypeSymbol(allocator, eht); |
| | 452 | } |
| | 453 | } |
| 418 | } | 454 | } |
| 419 | } | 455 | } |
| 420 | | 456 | |
| ... | @@ -433,6 +469,18 @@ pub fn parseFromStub(self: *Dylib, allocator: *Allocator, target: std.Target, li | ... | @@ -433,6 +469,18 @@ pub fn parseFromStub(self: *Dylib, allocator: *Allocator, target: std.Target, li |
| 433 | try self.addObjCClassSymbol(allocator, sym_name); | 469 | try self.addObjCClassSymbol(allocator, sym_name); |
| 434 | } | 470 | } |
| 435 | } | 471 | } |
| | 472 | |
| | 473 | if (reexp.objc_ivars) |objc_ivars| { |
| | 474 | for (objc_ivars) |ivar| { |
| | 475 | try self.addObjCIVarSymbol(allocator, ivar); |
| | 476 | } |
| | 477 | } |
| | 478 | |
| | 479 | if (reexp.objc_eh_types) |objc_eh_types| { |
| | 480 | for (objc_eh_types) |eht| { |
| | 481 | try self.addObjCEhTypeSymbol(allocator, eht); |
| | 482 | } |
| | 483 | } |
| 436 | } | 484 | } |
| 437 | } | 485 | } |
| 438 | | 486 | |
| ... | @@ -441,6 +489,18 @@ pub fn parseFromStub(self: *Dylib, allocator: *Allocator, target: std.Target, li | ... | @@ -441,6 +489,18 @@ pub fn parseFromStub(self: *Dylib, allocator: *Allocator, target: std.Target, li |
| 441 | try self.addObjCClassSymbol(allocator, sym_name); | 489 | try self.addObjCClassSymbol(allocator, sym_name); |
| 442 | } | 490 | } |
| 443 | } | 491 | } |
| | 492 | |
| | 493 | if (stub.objc_ivars) |objc_ivars| { |
| | 494 | for (objc_ivars) |ivar| { |
| | 495 | try self.addObjCIVarSymbol(allocator, ivar); |
| | 496 | } |
| | 497 | } |
| | 498 | |
| | 499 | if (stub.objc_eh_types) |objc_eh_types| { |
| | 500 | for (objc_eh_types) |eht| { |
| | 501 | try self.addObjCEhTypeSymbol(allocator, eht); |
| | 502 | } |
| | 503 | } |
| 444 | }, | 504 | }, |
| 445 | } | 505 | } |
| 446 | } | 506 | } |