annotate python/ppci/linker.py @ 334:6f4753202b9a

Added more recipes
author Windel Bouwman
date Thu, 13 Feb 2014 22:02:08 +0100
parents
children 582a1aaa3983
rev   line source
334
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
1
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
2 from .objectfile import ObjectFile
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
3
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
4 class Linker:
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
5 def set_symbol(self, sym):
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
6 self.dst.add_symbol(sym.name, sym.value)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
7
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
8 def link(self, objs):
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
9 self.dst = ObjectFile()
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
10 # First copy all sections into output sections:
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
11 for iobj in objs:
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
12 for sym in iobj.symbols:
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
13 print(sym)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
14 self.set_symbol(sym)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
15 # Do relocations:
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
16 # TODO
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
17 # Check that there are no more unresolved symbols:
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
18 # TODO
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
19 return self.dst