diff python/ppci/linker.py @ 365:98ff43cfdd36

Nasty bug in adr instruction
author Windel Bouwman
date Wed, 19 Mar 2014 22:32:04 +0100
parents c49459768aaa
children 9667d78ba79e
line wrap: on
line diff
--- a/python/ppci/linker.py	Wed Mar 19 20:24:03 2014 +0100
+++ b/python/ppci/linker.py	Wed Mar 19 22:32:04 2014 +0100
@@ -2,6 +2,7 @@
 import struct
 from .objectfile import ObjectFile
 from . import CompilerError
+from .bitfun import encode_imm32
 
 def align(x, m):
     while ((x % m) != 0):
@@ -99,7 +100,7 @@
         offset = -offset
         U = 0
     assert offset < 4096
-    section.data[reloc.offset+2] |= (U << 7) #(rel24 >> 16) & 0xFF
+    section.data[reloc.offset+2] |= (U << 7)
     section.data[reloc.offset+1] |= (offset >> 8) & 0xF
     section.data[reloc.offset+0] = offset & 0xFF
 
@@ -113,6 +114,7 @@
         offset = -offset
         U = 1
     assert offset < 4096
+    offset = encode_imm32(offset)
     section.data[reloc.offset+2] |= (U << 6)
     section.data[reloc.offset+1] |= (offset >> 8) & 0xF
     section.data[reloc.offset+0] = offset & 0xFF