wisp-cvs Mailing List for Wisp interpreter (Page 9)
Status: Alpha
Brought to you by:
digg
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(30) |
Sep
(312) |
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(5) |
Feb
(131) |
Mar
(17) |
Apr
(184) |
May
(252) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
From: <di...@us...> - 2003-05-13 21:17:05
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv25842 Modified Files: make-pe-exe.py Log Message: don't attempt to place symbol sums Index: make-pe-exe.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- make-pe-exe.py 13 May 2003 21:07:37 -0000 1.48 +++ make-pe-exe.py 13 May 2003 21:17:03 -0000 1.49 @@ -276,7 +276,7 @@ # emit thunk lists for dll in imports_by_dlls.keys(): imports.align(4) - imports.place_symbol('&.imports/%s/first-thunk #rva' % dll) + imports.place_symbol('&.imports/%s/first-thunk' % dll) for sym in imports_by_dlls[dll].keys(): imports.place_symbol('&.imports/slot/' + sym + '@' + dll) imports.emit_tetra_sum(['&.imports/thunk/%s@%s #rva' % (sym, dll)]) @@ -291,7 +291,7 @@ imports[::1] = 0 # emit DLL names for dll in imports_by_dlls.keys(): - imports.place_symbol('&.imports/%s/dll-name #rva' % dll) + imports.place_symbol('&.imports/%s/dll-name' % dll) imports.emit_string(dll + '.dll') imports[::1] = 0 |
From: <di...@us...> - 2003-05-13 21:07:40
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv21813 Modified Files: make-pe-exe.py Log Message: use clearer syntax Index: make-pe-exe.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v retrieving revision 1.47 retrieving revision 1.48 diff -u -d -r1.47 -r1.48 --- make-pe-exe.py 13 May 2003 21:04:20 -0000 1.47 +++ make-pe-exe.py 13 May 2003 21:07:37 -0000 1.48 @@ -108,15 +108,15 @@ t = Linkie('<') t.align(4) t.emit_string((name + '\0' * 8)[:8]) - t.emit_tetra_sum(['#%s/memsz' % name]) - t.emit_tetra_sum(['&%s #rva' % name]) - t.emit_tetra_sum(['#%s/filesz' % name]) - t.emit_tetra_sum(['!%s' % name]) - t.emit_tetra_sum(['!%s/reloc' % name]) - t.emit_tetra_sum(['!%s/lineno' % name]) - t.emit_wyde_sum(['#%s/reloc' % name]) - t.emit_wyde_sum(['#%s/lineno' % name]) - t.emit_tetra_sum(['#%s/flags' % name]) + t[::4] = '#%s/memsz' % name + t[::4] = '&%s #rva' % name + t[::4] = '#%s/filesz' % name + t[::4] = '!%s' % name + t[::4] = '!%s/reloc' % name + t[::4] = '!%s/lineno' % name + t[::2] = '#%s/reloc' % name + t[::2] = '#%s/lineno' % name + t[::4] = '#%s/flags' % name return t def make_pe_aout_header (): |
From: <di...@us...> - 2003-05-13 21:04:24
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv20370 Modified Files: make-pe-exe.py Log Message: use clearer syntax Index: make-pe-exe.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v retrieving revision 1.46 retrieving revision 1.47 diff -u -d -r1.46 -r1.47 --- make-pe-exe.py 13 May 2003 18:13:22 -0000 1.46 +++ make-pe-exe.py 13 May 2003 21:04:20 -0000 1.47 @@ -209,9 +209,9 @@ text[::1] = 0x68; text[::4] = 15 # push 15 text[::1] = 0x68; text[::4] = '&message' # push &message text[::1] = 0x50 # push %eax -text.emit_byte(0xe8); text.emit_tetra_sum(['&WriteFile@kernel32'], delta = -4, relative = 1) # call WriteFile -text.emit_byte(0x68); text.emit_tetra(0) # push 0 -text.emit_byte(0xe8); text.emit_tetra_sum(['&ExitProcess@kernel32'], delta = -4, relative = 1) # call ExitProcess +text[::1] = 0xe8; text.emit_tetra_sum(['&WriteFile@kernel32'], delta = -4, relative = 1) # call WriteFile +text[::1] = 0x68; text[::4] = 0 # push 0 +text[::1] = 0xe8; text.emit_tetra_sum(['&ExitProcess@kernel32'], delta = -4, relative = 1) # call ExitProcess print 'TEXT'; text.dump() @@ -286,22 +286,21 @@ for sym in imports_by_dlls[dll].keys(): imports.place_symbol('&.imports/thunk/%s@%s #rva' % (sym, dll)) imports.align(2) - imports.emit_wyde(0) # ordinal + imports[::2] = 0 # ordinal imports.emit_string(sym) - imports.emit_byte(0) + imports[::1] = 0 # emit DLL names for dll in imports_by_dlls.keys(): imports.place_symbol('&.imports/%s/dll-name #rva' % dll) imports.emit_string(dll + '.dll') - imports.emit_byte(0) + imports[::1] = 0 # generate stub procedures for dll in imports_by_dlls.keys(): for sym in imports_by_dlls[dll].keys(): istubs.align(8) istubs.place_symbol('&' + sym + '@' + dll) - istubs.emit_byte(0xFF) - istubs.emit_byte(0x25) + istubs[::1] = 0xFF, 0x25 istubs.emit_tetra_sum(['&.imports/slot/' + sym + '@' + dll]) # paste sections together |
From: <di...@us...> - 2003-05-13 18:19:19
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv8126 Modified Files: tran.py Log Message: inlined mainloop into main Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.66 retrieving revision 1.67 diff -u -d -r1.66 -r1.67 --- tran.py 22 Apr 2003 17:34:09 -0000 1.66 +++ tran.py 13 May 2003 18:15:53 -0000 1.67 @@ -274,13 +274,6 @@ State = outer_state Registers = {Generic_Register: 'reg'} # for reverse translation -def mainloop (): - tok = prep.get_token() - while tok <> None: - if verbose: print '(%s) %s' % (' '.join(map(str, Regstack)), tok) - State(tok) - tok = prep.get_token() - verbose = 0 def main (): @@ -305,7 +298,11 @@ if len(args) != 1: raise 'Invalid argument count -- must be 1', args prep = Preprocessor(args[0]) - mainloop() + tok = prep.get_token() + while tok <> None: + if verbose: print '(%s) %s' % (' '.join(map(str, Regstack)), tok) + State(tok) + tok = prep.get_token() print 'TEXT'; Text.dump() print 'DATA'; Data.dump() print 'BSS'; Bss.dump() |
From: <di...@us...> - 2003-05-13 18:13:25
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv6978 Modified Files: make-pe-exe.py Log Message: use clearer syntax Index: make-pe-exe.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v retrieving revision 1.45 retrieving revision 1.46 diff -u -d -r1.45 -r1.46 --- make-pe-exe.py 13 May 2003 18:00:17 -0000 1.45 +++ make-pe-exe.py 13 May 2003 18:13:22 -0000 1.46 @@ -202,13 +202,13 @@ text = Linkie('<') # ia32 text.place_symbol('&_start') -text.emit_byte(0x68); text.emit_tetra(-11 % 0x100000000) # push -11 -text.emit_byte(0xe8); text.emit_tetra_sum(['&GetStdHandle@kernel32'], delta = -4, relative = 1) # call GetStdHandle -text.emit_byte(0x68); text.emit_tetra(0) # push 0 -text.emit_byte(0x68); text.emit_tetra_sum(['&rckeep']) # push &rckeep -text.emit_byte(0x68); text.emit_tetra(15) # push 15 -text.emit_byte(0x68); text.emit_tetra_sum(['&message']) # push &message -text.emit_byte(0x50) # push %eax +text[::1] = 0x68; text[::4] = -11 # push -11 +text[::1] = 0xe8; text.emit_tetra_sum(['&GetStdHandle@kernel32'], delta = -4, relative = 1) # call GetStdHandle +text[::1] = 0x68; text[::4] = 0 # push 0 +text[::1] = 0x68; text[::4] = '&rckeep' # push &rckeep +text[::1] = 0x68; text[::4] = 15 # push 15 +text[::1] = 0x68; text[::4] = '&message' # push &message +text[::1] = 0x50 # push %eax text.emit_byte(0xe8); text.emit_tetra_sum(['&WriteFile@kernel32'], delta = -4, relative = 1) # call WriteFile text.emit_byte(0x68); text.emit_tetra(0) # push 0 text.emit_byte(0xe8); text.emit_tetra_sum(['&ExitProcess@kernel32'], delta = -4, relative = 1) # call ExitProcess |
From: <di...@us...> - 2003-05-13 18:00:23
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv31367 Modified Files: make-pe-exe.py Log Message: don't link result of make_mz_prefix before returning Index: make-pe-exe.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- make-pe-exe.py 13 May 2003 17:56:07 -0000 1.44 +++ make-pe-exe.py 13 May 2003 18:00:17 -0000 1.45 @@ -60,7 +60,6 @@ b.emit_string(message) b.place_symbol('#mz/bytes-in-last-block', b.filesz() % 0x200) b.place_symbol('#mz/blocks-in-file', (b.filesz() + 0x1FF) / 0x200) - b.link() return b def make_coff_header (): |
From: <di...@us...> - 2003-05-13 17:56:11
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv28728 Modified Files: make-pe-exe.py Log Message: use clearer syntax Index: make-pe-exe.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v retrieving revision 1.43 retrieving revision 1.44 diff -u -d -r1.43 -r1.44 --- make-pe-exe.py 13 May 2003 17:52:37 -0000 1.43 +++ make-pe-exe.py 13 May 2003 17:56:07 -0000 1.44 @@ -52,10 +52,10 @@ b.place_symbol('&mz/message', b.filesz() - 1) b.emit_string(message[1:]) b.emit_string('\x00' * (0x003C - b.filesz())) - b.emit_tetra_sum(['!pe']) + b[::4] = '!pe' else: b.emit_string('\x00' * (0x003C - b.filesz())) - b.emit_tetra_sum(['!pe']) + b[::4] = '!pe' b.place_symbol('&mz/message') b.emit_string(message) b.place_symbol('#mz/bytes-in-last-block', b.filesz() % 0x200) |
From: <di...@us...> - 2003-05-13 17:52:41
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv26489 Modified Files: make-pe-exe.py Log Message: use clearer syntax Index: make-pe-exe.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- make-pe-exe.py 13 May 2003 13:28:47 -0000 1.42 +++ make-pe-exe.py 13 May 2003 17:52:37 -0000 1.43 @@ -23,7 +23,7 @@ if message.find('\r') == -1: # if no CRs, insert them message = '\r\n'.join(message.split('\n')) b = Linkie('<') - b.emit_string('MZ') # 'MZ' + b[::2] = 0x4d, 0x5a # 'MZ' b[::2] = '#mz/bytes-in-last-block', '#mz/blocks-in-file' b[::2] = 0 # no relocation b[::2] = 0 # empty MZ header--load it all into memory @@ -109,15 +109,15 @@ t = Linkie('<') t.align(4) t.emit_string((name + '\0' * 8)[:8]) - t.emit_tetra_sum(['#' + name + '/memsz']) - t.emit_tetra_sum(['&' + name, '#rva']) - t.emit_tetra_sum(['#' + name + '/filesz']) - t.emit_tetra_sum(['!' + name]) - t.emit_tetra_sum(['!' + name + '/reloc']) - t.emit_tetra_sum(['!' + name + '/lineno']) - t.emit_wyde_sum(['#' + name + '/reloc']) - t.emit_wyde_sum(['#' + name + '/lineno']) - t.emit_tetra_sum(['#' + name + '/flags']) + t.emit_tetra_sum(['#%s/memsz' % name]) + t.emit_tetra_sum(['&%s #rva' % name]) + t.emit_tetra_sum(['#%s/filesz' % name]) + t.emit_tetra_sum(['!%s' % name]) + t.emit_tetra_sum(['!%s/reloc' % name]) + t.emit_tetra_sum(['!%s/lineno' % name]) + t.emit_wyde_sum(['#%s/reloc' % name]) + t.emit_wyde_sum(['#%s/lineno' % name]) + t.emit_tetra_sum(['#%s/flags' % name]) return t def make_pe_aout_header (): |
From: <di...@us...> - 2003-05-13 13:42:37
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv32067 Modified Files: linkie.py Log Message: dropped Linkie.paste Index: linkie.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/linkie.py,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- linkie.py 13 May 2003 13:20:21 -0000 1.60 +++ linkie.py 13 May 2003 13:42:34 -0000 1.61 @@ -199,46 +199,6 @@ for ofs, typ, arg in that._linker_notes: 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, - # /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. - # Origin of /this/ *should* be zero. - - 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] in '&%': - if not skip_addr: this._symbols.append((sym, val)) - 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 glue (this, offset, that, origin): # Pastes /that/ into /this/ at specified /offset/. # Adds /origin/ to all &symbols in /that/ and converta sll |
From: <di...@us...> - 2003-05-13 13:28:50
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv25213 Modified Files: make-pe-exe.py Log Message: use cleaner syntax Index: make-pe-exe.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- make-pe-exe.py 13 May 2003 12:47:35 -0000 1.41 +++ make-pe-exe.py 13 May 2003 13:28:47 -0000 1.42 @@ -124,15 +124,11 @@ h = Linkie('<') h.align(4) # #aout/magic = 0x10B - h.emit_wyde_sum(['#aout/magic']) - h.emit_byte_sum(['#aout/linker-version-major']) - h.emit_byte_sum(['#aout/linker-version-minor']) - h.emit_tetra_sum(['#aout/text-size']) - h.emit_tetra_sum(['#aout/data-size']) - h.emit_tetra_sum(['#aout/bss-size']) - h.emit_tetra_sum(['&_start', '#rva']) - h.emit_tetra_sum(['&.text', '#rva']) - h.emit_tetra_sum(['&.data', '#rva']) # not present in PE32+ (?) + h[::2] = '#aout/magic' + h[::1] = '#aout/linker-version-major', '#aout/linker-version-minor' + h[::4] = '#aout/text-size', '#aout/data-size', '#aout/bss-size' + h[::4] = '&_start #rva', '&.text #rva', + h[::4] = '&.data #rva' # not present in PE32+ (?) # #aout/image-base must be multiple of 64ki h.emit_tetra_sum(['#aout/image-base']) h.emit_tetra_sum(['#aout/memory-align']) |
From: <di...@us...> - 2003-05-13 13:20:24
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv21599 Modified Files: linkie.py Log Message: added Linkie.__slots__ Index: linkie.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/linkie.py,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- linkie.py 13 May 2003 13:20:04 -0000 1.59 +++ linkie.py 13 May 2003 13:20:21 -0000 1.60 @@ -11,7 +11,7 @@ class Linkie (Bits): __slots__ = ['_skipped', '_byte_order', '_symbols', '_alignment', - '_skipped', '_locals', '_unresolved_locals', '_linker_notes'] + '_locals', '_unresolved_locals', '_linker_notes'] def __init__ (this, byte_order = None): Bits.__init__(this, byte_order) this._skipped = 0 |
From: <di...@us...> - 2003-05-13 13:20:09
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv21491 Modified Files: linkie.py Log Message: added Linkie.__slots__ Index: linkie.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/linkie.py,v retrieving revision 1.58 retrieving revision 1.59 diff -u -d -r1.58 -r1.59 --- linkie.py 13 May 2003 12:58:46 -0000 1.58 +++ linkie.py 13 May 2003 13:20:04 -0000 1.59 @@ -10,6 +10,8 @@ from array import array class Linkie (Bits): + __slots__ = ['_skipped', '_byte_order', '_symbols', '_alignment', + '_skipped', '_locals', '_unresolved_locals', '_linker_notes'] def __init__ (this, byte_order = None): Bits.__init__(this, byte_order) this._skipped = 0 |
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] |
From: <di...@us...> - 2003-05-13 12:49:28
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv9298 Modified Files: linkie.py Log Message: dropped Linkie.set_origin Index: linkie.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/linkie.py,v retrieving revision 1.56 retrieving revision 1.57 diff -u -d -r1.56 -r1.57 --- linkie.py 12 May 2003 20:52:34 -0000 1.56 +++ linkie.py 13 May 2003 12:49:26 -0000 1.57 @@ -135,21 +135,6 @@ this._skipped += delta else: this._contents.fromstring(delta * '\0') - def set_origin (this, origin): - """set_origin(origin) - Sets the base address of the linkie to the specified value. - Recalculates the &foo symbols. Does NOT influence - already resolved references to changing labels, so be careful - if using after partial linkage.""" - if (origin % this._alignment) != 0: - raise 'New base address violates alignment', \ - (origin, this._alignment) - delta = origin - this._origin - for i in range(len(this._symbols)): - symbol, value = this._symbols[i] - if symbol[0] in '&': - this._symbols[i] = symbol, value + delta - this._origin = origin def get_file (this, force = 0): """get_file() -> array of chars |
From: <di...@us...> - 2003-05-13 12:47:37
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv8072 Modified Files: make-pe-exe.py Log Message: prefer Linkie.glue to Linkie.pastte throughout make-pe-exe.py Index: make-pe-exe.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- make-pe-exe.py 11 May 2003 09:45:42 -0000 1.40 +++ make-pe-exe.py 13 May 2003 12:47:35 -0000 1.41 @@ -17,12 +17,12 @@ return (value + boundary - 1) & ~(boundary - 1) def make_mz_prefix (message = 'OS too broken'): + # The result's assumed origin address is 0x100. if message.find('$') != -1: raise 'MZ message may not contain dollar signs', message if message.find('\r') == -1: # if no CRs, insert them message = '\r\n'.join(message.split('\n')) b = Linkie('<') - b.set_origin(0x100) b.emit_string('MZ') # 'MZ' b[::2] = '#mz/bytes-in-last-block', '#mz/blocks-in-file' b[::2] = 0 # no relocation @@ -235,14 +235,15 @@ sections = {'.text': text, '.istubs': istubs, '.data': data, '.bss': bss, '.imports': imports} sectnames = ['.text', '.istubs', '.data', '.bss', '.imports'] -e = Linkie('<'); e.paste(0, make_mz_prefix('OS too broken')) +e = Linkie('<'); +e.glue(0, make_mz_prefix('OS too broken'), 0x100) e.align(8) # PE header must be aligned to 8 e.place_symbol('!pe') e.emit_string('PE\0\0') -e.paste(None, make_coff_header()) -e.paste(None, make_pe_aout_header()) +e.glue(e.memsz(), make_coff_header(), None) +e.glue(e.memsz(), make_pe_aout_header(), None) for s in sectnames: - e.paste(None, make_section_header(s)) + e.glue(e.memsz(), make_section_header(s), None) e.place_symbol('!' + s + '/reloc', 0) e.place_symbol('!' + s + '/lineno', 0) e.place_symbol('#' + s + '/reloc', 0) @@ -319,15 +320,14 @@ # memory alignment memory_boundary = roundup(memory_boundary, \ max(0x1000, sections[s].get_alignment())) - # establish origin - sections[s].set_origin(memory_boundary) + # establish origin symbols e.place_symbol('!' + s) e.place_symbol('&' + s, memory_boundary) # process sizes e.place_symbol('#' + s + '/memsz', sections[s].memsz()) e.place_symbol('#' + s + '/filesz', roundup(sections[s].filesz(), 0x200)) # paste bits - e.paste(-1, sections[s]) + e.glue(e.memsz(), sections[s], memory_boundary) # increase memory_boundary memory_boundary = roundup(memory_boundary + sections[s].memsz(), 4096) |
From: <di...@us...> - 2003-05-13 12:34:58
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv2358 Modified Files: elf.py Log Message: prefer Linkie.glue to Linkie.pastte throughout elf.py Index: elf.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/elf.py,v retrieving revision 1.54 retrieving revision 1.55 diff -u -d -r1.54 -r1.55 --- elf.py 12 May 2003 21:36:02 -0000 1.54 +++ elf.py 13 May 2003 12:34:55 -0000 1.55 @@ -503,7 +503,7 @@ binary = Linkie('<') memory_boundary = memory_bottom # must be at page boundary - binary.paste(0, make_ELF32_header('<', reloc = want_relocatable)) + binary.glue(0, make_ELF32_header('<', reloc = want_relocatable), None) if want_relocatable: binary.place_symbol('#elf/type', ET.REL) else: @@ -540,7 +540,8 @@ for name in shentnames: if guess_ELF32_pflags(name) <> 0: phentnames.append(name) - binary.paste(-4, make_ELF32_phtable('<', phentnames)) + binary.align(4) + binary.glue(binary.memsz(), make_ELF32_phtable('<', phentnames), None) for name in shentnames: sections['.shstrtab'].emit_entry(name, '#.shstrtab/strings/' + name) @@ -612,7 +613,8 @@ # create section header table section_header_table = make_ELF32_shtable('<', shentnames, zero_addresses = want_relocatable) - binary.paste(-4, section_header_table) + binary.align(4) + binary.glue(binary.memsz(), section_header_table, None) binary.place_symbol('#elf/shstrndx', shentnames.index('.shstrtab') + 1) binary.link() return binary |
From: <di...@us...> - 2003-05-12 21:36:06
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv16831 Modified Files: elf.py Log Message: made make_ELF32_object not call set_origin on the linkees Index: elf.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/elf.py,v retrieving revision 1.53 retrieving revision 1.54 diff -u -d -r1.53 -r1.54 --- elf.py 6 May 2003 16:22:58 -0000 1.53 +++ elf.py 12 May 2003 21:36:02 -0000 1.54 @@ -491,7 +491,7 @@ def make_ELF32_object (text = None, data = None, bss = None, flags = '', memory_bottom = 0x08048000): - # Will set given sections' origins. + # Will NOT set given sections' origins. want_symbols = 's' in flags want_relocatable = 'r' in flags if bss <> None and bss.filesz() <> 0: @@ -562,17 +562,17 @@ offset = binary.filesz() if p_flags == 0: - section.set_origin(0) + org = 0 binary.place_symbol('&' + name, 0) elif want_relocatable: - section.set_origin(0) + org = 0 else: address = memory_boundary | (offset & 0xFFF) # take into account alignments larger than a page address = (address + alignment - 1) & ~(alignment - 1) binary.place_symbol('#' + name + '/p_flags', p_flags) binary.place_symbol('#' + name + '/p_type', guess_ELF32_ptype(name)) - section.set_origin(address) + org = address binary.place_symbol('&' + name, address) binary.place_symbol('#' + name + '/memsz', section.memsz()) @@ -599,7 +599,7 @@ # alignment has been processed already binary.place_symbol('!' + name) - binary.paste(-1, section, skip_addr = want_relocatable) + binary.glue(binary.memsz(), section, org) if want_symbols: symtab = sections['.symtab'] for symbol, value in section.get_symbols(): |
From: <di...@us...> - 2003-05-12 20:52:37
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv19771 Modified Files: linkie.py Log Message: dropped Linkie._origin_secondary Index: linkie.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/linkie.py,v retrieving revision 1.55 retrieving revision 1.56 diff -u -d -r1.55 -r1.56 --- linkie.py 11 May 2003 09:50:43 -0000 1.55 +++ linkie.py 12 May 2003 20:52:34 -0000 1.56 @@ -20,7 +20,6 @@ this._locals = [] # label no -> address this._unresolved_locals = [] # order is irrelevant this._origin = 0 # the base address of this linkie - this._origin_secondary = 0 # support MS-style RVAs (%foo symbols) this._linker_notes = [] # list of (location, type, data) def notify_linker (this, offset, type, arg): |
From: <di...@us...> - 2003-05-11 10:03:10
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv3719 Modified Files: linkie.py make-pe-exe.py Log Message: dropped Linkie.set_secondary_origin Index: linkie.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/linkie.py,v retrieving revision 1.53 retrieving revision 1.54 diff -u -d -r1.53 -r1.54 --- linkie.py 10 May 2003 19:03:03 -0000 1.53 +++ linkie.py 11 May 2003 09:45:41 -0000 1.54 @@ -151,21 +151,6 @@ if symbol[0] in '&': this._symbols[i] = symbol, value + delta this._origin = origin - def set_secondary_origin (this, origin): - """set_secondary_origin(origin) - Sets the secondary base address of the linkie to the specified - value. Recalculates the %foo symbols. Does NOT influence - already resolved references to changing labels, so be careful - if using after partial linkage.""" - if (origin % this._alignment) != 0: - raise 'New base address violates alignment', \ - (origin, this._alignment) - delta = origin - this._origin_secondary - for i in range(len(this._symbols)): - symbol, value = this._symbols[i] - if symbol[0] in '%': - this._symbols[i] = symbol, value + delta - this._origin_secondary = origin def get_file (this, force = 0): """get_file() -> array of chars Index: make-pe-exe.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- make-pe-exe.py 11 May 2003 07:35:47 -0000 1.39 +++ make-pe-exe.py 11 May 2003 09:45:42 -0000 1.40 @@ -319,9 +319,8 @@ # memory alignment memory_boundary = roundup(memory_boundary, \ max(0x1000, sections[s].get_alignment())) - # establish origins + # establish origin sections[s].set_origin(memory_boundary) - sections[s].set_secondary_origin(memory_boundary - base_address) e.place_symbol('!' + s) e.place_symbol('&' + s, memory_boundary) # process sizes |
From: <di...@us...> - 2003-05-11 09:50:46
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv4856 Modified Files: linkie.py Log Message: dropped %foo support from Linkie.dump Index: linkie.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/linkie.py,v retrieving revision 1.54 retrieving revision 1.55 diff -u -d -r1.54 -r1.55 --- linkie.py 11 May 2003 09:45:41 -0000 1.54 +++ linkie.py 11 May 2003 09:50:43 -0000 1.55 @@ -333,7 +333,6 @@ rnotes = {}; othernotes = [] for sym, val in this._symbols: if sym[0] == '&': val -= this._origin - if sym[0] == '%': val -= this._origin_secondary if sym[0] != '#' and 0 <= val < this.memsz(): if rsymbols.has_key(val): rsymbols[val].append(sym) else: rsymbols[val] = [sym] |
From: <di...@us...> - 2003-05-11 07:35:50
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv1990 Modified Files: make-pe-exe.py Log Message: a few references to %foo converted into references to &foo Index: make-pe-exe.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- make-pe-exe.py 11 May 2003 07:17:41 -0000 1.38 +++ make-pe-exe.py 11 May 2003 07:35:47 -0000 1.39 @@ -324,7 +324,6 @@ sections[s].set_secondary_origin(memory_boundary - base_address) e.place_symbol('!' + s) e.place_symbol('&' + s, memory_boundary) - e.place_symbol('%' + s, memory_boundary - base_address) # process sizes e.place_symbol('#' + s + '/memsz', sections[s].memsz()) e.place_symbol('#' + s + '/filesz', roundup(sections[s].filesz(), 0x200)) @@ -333,8 +332,7 @@ # increase memory_boundary memory_boundary = roundup(memory_boundary + sections[s].memsz(), 4096) -e.align(512) -e.place_symbol('%aout/image-end', memory_boundary) +e.place_symbol('&aout/image-end', memory_boundary) e.place_symbol('#coff/magic', 0x014C) # I386MAGIC e.place_symbol('#coff/nscns', len(sectnames)) |
From: <di...@us...> - 2003-05-11 07:17:44
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv29671 Modified Files: make-pe-exe.py Log Message: a few references to %foo converted into references to &foo Index: make-pe-exe.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- make-pe-exe.py 11 May 2003 07:06:47 -0000 1.37 +++ make-pe-exe.py 11 May 2003 07:17:41 -0000 1.38 @@ -370,33 +370,34 @@ e.place_symbol('#aout/heap-reserve-size', 1024 * 1024) # one megabyte e.place_symbol('#aout/heap-commit-size', 0x1000) # one page +# Note that null RVAs are those that equal base_address e.place_symbol('#aout/dict-entry-count', 16) -e.place_symbol('%export-table', 0) +e.place_symbol('&export-table', base_address) e.place_symbol('#export-table/size', 0) -e.place_symbol('%resource-table', 0) +e.place_symbol('&resource-table', base_address) e.place_symbol('#resource-table/size', 0) -e.place_symbol('%exception-table', 0) +e.place_symbol('&exception-table', base_address) e.place_symbol('#exception-table/size', 0) e.place_symbol('!certificate-table', 0) e.place_symbol('#certificate-table/size', 0) -e.place_symbol('%base-relocation-table', 0) +e.place_symbol('&base-relocation-table', base_address) e.place_symbol('#base-relocation-table/size', 0) -e.place_symbol('%debug-data', 0) +e.place_symbol('&debug-data', base_address) e.place_symbol('#debug-data/size', 0) -e.place_symbol('%architecture-specific', 0) +e.place_symbol('&architecture-specific', base_address) e.place_symbol('#architecture-specific/size', 0) -e.place_symbol('%global-pointer', 0) -e.place_symbol('%thread-local-storage', 0) +e.place_symbol('&global-pointer', base_address) +e.place_symbol('&thread-local-storage', base_address) e.place_symbol('#thread-local-storage/size', 0) -e.place_symbol('%load-config-table', 0) +e.place_symbol('&load-config-table', base_address) e.place_symbol('#load-config-table/size', 0) -e.place_symbol('%bound-import-table', 0) +e.place_symbol('&bound-import-table', base_address) e.place_symbol('#bound-import-table/size', 0) -e.place_symbol('%import-address-table', 0) +e.place_symbol('&import-address-table', base_address) e.place_symbol('#import-address-table/size', 0) -e.place_symbol('%delay-import-descriptor', 0) +e.place_symbol('&delay-import-descriptor', base_address) e.place_symbol('#delay-import-descriptor/size', 0) -e.place_symbol('%COM+-runtime-header', 0) +e.place_symbol('&COM+-runtime-header', base_address) e.place_symbol('#COM+-runtime-header/size', 0) e.link() |
From: <di...@us...> - 2003-05-11 07:06:50
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv27198 Modified Files: make-pe-exe.py Log Message: use cleaner syntax Index: make-pe-exe.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- make-pe-exe.py 11 May 2003 06:50:38 -0000 1.36 +++ make-pe-exe.py 11 May 2003 07:06:47 -0000 1.37 @@ -66,7 +66,7 @@ def make_coff_header (): h = Linkie('<') h.align(4) - h.emit_wyde_sum(['#coff/magic']) + h[::2] = '#coff/magic' # Known magic values: # 0x0000 unknown # 0x014C i80386 @@ -87,12 +87,9 @@ # 0x0284 Alpha AXP 64-bit # 0x0366 Mips with FPU # 0x0466 Mips 16 with FPU - h.emit_wyde_sum(['#coff/nscns']) - h.emit_tetra_sum(['#coff/timdat']) - h.emit_tetra_sum(['!coff/symptr']) - h.emit_tetra_sum(['#coff/nsyms']) - h.emit_wyde_sum(['#coff/opthdr']) - h.emit_wyde_sum(['#coff/flags']) + h[::2] = '#coff/nscns' + h[::4] = '#coff/timdat', '!coff/symptr', '#coff/nsyms' + h[::2] = '#coff/opthdr', '#coff/flags' # Flags for PE: # 0x0001 no relocations -- can only be loaded at the preferred address # 0x0002 executable |
From: <di...@us...> - 2003-05-11 06:50:44
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv23762 Modified Files: make-pe-exe.py Log Message: use cleaner syntax Index: make-pe-exe.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- make-pe-exe.py 11 May 2003 06:22:25 -0000 1.35 +++ make-pe-exe.py 11 May 2003 06:50:38 -0000 1.36 @@ -30,16 +30,15 @@ b[::2] = 0x40, 0x40 # low and high memory limits in paragraphs b[::2] = -0x10, 0x100 # initial SS, SP b[::2] = 0 # no checksum - b.emit_wyde_sum(['&mz/_start']) # initial IP - b.emit_wyde(-0x10) # initial CS - b.emit_wyde(0) # relocation table offset - b.emit_wyde(0) # not an overlay + b[::2] = '&mz/_start', -0x10 # initial IP, CS + b[::2] = 0 # relocation table offset + b[::2] = 0 # not an overlay b.place_symbol('&mz/_start') - b.emit_string('\x8C\xC8\x8E\xD8') # mov %ax, %cs; mov %ds, mov %ax - b.emit_string('\xB4\x09') # mov %ah, 0x09 - b.emit_byte(0xBA); b.emit_wyde_sum(['&mz/message']) # mov %dx, message - b.emit_string('\xCD\x21') # int 0x21 - b.emit_string('\xB8\xFF\x4C\xCD\x21') # mov %ax, 0x4CFF; int 0x21 + b[::1] = 0x8C, 0xC8, 0x8E, 0xD8 # mov %ax, %cs; mov %ds, mov %ax + b[::1] = 0xB4, 0x09 # mov %ah, 0x09 + b[::1] = 0xBA; b[::2] = '&mz/message' # mov %dx, message + b[::1] = 0xCD, 0x21 # int 0x21 + b[::1] = 0xB8, 0xFF, 0x4C, 0xCD, 0x21 # mov %ax, 0x4CFF; int 0x21 message += '$' # Dollar the Terminator # a pointer to the PE signature must appear at the offset 0x003C |
From: <di...@us...> - 2003-05-11 06:22:30
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv17044 Modified Files: make-pe-exe.py Log Message: include size of .istubs in #aout/text-size Index: make-pe-exe.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- make-pe-exe.py 11 May 2003 06:14:21 -0000 1.34 +++ make-pe-exe.py 11 May 2003 06:22:25 -0000 1.35 @@ -350,7 +350,7 @@ e.place_symbol('#aout/magic', 0x010B) # PE32 e.place_symbol('#aout/linker-version-major', 0) e.place_symbol('#aout/linker-version-minor', 1) -e.place_symbol('#aout/text-size', roundup(text.memsz(), 0x200)) +e.place_symbol('#aout/text-size', roundup(text.memsz(), 0x200) + roundup(istubs.memsz(), 0x200)) e.place_symbol('#aout/data-size', roundup(data.memsz(), 0x200)) e.place_symbol('#aout/bss-size', roundup(bss.memsz(), 0x200)) e.place_symbol('#aout/image-base', 0x00400000) |