OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import("//build/config/chrome_build.gni") | 5 import("//build/config/chrome_build.gni") |
6 import("//build/config/compiler/compiler.gni") | 6 import("//build/config/compiler/compiler.gni") |
7 import("//build/config/sanitizers/sanitizers.gni") | 7 import("//build/config/sanitizers/sanitizers.gni") |
| 8 import("//build/win/syzygy/syzygy.gni") |
8 | 9 |
9 assert(!syzygy_optimize || !is_syzyasan, | 10 assert(!syzygy_optimize || !is_syzyasan, |
10 "Don't do both syzygy_optimize and is_syzyasan") | 11 "Don't do both syzygy_optimize and is_syzyasan") |
11 | 12 |
12 # Where the output binaries will be placed. | 13 # Where the output binaries will be placed. |
13 syzygy_dest_dir = "$root_out_dir/syzygy" | 14 syzygy_dest_dir = "$root_out_dir/syzygy" |
14 | 15 |
15 if (syzygy_optimize) { | 16 if (syzygy_optimize) { |
16 # Generates a Syzygy optimize target. | |
17 # | |
18 # dll_name (required) | |
19 # Name of the DLL to be instrumented, with no extension or path. This | |
20 # ${dll_name}.dll is assumed to be in the output directory and must be | |
21 # generated by a dependency of this target. | |
22 # | |
23 # deps (required) | |
24 # Normal meaning. | |
25 # | |
26 # data_deps | |
27 # Normal meaning. | |
28 template("syzygy_optimize") { | |
29 action(target_name) { | |
30 if (defined(invoker.visibility)) { | |
31 visibility = invoker.visibility | |
32 } | |
33 script = "//chrome/tools/build/win/syzygy/reorder.py" | |
34 | |
35 dll_name = invoker.dll_name | |
36 input_dll = "$root_out_dir/$dll_name.dll" | |
37 input_pdb = "$root_out_dir/$dll_name.dll.pdb" | |
38 | |
39 inputs = [ | |
40 input_dll, | |
41 #input_pdb, | |
42 ] | |
43 | |
44 outputs = [ | |
45 "$syzygy_dest_dir/$dll_name.dll", | |
46 "$syzygy_dest_dir/$dll_name.dll.pdb", | |
47 ] | |
48 | |
49 args = [ | |
50 "--input_executable", | |
51 rebase_path(input_dll, root_build_dir), | |
52 "--input_symbol", | |
53 rebase_path(input_pdb, root_build_dir), | |
54 "--destination_dir", | |
55 rebase_path(syzygy_dest_dir, root_build_dir), | |
56 ] | |
57 | |
58 forward_variables_from(invoker, | |
59 [ | |
60 "deps", | |
61 "data_deps", | |
62 "public_deps", | |
63 ]) | |
64 } | |
65 } | |
66 | |
67 syzygy_optimize("chrome_dll_syzygy") { | 17 syzygy_optimize("chrome_dll_syzygy") { |
68 dll_name = "chrome" | 18 binary_name = "chrome.dll" |
69 deps = [ | 19 deps = [ |
70 "//chrome:main_dll", | 20 "//chrome:main_dll", |
71 ] | 21 ] |
72 if (is_multi_dll_chrome) { | 22 if (is_multi_dll_chrome) { |
73 data_deps = [ | 23 data_deps = [ |
74 ":chrome_child_dll_syzygy", | 24 ":chrome_child_dll_syzygy", |
75 ] | 25 ] |
76 } | 26 } |
77 } | 27 } |
78 if (is_multi_dll_chrome) { | 28 if (is_multi_dll_chrome) { |
79 # Also instrument chrome_child.dll. | 29 # Also instrument chrome_child.dll. |
80 syzygy_optimize("chrome_child_dll_syzygy") { | 30 syzygy_optimize("chrome_child_dll_syzygy") { |
81 dll_name = "chrome_child" | 31 binary_name = "chrome_child.dll" |
82 deps = [ | 32 deps = [ |
83 "//chrome:chrome_child", | 33 "//chrome:chrome_child", |
84 ] | 34 ] |
85 } | 35 } |
86 } | 36 } |
87 } else if (is_syzyasan) { | 37 } else if (is_syzyasan) { |
88 # Instruments a binary with SyzyAsan. | |
89 # | |
90 # binary_name (required) | |
91 # Name of the binary to be instrumented, with no extension or path. This | |
92 # binary_name is assumed to be in the output directory and must be | |
93 # generated by a dependency of this target. | |
94 # | |
95 # dest_dir (required) | |
96 # The destination directory where the instrumented image should be | |
97 # written. | |
98 # | |
99 # deps (required) | |
100 # Normal meaning. | |
101 # | |
102 # public_deps | |
103 # Normal meaning. | |
104 # | |
105 # data_deps | |
106 # Normal meaning. | |
107 template("syzygy_asan") { | |
108 action(target_name) { | |
109 if (defined(invoker.visibility)) { | |
110 visibility = invoker.visibility | |
111 } | |
112 script = "//chrome/tools/build/win/syzygy/instrument.py" | |
113 | |
114 filter = "syzyasan-instrumentation-filter.txt" | |
115 | |
116 binary_name = invoker.binary_name | |
117 dest_dir = invoker.dest_dir | |
118 input_image = "$root_out_dir/$binary_name" | |
119 input_pdb = "$root_out_dir/$binary_name.pdb" | |
120 | |
121 inputs = [ | |
122 filter, | |
123 input_image, | |
124 | |
125 #input_pdb, | |
126 ] | |
127 | |
128 output_filter = "$dest_dir/win-syzyasan-filter-$binary_name.txt.json" | |
129 | |
130 outputs = [ | |
131 "$dest_dir/$input_image", | |
132 "$dest_dir/$input_image.pdb", | |
133 output_filter, | |
134 ] | |
135 | |
136 args = [ | |
137 "--mode", | |
138 "asan", | |
139 "--input_executable", | |
140 rebase_path(input_image, root_build_dir), | |
141 "--input_symbol", | |
142 rebase_path(input_pdb, root_build_dir), | |
143 "--filter", | |
144 rebase_path(filter, root_build_dir), | |
145 "--output-filter-file", | |
146 rebase_path(output_filter, root_build_dir), | |
147 "--destination_dir", | |
148 rebase_path(dest_dir, root_build_dir), | |
149 ] | |
150 | |
151 deps = [ | |
152 "//chrome/tools/build/win/syzygy:copy_syzyasan_binaries", | |
153 ] | |
154 if (defined(invoker.deps)) { | |
155 deps += invoker.deps | |
156 } | |
157 forward_variables_from(invoker, | |
158 [ | |
159 "data_deps", | |
160 "public_deps", | |
161 ]) | |
162 } | |
163 } | |
164 | |
165 syzygy_asan("chrome_dll_syzygy") { | 38 syzygy_asan("chrome_dll_syzygy") { |
166 binary_name = "chrome.dll" | 39 binary_name = "chrome.dll" |
167 dest_dir = syzygy_dest_dir | 40 dest_dir = syzygy_dest_dir |
168 deps = [ | 41 deps = [ |
169 "//chrome:main_dll", | 42 "//chrome:main_dll", |
170 ] | 43 ] |
| 44 if (is_multi_dll_chrome) { |
| 45 data_deps = [ |
| 46 ":chrome_child_dll_syzygy", |
| 47 ] |
| 48 } |
171 } | 49 } |
172 | 50 |
173 if (is_multi_dll_chrome) { | 51 if (is_multi_dll_chrome) { |
174 # Also instrument chrome_child.dll. | 52 # Also instrument chrome_child.dll. |
175 # | 53 # |
176 # For official builds, the instrumented version will be put into an | 54 # For official builds, the instrumented version will be put into an |
177 # "instrumented" subdirectory and the regular output will be | 55 # "instrumented" subdirectory and the regular output will be |
178 # uninstrumented. Otherwise, chrome_child is also instrumented to the | 56 # uninstrumented. Otherwise, chrome_child is also instrumented to the |
179 # normal place. | 57 # normal place. |
180 syzygy_asan("chrome_child_dll_syzygy") { | 58 syzygy_asan("chrome_child_dll_syzygy") { |
181 binary_name = "chrome_child.dll" | 59 binary_name = "chrome_child.dll" |
182 deps = [ | 60 deps = [ |
183 "//chrome:chrome_child", | 61 "//chrome:chrome_child", |
184 ] | 62 ] |
185 | 63 |
186 if (is_official_build) { | 64 if (is_official_build) { |
187 dest_dir = "$syzygy_dest_dir/instrumented" | 65 dest_dir = "$syzygy_dest_dir/instrumented" |
188 deps += [ ":chrome_child_dll_syzygy_copy" ] | 66 deps += [ ":chrome_child_dll_syzygy_copy" ] |
189 } else { | 67 } else { |
190 dest_dir = syzygy_dest_dir | 68 dest_dir = syzygy_dest_dir |
191 } | 69 } |
192 | |
193 data_deps = [ | |
194 ":chrome_child_dll_syzygy", | |
195 ] | |
196 } | 70 } |
197 | 71 |
198 if (is_official_build) { | 72 if (is_official_build) { |
199 # Copies the uninstrumented chrome_child.dll. | 73 # Copies the uninstrumented chrome_child.dll. |
200 # GYP version: chrome/chrome_syzygy.gyp:chrome_child_dll_syzygy_copy | 74 # GYP version: chrome/chrome_syzygy.gyp:chrome_child_dll_syzygy_copy |
201 copy("chrome_child_dll_syzygy_copy") { | 75 copy("chrome_child_dll_syzygy_copy") { |
202 sources = [ | 76 sources = [ |
203 "$root_out_dir/chrome_child.dll", | 77 "$root_out_dir/chrome_child.dll", |
204 "$root_out_dir/chrome_child.dll.pdb", | |
205 ] | 78 ] |
206 outputs = [ | 79 outputs = [ |
207 "$dest_dir/{{source_file_part}}", | 80 "$syzygy_dest_dir/{{source_file_part}}", |
208 ] | 81 ] |
209 deps = [ | 82 deps = [ |
210 "//chrome:chrome_child", | 83 "//chrome:chrome_child", |
211 ] | 84 ] |
212 } | 85 } |
213 } | 86 } |
214 } | 87 } |
215 } else { | 88 } else { |
216 # No syzygy. Generate dummy targets so other targets can unconditionally | 89 # No syzygy. Generate dummy targets so other targets can unconditionally |
217 # depend on these without having to duplicate our conditions. | 90 # depend on these without having to duplicate our conditions. |
218 group("chrome_dll_syzygy") { | 91 group("chrome_dll_syzygy") { |
219 } | 92 } |
220 if (is_multi_dll_chrome) { | 93 if (is_multi_dll_chrome) { |
221 group("chrome_child_dll_syzygy") { | 94 group("chrome_child_dll_syzygy") { |
222 } | 95 } |
223 } | 96 } |
224 } | 97 } |
225 | 98 |
226 if (is_syzyasan || syzygy_optimize) { | |
227 copy("copy_syzyasan_binaries") { | |
228 visibility = [ "//chrome/*" ] | |
229 | |
230 source_dir = "//third_party/syzygy/binaries/exe" | |
231 | |
232 sources = [ | |
233 "$source_dir/agent_logger.exe", | |
234 "$source_dir/minidump_symbolizer.py", | |
235 "$source_dir/syzyasan_rtl.dll", | |
236 "$source_dir/syzyasan_rtl.dll.pdb", | |
237 ] | |
238 | |
239 outputs = [ | |
240 "$syzygy_dest_dir/{{source_file_part}}", | |
241 ] | |
242 } | |
243 } | |
244 | |
245 # Prevent unused variable warning for code paths where this is unused. | 99 # Prevent unused variable warning for code paths where this is unused. |
246 assert(syzygy_dest_dir != "") | 100 assert(syzygy_dest_dir != "") |
OLD | NEW |