diff python/ppci/linker.py @ 345:b4882ff0ed06

Added more arm isa tests
author Windel Bouwman
date Sun, 02 Mar 2014 17:12:08 +0100
parents d1ecc493384e
children 442fb043d149
line wrap: on
line diff
--- a/python/ppci/linker.py	Sat Mar 01 16:32:27 2014 +0100
+++ b/python/ppci/linker.py	Sun Mar 02 17:12:08 2014 +0100
@@ -76,6 +76,18 @@
     section.data[reloc.offset] |= imm6
     section.data[reloc.offset + 1] |= (s << 2)
 
+# ARM reloc!!
+# TODO: move to target classes???
+@reloc('b_imm24')
+def apply_b_imm24(reloc, sym, section, reloc_value):
+    assert sym.value % 4 == 0
+    assert reloc_value % 4 == 0
+    offset = (sym.value - (reloc_value + 8))
+    rel24 = wrap_negative(offset >> 2, 24)
+    section.data[reloc.offset+2] = (rel24 >> 16) & 0xFF
+    section.data[reloc.offset+1] = (rel24 >> 8) & 0xFF
+    section.data[reloc.offset+0] = rel24 & 0xFF
+
 
 class Linker:
     """ Merges the sections of several object files and