diff python/ppci/linker.py @ 354:5477e499b039

Added some sort of string functionality
author Windel Bouwman
date Thu, 13 Mar 2014 18:59:06 +0100
parents 2b02bd286fe9
children 396e5cefba13
line wrap: on
line diff
--- a/python/ppci/linker.py	Sun Mar 09 18:49:10 2014 +0100
+++ b/python/ppci/linker.py	Thu Mar 13 18:59:06 2014 +0100
@@ -103,6 +103,21 @@
     section.data[reloc.offset+1] |= (offset >> 8) & 0xF
     section.data[reloc.offset+0] = offset & 0xFF
 
+@reloc('adr_imm12')
+def apply_adr_imm12(reloc, sym, section, reloc_value):
+    assert sym.value % 4 == 0
+    assert reloc_value % 4 == 0
+    offset = (sym.value - (reloc_value + 8))
+    U = 2
+    if offset < 0:
+        offset = -offset
+        U = 1
+    assert offset < 4096
+    section.data[reloc.offset+2] |= (U << 6) #(rel24 >> 16) & 0xFF
+    section.data[reloc.offset+1] |= (offset >> 8) & 0xF
+    section.data[reloc.offset+0] = offset & 0xFF
+
+
 class Linker:
     """ Merges the sections of several object files and 
         performs relocation """