[Wisp-cvs] wisp/users/dig elf.py,1.15,1.16 makehello.py,1.17,1.18
Status: Alpha
Brought to you by:
digg
From: <di...@us...> - 2003-04-03 09:12:06
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv354 Modified Files: elf.py makehello.py Log Message: wrote emit_ELF32_symtab_entry Index: elf.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/elf.py,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- elf.py 3 Apr 2003 08:49:11 -0000 1.15 +++ elf.py 3 Apr 2003 09:12:01 -0000 1.16 @@ -393,6 +393,19 @@ symstr.emit_byte(0) return ofs +def emit_ELF32_symtab_entry (symtab, symstr, pname, + value = None, section = SHN.ABS): + # No explicit alignment. .symtab doesn't bear padding; if + # you get it out of align, you're out of luck anyway. + ofs = emit_ELF32_symstr_entry (symstr, pname[1:]) + symtab.emit_tetra(ofs) + if value == None: symtab.emit_tetra_sum([pname]) + else: symtab.emit_tetra(value) + symtab.emit_tetra(0) # st_size + symtab.emit_byte(STB.GLOBAL << 4 | STT.NOTYPE) + symtab.emit_byte(0) # st_other; reserved + symtab.emit_wyde(section) + # Thoughts of generating ELF32 files # * In ELF parlance, linker notes are called relocations. # We need to solve relocations only when generating an Index: makehello.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/makehello.py,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- makehello.py 3 Apr 2003 08:49:12 -0000 1.17 +++ makehello.py 3 Apr 2003 09:12:02 -0000 1.18 @@ -164,16 +164,12 @@ binary.place_symbol('!' + name) binary.paste(-1, section) if want_symbols: + symtab = sections['.symtab'] + symstr = sections['.symstr'] for symbol, value in section.get_symbols(): - if symbol[0] != '&': continue # only process memory references - symbol = symbol[1:] # but not their prefixen - ofs = emit_ELF32_symstr_entry(sections['.symstr'], symbol) - sections['.symtab'].emit_tetra(ofs) - sections['.symtab'].emit_tetra_sum(['&' + name]) - sections['.symtab'].emit_tetra(0) - sections['.symtab'].emit_byte(STB.GLOBAL << 4 | STT.NOTYPE) - sections['.symtab'].emit_byte(0) - sections['.symtab'].emit_wyde(shentnames.index(name) + 1) + if symbol[0] == '&': # only process memory references + emit_ELF32_symtab_entry(symtab, symstr, symbol, value, + shentnames.index(name) + 1) memory_boundary += section.memsz() memory_boundary = (memory_boundary + 0xFFF) & ~0xFFF |