| ... | ... | @@ -2019,10 +2019,14 @@ pub fn compactUnwindToDwarfRegNumber(unwind_reg_number: u3) !u8 { |
| 2019 | 2019 | /// This function is to make it handy to comment out the return and make it |
| 2020 | 2020 | /// into a crash when working on this file. |
| 2021 | 2021 | pub fn bad() error{InvalidDebugInfo} { |
| 2022 | | if (debug_debug_mode) @panic("bad dwarf"); |
| 2022 | invalidDebugInfoDetected(); |
| 2023 | 2023 | return error.InvalidDebugInfo; |
| 2024 | 2024 | } |
| 2025 | 2025 | |
| 2026 | fn invalidDebugInfoDetected() void { |
| 2027 | if (debug_debug_mode) @panic("bad dwarf"); |
| 2028 | } |
| 2029 | |
| 2026 | 2030 | fn missing() error{MissingDebugInfo} { |
| 2027 | 2031 | if (debug_debug_mode) @panic("missing dwarf"); |
| 2028 | 2032 | return error.MissingDebugInfo; |
| ... | ... | @@ -2239,13 +2243,19 @@ pub const ElfModule = struct { |
| 2239 | 2243 | const chdr = section_reader.takeStruct(elf.Chdr, endian) catch continue; |
| 2240 | 2244 | if (chdr.ch_type != .ZLIB) continue; |
| 2241 | 2245 | |
| 2242 | | var zlib_stream: std.compress.flate.Decompress = .init(&section_reader, .zlib, &.{}); |
| 2243 | | const decompressed_section = zlib_stream.reader.allocRemaining(gpa, .unlimited) catch continue; |
| 2244 | | errdefer gpa.free(decompressed_section); |
| 2245 | | assert(chdr.ch_size == decompressed_section.len); |
| 2246 | | |
| 2246 | var decompress: std.compress.flate.Decompress = .init(&section_reader, .zlib, &.{}); |
| 2247 | var decompressed_section: std.ArrayListUnmanaged(u8) = .empty; |
| 2248 | defer decompressed_section.deinit(gpa); |
| 2249 | decompress.reader.appendRemainingUnlimited(gpa, null, &decompressed_section, std.compress.flate.history_len) catch { |
| 2250 | invalidDebugInfoDetected(); |
| 2251 | continue; |
| 2252 | }; |
| 2253 | if (chdr.ch_size != decompressed_section.items.len) { |
| 2254 | invalidDebugInfoDetected(); |
| 2255 | continue; |
| 2256 | } |
| 2247 | 2257 | break :blk .{ |
| 2248 | | .data = decompressed_section, |
| 2258 | .data = try decompressed_section.toOwnedSlice(gpa), |
| 2249 | 2259 | .virtual_address = shdr.sh_addr, |
| 2250 | 2260 | .owned = true, |
| 2251 | 2261 | }; |