diff python/ppci/linker.py @ 383:173e20a47fda

Added linker description loader
author Windel Bouwman
date Sun, 27 Apr 2014 17:40:39 +0200
parents 6df89163e114
children d056b552d3f4
line wrap: on
line diff
--- a/python/ppci/linker.py	Sun Apr 27 12:24:21 2014 +0200
+++ b/python/ppci/linker.py	Sun Apr 27 17:40:39 2014 +0200
@@ -3,6 +3,8 @@
 from .objectfile import ObjectFile
 from . import CompilerError
 from .bitfun import encode_imm32
+from .layout import Layout, Section
+
 
 def align(x, m):
     while ((x % m) != 0):
@@ -138,12 +140,15 @@
 
     def link(self, objs, layout):
         assert type(objs) is list
+        assert type(layout) is Layout
         # Create new object file to store output:
         self.dst = ObjectFile()
 
         # Create sections with address:
-        for section_name, address in layout.items():
-            self.dst.get_section(section_name).address = address
+        for mem in layout.mems:
+            for inp in mem.inputs:
+                if type(inp) is Section:
+                    self.dst.get_section(inp.section_name).address = mem.location
 
         # First copy all sections into output sections:
         for iobj in objs: