| author | |
| committer | |
| log | f551c7c581c7bf1f3324c0611a73c22f2aae82b4 |
| tree | 41e8a857c7fc2b78e3e77ca3711d30c2e38e2053 |
| parent | 5360968e03525be4d312ca61a7ba2dcb7890ec42 |
Apparently raw LLVM IR Bitcode files ("Bitstreams") may appear in
archives with LTO enabled. I observed this in the wild on
Chimera Linux.
I'm not yet sure if it's in scope for Zig to support these special
archives, but we should at least give a correct error message.1 files changed, 3 insertions(+), 0 deletions(-)
src/link/Elf/Object.zig+3| ... | ... | @@ -106,6 +106,9 @@ pub fn parseCommon( |
| 106 | 106 | const header_buffer = try Elf.preadAllAlloc(gpa, handle, offset, @sizeOf(elf.Elf64_Ehdr)); |
| 107 | 107 | defer gpa.free(header_buffer); |
| 108 | 108 | self.header = @as(*align(1) const elf.Elf64_Ehdr, @ptrCast(header_buffer)).*; |
| 109 | if (!mem.eql(u8, self.header.?.e_ident[0..4], elf.MAGIC)) { | |
| 110 | return diags.failParse(path, "not an ELF file", .{}); | |
| 111 | } | |
| 109 | 112 | |
| 110 | 113 | const em = target.toElfMachine(); |
| 111 | 114 | if (em != self.header.?.e_machine) { |