From fe10cc9d521b13a773755be8dc64fcb05a31f181 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Tue, 15 Dec 2020 15:44:43 +0100 Subject: [PATCH] Fix jitdump header magic field on big-endian platforms (#2511) The jitdump header contains a "magic" field that is defined to hold the value 0x4A695444 as u32 in native endianness. (This allows consumers of the file to detect the endianness of the platform where the file was written, and apply it when reading other fields.) However, current code always writes 0x4A695444 in little-endian byte order, even on big-endian system. This makes consumers fail when attempting to read files written on big-endian platforms. Fixed by always writing the magic in native endianness. --- crates/profiling/src/jitdump_linux.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/crates/profiling/src/jitdump_linux.rs b/crates/profiling/src/jitdump_linux.rs index e16978843f..ef6684c95f 100644 --- a/crates/profiling/src/jitdump_linux.rs +++ b/crates/profiling/src/jitdump_linux.rs @@ -249,11 +249,7 @@ impl State { let header = FileHeader { timestamp: self.get_time_stamp(), e_machine: self.get_e_machine(), - magic: if cfg!(target_endian = "little") { - 0x4A695444 - } else { - 0x4454694a - }, + magic: 0x4A695444, version: 1, size: mem::size_of::() as u32, pad1: 0,