[Wisp-cvs] wisp/users/dig linkie.py,1.7,1.8 makehello.py,1.6,1.7
Status: Alpha
Brought to you by:
digg
From: <di...@us...> - 2003-02-15 15:35:36
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv10008 Modified Files: linkie.py makehello.py Log Message: a new output format for Linkie.dump Index: linkie.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/linkie.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- linkie.py 15 Feb 2003 09:14:47 -0000 1.7 +++ linkie.py 15 Feb 2003 15:35:30 -0000 1.8 @@ -246,18 +246,42 @@ if rnotes.has_key(ofs): rnotes[ofs].append((typ, arg)) else: rnotes[ofs] = [(typ, arg)] else: othernotes.append((ofs, typ, arg)) - buf = []; bufstart = 0 - for i in range(this.memsz()): - if len(buf) >= 16 or rsymbols.has_key(i) or rnotes.has_key(i): - if buf: print ' 0x%08x:' % bufstart, ' '.join(buf) - buf = []; bufstart = i - if rsymbols.has_key(i): - for s in rsymbols[i]: print s + ':' - if rnotes.has_key(i): - for typ, ofs in rnotes[i]: - print '%r(%s)' % (typ, ofs) - if i < len(this._binary): - buf.append('%02x' % ord(this._binary[i])) - else: - buf.append('oo') - if buf: print ' 0x%08x:' % bufstart, ' '.join(buf) + row = 0 + while row < this.memsz(): + start = 0 + while start < 16: + stop = start + 1 + while stop < 16 and not rsymbols.has_key(row + stop): + stop += 1 + # labels + offset = row + start + if rsymbols.has_key(offset): + for s in rsymbols[offset]: + print s + ':', + print + # bits + hex = ''; ascii = '' + for column in range(16): + if start <= column < stop: + offset = row + column + if offset < this.filesz(): + byte = this._binary[offset] + hex += '%02x ' % ord(byte) + if byte < ' ' or byte > '~': byte = '.' + ascii += byte + elif offset < this.memsz(): + hex += 'oo '; ascii += ':' + else: + hex += ' '; ascii += ' ' + else: + hex += ' '; ascii += ' ' + print ' [%08x] ' % row, hex, ascii + # FIXME: this doesn't handle wraparound of improperly + # aligned relocations quite properly + for offset in range(row + stop - 1, row + start - 1, -1): + if rnotes.has_key(offset): + for typ, arg in rnotes[offset]: + print ' ' * (14 + (offset & 15) * 3) + \ + '^^-' * abs(typ) + arg + start = stop + row += 16 Index: makehello.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/makehello.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- makehello.py 15 Feb 2003 09:14:47 -0000 1.6 +++ makehello.py 15 Feb 2003 15:35:30 -0000 1.7 @@ -9,6 +9,10 @@ from linkie import Linkie from elf import * +def binround_down (x, unit): + return x & ~(unit - 1) +def binround_up (x, unit): + return (x | (unit - 1)) + 1 def make_marker (name): m = Linkie('<') m.place_symbol(name) @@ -29,25 +33,9 @@ data.place_symbol('message') data.emit_string('Hello, world!\n') -header = make_ELF32_header('<') - -pheader = make_ELF32_pheader('<', '.text') -sheader = make_ELF32_pheader('<', '.text') - -(header + make_marker('PHEADER') + pheader + code + data + - make_marker('SHEADER') + sheader).dump() - -def binround_down (x, unit): - return x & ~(unit - 1) - -def binround_up (x, unit): - return (x | (unit - 1)) + 1 - -print; print '=== hello ===' hello = Linkie('<') memory_boundary = 0x8048000 hello.extend(make_ELF32_header('<')) -hello.align(4) symbols = {} symbols['elf/type'] = ET.EXEC symbols['elf/machine'] = EM.I386 |