diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-03-11 14:30:06 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-11 14:30:06 -0500 |
| commit | b1a22fdbab4a30a91cd628037f2c7e15978607a5 (patch) | |
| tree | a39ca5fb2a19997c3eecd17593c4b223c6bac4fd /lib/std | |
| parent | f2b96782ecdc9e2f8740eb7d294203b2a585ea52 (diff) | |
| parent | 24e5959840c790ec74665d22a21d82b68418bc57 (diff) | |
| download | zig-b1a22fdbab4a30a91cd628037f2c7e15978607a5.tar.gz zig-b1a22fdbab4a30a91cd628037f2c7e15978607a5.zip | |
Merge pull request #8193 from kivikakk/elf-expose-em
elf: expose machine field in ELF header
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/elf.zig | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/std/elf.zig b/lib/std/elf.zig index 26674288a4..36382ecc42 100644 --- a/lib/std/elf.zig +++ b/lib/std/elf.zig @@ -337,6 +337,7 @@ pub const ET = extern enum(u16) { /// All integers are native endian. pub const Header = struct { endian: builtin.Endian, + machine: EM, is_64: bool, entry: u64, phoff: u64, @@ -387,8 +388,14 @@ pub const Header = struct { else => return error.InvalidElfClass, }; + const machine = if (need_bswap) blk: { + const value = @enumToInt(hdr32.e_machine); + break :blk @intToEnum(EM, @byteSwap(@TypeOf(value), value)); + } else hdr32.e_machine; + return @as(Header, .{ .endian = endian, + .machine = machine, .is_64 = is_64, .entry = int(is_64, need_bswap, hdr32.e_entry, hdr64.e_entry), .phoff = int(is_64, need_bswap, hdr32.e_phoff, hdr64.e_phoff), @@ -1518,6 +1525,8 @@ pub const EM = extern enum(u16) { /// Linux kernel bpf virtual machine _BPF = 247, + + _, }; /// Section data should be writable during execution. |
