* arm64: how to check endianness of Image file? @ 2015-08-28 22:23 Kevin Hilman 2015-09-01 14:17 ` Mark Rutland 0 siblings, 1 reply; 3+ messages in thread From: Kevin Hilman @ 2015-08-28 22:23 UTC (permalink / raw) To: linux-arm-kernel Will, Catalin, Any suggestions on a quick way to check if an arm64 kernel Image file is big-endian? We're adding more boot support for arm64 defconfig + CONFIG_CPU_BIG_ENDIAN=y to kernelci.org, and are looking for a reliable way to check the endianness of the kernel Image file, we don't have the vmlinux around to check the ELF headers. On arm32, the zImage has some magic fields set from arch/arm/boot/compressed/head.S, but arm64 doesn't have the equivalent. Kevin ^ permalink raw reply [flat|nested] 3+ messages in thread
* arm64: how to check endianness of Image file? 2015-08-28 22:23 arm64: how to check endianness of Image file? Kevin Hilman @ 2015-09-01 14:17 ` Mark Rutland 2015-09-01 14:57 ` Kevin Hilman 0 siblings, 1 reply; 3+ messages in thread From: Mark Rutland @ 2015-09-01 14:17 UTC (permalink / raw) To: linux-arm-kernel Hi Kevin, On Fri, Aug 28, 2015 at 11:23:20PM +0100, Kevin Hilman wrote: > Will, Catalin, > > Any suggestions on a quick way to check if an arm64 kernel Image file > is big-endian? > > We're adding more boot support for arm64 defconfig + > CONFIG_CPU_BIG_ENDIAN=y to kernelci.org, and are looking for a > reliable way to check the endianness of the kernel Image file, we > don't have the vmlinux around to check the ELF headers. > > On arm32, the zImage has some magic fields set from > arch/arm/boot/compressed/head.S, but arm64 doesn't have the > equivalent. We have an endianness flag in the arm64 Image header, added per your request in v3.17 [1,2]. Per Documentation/arm64/booting.txt (trimmed for context): ---- The decompressed kernel image contains a 64-byte header as follows: u32 code0; /* Executable code */ u32 code1; /* Executable code */ u64 text_offset; /* Image load offset, little endian */ u64 image_size; /* Effective Image size, little endian */ u64 flags; /* kernel flags, little endian */ u64 res2 = 0; /* reserved */ u64 res3 = 0; /* reserved */ u64 res4 = 0; /* reserved */ u32 magic = 0x644d5241; /* Magic number, little endian, "ARM\x64" */ u32 res5; /* reserved (used for PE COFF offset) */ - The flags field (introduced in v3.17) is a little-endian 64-bit field composed as follows: Bit 0: Kernel endianness. 1 if BE, 0 if LE. Bits 1-63: Reserved. ---- Kernels prior to v3.17 (where image_size is zero) don't expose the endianness explicitly, but you can figure it out by inspecting text_offset if you need to work with kernels prior to v3.17. See the notes in booting.txt for more details. Thanks, Mark. [1] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-June/264697.html [2] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-June/266023.html ^ permalink raw reply [flat|nested] 3+ messages in thread
* arm64: how to check endianness of Image file? 2015-09-01 14:17 ` Mark Rutland @ 2015-09-01 14:57 ` Kevin Hilman 0 siblings, 0 replies; 3+ messages in thread From: Kevin Hilman @ 2015-09-01 14:57 UTC (permalink / raw) To: linux-arm-kernel On Tue, Sep 1, 2015 at 7:17 AM, Mark Rutland <mark.rutland@arm.com> wrote: > Hi Kevin, > > On Fri, Aug 28, 2015 at 11:23:20PM +0100, Kevin Hilman wrote: >> Will, Catalin, >> >> Any suggestions on a quick way to check if an arm64 kernel Image file >> is big-endian? >> >> We're adding more boot support for arm64 defconfig + >> CONFIG_CPU_BIG_ENDIAN=y to kernelci.org, and are looking for a >> reliable way to check the endianness of the kernel Image file, we >> don't have the vmlinux around to check the ELF headers. >> >> On arm32, the zImage has some magic fields set from >> arch/arm/boot/compressed/head.S, but arm64 doesn't have the >> equivalent. > > We have an endianness flag in the arm64 Image header, added per your > request in v3.17 [1,2]. Doh, I completely forgot about that. :/ Thanks for the reminder! Kevin ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-09-01 14:57 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-08-28 22:23 arm64: how to check endianness of Image file? Kevin Hilman 2015-09-01 14:17 ` Mark Rutland 2015-09-01 14:57 ` Kevin Hilman
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox