Fix for libgcc compat generation script.
Taking into account possibility that external symbol could have been an OBJECT instead of function. b/14090368 Change-Id: Iac173d2dd1309ed53024306578137c26b1dbbf15
This commit is contained in:
@@ -71,23 +71,7 @@ import subprocess
|
||||
import tempfile
|
||||
import re
|
||||
|
||||
libgcc_compat_header = "/* Generated by genlibgcc_compat.py */\n" + \
|
||||
"""
|
||||
#define COMPAT_FUNCTIONS_LIST \\
|
||||
"""
|
||||
|
||||
libgcc_compat_footer = """
|
||||
|
||||
#define XX(f) extern void f(void);
|
||||
COMPAT_FUNCTIONS_LIST
|
||||
#undef XX
|
||||
|
||||
void __bionic_libgcc_compat_hooks(void) {
|
||||
#define XX(f) f();
|
||||
COMPAT_FUNCTIONS_LIST
|
||||
#undef XX
|
||||
}
|
||||
"""
|
||||
libgcc_compat_header = "/* Generated by genlibgcc_compat.py */\n\n"
|
||||
|
||||
class Generator:
|
||||
def process(self):
|
||||
@@ -114,29 +98,36 @@ class Generator:
|
||||
|
||||
print "* Build complete, logfile: " + build_output_file_path
|
||||
|
||||
func_set = set()
|
||||
symbol_set = set()
|
||||
prog=re.compile("(?<=undefined reference to ')\w+")
|
||||
fd = open(build_output_file_path, 'r')
|
||||
for line in fd:
|
||||
m = prog.search(line)
|
||||
if m:
|
||||
func_set.add(m.group(0))
|
||||
symbol_set.add(m.group(0))
|
||||
|
||||
fd.close()
|
||||
|
||||
func_list = sorted(func_set)
|
||||
symbol_list = sorted(symbol_set)
|
||||
|
||||
print "* Found " + repr(len(func_list)) + " referenced functions: " + repr(func_list)
|
||||
print "* Found " + repr(len(symbol_list)) + " referenced symbols: " + repr(symbol_list)
|
||||
|
||||
if 0 == len(func_list):
|
||||
sys.exit("Error: function list is empty, please check the build log: " + build_output_file_path)
|
||||
if 0 == len(symbol_list):
|
||||
sys.exit("Error: symbol list is empty, please check the build log: " + build_output_file_path)
|
||||
|
||||
print "* Generating " + file_path
|
||||
fres = open(file_path, 'w')
|
||||
fres.write(libgcc_compat_header)
|
||||
for func_name in func_list:
|
||||
fres.write(" XX("+func_name+") \\\n")
|
||||
fres.write(libgcc_compat_footer)
|
||||
|
||||
for sym_name in symbol_list:
|
||||
fres.write("extern char "+sym_name+";\n")
|
||||
fres.write("\n");
|
||||
|
||||
fres.write("void* __bionic_libgcc_compat_symbols[] = {\n");
|
||||
for sym_name in symbol_list:
|
||||
fres.write(" &"+sym_name+",\n")
|
||||
fres.write("};\n");
|
||||
|
||||
fres.close()
|
||||
|
||||
generator = Generator()
|
||||
|
Reference in New Issue
Block a user