[Wisp-cvs] wisp/users/dig elf.py,1.56,1.57 pe.py,1.6,1.7 tran.py,1.87,1.88
Status: Alpha
Brought to you by:
digg
From: <di...@us...> - 2003-05-17 10:17:05
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv11686 Modified Files: elf.py pe.py tran.py Log Message: implemented the --base option Index: elf.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/elf.py,v retrieving revision 1.56 retrieving revision 1.57 diff -u -d -r1.56 -r1.57 --- elf.py 16 May 2003 13:37:20 -0000 1.56 +++ elf.py 17 May 2003 10:16:53 -0000 1.57 @@ -490,7 +490,7 @@ return p_flags def make_ELF32_object (text = None, data = None, bss = None, flags = '', - memory_bottom = 0x08048000): + base_address = 0x08048000): # Will NOT set given sections' origins. want_symbols = 's' in flags want_relocatable = 'r' in flags @@ -502,7 +502,7 @@ if bss <> None: sections['.bss'] = bss binary = Linkie('<') - memory_boundary = memory_bottom # must be at page boundary + memory_boundary = base_address # must be at page boundary binary.glue(0, make_ELF32_header('<', reloc = want_relocatable), None) if want_relocatable: binary.place_symbol('#elf/type', ET.REL) Index: pe.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/pe.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- pe.py 16 May 2003 17:14:29 -0000 1.6 +++ pe.py 17 May 2003 10:16:53 -0000 1.7 @@ -298,8 +298,8 @@ e.place_symbol('#aout/text-size', roundup(text.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) - e.place_symbol('#rva', -0x00400000) # adding this to an address will yield RVA + e.place_symbol('#aout/image-base', base_address) + e.place_symbol('#rva', -base_address) # adding this to an address will yield RVA e.place_symbol('#aout/memory-align', 4096) e.place_symbol('#aout/file-align', 512) # 4.0 = MSW95 Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.87 retrieving revision 1.88 diff -u -d -r1.87 -r1.88 --- tran.py 17 May 2003 09:25:33 -0000 1.87 +++ tran.py 17 May 2003 10:16:53 -0000 1.88 @@ -293,12 +293,15 @@ def main (): global prep, verbose, format - opts, args = getopt(sys.argv[1:], 'vo:f:', ['verbose', 'output=', 'format=', 'list-words']) + opts, args = getopt(sys.argv[1:], 'vo:b:f:', + ['verbose', 'output=', 'base=', 'format=', 'list-words']) output_name = None list_words = 0 + base = None for opt, arg in opts: - if opt in ('-o', '--output'): output_name = arg if opt in ('-v', '--verbose'): verbose = 1 + if opt in ('-o', '--output'): output_name = arg + if opt in ('-b', '--base'): base = string.atol(arg, 16) if opt in ('-f', '--format'): format = arg if opt == '--list-words': list_words = 1 if output_name == None: output_name = default_output_names[format] @@ -325,15 +328,17 @@ interpreter.bss.dump(title = 'BSS') if Regstack: raise 'Regstack not empty after parsing ended', Regstack + argum = { + 'text': interpreter.text, + 'data': interpreter.data, + 'bss': interpreter.bss, + } + if base <> None: argum['base_address'] = base if format == 'elf': - binary = elf.make_ELF32_object(text = interpreter.text, - data = interpreter.data, - bss = interpreter.bss, - flags = 's') + argum['flags'] = 's' + binary = apply(elf.make_ELF32_object, [], argum) elif format == 'pe': - binary = pe.make_pe_executable(text = interpreter.text, - data = interpreter.data, - bss = interpreter.bss) + binary = apply(pe.make_pe_executable, [], argum) f = open(output_name, 'w') binary.get_file().tofile(f) f.close() |