Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv10809
Modified Files:
Makefile.am elf.py tran-builtins tran.py
Added Files:
elf.tran
Log Message:
converted the body of make_ELF32_header into the |make-elf32-phentry| tran macro
--- NEW FILE: elf.tran ---
\\\\ elf.tran - ELF generation routines
\
\ Copyleft © 2003 by Andres Soolo (di...@us...)
\ This file is licensed under the GNU GPL v2. If you
\ don't know what that means, please do read the GPL.
\
\\\\ @(#) $Id: elf.tran,v 1.1 2003/05/17 14:16:24 digg Exp $
:[ ] make-elf32-phentry
4 align
dup mingle #*/p_type t,
dup mingle !* t, \ offset
dup mingle &* t, \ p_vaddr
dup mingle &* t, \ p_paddr
dup mingle #*/filesz t,
dup mingle #*/memsz t,
dup mingle #*/p_flags t,
mingle #*/p_align t,
;
\ vim: ft=tran
Index: Makefile.am
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/Makefile.am,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- Makefile.am 17 May 2003 13:50:52 -0000 1.19
+++ Makefile.am 17 May 2003 14:16:23 -0000 1.20
@@ -9,7 +9,7 @@
EXTRA_DIST = .cvsignore .pycheckrc struburn.wisp bits.py linkie.py \
coff.py elf.py pe.py \
i8086.tran i80386.tran ia16.tran ia32.tran \
- coff.tran \
+ coff.tran elf.tran \
winapi.tran \
hello.tran mswhello.tran \
makehello.py elfdump.py
Index: elf.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/elf.py,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- elf.py 17 May 2003 11:11:30 -0000 1.58
+++ elf.py 17 May 2003 14:16:24 -0000 1.59
@@ -322,6 +322,7 @@
NUM = 11
from linkie import Linkie
+from tran import interpret_single
def make_ELF32_header (byte_order, reloc = 0):
h = Linkie(byte_order)
@@ -352,14 +353,8 @@
t.align(4)
t |= '!elf/proghdr'
for name in names:
- t[::4] = '#' + name + '/p_type'
- t[::4] = '!' + name # offset
- t[::4] = '&' + name # p_vaddr
- t[::4] = '&' + name # p_paddr
- t[::4] = '#' + name + '/filesz'
- t[::4] = '#' + name + '/memsz'
- t[::4] = '#' + name + '/p_flags'
- t[::4] = '#' + name + '/p_align'
+ interpret_single(['ref', name, 'make-elf32-phentry'],
+ t, include = 'elf')
t.place_symbol('#elf/phnum', len(names))
return t
Index: tran-builtins
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran-builtins,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- tran-builtins 17 May 2003 13:50:52 -0000 1.24
+++ tran-builtins 17 May 2003 14:16:24 -0000 1.25
@@ -137,6 +137,13 @@
dup any
interpreter.regstack.append(interpreter.regstack[-1])
+mingle sym|tpl
+ core = str(interpreter.regstack.pop())[1:]
+ tpl = tpl.split('*', 1)
+ if len(tpl) <> 2: raise 'not exactly one star', tpl
+ before, after = tpl
+ interpreter.regstack.append(Symbol_Literal(before + core + after))
+
label|name
interpreter.current.place_symbol('&' + name)
Index: tran.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -d -r1.103 -r1.104
--- tran.py 17 May 2003 13:50:52 -0000 1.103
+++ tran.py 17 May 2003 14:16:24 -0000 1.104
@@ -106,7 +106,7 @@
shlex.__init__(this, instream = open(filename, 'r'), infile = filename)
this.commenters = '\\'
this.quotes = '"'
- this.wordchars += '!#$%*+,-./:;<=>?@[]'
+ this.wordchars += '!#$%&*+,-./:;<=>?@[]'
def get_token (this):
tok = shlex.get_token(this)
if tok == '': tok = None
@@ -309,7 +309,7 @@
this.toksrc = None
def interpret_single (toksrc, target, include = [], verbose = 0):
- if isinstance(toksrc, str): toksrc = [toksrc]
+ if isinstance(toksrc, str): toksrc = toksrc.split() # FIXME: integers?
if isinstance(toksrc, list): toksrc = Macro_Cursor(toksrc)
if isinstance(target, str): target = Linkie(target) # byte order
@@ -327,7 +327,7 @@
return target
def interpret_multi (toksrc, target, include = [], verbose = 0):
- if isinstance(toksrc, str): toksrc = [toksrc]
+ if isinstance(toksrc, str): toksrc = toksrc.split() # FIXME: integers?
if isinstance(toksrc, list): toksrc = Macro_Cursor(toksrc)
if isinstance(target, str): target = target.split()
|