Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv7924
Modified Files:
elf.py
Log Message:
avoid duplicate .symstr entries
Index: elf.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/elf.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- elf.py 14 Apr 2003 01:19:56 -0000 1.32
+++ elf.py 14 Apr 2003 01:33:12 -0000 1.33
@@ -391,17 +391,25 @@
t.place_symbol('#elf/shnum', len(names) + 1)
return t
-# Returns offset of the string added
-def emit_ELF32_symstr_entry (symstr, string):
- ofs = symstr.memsz()
- symstr.emit_string (string)
- symstr.emit_byte(0)
- return ofs
+class ELF32_symstr (Linkie):
+ def __init__ (this, byte_order):
+ Linkie.__init__(this, byte_order)
+ this._emitted_symbols = {}
+ # Returns offset of the string added.
+ # Avoids introducing duplicate entries.
+ def emit_entry (this, s):
+ if this._emitted_symbols.has_key(s):
+ return this._emitted_symbols[s]
+ ofs = this.memsz()
+ this._emitted_symbols[s] = ofs
+ this.emit_string(s)
+ this.emit_byte(0)
+ return ofs
# Returns index of the entry added.
def emit_ELF32_symtab_entry (symtab, symstr, pname,
value = None, section = SHN.ABS):
- ofs = emit_ELF32_symstr_entry(symstr, pname[1:])
+ ofs = symstr.emit_entry(pname[1:])
# No explicit alignment. .symtab doesn't bear padding; if
# you get it out of align, you're out of luck anyway.
i = symtab.memsz() / 16
@@ -505,7 +513,7 @@
shentnames = ['.text', '.data']
if want_symbols or want_relocatable:
shentnames += ['.symstr', '.symtab']
- sections['.symstr'] = Linkie('<')
+ sections['.symstr'] = ELF32_symstr('<')
sections['.symstr'].emit_byte(0)
sections['.symtab'] = Linkie('<')
|