Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv25626
Modified Files:
linkie.py
Log Message:
introduced Linkie.glue
Index: linkie.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/linkie.py,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- linkie.py 27 Apr 2003 17:59:45 -0000 1.49
+++ linkie.py 6 May 2003 17:31:30 -0000 1.50
@@ -280,6 +280,45 @@
for ofs, typ, arg in that._linker_notes:
this._linker_notes.append((ofs + thatofs, typ, arg))
# return nothing
+ def glue (this, offset, that, amp = None, perc = None):
+ # Glues /that/ into /this/ at specified /offset/ (if negative,
+ # /offset/ is treated as an alignment restriction and the actual
+ # offset is automatically calculated from that). Symbols in the
+ # form of &foo get added /amp/ and symbols in the form of %foo
+ # get added /perc/ to their values.
+ # Note that the specified alignment of /that/ is
+ # IGNORED except when /offset/ is given as None.
+
+ if this._unresolved_locals: raise 'Incomplete linkie', this
+ if that._unresolved_locals: raise 'Incomplete linkie', that
+
+ # provide sufficient padding
+ if offset == None: this.align(that.get_alignment())
+ elif offset < 0: this.align(- offset)
+ else: this.skip(offset - this.memsz())
+
+ # convert any padding to hard zeroes if needed
+ if that.filesz(): this.deskip()
+
+ # remember the start offset of /that/
+ thatofs = this.memsz()
+
+ # carry over all the bits
+ this._contents.extend(that._contents)
+ this._skipped = that._skipped
+
+ # carry over and process the symbols
+ for sym, val in that._symbols:
+ if sym[0] == '!': this._symbols.append((sym, val + thatofs))
+ elif sym[0] == '#': this._symbols.append((sym, val))
+ elif sym[0] == '&': this._symbols.append((sym, val + amp))
+ elif sym[0] == '%': this._symbols.append((sym, val + perc))
+ else: raise 'unprefixed symbol', sym
+
+ # carry over the linker notes
+ for ofs, typ, arg in that._linker_notes:
+ this._linker_notes.append((ofs + thatofs, typ, arg))
+ # return nothing
def __add__ (this, that):
this = this.copy()
this.extend(that)
|