From 7cc86ebe881f36bfef18d8eeee666d2a55eae892 Mon Sep 17 00:00:00 2001
From: Guilherme Iscaro <iscaro@profusion.mobi>
Date: Fri, 31 Mar 2017 10:31:49 -0300
Subject: [PATCH] Fix build on ARMv6.

The ARMv6 and older architures does not support the movw and movl
instructions, thus causing a build break.
This patch fix the problem by creating a new offlineasm instruction,
which will use the ldr instruction to load a immediate into a register.

https://bugs.webkit.org/show_bug.cgi?id=141288

Reviewed by NOBODY (OOPS!).

* llint/LowLevelInterpreter.asm:
* offlineasm/arm.rb:
* offlineasm/instructions.rb:
---
 Source/JavaScriptCore/llint/LowLevelInterpreter.asm | 8 +++++++-
 Source/JavaScriptCore/offlineasm/arm.rb             | 2 ++
 Source/JavaScriptCore/offlineasm/instructions.rb    | 3 ++-
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/Source/JavaScriptCore/llint/LowLevelInterpreter.asm b/Source/JavaScriptCore/llint/LowLevelInterpreter.asm
index ab3c0c8e771..6c32eef8852 100644
--- a/Source/JavaScriptCore/llint/LowLevelInterpreter.asm
+++ b/Source/JavaScriptCore/llint/LowLevelInterpreter.asm
@@ -1167,7 +1167,13 @@ macro setEntryAddress(index, label)
         move index, t4
         storep t1, [a0, t4, 8]
     elsif ARM or ARMv7 or ARMv7_TRADITIONAL
-        mvlbl (label - _relativePCBase), t4
+        if ARM
+           ldrlbl t4, label
+           ldrlbl t3, _relativePCBase
+           subp t4, t3, t4
+        else
+           mvlbl (label - _relativePCBase), t4
+        end
         addp t4, t1, t4
         move index, t3
         storep t4, [a0, t3, 4]
diff --git a/Source/JavaScriptCore/offlineasm/arm.rb b/Source/JavaScriptCore/offlineasm/arm.rb
index c8064a59196..a9c40c8995c 100644
--- a/Source/JavaScriptCore/offlineasm/arm.rb
+++ b/Source/JavaScriptCore/offlineasm/arm.rb
@@ -504,6 +504,8 @@ class Instruction
         when "mvlbl"
                 $asm.puts "movw #{operands[1].armOperand}, \#:lower16:#{operands[0].value}"
                 $asm.puts "movt #{operands[1].armOperand}, \#:upper16:#{operands[0].value}"
+        when "ldrlbl"
+            $asm.puts "ldr #{operands[0].armOperand}, =#{operands[1].value}"
         when "nop"
             $asm.puts "nop"
         when "bieq", "bpeq", "bbeq"
diff --git a/Source/JavaScriptCore/offlineasm/instructions.rb b/Source/JavaScriptCore/offlineasm/instructions.rb
index bbfce7193b3..8cc1cb961ce 100644
--- a/Source/JavaScriptCore/offlineasm/instructions.rb
+++ b/Source/JavaScriptCore/offlineasm/instructions.rb
@@ -261,7 +261,8 @@ X86_INSTRUCTIONS =
 ARM_INSTRUCTIONS =
     [
      "clrbp",
-     "mvlbl"
+     "mvlbl",
+     "ldrlbl"
     ]
 
 ARM64_INSTRUCTIONS =
-- 
2.12.1
