| ... | ... | @@ -337,6 +337,7 @@ pub const ET = extern enum(u16) { |
| 337 | 337 | /// All integers are native endian. |
| 338 | 338 | pub const Header = struct { |
| 339 | 339 | endian: builtin.Endian, |
| 340 | machine: EM, |
| 340 | 341 | is_64: bool, |
| 341 | 342 | entry: u64, |
| 342 | 343 | phoff: u64, |
| ... | ... | @@ -387,8 +388,14 @@ pub const Header = struct { |
| 387 | 388 | else => return error.InvalidElfClass, |
| 388 | 389 | }; |
| 389 | 390 | |
| 391 | const machine = if (need_bswap) blk: { |
| 392 | const value = @enumToInt(hdr32.e_machine); |
| 393 | break :blk @intToEnum(EM, @byteSwap(@TypeOf(value), value)); |
| 394 | } else hdr32.e_machine; |
| 395 | |
| 390 | 396 | return @as(Header, .{ |
| 391 | 397 | .endian = endian, |
| 398 | .machine = machine, |
| 392 | 399 | .is_64 = is_64, |
| 393 | 400 | .entry = int(is_64, need_bswap, hdr32.e_entry, hdr64.e_entry), |
| 394 | 401 | .phoff = int(is_64, need_bswap, hdr32.e_phoff, hdr64.e_phoff), |
| ... | ... | @@ -1518,6 +1525,8 @@ pub const EM = extern enum(u16) { |
| 1518 | 1525 | |
| 1519 | 1526 | /// Linux kernel bpf virtual machine |
| 1520 | 1527 | _BPF = 247, |
| 1528 | |
| 1529 | _, |
| 1521 | 1530 | }; |
| 1522 | 1531 | |
| 1523 | 1532 | /// Section data should be writable during execution. |