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