Skip to content

Commit

Permalink
Move the Syzygy scripts out of //chrome/
Browse files Browse the repository at this point in the history
Also move the syzygy_optimize and syzygy_asan GN templates to //build/win/syzygy so they can be reused in //content (without adding a dependency with //chrome).

BUG=619086

Committed: https://crrev.com/71a43cab53042f33d77fe8eebe8c2463a92f9758
Review-Url: https://codereview.chromium.org/2126673002
Cr-Original-Commit-Position: refs/heads/master@{#404503}
Cr-Commit-Position: refs/heads/master@{#404672}
  • Loading branch information
sebmarchand authored and Commit bot committed Jul 11, 2016
1 parent 557ed0b commit 3e9548c
Show file tree
Hide file tree
Showing 13 changed files with 187 additions and 171 deletions.
3 changes: 0 additions & 3 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -988,9 +988,6 @@ if (!is_ios && !is_android && !is_chromecast) {
# TODO(GYP): Add this once it exists, https://crbug.com/619086
# "//content/shell:content_shell_syzyasan
]
if (is_multi_dll_chrome) {
deps += [ "//chrome/tools/build/win/syzygy:chrome_child_dll_syzygy" ]
}
}
}
}
Expand Down
23 changes: 23 additions & 0 deletions build/win/syzygy/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

copy("copy_syzyasan_binaries") {
visibility = [
"//chrome/*",
"//content/*",
]

source_dir = "//third_party/syzygy/binaries/exe"

sources = [
"$source_dir/agent_logger.exe",
"$source_dir/minidump_symbolizer.py",
"$source_dir/syzyasan_rtl.dll",
"$source_dir/syzyasan_rtl.dll.pdb",
]

outputs = [
"$root_out_dir/syzygy/{{source_file_part}}",
]
}
3 changes: 3 additions & 0 deletions build/win/syzygy/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
chrisha@chromium.org
sebmarchand@chromiun.org
siggi@chromium.org
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# The default directory containing the Syzygy toolchain.
_DEFAULT_SYZYGY_DIR = os.path.abspath(os.path.join(
os.path.dirname(__file__), '../../../../..',
os.path.dirname(__file__), '../../..',
'third_party/syzygy/binaries/exe/'))

# Basenames of various tools.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# The default relink executable to use to reorder binaries.
_DEFAULT_RELINKER = os.path.join(
os.path.join(os.path.dirname(__file__), '../../../../..'),
os.path.join(os.path.dirname(__file__), '../../..'),
'third_party/syzygy/binaries/exe/relink.exe')

_LOGGER = logging.getLogger()
Expand Down
137 changes: 137 additions & 0 deletions build/win/syzygy/syzygy.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

assert(is_win)

# Where the output binaries will be placed.
syzygy_dest_dir = "$root_out_dir/syzygy"

# Generates a Syzygy optimize target.
#
# binary_name (required)
# Name of the binary to be instrumented, with no extension or path. This
# binary_name is assumed to be in the output directory and must be
# generated by a dependency of this target.
#
# deps (required)
# Normal meaning.
#
# data_deps
# Normal meaning.
template("syzygy_optimize") {
action(target_name) {
if (defined(invoker.visibility)) {
visibility = invoker.visibility
}
script = "//build/win/syzygy/reorder.py"

binary_name = invoker.binary_name
input_dll = "$root_out_dir/$binary_name"
input_pdb = "$root_out_dir/$binary_name.pdb"

inputs = [
input_dll,
#input_pdb,
]

outputs = [
"$syzygy_dest_dir/$binary_name",
"$syzygy_dest_dir/$binary_name.pdb",
]

args = [
"--input_executable",
rebase_path(input_dll, root_build_dir),
"--input_symbol",
rebase_path(input_pdb, root_build_dir),
"--destination_dir",
rebase_path(syzygy_dest_dir, root_build_dir),
]

forward_variables_from(invoker,
[
"deps",
"data_deps",
"public_deps",
])
}
}

