[Wisp-cvs] wisp/users/dig linkie.py,1.51,1.52
Status: Alpha
Brought to you by:
digg
From: <di...@us...> - 2003-05-10 17:17:40
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv2638 Modified Files: linkie.py Log Message: a new try at Linkie.glue Index: linkie.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/linkie.py,v retrieving revision 1.51 retrieving revision 1.52 diff -u -d -r1.51 -r1.52 --- linkie.py 7 May 2003 06:25:40 -0000 1.51 +++ linkie.py 10 May 2003 17:17:35 -0000 1.52 @@ -241,7 +241,7 @@ this._linker_notes.append((ofs + delta, typ, arg)) return delta def paste (this, offset, that, skip_addr = 0): - # Pastes /that/ into /this/ at specified /offset/ (if negative + # Pastes /that/ into /this/ at specified /offset/ (if negative, # /offset/ is treated as an alignment restriction and the actual # offset is automatically calculated from that). # Note that the specified alignment of /that/ is IGNORED. @@ -279,6 +279,41 @@ # carry over the linker notes for ofs, typ, arg in that._linker_notes: this._linker_notes.append((ofs + thatofs, typ, arg)) + # return nothing + def glue (this, offset, that, origin): + # Pastes /that/ into /this/ at specified /offset/. + # Adds /origin/ to all &symbols in /that/ and converta sll + # relative references to &symbols in /that/ into absolute + # references. + # Note that the specified alignment and origin of /that/ are IGNORED. + + if this._unresolved_locals: raise 'Incomplete linkie', this + if that._unresolved_locals: raise 'Incomplete linkie', that + if this.memsz() > offset: raise 'Invalid overlap', (this, offset) + + # provide sufficient padding + this.skip(offset - this.memsz()) + + # convert any padding to hard zeroes if needed + if that.filesz(): this.deskip() + + # carry over all the bits + this._contents.extend(that._contents) + this._skipped = that._skipped + + # carry over the symbols + for sym, val in that._symbols: + if sym[0] == '!': this._symbols.append((sym, val + offset)) + elif sym[0] in '&': this._symbols.append((sym, val + origin)) + elif sym[0] in '#': this._symbols.append((sym, val)) + else: raise 'unprefixed symbol', sym + + # carry over the linker notes + for ofs, typ, arg in that._linker_notes: + if typ < 0: # relative? + typ = -typ + this[ofs + offset :: typ] -= ofs + origin + this._linker_notes.append((ofs + offset, typ, arg)) # return nothing def __add__ (this, that): this = this.copy() |