334
|
1
|
|
2 """
|
|
3 Object files are used to store assembled code. Information contained
|
|
4 is code, symbol table and relocation information.
|
|
5 """
|
|
6
|
|
7 class Symbol:
|
|
8 def __init__(self, name, value):
|
|
9 self.name = name
|
|
10 self.value = value
|
|
11
|
|
12
|
|
13 class Relocation:
|
|
14 def __init__(self, typ):
|
|
15 pass
|
|
16
|
|
17
|
|
18 class Section:
|
|
19 def __init__(self, name):
|
|
20 self.name = name
|
|
21
|
|
22
|
|
23 class ObjectFile:
|
|
24 def __init__(self):
|
|
25 self.symbols = {}
|
|
26 self.sections = {}
|
|
27 self.relocations = []
|
|
28
|
|
29 def add_symbol(self, name, value):
|
|
30 sym = Symbol(name, value)
|
|
31 self.symbols[name] = sym
|
|
32 return sym
|