| ... | @@ -65,6 +65,9 @@ stub_helper_section_index: ?u16 = null, | ... | @@ -65,6 +65,9 @@ stub_helper_section_index: ?u16 = null, |
| 65 | text_const_section_index: ?u16 = null, | 65 | text_const_section_index: ?u16 = null, |
| 66 | cstring_section_index: ?u16 = null, | 66 | cstring_section_index: ?u16 = null, |
| 67 | ustring_section_index: ?u16 = null, | 67 | ustring_section_index: ?u16 = null, |
| | 68 | gcc_except_tab: ?u16 = null, |
| | 69 | unwind_info: ?u16 = null, |
| | 70 | eh_frame: ?u16 = null, |
| 68 | | 71 | |
| 69 | // __DATA_CONST segment sections | 72 | // __DATA_CONST segment sections |
| 70 | got_section_index: ?u16 = null, | 73 | got_section_index: ?u16 = null, |
| ... | @@ -649,6 +652,7 @@ fn updateMetadata(self: *Zld) !void { | ... | @@ -649,6 +652,7 @@ fn updateMetadata(self: *Zld) !void { |
| 649 | }); | 652 | }); |
| 650 | continue; | 653 | continue; |
| 651 | } | 654 | } |
| | 655 | |
| 652 | if (sect.isDebug()) { | 656 | if (sect.isDebug()) { |
| 653 | if (mem.eql(u8, "__LD", segname) and mem.eql(u8, "__compact_unwind", sectname)) { | 657 | if (mem.eql(u8, "__LD", segname) and mem.eql(u8, "__compact_unwind", sectname)) { |
| 654 | log.debug("TODO compact unwind section: type 0x{x}, name '{s},{s}'", .{ | 658 | log.debug("TODO compact unwind section: type 0x{x}, name '{s},{s}'", .{ |
| ... | @@ -677,6 +681,24 @@ fn updateMetadata(self: *Zld) !void { | ... | @@ -677,6 +681,24 @@ fn updateMetadata(self: *Zld) !void { |
| 677 | .reserved2 = 0, | 681 | .reserved2 = 0, |
| 678 | .reserved3 = 0, | 682 | .reserved3 = 0, |
| 679 | }); | 683 | }); |
| | 684 | } else if (mem.eql(u8, sectname, "__gcc_except_tab")) { |
| | 685 | if (self.gcc_except_tab != null) continue; |
| | 686 | |
| | 687 | self.gcc_except_tab = @intCast(u16, text_seg.sections.items.len); |
| | 688 | try text_seg.addSection(self.allocator, .{ |
| | 689 | .sectname = makeStaticString("__gcc_except_tab"), |
| | 690 | .segname = makeStaticString("__TEXT"), |
| | 691 | .addr = 0, |
| | 692 | .size = 0, |
| | 693 | .offset = 0, |
| | 694 | .@"align" = 0, |
| | 695 | .reloff = 0, |
| | 696 | .nreloc = 0, |
| | 697 | .flags = macho.S_REGULAR, |
| | 698 | .reserved1 = 0, |
| | 699 | .reserved2 = 0, |
| | 700 | .reserved3 = 0, |
| | 701 | }); |
| 680 | } else { | 702 | } else { |
| 681 | if (self.text_const_section_index != null) continue; | 703 | if (self.text_const_section_index != null) continue; |
| 682 | | 704 | |
| ... | @@ -975,6 +997,11 @@ fn getMatchingSection(self: *Zld, sect: Object.Section) ?MatchingSection { | ... | @@ -975,6 +997,11 @@ fn getMatchingSection(self: *Zld, sect: Object.Section) ?MatchingSection { |
| 975 | .seg = self.text_segment_cmd_index.?, | 997 | .seg = self.text_segment_cmd_index.?, |
| 976 | .sect = self.ustring_section_index.?, | 998 | .sect = self.ustring_section_index.?, |
| 977 | }; | 999 | }; |
| | 1000 | } else if (mem.eql(u8, sectname, "__gcc_except_tab")) { |
| | 1001 | break :blk .{ |
| | 1002 | .seg = self.text_segment_cmd_index.?, |
| | 1003 | .sect = self.gcc_except_tab.?, |
| | 1004 | }; |
| 978 | } else { | 1005 | } else { |
| 979 | break :blk .{ | 1006 | break :blk .{ |
| 980 | .seg = self.text_segment_cmd_index.?, | 1007 | .seg = self.text_segment_cmd_index.?, |
| ... | @@ -1031,6 +1058,7 @@ fn sortSections(self: *Zld) !void { | ... | @@ -1031,6 +1058,7 @@ fn sortSections(self: *Zld) !void { |
| 1031 | &self.text_section_index, | 1058 | &self.text_section_index, |
| 1032 | &self.stubs_section_index, | 1059 | &self.stubs_section_index, |
| 1033 | &self.stub_helper_section_index, | 1060 | &self.stub_helper_section_index, |
| | 1061 | &self.gcc_except_tab, |
| 1034 | &self.text_const_section_index, | 1062 | &self.text_const_section_index, |
| 1035 | &self.cstring_section_index, | 1063 | &self.cstring_section_index, |
| 1036 | &self.ustring_section_index, | 1064 | &self.ustring_section_index, |