Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv15814
Modified Files:
linkie.py makehello.py
Log Message:
made Linkie.extend return the offset of linkage point
Index: linkie.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/linkie.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- linkie.py 14 Feb 2003 13:50:55 -0000 1.6
+++ linkie.py 15 Feb 2003 09:14:47 -0000 1.7
@@ -197,6 +197,7 @@
that._linker_notes = this._linker_notes[:]
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
if that.filesz(): this.deskip()
@@ -208,7 +209,7 @@
this._symbols.append((sym, val + delta))
for ofs, typ, arg in that._linker_notes:
this._linker_notes.append((ofs + delta, typ, arg))
- return this
+ return delta
def __add__ (this, that):
this = this.copy()
this.extend(that)
Index: makehello.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/makehello.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- makehello.py 14 Feb 2003 13:50:56 -0000 1.5
+++ makehello.py 15 Feb 2003 09:14:47 -0000 1.6
@@ -37,14 +37,24 @@
(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
-symbols['elf/phoff'] = hello.place_symbol('elf/phoff')
-hello.extend(make_ELF32_pheader('<', '.text'))
+symbols['elf/flags'] = 0 # no flags for ia386
+program_header_table = make_ELF32_pheader('<', '.text')
+symbols['elf/phoff'] = hello.extend(program_header_table)
+# process the text segment
+symbols['.text/offset'] = hello.extend(code)
hello.link(symbols)
hello.dump()
|