Changeset 3c80f2b in mainline
- Timestamp:
- 2010-03-19T11:41:01Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4e9aaf5
- Parents:
- 177e4ea
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/tools/genmap.py
r177e4ea r3c80f2b 1 1 #!/usr/bin/env python 2 # 3 # Copyright (c) 2006 Ondrej Palkovsky 4 # All rights reserved. 5 # 6 # Redistribution and use in source and binary forms, with or without 7 # modification, are permitted provided that the following conditions 8 # are met: 9 # 10 # - Redistributions of source code must retain the above copyright 11 # notice, this list of conditions and the following disclaimer. 12 # - Redistributions in binary form must reproduce the above copyright 13 # notice, this list of conditions and the following disclaimer in the 14 # documentation and/or other materials provided with the distribution. 15 # - The name of the author may not be used to endorse or promote products 16 # derived from this software without specific prior written permission. 17 # 18 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 # 29 30 """ 31 Create binary symbol map out of linker map file 32 """ 2 33 3 34 import sys … … 5 36 import re 6 37 7 MAXSTRING=63 8 symtabfmt = "<Q%ds" % (MAXSTRING+1) 9 38 MAXSTRING = 63 39 symtabfmt = "<Q%ds" % (MAXSTRING + 1) 10 40 11 41 funcline = re.compile(r'([0-9a-f]+)\s+[lg]\s+.\s+\.text\s+([0-9a-f]+)\s+(.*)$') … … 13 43 dataline = re.compile(r'([0-9a-f]+)\s+[lg]\s+[a-zA-Z]\s+\.data\s+([0-9a-f]+)\s+(.*)$') 14 44 fileexp = re.compile(r'([^\s]+):\s+file format') 45 startfile = re.compile(r'\.(text|bss|data)\s+(0x[0-9a-f]+)\s+0x[0-9a-f]+\s+(.*)$') 46 15 47 def read_obdump(inp): 16 funcs = {} 17 data = {} 18 bss ={} 19 fname = '' 20 for line in inp: 21 line = line.strip() 22 res = funcline.match(line) 23 if res: 24 funcs.setdefault(fname,[]).append((int(res.group(1),16), 25 res.group(3))) 26 continue 27 res = bssline.match(line) 28 if res: 29 start = int(res.group(1),16) 30 end = int(res.group(2),16) 31 if end: 32 bss.setdefault(fname,[]).append((start,res.group(3))) 33 res = dataline.match(line) 34 if res: 35 start = int(res.group(1),16) 36 end = int(res.group(2),16) 37 if end: 38 data.setdefault(fname,[]).append((start,res.group(3))) 39 res = fileexp.match(line) 40 if res: 41 fname = res.group(1) 42 continue 48 "Parse input" 49 50 funcs = {} 51 data = {} 52 bss = {} 53 fname = '' 54 55 for line in inp: 56 line = line.strip() 57 res = funcline.match(line) 58 if (res): 59 funcs.setdefault(fname, []).append((int(res.group(1), 16), res.group(3))) 60 continue 61 62 res = bssline.match(line) 63 if (res): 64 start = int(res.group(1), 16) 65 end = int(res.group(2), 16) 66 if (end): 67 bss.setdefault(fname, []).append((start, res.group(3))) 68 69 res = dataline.match(line) 70 if (res): 71 start = int(res.group(1), 16) 72 end = int(res.group(2), 16) 73 if (end): 74 data.setdefault(fname, []).append((start, res.group(3))) 75 76 res = fileexp.match(line) 77 if (res): 78 fname = res.group(1) 79 continue 80 81 return {'text' : funcs, 'bss' : bss, 'data' : data } 43 82 44 return {45 'text' : funcs,46 'bss' : bss,47 'data' : data48 }49 50 startfile = re.compile(r'\.(text|bss|data)\s+(0x[0-9a-f]+)\s+0x[0-9a-f]+\s+(.*)$')51 83 def generate(kmapf, obmapf, out): 52 obdump = read_obdump(obmapf) 53 54 def sorter(x,y): 55 return cmp(x[0],y[0]) 56 57 for line in kmapf: 58 line = line.strip() 59 res = startfile.match(line) 60 61 if res and obdump[res.group(1)].has_key(res.group(3)): 62 offset = int(res.group(2),16) 63 fname = res.group(3) 64 symbols = obdump[res.group(1)][fname] 65 symbols.sort(sorter) 66 for addr,symbol in symbols: 67 value = fname + ':' + symbol 68 data = struct.pack(symtabfmt,addr+offset,value[:MAXSTRING]) 69 out.write(data) 70 71 out.write(struct.pack(symtabfmt,0,'')) 84 "Generate output file" 85 86 obdump = read_obdump(obmapf) 87 88 def sorter(x,y): 89 return cmp(x[0],y[0]) 90 91 for line in kmapf: 92 line = line.strip() 93 res = startfile.match(line) 94 95 if ((res) and (obdump[res.group(1)].has_key(res.group(3)))): 96 offset = int(res.group(2), 16) 97 fname = res.group(3) 98 symbols = obdump[res.group(1)][fname] 99 symbols.sort(sorter) 100 for addr, symbol in symbols: 101 value = fname + ':' + symbol 102 data = struct.pack(symtabfmt, addr + offset, value[:MAXSTRING]) 103 out.write(data) 104 105 out.write(struct.pack(symtabfmt, 0, '')) 72 106 73 107 def main(): 74 if len(sys.argv) != 4: 75 print "Usage: %s <kernel.map> <nm dump> <output.bin>" % sys.argv[0] 76 sys.exit(1) 77 78 kmapf = open(sys.argv[1],'r') 79 obmapf = open(sys.argv[2],'r') 80 out = open(sys.argv[3],'w') 81 generate(kmapf,obmapf,out) 82 kmapf.close() 83 obmapf.close() 84 out.close() 108 if (len(sys.argv) != 4): 109 print "Usage: %s <kernel.map> <nm dump> <output.bin>" % sys.argv[0] 110 return 1 111 112 kmapf = open(sys.argv[1], 'r') 113 obmapf = open(sys.argv[2], 'r') 114 out = open(sys.argv[3], 'w') 115 116 generate(kmapf, obmapf, out) 117 118 kmapf.close() 119 obmapf.close() 120 out.close() 85 121 86 122 if __name__ == '__main__': 87 main()123 sys.exit(main()) -
tools/autotool.py
r177e4ea r3c80f2b 27 27 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 # 29 29 30 """ 30 31 Detect important prerequisites and parameters for building HelenOS -
tools/config.py
r177e4ea r3c80f2b 28 28 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 29 # 30 30 31 """ 31 32 HelenOS configuration system 32 33 """ 34 33 35 import sys 34 36 import os -
tools/jobfile.py
r177e4ea r3c80f2b 27 27 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 # 29 29 30 """ 30 31 Add a source/object file pair to a checker jobfile -
tools/mkfat.py
r177e4ea r3c80f2b 27 27 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 # 29 29 30 """ 30 31 FAT creator -
tools/mkhord.py
r177e4ea r3c80f2b 27 27 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 # 29 29 30 """ 30 31 HORD encapsulator -
tools/mktmpfs.py
r177e4ea r3c80f2b 27 27 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 # 29 29 30 """ 30 31 TMPFS creator
Note:
See TracChangeset
for help on using the changeset viewer.