lfn
serial
ticket/834-toolchain-update
topic/msim-upgrade
topic/simplify-dev-export
Last change
on this file since 6153749 was ae9624e, checked in by Ondrej Palkovsky <ondrap@…>, 20 years ago |
Symbol table now contains static functions too.
NOTE: gcc heavily inlines, be aware of optimizations.
Removed excesive item from boot page tables.
|
-
Property mode
set to
100755
|
File size:
1.7 KB
|
Rev | Line | |
---|
[ab08b42] | 1 | #!/usr/bin/env python
|
---|
| 2 |
|
---|
| 3 | import sys
|
---|
| 4 | import struct
|
---|
| 5 | import re
|
---|
| 6 |
|
---|
[b6d20a7] | 7 | MAXSTRING=63
|
---|
| 8 | symtabfmt = "<Q%ds" % (MAXSTRING+1)
|
---|
[ab08b42] | 9 |
|
---|
| 10 |
|
---|
[ae9624e] | 11 | objline = re.compile(r'([0-9a-f]+)\s+[lg]\s+F\s+\.text\s+[0-9a-f]+\s+(.*)$')
|
---|
| 12 | fileexp = re.compile(r'([^\s]+):\s+file format')
|
---|
| 13 | def read_obdump(inp):
|
---|
| 14 | result = {}
|
---|
| 15 | fname = ''
|
---|
| 16 | for line in inp:
|
---|
[ab08b42] | 17 | line = line.strip()
|
---|
[ae9624e] | 18 | res = objline.match(line)
|
---|
[b6d20a7] | 19 | if res:
|
---|
[ae9624e] | 20 | result.setdefault(fname,[]).append((int(res.group(1),16),
|
---|
| 21 | res.group(2)))
|
---|
| 22 | res = fileexp.match(line)
|
---|
[ab08b42] | 23 | if res:
|
---|
[ae9624e] | 24 | fname = res.group(1)
|
---|
[ab08b42] | 25 | continue
|
---|
[ae9624e] | 26 |
|
---|
| 27 | return result
|
---|
| 28 |
|
---|
| 29 | startfile = re.compile(r'\.text\s+(0x[0-9a-f]+)\s+0x[0-9a-f]+\s+(.*)$')
|
---|
| 30 | def generate(kmapf, obmapf, out):
|
---|
| 31 | obdump = read_obdump(obmapf)
|
---|
| 32 |
|
---|
| 33 | def sorter(x,y):
|
---|
| 34 | return cmp(x[0],y[0])
|
---|
| 35 |
|
---|
| 36 | for line in kmapf:
|
---|
| 37 | line = line.strip()
|
---|
| 38 | res = startfile.match(line)
|
---|
| 39 | if res and obdump.has_key(res.group(2)):
|
---|
| 40 | offset = int(res.group(1),16)
|
---|
| 41 | fname = res.group(2)
|
---|
| 42 | symbols = obdump[fname]
|
---|
| 43 | symbols.sort(sorter)
|
---|
| 44 | for addr,symbol in symbols:
|
---|
| 45 | value = fname + ':' + symbol
|
---|
| 46 | data = struct.pack(symtabfmt,addr+offset,value[:MAXSTRING])
|
---|
| 47 | out.write(data)
|
---|
| 48 |
|
---|
[ab08b42] | 49 | out.write(struct.pack(symtabfmt,0,''))
|
---|
| 50 |
|
---|
| 51 | def main():
|
---|
[ae9624e] | 52 | if len(sys.argv) != 4:
|
---|
| 53 | print "Usage: %s <kernel.map> <nm dump> <output.bin>" % sys.argv[0]
|
---|
[ab08b42] | 54 | sys.exit(1)
|
---|
| 55 |
|
---|
[ae9624e] | 56 | kmapf = open(sys.argv[1],'r')
|
---|
| 57 | obmapf = open(sys.argv[2],'r')
|
---|
| 58 | out = open(sys.argv[3],'w')
|
---|
| 59 | generate(kmapf,obmapf,out)
|
---|
| 60 | kmapf.close()
|
---|
| 61 | obmapf.close()
|
---|
[ab08b42] | 62 | out.close()
|
---|
| 63 |
|
---|
| 64 | if __name__ == '__main__':
|
---|
| 65 | main()
|
---|
Note:
See
TracBrowser
for help on using the repository browser.