| ... | @@ -462,6 +462,8 @@ pub const ET = enum(u16) { | ... | @@ -462,6 +462,8 @@ pub const ET = enum(u16) { |
| 462 | /// Core file | 462 | /// Core file |
| 463 | CORE = 4, | 463 | CORE = 4, |
| 464 | | 464 | |
| | 465 | _, |
| | 466 | |
| 465 | /// Beginning of OS-specific codes | 467 | /// Beginning of OS-specific codes |
| 466 | pub const LOOS = 0xfe00; | 468 | pub const LOOS = 0xfe00; |
| 467 | | 469 | |
| ... | @@ -532,17 +534,21 @@ pub const Header = struct { | ... | @@ -532,17 +534,21 @@ pub const Header = struct { |
| 532 | }; | 534 | }; |
| 533 | const need_bswap = endian != native_endian; | 535 | const need_bswap = endian != native_endian; |
| 534 | | 536 | |
| | 537 | // Converting integers to exhaustive enums using `@enumFromInt` could cause a panic. |
| | 538 | comptime assert(!@typeInfo(OSABI).@"enum".is_exhaustive); |
| 535 | const os_abi: OSABI = @enumFromInt(hdr32.e_ident[EI_OSABI]); | 539 | const os_abi: OSABI = @enumFromInt(hdr32.e_ident[EI_OSABI]); |
| 536 | | 540 | |
| 537 | // The meaning of this value depends on `os_abi` so just make it available as `u8`. | 541 | // The meaning of this value depends on `os_abi` so just make it available as `u8`. |
| 538 | const abi_version = hdr32.e_ident[EI_ABIVERSION]; | 542 | const abi_version = hdr32.e_ident[EI_ABIVERSION]; |
| 539 | | 543 | |
| 540 | const @"type" = if (need_bswap) blk: { | 544 | const @"type" = if (need_bswap) blk: { |
| | 545 | comptime assert(!@typeInfo(ET).@"enum".is_exhaustive); |
| 541 | const value = @intFromEnum(hdr32.e_type); | 546 | const value = @intFromEnum(hdr32.e_type); |
| 542 | break :blk @as(ET, @enumFromInt(@byteSwap(value))); | 547 | break :blk @as(ET, @enumFromInt(@byteSwap(value))); |
| 543 | } else hdr32.e_type; | 548 | } else hdr32.e_type; |
| 544 | | 549 | |
| 545 | const machine = if (need_bswap) blk: { | 550 | const machine = if (need_bswap) blk: { |
| | 551 | comptime assert(!@typeInfo(EM).@"enum".is_exhaustive); |
| 546 | const value = @intFromEnum(hdr32.e_machine); | 552 | const value = @intFromEnum(hdr32.e_machine); |
| 547 | break :blk @as(EM, @enumFromInt(@byteSwap(value))); | 553 | break :blk @as(EM, @enumFromInt(@byteSwap(value))); |
| 548 | } else hdr32.e_machine; | 554 | } else hdr32.e_machine; |