authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-07-02 14:48:45-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2019-07-02 14:48:45-04:00
log06733c3ff5ed3d7ab0d6a3a6baae6d6699d33f8c
treea8a81037d96f586797ebe650620d91c35e688265
parent704444a6e329ee3bb7a99f8b2cc6cebde18b93cd
parent027517a0c933f7c07497497c1e8cc0700b7f02bb
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #2788 from emekoi/pdb-fix

fixed coff header parsing

2 files changed, 15 insertions(+), 11 deletions(-)

std/coff.zig+14-2
......@@ -39,6 +39,18 @@ pub const Coff = struct {
3939 guid: [16]u8,
4040 age: u32,
4141
42 pub fn init(allocator: *mem.Allocator, in_file: File) Coff {
43 return Coff{
44 .in_file = in_file,
45 .allocator = allocator,
46 .coff_header = undefined,
47 .pe_header = undefined,
48 .sections = ArrayList(Section).init(allocator),
49 .guid = undefined,
50 .age = undefined,
51 };
52 }
53
4254 pub fn loadHeader(self: *Coff) !void {
4355 const pe_pointer_offset = 0x3C;
4456
......@@ -142,10 +154,10 @@ pub const Coff = struct {
142154 }
143155
144156 pub fn loadSections(self: *Coff) !void {
145 if (self.sections.len != 0)
157 if (self.sections.len == self.coff_header.number_of_sections)
146158 return;
147159
148 self.sections = ArrayList(Section).init(self.allocator);
160 try self.sections.ensureCapacity(self.coff_header.number_of_sections);
149161
150162 var file_stream = self.in_file.inStream();
151163 const in = &file_stream.stream;
std/debug.zig+1-9
......@@ -826,15 +826,7 @@ fn openSelfDebugInfoWindows(allocator: *mem.Allocator) !DebugInfo {
826826 defer self_file.close();
827827
828828 const coff_obj = try allocator.create(coff.Coff);
829 coff_obj.* = coff.Coff{
830 .in_file = self_file,
831 .allocator = allocator,
832 .coff_header = undefined,
833 .pe_header = undefined,
834 .sections = undefined,
835 .guid = undefined,
836 .age = undefined,
837 };
829 coff_obj.* = coff.Coff.init(allocator, self_file);
838830
839831 var di = DebugInfo{
840832 .coff = coff_obj,