| ... | @@ -2377,7 +2377,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void { | ... | @@ -2377,7 +2377,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void { |
| 2377 | const debug_line_sect = &self.sections.items[self.debug_line_section_index.?]; | 2377 | const debug_line_sect = &self.sections.items[self.debug_line_section_index.?]; |
| 2378 | const src_fn = &decl.fn_link.elf; | 2378 | const src_fn = &decl.fn_link.elf; |
| 2379 | src_fn.len = @intCast(u32, dbg_line_buffer.items.len); | 2379 | src_fn.len = @intCast(u32, dbg_line_buffer.items.len); |
| 2380 | if (self.dbg_line_fn_last) |last| { | 2380 | if (self.dbg_line_fn_last) |last| not_first: { |
| 2381 | if (src_fn.next) |next| { | 2381 | if (src_fn.next) |next| { |
| 2382 | // Update existing function - non-last item. | 2382 | // Update existing function - non-last item. |
| 2383 | if (src_fn.off + src_fn.len + min_nop_size > next.off) { | 2383 | if (src_fn.off + src_fn.len + min_nop_size > next.off) { |
| ... | @@ -2400,9 +2400,15 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void { | ... | @@ -2400,9 +2400,15 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void { |
| 2400 | src_fn.off = last.off + padToIdeal(last.len); | 2400 | src_fn.off = last.off + padToIdeal(last.len); |
| 2401 | } | 2401 | } |
| 2402 | } else if (src_fn.prev == null) { | 2402 | } else if (src_fn.prev == null) { |
| | 2403 | if (src_fn == last) { |
| | 2404 | // Special case: there is only 1 function and it is being updated. |
| | 2405 | // In this case there is nothing to do. The function's length has |
| | 2406 | // already been updated, and the logic below takes care of |
| | 2407 | // resizing the .debug_line section. |
| | 2408 | break :not_first; |
| | 2409 | } |
| 2403 | // Append new function. | 2410 | // Append new function. |
| 2404 | // TODO Look at the free list before appending at the end. | 2411 | // TODO Look at the free list before appending at the end. |
| 2405 | assert(src_fn != last); | | |
| 2406 | src_fn.prev = last; | 2412 | src_fn.prev = last; |
| 2407 | last.next = src_fn; | 2413 | last.next = src_fn; |
| 2408 | self.dbg_line_fn_last = src_fn; | 2414 | self.dbg_line_fn_last = src_fn; |
| ... | @@ -2527,7 +2533,7 @@ fn updateDeclDebugInfoAllocation(self: *Elf, text_block: *TextBlock, len: u32) ! | ... | @@ -2527,7 +2533,7 @@ fn updateDeclDebugInfoAllocation(self: *Elf, text_block: *TextBlock, len: u32) ! |
| 2527 | | 2533 | |
| 2528 | const debug_info_sect = &self.sections.items[self.debug_info_section_index.?]; | 2534 | const debug_info_sect = &self.sections.items[self.debug_info_section_index.?]; |
| 2529 | text_block.dbg_info_len = len; | 2535 | text_block.dbg_info_len = len; |
| 2530 | if (self.dbg_info_decl_last) |last| { | 2536 | if (self.dbg_info_decl_last) |last| not_first: { |
| 2531 | if (text_block.dbg_info_next) |next| { | 2537 | if (text_block.dbg_info_next) |next| { |
| 2532 | // Update existing Decl - non-last item. | 2538 | // Update existing Decl - non-last item. |
| 2533 | if (text_block.dbg_info_off + text_block.dbg_info_len + min_nop_size > next.dbg_info_off) { | 2539 | if (text_block.dbg_info_off + text_block.dbg_info_len + min_nop_size > next.dbg_info_off) { |
| ... | @@ -2549,6 +2555,13 @@ fn updateDeclDebugInfoAllocation(self: *Elf, text_block: *TextBlock, len: u32) ! | ... | @@ -2549,6 +2555,13 @@ fn updateDeclDebugInfoAllocation(self: *Elf, text_block: *TextBlock, len: u32) ! |
| 2549 | text_block.dbg_info_off = last.dbg_info_off + padToIdeal(last.dbg_info_len); | 2555 | text_block.dbg_info_off = last.dbg_info_off + padToIdeal(last.dbg_info_len); |
| 2550 | } | 2556 | } |
| 2551 | } else if (text_block.dbg_info_prev == null) { | 2557 | } else if (text_block.dbg_info_prev == null) { |
| | 2558 | if (text_block == last) { |
| | 2559 | // Special case: there is only 1 .debug_info block and it is being updated. |
| | 2560 | // In this case there is nothing to do. The block's length has |
| | 2561 | // already been updated, and logic in writeDeclDebugInfo takes care of |
| | 2562 | // resizing the .debug_info section. |
| | 2563 | break :not_first; |
| | 2564 | } |
| 2552 | // Append new Decl. | 2565 | // Append new Decl. |
| 2553 | // TODO Look at the free list before appending at the end. | 2566 | // TODO Look at the free list before appending at the end. |
| 2554 | text_block.dbg_info_prev = last; | 2567 | text_block.dbg_info_prev = last; |