[Wisp-cvs] wisp/users/dig elf.py,1.4,1.5
Status: Alpha
Brought to you by:
digg
From: <di...@us...> - 2003-02-06 21:57:09
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv20599 Modified Files: elf.py Log Message: implemented make_ELF32_header Index: elf.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/elf.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- elf.py 6 Feb 2003 21:40:39 -0000 1.4 +++ elf.py 6 Feb 2003 21:57:05 -0000 1.5 @@ -16,6 +16,11 @@ TETRA = 1 # 32-bit objects OCTA = 2 # 64-bit objects NUM = 3 +class ELFDATA: # Data encoding + NONE = 0 # Invalid data encoding + TWOLSB = 1 # 2's complement, little endian + TWOMSB = 2 # 2's complement, big endian + NUM = 3 class ET: # Legal values for e_type (object file type). NONE = 0 # No file type REL = 1 # Relocatable file @@ -322,4 +327,25 @@ h = Linkie(byte_order) h.emit_string('\x7F' + 'ELF') # magic h.emit_byte(ELFCLASS.TETRA) + if byte_order == '<': + h.emit_byte(ELFDATA.TWOLSB) + elif byte_order == '>': + h.emit_byte(ELFDATA.TWOMSB) + else: + raise 'Invalid byte order', byte_order + h.emit_byte(EV.CURRENT) + h.emit_string('\0' * 9) + h.emit_wyde_sum(['elf/type']) + h.emit_wyde_sum(['elf/machine']) + h.emit_tetra(EV.CURRENT) + h.emit_tetra_sum(['_start']) + h.emit_tetra_sum(['elf/phoff']) + h.emit_tetra_sum(['elf/shoff']) + h.emit_tetra_sum(['elf/flags']) + h.emit_wyde(0x34) # e_ehsize + h.emit_wyde_sum(['elf/phentsize']) + h.emit_wyde_sum(['elf/phnum']) + h.emit_wyde_sum(['elf/shentsize']) + h.emit_wyde_sum(['elf/shnum']) + h.emit_wyde_sum(['elf/shstrndx']) return h |