[Wisp-cvs] wisp/users/dig coff.tran,NONE,1.1 Makefile.am,1.18,1.19 coff.py,1.2,1.3 tran-builtins,1.2
Status: Alpha
Brought to you by:
digg
From: <di...@us...> - 2003-05-17 13:51:01
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv556 Modified Files: Makefile.am coff.py tran-builtins tran.py Added Files: coff.tran Log Message: converted the body of make_coff_header into a tran macro --- NEW FILE: coff.tran --- \\\\ coff.tran - COFF 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: coff.tran,v 1.1 2003/05/17 13:50:52 digg Exp $ :[ ] make-coff-header 4 align ref #coff/magic w, \ Known magic values: \ 0x0000 unknown \ 0x014C i80386 \ 0x014D i80486 \ 0x014E Pentium \ 0x0162 Mips Mark I (R2000, R3000) \ 0x0163 Mips Mark II (R6000) \ 0x0166 Mips Mark III (R4000) \ 0x0168 R10000 \ 0x0184 Alpha AXP \ 0x01A2 Hitachi SH3 \ 0x01A6 Hitachi SH4 \ 0x01C0 ARM \ 0x01F0 PowerPC LittleEndian \ 0x0200 ia64 \ 0x0266 Mips 16 \ 0x0268 m68k \ 0x0284 Alpha AXP 64-bit \ 0x0366 Mips with FPU \ 0x0466 Mips 16 with FPU ref #coff/nscns w, ref #coff/timdat t, ref !coff/symptr t, ref #coff/nsyms t, ref #coff/opthdr w, ref #coff/flags w, \ Flags for COFF: \ 0x0001 no relocations -- can only be loaded at the preferred address \ 0x0002 executable \ 0x0004 no COFF line number data \ 0x0008 no COFF local symbol entries \ Additional flags for PE: \ 0x0010 aggressively trim working set (?) \ 0x0020 program is aware of addresses larger than 2Gi \ 0x0040 reserved \ 0x0200 debugging information stripped away \ 0x0400 if file on removable media, copy and run from swap (?) \ 0x1000 is a system program (?) \ 0x2000 library \ 0x4000 should only be run on uniprocessor machines ; \ vim: ft=tran Index: Makefile.am =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/Makefile.am,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- Makefile.am 17 May 2003 12:59:13 -0000 1.18 +++ Makefile.am 17 May 2003 13:50:52 -0000 1.19 @@ -9,6 +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 \ winapi.tran \ hello.tran mswhello.tran \ makehello.py elfdump.py Index: coff.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/coff.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- coff.py 16 May 2003 16:23:04 -0000 1.2 +++ coff.py 17 May 2003 13:50:52 -0000 1.3 @@ -7,49 +7,10 @@ #### @(#) $Id$ from linkie import Linkie +from tran import interpret_single -def make_coff_header (): - h = Linkie('<') - h.align(4) - h[::2] = '#coff/magic' - # Known magic values: - # 0x0000 unknown - # 0x014C i80386 - # 0x014D i80486 - # 0x014E Pentium - # 0x0162 Mips Mark I (R2000, R3000) - # 0x0163 Mips Mark II (R6000) - # 0x0166 Mips Mark III (R4000) - # 0x0168 R10000 - # 0x0184 Alpha AXP - # 0x01A2 Hitachi SH3 - # 0x01A6 Hitachi SH4 - # 0x01C0 ARM - # 0x01F0 PowerPC LittleEndian - # 0x0200 ia64 - # 0x0266 Mips 16 - # 0x0268 m68k - # 0x0284 Alpha AXP 64-bit - # 0x0366 Mips with FPU - # 0x0466 Mips 16 with FPU - h[::2] = '#coff/nscns' - h[::4] = '#coff/timdat', '!coff/symptr', '#coff/nsyms' - h[::2] = '#coff/opthdr', '#coff/flags' - # Flags for COFF: - # 0x0001 no relocations -- can only be loaded at the preferred address - # 0x0002 executable - # 0x0004 no COFF line number data - # 0x0008 no COFF local symbol entries - # Additional flags for PE: - # 0x0010 aggressively trim working set (?) - # 0x0020 program is aware of addresses larger than 2Gi - # 0x0040 reserved - # 0x0200 debugging information stripped away - # 0x0400 if file on removable media, copy and run from swap (?) - # 0x1000 is a system program (?) - # 0x2000 library - # 0x4000 should only be run on uniprocessor machines - return h +def make_coff_header (target = '<'): + return interpret_single('make-coff-header', target, include = 'coff') def make_coff_section_header (byte_order, name): h = Linkie(byte_order) Index: tran-builtins =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran-builtins,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- tran-builtins 17 May 2003 12:50:49 -0000 1.23 +++ tran-builtins 17 May 2003 13:50:52 -0000 1.24 @@ -147,7 +147,8 @@ interpreter.toksrc.push(Lexer(str(name) + '.tran')) ref|name - interpreter.regstack.append(Symbol_Literal('&' + name)) + if not name[0] in '&#!': name = '&' + name + interpreter.regstack.append(Symbol_Literal(name)) reserve int interpreter.current.skip(interpreter.regstack.pop()) Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.102 retrieving revision 1.103 diff -u -d -r1.102 -r1.103 --- tran.py 17 May 2003 13:33:49 -0000 1.102 +++ tran.py 17 May 2003 13:50:52 -0000 1.103 @@ -298,6 +298,7 @@ else: raise 'Unknown meaning format for', tok else: raise 'bad token', tok def run (this, toksrc, verbose = 0): + if isinstance(toksrc, str): toksrc = Lexer(toksrc) this.toksrc = Preprocessor(toksrc) tok = this.toksrc.get_token() while tok <> None: @@ -308,13 +309,15 @@ this.toksrc = None def interpret_single (toksrc, target, include = [], verbose = 0): + if isinstance(toksrc, str): toksrc = [toksrc] if isinstance(toksrc, list): toksrc = Macro_Cursor(toksrc) - if isinstance(toksrc, str): toksrc = Lexer(toksrc) if isinstance(target, str): target = Linkie(target) # byte order elif isinstance(target, Linkie): pass else: raise 'neither a linkie nor a byte order specifier', target + if isinstance(include, str): include = include.split() + interp = Interpreter(target) for i in include: interp.run(i + '.tran') interp.run(toksrc, verbose = verbose) @@ -324,10 +327,13 @@ return target def interpret_multi (toksrc, target, include = [], verbose = 0): + if isinstance(toksrc, str): toksrc = [toksrc] if isinstance(toksrc, list): toksrc = Macro_Cursor(toksrc) - if isinstance(toksrc, str): toksrc = Lexer(toksrc) if isinstance(target, str): target = target.split() + + if isinstance(include, str): include = include.split() + byte_order = target[0] sections = target[1:] interp = Interpreter(byte_order = byte_order, output = sections) |