[Wisp-cvs] wisp/users/dig elf.py,1.33,1.34
Status: Alpha
Brought to you by:
digg
From: <di...@us...> - 2003-04-14 01:38:47
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv10320 Modified Files: elf.py Log Message: converted the ELF32_symstr class to a more generic ELF32_strtab class Index: elf.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/elf.py,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- elf.py 14 Apr 2003 01:33:12 -0000 1.33 +++ elf.py 14 Apr 2003 01:38:44 -0000 1.34 @@ -391,16 +391,18 @@ t.place_symbol('#elf/shnum', len(names) + 1) return t -class ELF32_symstr (Linkie): +class ELF32_strtab (Linkie): def __init__ (this, byte_order): Linkie.__init__(this, byte_order) this._emitted_symbols = {} + this.emit_byte(0) # Returns offset of the string added. # Avoids introducing duplicate entries. - def emit_entry (this, s): + def emit_entry (this, s, entry_label = None): if this._emitted_symbols.has_key(s): return this._emitted_symbols[s] ofs = this.memsz() + if entry_label <> None: this.place_symbol(entry_label, ofs) this._emitted_symbols[s] = ofs this.emit_string(s) this.emit_byte(0) @@ -513,9 +515,7 @@ shentnames = ['.text', '.data'] if want_symbols or want_relocatable: shentnames += ['.symstr', '.symtab'] - sections['.symstr'] = ELF32_symstr('<') - sections['.symstr'].emit_byte(0) - + sections['.symstr'] = ELF32_strtab('<') sections['.symtab'] = Linkie('<') sections['.symtab'].align(4) sections['.symtab'].emit_string('\0' * 16) @@ -534,8 +534,7 @@ raise 'Unrepresentable relocation type', (ofs, typ, arg) shentnames.append('.shstrtab') - sections['.shstrtab'] = Linkie('<') - sections['.shstrtab'].emit_byte(0) + sections['.shstrtab'] = ELF32_strtab('<') if not want_relocatable: phentnames = [] @@ -545,9 +544,7 @@ binary.paste(-4, make_ELF32_phtable('<', phentnames)) for name in shentnames: - sections['.shstrtab'].place_symbol('#.shstrtab/strings/' + name) - sections['.shstrtab'].emit_string(name) - sections['.shstrtab'].emit_byte(0) + sections['.shstrtab'].emit_entry(name, '#.shstrtab/strings/' + name) for name in shentnames: section = sections[name] |