annotate python/ppci/objectfile.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 """
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
3 Object files are used to store assembled code. Information contained
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
4 is code, symbol table and relocation information.
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
5 """
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
6
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
7 class Symbol:
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
8 def __init__(self, name, value):
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
9 self.name = name
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
10 self.value = value
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
11
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
12
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
13 class Relocation:
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
14 def __init__(self, typ):
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
15 pass
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
16
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
17
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
18 class Section:
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
19 def __init__(self, name):
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
20 self.name = name
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
21
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
22
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
23 class ObjectFile:
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
24 def __init__(self):
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
25 self.symbols = {}
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
26 self.sections = {}
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
27 self.relocations = []
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
28
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
29 def add_symbol(self, name, value):
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
30 sym = Symbol(name, value)
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
31 self.symbols[name] = sym
6f4753202b9a Added more recipes
Windel Bouwman
parents:
diff changeset
32 return sym