| ... | ... | @@ -1073,6 +1073,15 @@ fn freeTextBlock(self: *MachO, text_block: *TextBlock) void { |
| 1073 | 1073 | // TODO shrink the __text section size here |
| 1074 | 1074 | self.last_text_block = text_block.prev; |
| 1075 | 1075 | } |
| 1076 | if (self.d_sym) |*ds| { |
| 1077 | if (ds.dbg_info_decl_first == text_block) { |
| 1078 | ds.dbg_info_decl_first = text_block.dbg_info_next; |
| 1079 | } |
| 1080 | if (ds.dbg_info_decl_last == text_block) { |
| 1081 | // TODO shrink the .debug_info section size here |
| 1082 | ds.dbg_info_decl_last = text_block.dbg_info_prev; |
| 1083 | } |
| 1084 | } |
| 1076 | 1085 | |
| 1077 | 1086 | if (text_block.prev) |prev| { |
| 1078 | 1087 | prev.next = text_block.next; |
| ... | ... | @@ -1091,6 +1100,20 @@ fn freeTextBlock(self: *MachO, text_block: *TextBlock) void { |
| 1091 | 1100 | } else { |
| 1092 | 1101 | text_block.next = null; |
| 1093 | 1102 | } |
| 1103 | |
| 1104 | if (text_block.dbg_info_prev) |prev| { |
| 1105 | prev.dbg_info_next = text_block.dbg_info_next; |
| 1106 | |
| 1107 | // TODO the free list logic like we do for text blocks above |
| 1108 | } else { |
| 1109 | text_block.dbg_info_prev = null; |
| 1110 | } |
| 1111 | |
| 1112 | if (text_block.dbg_info_next) |next| { |
| 1113 | next.dbg_info_prev = text_block.dbg_info_prev; |
| 1114 | } else { |
| 1115 | text_block.dbg_info_next = null; |
| 1116 | } |
| 1094 | 1117 | } |
| 1095 | 1118 | |
| 1096 | 1119 | fn shrinkTextBlock(self: *MachO, text_block: *TextBlock, new_block_size: u64) void { |
| ... | ... | @@ -1477,6 +1500,29 @@ pub fn freeDecl(self: *MachO, decl: *Module.Decl) void { |
| 1477 | 1500 | |
| 1478 | 1501 | decl.link.macho.local_sym_index = 0; |
| 1479 | 1502 | } |
| 1503 | if (self.d_sym) |*ds| { |
| 1504 | // TODO make this logic match freeTextBlock. Maybe abstract the logic |
| 1505 | // out since the same thing is desired for both. |
| 1506 | _ = ds.dbg_line_fn_free_list.remove(&decl.fn_link.macho); |
| 1507 | if (decl.fn_link.macho.prev) |prev| { |
| 1508 | ds.dbg_line_fn_free_list.put(self.base.allocator, prev, {}) catch {}; |
| 1509 | prev.next = decl.fn_link.macho.next; |
| 1510 | if (decl.fn_link.macho.next) |next| { |
| 1511 | next.prev = prev; |
| 1512 | } else { |
| 1513 | ds.dbg_line_fn_last = prev; |
| 1514 | } |
| 1515 | } else if (decl.fn_link.macho.next) |next| { |
| 1516 | ds.dbg_line_fn_first = next; |
| 1517 | next.prev = null; |
| 1518 | } |
| 1519 | if (ds.dbg_line_fn_first == &decl.fn_link.macho) { |
| 1520 | ds.dbg_line_fn_first = decl.fn_link.macho.next; |
| 1521 | } |
| 1522 | if (ds.dbg_line_fn_last == &decl.fn_link.macho) { |
| 1523 | ds.dbg_line_fn_last = decl.fn_link.macho.prev; |
| 1524 | } |
| 1525 | } |
| 1480 | 1526 | } |
| 1481 | 1527 | |
| 1482 | 1528 | pub fn getDeclVAddr(self: *MachO, decl: *const Module.Decl) u64 { |