aboutsummaryrefslogtreecommitdiff
path: root/src/link/MachO/Object.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2023-01-21 13:26:27 +0100
committerJakub Konka <kubkon@jakubkonka.com>2023-01-21 13:37:48 +0100
commit3dff040ca58effc5aaf1c7313a7baa28ec2ac6dd (patch)
treed8a184dc36e16755633529c7fe4bb88591a91fc7 /src/link/MachO/Object.zig
parent24f6c07653eaadb70901ef251d091d3c3c0e010f (diff)
downloadzig-3dff040ca58effc5aaf1c7313a7baa28ec2ac6dd.tar.gz
zig-3dff040ca58effc5aaf1c7313a7baa28ec2ac6dd.zip
macho: synthesise unwind records in absence of compact unwind section
Unlike Apple ld, we will not do any DWARF CFI parsing and simply output DWARF type unwind records.
Diffstat (limited to 'src/link/MachO/Object.zig')
-rw-r--r--src/link/MachO/Object.zig13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/link/MachO/Object.zig b/src/link/MachO/Object.zig
index 2196e9ccf0..944cb7a677 100644
--- a/src/link/MachO/Object.zig
+++ b/src/link/MachO/Object.zig
@@ -725,7 +725,18 @@ fn parseEhFrameSection(self: *Object, zld: *Zld, object_id: u32) !void {
}
fn parseUnwindInfo(self: *Object, zld: *Zld, object_id: u32) !void {
- const sect = self.unwind_info_sect orelse return;
+ const sect = self.unwind_info_sect orelse {
+ // If it so happens that the object had `__eh_frame` section defined but no `__compact_unwind`,
+ // we will try fully synthesising unwind info records to somewhat match Apple ld's
+ // approach. However, we will only synthesise DWARF records and nothing more. For this reason,
+ // we still create the output `__TEXT,__unwind_info` section.
+ if (self.eh_frame_sect != null) {
+ if (zld.getSectionByName("__TEXT", "__unwind_info") == null) {
+ _ = try zld.initSection("__TEXT", "__unwind_info", .{});
+ }
+ }
+ return;
+ };
log.debug("parsing unwind info in {s}", .{self.name});