this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Create stub-gen-c-func.py

authored by

Andrew Hyatt and committed by
GitHub
0c00bb48 5b4acc74

+76
+76
tools/stub-gen-c-func.py
··· 1 + # This file is part of Darling. 2 + # 3 + # Copyright (C) 2017 Lubos Dolezel 4 + # 5 + # Darling is free software: you can redistribute it and/or modify 6 + # it under the terms of the GNU General Public License as published by 7 + # the Free Software Foundation, either version 3 of the License, or 8 + # (at your option) any later version. 9 + # 10 + # Darling is distributed in the hope that it will be useful, 11 + # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + # GNU General Public License for more details. 14 + # 15 + # You should have received a copy of the GNU General Public License 16 + # along with Darling. If not, see <http://www.gnu.org/licenses/>. 17 + 18 + import sys, subprocess 19 + 20 + def usage(): 21 + print "Usage: %s <Mach-O> <output directory>" % sys.argv[0] 22 + 23 + if len(sys.argv) != 3: 24 + usage() 25 + 26 + macho = sys.argv[1] 27 + dest = sys.argv[2] 28 + 29 + out = subprocess.check_output(["nm", "-Ug", macho]) 30 + 31 + functions = [] 32 + for line in out.split("\n"): 33 + if line == "": 34 + continue 35 + components = line.split(" ") 36 + id = components[1] 37 + name = components[2] 38 + # Remove the underscore 39 + name = name[1 : len(name)] 40 + 41 + if id == "T": 42 + functions.append(name) 43 + 44 + header = open(dest + "/functions.h", "w") 45 + source = open(dest + "/functions.c", "w") 46 + 47 + copyright ="""/* 48 + This file is part of Darling. 49 + 50 + Copyright (C) 2017 Lubos Dolezel 51 + 52 + Darling is free software: you can redistribute it and/or modify 53 + it under the terms of the GNU General Public License as published by 54 + the Free Software Foundation, either version 3 of the License, or 55 + (at your option) any later version. 56 + 57 + Darling is distributed in the hope that it will be useful, 58 + but WITHOUT ANY WARRANTY; without even the implied warranty of 59 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 60 + GNU General Public License for more details. 61 + 62 + You should have received a copy of the GNU General Public License 63 + along with Darling. If not, see <http://www.gnu.org/licenses/>. 64 + */ 65 + 66 + """ 67 + 68 + header.write(copyright) 69 + source.write(copyright) 70 + 71 + for funcname in functions: 72 + header.write("void %s(void);\n" % funcname) 73 + source.write("void %s(void) { }\n" % funcname) 74 + 75 + header.close() 76 + source.close()