From 0687c9a57ae6ffef878ef6e80f82422f784e632b Mon Sep 17 00:00:00 2001 From: John Reiser Date: Sun, 19 Nov 2006 14:28:15 -0800 Subject: [PATCH] PackLinuxElf32::ARM_buildLoader endianness bugs --- src/p_lx_elf.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp index ef5d56c2..b3bb176d 100644 --- a/src/p_lx_elf.cpp +++ b/src/p_lx_elf.cpp @@ -1494,7 +1494,7 @@ ARM_getFilters(bool const isBE) { static const int f50[] = { 0x50, -1 }; static const int f51[] = { 0x51, -1 }; - if (HostPolicy::isBE ^ isBE) + if (isBE) return f51; return f50; } @@ -1517,7 +1517,7 @@ PackLinuxElf32::ARM_buildLoader(const Filter *ft, bool const isBE) unsigned const sz_loader = sizeof(linux_elf32arm_loader); unsigned const sz_fold = sizeof(linux_elf32arm_fold); - // Was ARM code assembled for same endianness as the target? + // Was ARM stub assembled for same endianness as the target? bool const asm_brev = (this->ei_data != ((Elf32_Ehdr const *)linux_elf32arm_fold)->e_ident[Elf32_Ehdr::EI_DATA] ); @@ -1525,17 +1525,15 @@ PackLinuxElf32::ARM_buildLoader(const Filter *ft, bool const isBE) memcpy(tmp_fold, linux_elf32arm_fold, sz_fold); // 0xe3530050 is "cmp fid,#0x50" with fid .req r3 - if (HostPolicy::isBE ^ isBE) { // change filter 0x50 to filter 0x51 - if (HostPolicy::isBE ^ isBE ^ asm_brev) { // find 0xe3530050 big-endian - checkPatch(NULL,0,0,0); // reset + if (isBE) { // change filter 0x50 to filter 0x51 + checkPatch(NULL,0,0,0); // reset + if (!asm_brev) { // find 0xe3530050 big-endian patch_be32(tmp_fold, sz_fold, "\xe3\x53\x00\x50", 0xe3530051); - checkPatch(NULL,0,0,0); // reset } else { // find 0xe3530050 little-endian - checkPatch(NULL,0,0,0); // reset patch_le32(tmp_fold, sz_fold, "\x50\x00\x53\xe3", 0xe3530051); - checkPatch(NULL,0,0,0); // reset } + checkPatch(NULL,0,0,0); // reset } if (!asm_brev) { // was assembled to match target buildLinuxLoader(linux_elf32arm_loader, sz_loader,