mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
macho+zld: return null rather than error on invalid AbbrevKind
This commit is contained in:
parent
a88ffa7fa9
commit
073f9a18a9
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user