[Wisp-cvs] wisp/users/dig linkie.py,1.57,1.58
Status: Alpha
Brought to you by:
digg
From: <di...@us...> - 2003-05-13 12:58:50
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv12925 Modified Files: linkie.py Log Message: dropped Linkie._origin Index: linkie.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/linkie.py,v retrieving revision 1.57 retrieving revision 1.58 diff -u -d -r1.57 -r1.58 --- linkie.py 13 May 2003 12:49:26 -0000 1.57 +++ linkie.py 13 May 2003 12:58:46 -0000 1.58 @@ -19,7 +19,6 @@ this._skipped = 0 # uninitialized space after bits this._locals = [] # label no -> address this._unresolved_locals = [] # order is irrelevant - this._origin = 0 # the base address of this linkie this._linker_notes = [] # list of (location, type, data) def notify_linker (this, offset, type, arg): @@ -106,8 +105,6 @@ def place_symbol (this, symbol, value = None): """place_symbol(symbol, value = None) => value Places a globally visible symbol in the linkie. - Takes care of adding the base address if the symbol - starts in '&' or '%'. Does NOT check uniqueness. None signifies the current offset.""" if not isinstance(symbol, str): raise 'Not a string', symbol @@ -115,7 +112,6 @@ if not symbol[0] in '#&!%': raise 'unprefixed symbol being placed', symbol if value == None: value = len(this._contents) + this._skipped - if symbol[0] in '&%': value += this._origin this._symbols.append((symbol, value)) return value def __ior__ (this, symbol): @@ -124,11 +120,7 @@ def align (this, boundary): """align(boundary) Ensures that the following byte's memory address is divisible by - the specified boundary (which must be a power of 2). Error if - the current base address doesn't match the alignment.""" - if (this._origin % boundary) != 0: - raise 'Base address violates new alignment', \ - (this._origin, boundary) + the specified boundary (which must be a power of 2).""" if this._alignment < boundary: this._alignment = boundary delta = (boundary - 1) & - (len(this._contents) + this._skipped) if this._skipped: @@ -181,8 +173,6 @@ Returns length of the linker note list of this linkie.""" if this._unresolved_locals: raise 'Incomplete linkie', this return len(this._linker_notes) - def get_origin (this): - return this._origin def copy (this): if this._unresolved_locals: raise 'Incomplete linkie', this @@ -192,16 +182,14 @@ that._skipped = this._skipped that._symbols = this._symbols[:] that._linker_notes = this._linker_notes[:] - that._origin = this._origin return that def extend (this, that): # Returns the offset of /that/ inside /this/ after extension. if this._unresolved_locals: raise 'Incomplete linkie', this if that._unresolved_locals: raise 'Incomplete linkie', that - this._origin = 0 if that.filesz(): this.deskip() this.align(that._alignment) - delta = this.memsz() - that._origin + delta = this.memsz() this._contents.extend(that._contents) this._skipped = that._skipped for sym, val in that._symbols: @@ -299,8 +287,7 @@ if type in (1, 2, 4): this[offset::type] += symbols[arg] elif type in (-1, -2, -4): - this[offset::-type] += \ - symbols[arg] - (this._origin + offset) + this[offset::-type] += symbols[arg] - offset else: raise 'Invalid linker note type', (offset, type, arg) del this._linker_notes[i] return len(this._linker_notes) @@ -309,14 +296,12 @@ filesz = len(this._contents) skipsz = this._skipped memsz = filesz + skipsz - origin = this._origin - print 'Linkie (0x%x + 0x%x = 0x%x @ 0x%x)' % \ - (filesz, skipsz, memsz, origin), + print 'Linkie (0x%x + 0x%x = 0x%x)' % \ + (filesz, skipsz, memsz), print 'aligned at 0x%x' % this._alignment rsymbols = {}; othersymbols = [] rnotes = {}; othernotes = [] for sym, val in this._symbols: - if sym[0] == '&': val -= this._origin if sym[0] != '#' and 0 <= val < this.memsz(): if rsymbols.has_key(val): rsymbols[val].append(sym) else: rsymbols[val] = [sym] |