зеркало из https://github.com/AvaloniaUI/angle.git
Android: Fix symbol compression logic
Update the logic to compress ANGLE's symbols for Android to correctly include the necessary symbols. Bug: angleproject:3448 Test: Build and install APK, verify symbols are present during crash Change-Id: Ibb995aa775d47fb9921e4ab11b956c63ac474c30 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1611750 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com>
This commit is contained in:
Родитель
af6a51e0db
Коммит
73e17bf7d9
5
BUILD.gn
5
BUILD.gn
|
@ -1094,14 +1094,15 @@ if (!is_component_build && is_android && symbol_level != 0) {
|
|||
]
|
||||
|
||||
android_nm = "${android_tool_prefix}nm"
|
||||
android_strip = "${android_tool_prefix}strip"
|
||||
|
||||
args = [
|
||||
"--objcopy",
|
||||
rebase_path(android_objcopy, root_build_dir),
|
||||
"--nm",
|
||||
rebase_path(android_nm, root_build_dir),
|
||||
"--sofile",
|
||||
"{{source}}",
|
||||
"--strip",
|
||||
rebase_path(android_strip, root_build_dir),
|
||||
"--unstrippedsofile",
|
||||
"{{source_dir}}/lib.unstripped/{{source_file_part}}",
|
||||
"--output",
|
||||
|
|
|
@ -5,10 +5,9 @@
|
|||
|
||||
# Generate library file with compressed symbols per Android build
|
||||
# process.
|
||||
#
|
||||
# https://www.ece.villanova.edu/VECR/doc/gdb/MiniDebugInfo.html
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
@ -18,11 +17,7 @@ def main():
|
|||
parser.add_argument(
|
||||
'--objcopy', required=True, help='The objcopy binary to run', metavar='PATH')
|
||||
parser.add_argument('--nm', required=True, help='The nm binary to run', metavar='PATH')
|
||||
parser.add_argument(
|
||||
'--sofile',
|
||||
required=True,
|
||||
help='Shared object file produced by linking command',
|
||||
metavar='FILE')
|
||||
parser.add_argument('--strip', required=True, help='The strip binary to run', metavar='PATH')
|
||||
parser.add_argument(
|
||||
'--output', required=True, help='Final output shared object file', metavar='FILE')
|
||||
parser.add_argument(
|
||||
|
@ -32,65 +27,54 @@ def main():
|
|||
metavar='FILE')
|
||||
args = parser.parse_args()
|
||||
|
||||
copy_cmd = ["cp", args.sofile, args.output]
|
||||
copy_cmd = ["cp", args.unstrippedsofile, args.output]
|
||||
result = subprocess.call(copy_cmd)
|
||||
|
||||
objcopy_cmd = [args.objcopy]
|
||||
objcopy_cmd.append('--only-keep-debug')
|
||||
objcopy_cmd.append(args.unstrippedsofile)
|
||||
objcopy_cmd.append(args.output + '.debug')
|
||||
result = subprocess.call(objcopy_cmd)
|
||||
|
||||
nm_cmd = subprocess.Popen([args.nm, args.unstrippedsofile, '--format=posix', '--defined-only'],
|
||||
nm_cmd = subprocess.Popen([args.nm, '-D', args.output, '--format=posix', '--defined-only'],
|
||||
stdout=subprocess.PIPE)
|
||||
|
||||
awk_cmd = subprocess.Popen(['awk', '{ print $1}'], stdin=nm_cmd.stdout, stdout=subprocess.PIPE)
|
||||
|
||||
dynsym_out = open(args.output + '.dynsyms', 'w')
|
||||
sort_cmd = subprocess.Popen(['sort'], stdin=awk_cmd.stdout, stdout=dynsym_out)
|
||||
sort_cmd.wait()
|
||||
dynsym_out.close()
|
||||
|
||||
nm_cmd = subprocess.Popen([args.nm, args.unstrippedsofile, '--format=posix', '--defined-only'],
|
||||
funcsyms_out = open(args.output + '.funcsyms', 'w')
|
||||
nm_cmd = subprocess.Popen([args.nm, args.output, '--format=posix', '--defined-only'],
|
||||
stdout=subprocess.PIPE)
|
||||
|
||||
awk_cmd = subprocess.Popen(
|
||||
['awk', '{ if ($2 == "T" || $2 == "t" ||' + ' $2 == "D") print $1 }'],
|
||||
stdin=nm_cmd.stdout,
|
||||
stdout=subprocess.PIPE)
|
||||
awk_cmd = subprocess.Popen(['awk', '{ if ($2 == "T" || $2 == "t" || $2 == "D") print $1 }'],
|
||||
stdin=nm_cmd.stdout,
|
||||
stdout=subprocess.PIPE)
|
||||
|
||||
funcsyms_out = open(args.output + '.funcsyms', 'w')
|
||||
sort_cmd = subprocess.Popen(['sort'], stdin=awk_cmd.stdout, stdout=funcsyms_out)
|
||||
sort_cmd.wait()
|
||||
funcsyms_out.close()
|
||||
|
||||
keep_symbols = open(args.output + '.keep_symbols', 'w')
|
||||
sort_cmd = subprocess.Popen(
|
||||
['comm', '-13', args.output + '.dynsyms', args.output + '.funcsyms'],
|
||||
stdin=awk_cmd.stdout,
|
||||
stdout=keep_symbols)
|
||||
comm_cmd = subprocess.Popen(
|
||||
['comm', '-13', args.output + '.dynsyms', args.output + '.funcsyms'], stdout=keep_symbols)
|
||||
comm_cmd.wait()
|
||||
|
||||
# Ensure that the keep_symbols file is not empty.
|
||||
keep_symbols.write("\n")
|
||||
keep_symbols.close()
|
||||
|
||||
objcopy_cmd = [
|
||||
args.objcopy, '--rename-section', '.debug_frame=saved_debug_frame', args.output + '.debug',
|
||||
args.output + ".mini_debuginfo"
|
||||
]
|
||||
objcopy_cmd = [args.objcopy, '--only-keep-debug', args.output, args.output + '.debug']
|
||||
subprocess.check_call(objcopy_cmd)
|
||||
|
||||
objcopy_cmd = [
|
||||
args.objcopy, '-S', '--remove-section', '.gdb_index', '--remove-section', '.comment',
|
||||
'--keep-symbols=' + args.output + '.keep_symbols', args.output + '.mini_debuginfo'
|
||||
'--keep-symbols', args.output + '.keep_symbols', args.output + '.debug',
|
||||
args.output + '.mini_debuginfo'
|
||||
]
|
||||
subprocess.check_call(objcopy_cmd)
|
||||
|
||||
objcopy_cmd = [
|
||||
args.objcopy, '--rename-section', '.saved_debug_frame=.debug_frame',
|
||||
args.output + ".mini_debuginfo"
|
||||
]
|
||||
subprocess.check_call(objcopy_cmd)
|
||||
strip_cmd = [args.strip, '--strip-all', '-R', '.comment', args.output]
|
||||
subprocess.check_call(strip_cmd)
|
||||
|
||||
xz_cmd = ['xz', args.output + '.mini_debuginfo']
|
||||
xz_cmd = ['xz', '-f', args.output + '.mini_debuginfo']
|
||||
subprocess.check_call(xz_cmd)
|
||||
|
||||
objcopy_cmd = [
|
||||
|
|
Загрузка…
Ссылка в новой задаче