From: <di...@us...> - 2003-05-13 12:47:37
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv8072 Modified Files: make-pe-exe.py Log Message: prefer Linkie.glue to Linkie.pastte throughout make-pe-exe.py Index: make-pe-exe.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- make-pe-exe.py 11 May 2003 09:45:42 -0000 1.40 +++ make-pe-exe.py 13 May 2003 12:47:35 -0000 1.41 @@ -17,12 +17,12 @@ return (value + boundary - 1) & ~(boundary - 1) def make_mz_prefix (message = 'OS too broken'): + # The result's assumed origin address is 0x100. if message.find('$') != -1: raise 'MZ message may not contain dollar signs', message if message.find('\r') == -1: # if no CRs, insert them message = '\r\n'.join(message.split('\n')) b = Linkie('<') - b.set_origin(0x100) b.emit_string('MZ') # 'MZ' b[::2] = '#mz/bytes-in-last-block', '#mz/blocks-in-file' b[::2] = 0 # no relocation @@ -235,14 +235,15 @@ sections = {'.text': text, '.istubs': istubs, '.data': data, '.bss': bss, '.imports': imports} sectnames = ['.text', '.istubs', '.data', '.bss', '.imports'] -e = Linkie('<'); e.paste(0, make_mz_prefix('OS too broken')) +e = Linkie('<'); +e.glue(0, make_mz_prefix('OS too broken'), 0x100) e.align(8) # PE header must be aligned to 8 e.place_symbol('!pe') e.emit_string('PE\0\0') -e.paste(None, make_coff_header()) -e.paste(None, make_pe_aout_header()) +e.glue(e.memsz(), make_coff_header(), None) +e.glue(e.memsz(), make_pe_aout_header(), None) for s in sectnames: - e.paste(None, make_section_header(s)) + e.glue(e.memsz(), make_section_header(s), None) e.place_symbol('!' + s + '/reloc', 0) e.place_symbol('!' + s + '/lineno', 0) e.place_symbol('#' + s + '/reloc', 0) @@ -319,15 +320,14 @@ # memory alignment memory_boundary = roundup(memory_boundary, \ max(0x1000, sections[s].get_alignment())) - # establish origin - sections[s].set_origin(memory_boundary) + # establish origin symbols e.place_symbol('!' + s) e.place_symbol('&' + s, memory_boundary) # process sizes e.place_symbol('#' + s + '/memsz', sections[s].memsz()) e.place_symbol('#' + s + '/filesz', roundup(sections[s].filesz(), 0x200)) # paste bits - e.paste(-1, sections[s]) + e.glue(e.memsz(), sections[s], memory_boundary) # increase memory_boundary memory_boundary = roundup(memory_boundary + sections[s].memsz(), 4096) |