diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/std/elf.zig | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/std/elf.zig b/lib/std/elf.zig index c37cc74223..147045e720 100644 --- a/lib/std/elf.zig +++ b/lib/std/elf.zig @@ -4,13 +4,13 @@ // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. const std = @import("std.zig"); -const builtin = std.builtin; const io = std.io; const os = std.os; const math = std.math; const mem = std.mem; const debug = std.debug; const File = std.fs.File; +const native_endian = @import("builtin").target.cpu.arch.endian(); pub const AT_NULL = 0; pub const AT_IGNORE = 1; @@ -336,7 +336,7 @@ pub const ET = enum(u16) { /// All integers are native endian. pub const Header = struct { - endian: builtin.Endian, + endian: std.builtin.Endian, machine: EM, is_64: bool, entry: u64, @@ -380,7 +380,7 @@ pub const Header = struct { ELFDATA2MSB => .Big, else => return error.InvalidElfEndian, }; - const need_bswap = endian != std.builtin.endian; + const need_bswap = endian != native_endian; const is_64 = switch (hdr32.e_ident[EI_CLASS]) { ELFCLASS32 => false, @@ -426,7 +426,7 @@ pub fn ProgramHeaderIterator(ParseSource: anytype) type { try self.parse_source.reader().readNoEof(mem.asBytes(&phdr)); // ELF endianness matches native endianness. - if (self.elf_header.endian == std.builtin.endian) return phdr; + if (self.elf_header.endian == native_endian) return phdr; // Convert fields to native endianness. bswapAllFields(Elf64_Phdr, &phdr); @@ -439,7 +439,7 @@ pub fn ProgramHeaderIterator(ParseSource: anytype) type { try self.parse_source.reader().readNoEof(mem.asBytes(&phdr)); // ELF endianness does NOT match native endianness. - if (self.elf_header.endian != std.builtin.endian) { + if (self.elf_header.endian != native_endian) { // Convert fields to native endianness. bswapAllFields(Elf32_Phdr, &phdr); } @@ -476,7 +476,7 @@ pub fn SectionHeaderIterator(ParseSource: anytype) type { try self.parse_source.reader().readNoEof(mem.asBytes(&shdr)); // ELF endianness matches native endianness. - if (self.elf_header.endian == std.builtin.endian) return shdr; + if (self.elf_header.endian == native_endian) return shdr; // Convert fields to native endianness. return Elf64_Shdr{ @@ -499,7 +499,7 @@ pub fn SectionHeaderIterator(ParseSource: anytype) type { try self.parse_source.reader().readNoEof(mem.asBytes(&shdr)); // ELF endianness does NOT match native endianness. - if (self.elf_header.endian != std.builtin.endian) { + if (self.elf_header.endian != native_endian) { // Convert fields to native endianness. shdr = .{ .sh_name = @byteSwap(@TypeOf(shdr.sh_name), shdr.sh_name), |
