aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2023-03-21 11:38:49 +0100
committerJakub Konka <kubkon@jakubkonka.com>2023-03-21 11:38:49 +0100
commit073f9a18a92fd233e07470e737e15e651618e47f (patch)
treebdb4754cf874e8a3536bcecbd0d310fd7d3b6ff5 /src
parenta88ffa7fa91e568fe234ac9ea2b15f005876cca6 (diff)
downloadzig-073f9a18a92fd233e07470e737e15e651618e47f.tar.gz
zig-073f9a18a92fd233e07470e737e15e651618e47f.zip
macho+zld: return null rather than error on invalid AbbrevKind
Diffstat (limited to 'src')
-rw-r--r--src/link/MachO/DwarfInfo.zig21
1 files changed, 3 insertions, 18 deletions
diff --git a/src/link/MachO/DwarfInfo.zig b/src/link/MachO/DwarfInfo.zig
index 1ec4a79871..3218435734 100644
--- a/src/link/MachO/DwarfInfo.zig
+++ b/src/link/MachO/DwarfInfo.zig
@@ -27,7 +27,7 @@ const CompileUnitIterator = struct {
pub fn next(self: *CompileUnitIterator) !?CompileUnit {
if (self.pos >= self.ctx.debug_info.len) return null;
- var stream = std.io.fixedBufferStream(self.ctx.debug_info);
+ var stream = std.io.fixedBufferStream(self.ctx.debug_info[self.pos..]);
var creader = std.io.countingReader(stream.reader());
const reader = creader.reader();
@@ -37,7 +37,7 @@ const CompileUnitIterator = struct {
const cu = CompileUnit{
.cuh = cuh,
- .debug_info_off = offset,
+ .debug_info_off = self.pos + offset,
};
self.pos += (math.cast(usize, total_length) orelse return error.Overflow);
@@ -188,7 +188,7 @@ const AbbrevEntryIterator = struct {
return AbbrevEntry.null();
}
- const abbrev_pos = lookup.get(kind) orelse return error.MalformedDwarf;
+ const abbrev_pos = lookup.get(kind) orelse return null;
const len = try findAbbrevEntrySize(
self.ctx,
abbrev_pos.pos,
@@ -290,21 +290,6 @@ pub const Attribute = struct {
};
}
- pub fn getReference(self: Attribute, ctx: DwarfInfo) !?u64 {
- const debug_info = self.getDebugInfo(ctx);
- var stream = std.io.fixedBufferStream(debug_info);
- const reader = stream.reader();
-
- return switch (self.form) {
- dwarf.FORM.ref1 => debug_info[0],
- dwarf.FORM.ref2 => mem.readIntLittle(u16, debug_info[0..2]),
- dwarf.FORM.ref4 => mem.readIntLittle(u32, debug_info[0..4]),
- dwarf.FORM.ref8 => mem.readIntLittle(u64, debug_info[0..8]),
- dwarf.FORM.ref_udata => try leb.readULEB128(u64, reader),
- else => null,
- };
- }
-
pub fn getAddr(self: Attribute, ctx: DwarfInfo, cuh: CompileUnit.Header) ?u64 {
if (self.form != dwarf.FORM.addr) return null;
const debug_info = self.getDebugInfo(ctx);