Fix runtime/tools/bin_to_assembly.py not setting symbol type and size.

The absence of symbol sizes broke build comparison that looks for and
ignores snapshots. Add symbol types for good measure to match the compiler
behavior.

Consider unknown operating systems to use as(1)-style assembly, which is
generally true. If an unknown operating system uses another syntax, the
generated files will fail to assemble and the porter should soon find
this script and add support for their operating system.

R=whesse@google.com

Review-Url: https://codereview.chromium.org/2939013002 .
This commit is contained in:
Jonas Termansen 2017-06-15 13:40:29 +02:00
parent f18601df57
commit 742822af73

View file

@ -57,14 +57,6 @@ def Main():
output_file.write(".global _%s\n" % options.symbol_name)
output_file.write(".balign 32\n")
output_file.write("_%s:\n" % options.symbol_name)
elif options.target_os in ["linux", "android", "fuchsia"]:
if options.executable:
output_file.write(".text\n")
else:
output_file.write(".section .rodata\n")
output_file.write(".global %s\n" % options.symbol_name)
output_file.write(".balign 32\n")
output_file.write("%s:\n" % options.symbol_name)
elif options.target_os in ["win"]:
output_file.write("ifndef _ML64_X64\n")
output_file.write(".model flat, C\n")
@ -76,8 +68,15 @@ def Main():
output_file.write("public %s\n" % options.symbol_name)
output_file.write("%s label byte\n" % options.symbol_name)
else:
sys.stderr.write("Unknown target_os: %s" % options.target_os)
return -1
if options.executable:
output_file.write(".text\n")
output_file.write(".type %s STT_FUNC\n" % options.symbol_name)
else:
output_file.write(".section .rodata\n")
output_file.write(".type %s STT_OBJECT\n" % options.symbol_name)
output_file.write(".global %s\n" % options.symbol_name)
output_file.write(".balign 32\n")
output_file.write("%s:\n" % options.symbol_name)
with open(options.input, "rb") as input_file:
if options.target_os in ["win"]:
@ -88,6 +87,9 @@ def Main():
for byte in input_file.read():
output_file.write(".byte %d\n" % ord(byte))
if options.target_os not in ["mac", "ios", "win"]:
output_file.write(".size {0}, .-{0}\n".format(options.symbol_name))
return 0
if __name__ == "__main__":