# Instruments a binary with SyzyAsan.
#
# binary_name (required)
# Name of the binary to be instrumented, with no extension or path. This
# binary_name is assumed to be in the output directory and must be
# generated by a dependency of this target.
#
# dest_dir (required)
# The destination directory where the instrumented image should be
# written.
#
# deps (required)
# Normal meaning.
#
# public_deps
# Normal meaning.
#
# data_deps
# Normal meaning.
template("syzygy_asan") {
action(target_name) {
if (defined(invoker.visibility)) {
visibility = invoker.visibility
}
script = "//build/win/syzygy/instrument.py"

filter = "//build/win/syzygy/syzyasan-instrumentation-filter.txt"

binary_name = invoker.binary_name
dest_dir = invoker.dest_dir
input_image = "$root_out_dir/$binary_name"
input_pdb = "$root_out_dir/$binary_name.pdb"

inputs = [
filter,
input_image,

#input_pdb,
]

output_filter = "$dest_dir/win-syzyasan-filter-$binary_name.txt.json"

outputs = [
"$dest_dir/$binary_name",
"$dest_dir/$binary_name.pdb",
output_filter,
]

args = [
"--mode",
"asan",
"--input_executable",
rebase_path(input_image, root_build_dir),
"--input_symbol",
rebase_path(input_pdb, root_build_dir),
"--filter",
rebase_path(filter, root_build_dir),
"--output-filter-file",
rebase_path(output_filter, root_build_dir),
"--destination_dir",
rebase_path(dest_dir, root_build_dir),
]

deps = [
"//build/win/syzygy:copy_syzyasan_binaries",
]
if (defined(invoker.deps)) {
deps += invoker.deps
}
forward_variables_from(invoker,
[
"data_deps",
"public_deps",
"testonly",
])
}
}
13 changes: 6 additions & 7 deletions chrome/chrome_syzygy.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{
'action_name': 'Reorder Chrome with Syzygy',
'inputs': [
'<(DEPTH)/chrome/tools/build/win/syzygy/reorder.py',
'<(DEPTH)/build/win/syzygy/reorder.py',
'<(PRODUCT_DIR)/<(dll_name).dll',
'<(PRODUCT_DIR)/<(dll_name).dll.pdb',
],
Expand All @@ -33,7 +33,7 @@
],
'action': [
'python',
'<(DEPTH)/chrome/tools/build/win/syzygy/reorder.py',
'<(DEPTH)/build/win/syzygy/reorder.py',
'--input_executable', '<(PRODUCT_DIR)/<(dll_name).dll',
'--input_symbol', '<(PRODUCT_DIR)/<(dll_name).dll.pdb',
'--destination_dir', '<(dest_dir)',
Expand All @@ -47,8 +47,8 @@
{
'action_name': 'Instrument Chrome with SyzyAsan',
'inputs': [
'<(DEPTH)/chrome/tools/build/win/syzygy/instrument.py',
'<(DEPTH)/chrome/tools/build/win/syzygy/'
'<(DEPTH)/build/win/syzygy/instrument.py',
'<(DEPTH)/build/win/syzygy/'
'syzyasan-instrumentation-filter.txt',
'<(PRODUCT_DIR)/<(dll_name).dll',
],
Expand All @@ -59,13 +59,12 @@
],
'action': [
'python',
'<(DEPTH)/chrome/tools/build/win/syzygy/instrument.py',
'<(DEPTH)/build/win/syzygy/instrument.py',
'--mode', 'asan',
'--input_executable', '<(PRODUCT_DIR)/<(dll_name).dll',
'--input_symbol', '<(PRODUCT_DIR)/<(dll_name).dll.pdb',
'--filter',
'<(DEPTH)/chrome/tools/build/win/syzygy/'
'syzyasan-instrumentation-filter.txt',
'<(DEPTH)/build/win/syzygy/syzyasan-instrumentation-filter.txt',
'--output-filter-file',
'<(dest_dir)/win-syzyasan-filter-<(dll_name).txt.json',
'--destination_dir', '<(dest_dir)',
Expand Down
2 changes: 1 addition & 1 deletion chrome/installer/mini_installer/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ generate_mini_installer("mini_installer") {
chrome_dll_target = "//chrome:main_dll"
}

if (syzygy_optimize) {
if (syzygy_optimize || is_syzyasan) {
generate_mini_installer("mini_installer_syzygy") {
out_dir = "$root_out_dir/syzygy/"
chrome_dll_file = "$root_out_dir/syzygy/chrome.dll"
Expand Down
Loading

0 comments on commit 3e9548c

Please sign in to comment.