| ... | ... | @@ -356,7 +356,6 @@ pub const SectionHeader = struct { |
| 356 | 356 | pub const Elf = struct { |
| 357 | 357 | seekable_stream: *io.SeekableStream(anyerror, anyerror), |
| 358 | 358 | in_stream: *io.InStream(anyerror), |
| 359 | | auto_close_stream: bool, |
| 360 | 359 | is_64: bool, |
| 361 | 360 | endian: builtin.Endian, |
| 362 | 361 | file_type: FileType, |
| ... | ... | @@ -368,25 +367,23 @@ pub const Elf = struct { |
| 368 | 367 | string_section: *SectionHeader, |
| 369 | 368 | section_headers: []SectionHeader, |
| 370 | 369 | allocator: *mem.Allocator, |
| 371 | | prealloc_file: File, |
| 372 | 370 | |
| 373 | 371 | /// Call close when done. |
| 374 | | pub fn openPath(elf: *Elf, allocator: *mem.Allocator, path: []const u8) !void { |
| 372 | pub fn openPath(allocator: *mem.Allocator, path: []const u8) !Elf { |
| 375 | 373 | @compileError("TODO implement"); |
| 376 | 374 | } |
| 377 | 375 | |
| 378 | 376 | /// Call close when done. |
| 379 | | pub fn openFile(elf: *Elf, allocator: *mem.Allocator, file: File) !void { |
| 377 | pub fn openFile(allocator: *mem.Allocator, file: File) !Elf { |
| 380 | 378 | @compileError("TODO implement"); |
| 381 | 379 | } |
| 382 | 380 | |
| 383 | 381 | pub fn openStream( |
| 384 | | elf: *Elf, |
| 385 | 382 | allocator: *mem.Allocator, |
| 386 | 383 | seekable_stream: *io.SeekableStream(anyerror, anyerror), |
| 387 | 384 | in: *io.InStream(anyerror), |
| 388 | | ) !void { |
| 389 | | elf.auto_close_stream = false; |
| 385 | ) !Elf { |
| 386 | var elf: Elf = undefined; |
| 390 | 387 | elf.allocator = allocator; |
| 391 | 388 | elf.seekable_stream = seekable_stream; |
| 392 | 389 | elf.in_stream = in; |
| ... | ... | @@ -523,12 +520,12 @@ pub const Elf = struct { |
| 523 | 520 | // not a string table |
| 524 | 521 | return error.InvalidFormat; |
| 525 | 522 | } |
| 523 | |
| 524 | return elf; |
| 526 | 525 | } |
| 527 | 526 | |
| 528 | 527 | pub fn close(elf: *Elf) void { |
| 529 | 528 | elf.allocator.free(elf.section_headers); |
| 530 | | |
| 531 | | if (elf.auto_close_stream) elf.prealloc_file.close(); |
| 532 | 529 | } |
| 533 | 530 | |
| 534 | 531 | pub fn findSection(elf: *Elf, name: []const u8) !?*SectionHeader { |