1#! /usr/bin/env python 2 3import sys; 4 5dataSymbolsByAddress = {} 6dataSymbols = [] 7versionedDataSymbolsByName = {} 8functionSymbolsByAddress = {} 9functionSymbols = [] 10versionedFunctionSymbolsByName = {} 11 12for line in sys.stdin.readlines(): 13 if line[0] != '0': 14 # ignore lines without an address 15 continue 16 17 (address, type, symbol) = line.split() 18 19 # select interesting types of symbols 20 if type not in 'BCDGRSTuVvWw': 21 continue 22 23 # drop symbols from legacy compiler that contain a dot (those produce 24 # syntax errors) 25 if '.' in symbol: 26 continue 27 28 if type in 'BD': 29 if '@' in symbol: 30 versionedDataSymbolsByName[symbol] = address 31 else: 32 if type not in 'VW': 33 dataSymbolsByAddress[address] = symbol 34 dataSymbols.append(symbol) 35 else: 36 if '@' in symbol: 37 versionedFunctionSymbolsByName[symbol] = address 38 else: 39 if type not in 'VW': 40 functionSymbolsByAddress[address] = symbol 41 functionSymbols.append(symbol) 42 43# add data symbols 44for dataSymbol in sorted(dataSymbols): 45 print 'int %s;' % dataSymbol 46 47print 48 49# add function symbols 50for functionSymbol in sorted(functionSymbols): 51 print 'void %s() {}' % functionSymbol 52 53print 54print "#include <symbol_versioning.h>" 55print 56 57# add symbol versioning information for data symbols 58for symbol in sorted(versionedDataSymbolsByName.keys()): 59 address = versionedDataSymbolsByName[symbol] 60 targetSymbol = dataSymbolsByAddress[address] 61 (symbolName, unused, versionTag) = symbol.partition('LIBROOT_') 62 print 'DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("%s", "%s", "%s");' \ 63 % (targetSymbol, symbolName, versionTag) 64 65# add symbol versioning information for function symbols 66for symbol in sorted(versionedFunctionSymbolsByName.keys()): 67 address = versionedFunctionSymbolsByName[symbol] 68 targetSymbol = functionSymbolsByAddress[address] 69 (symbolName, unused, versionTag) = symbol.partition('LIBROOT_') 70 print 'DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("%s", "%s", "%s");' \ 71 % (targetSymbol, symbolName, versionTag) 72