From 7c008ee6a3d84d7138db774ef85df4ac413b2406 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Tue, 30 Jul 2013 08:57:28 +0900 Subject: [PATCH] Bug 898998 - Turn BL into BLX when doing thumb call relocations and the target is ARM. r=nfroyd --- build/unix/elfhack/elfhack.cpp | 21 +++++++++++++++++++-- build/unix/elfhack/inject.c | 5 ++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/build/unix/elfhack/elfhack.cpp b/build/unix/elfhack/elfhack.cpp index fe3d4af3f6c..ed5fffce916 100644 --- a/build/unix/elfhack/elfhack.cpp +++ b/build/unix/elfhack/elfhack.cpp @@ -240,9 +240,26 @@ private: unsigned int word0 = addend & 0xffff, word1 = addend >> 16; - if (((word0 & 0xf800) != 0xf000) || ((word1 & 0x9000) != 0x9000)) + /* Encoding T4 of B.W is 10x1 ; Encoding T1 of BL is 11x1. */ + unsigned int type = (word1 & 0xd000) >> 12; + if (((word0 & 0xf800) != 0xf000) || ((type & 0x9) != 0x9)) throw std::runtime_error("R_ARM_THM_JUMP24/R_ARM_THM_CALL relocation only supported for B.W