blob: 15db2ad6e0c0bceb1f02b57709d52b04fc34278d [file] [log] [blame]
Colin Cross4d9c2d12016-07-29 12:48:20 -07001// Copyright 2016 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package cc
16
17import (
Dan Willemsena0790e32018-10-12 00:24:23 -070018 "github.com/google/blueprint"
19
Colin Cross4d9c2d12016-07-29 12:48:20 -070020 "android/soong/android"
21)
22
23type BinaryLinkerProperties struct {
24 // compile executable with -static
25 Static_executable *bool `android:"arch_variant"`
26
27 // set the name of the output
Nan Zhang0007d812017-11-07 10:57:05 -080028 Stem *string `android:"arch_variant"`
Colin Cross4d9c2d12016-07-29 12:48:20 -070029
30 // append to the name of the output
Nan Zhang0007d812017-11-07 10:57:05 -080031 Suffix *string `android:"arch_variant"`
Colin Cross4d9c2d12016-07-29 12:48:20 -070032
33 // if set, add an extra objcopy --prefix-symbols= step
Nan Zhang0007d812017-11-07 10:57:05 -080034 Prefix_symbols *string
Colin Cross1e7d3702016-08-24 15:25:47 -070035
36 // if set, install a symlink to the preferred architecture
Nan Zhang0007d812017-11-07 10:57:05 -080037 Symlink_preferred_arch *bool
Colin Cross522e3732016-09-07 13:14:06 -070038
Colin Cross9b09f242016-12-07 13:37:42 -080039 // install symlinks to the binary. Symlink names will have the suffix and the binary
40 // extension (if any) appended
41 Symlinks []string `android:"arch_variant"`
42
Colin Cross522e3732016-09-07 13:14:06 -070043 DynamicLinker string `blueprint:"mutated"`
Yifan Hong946e32e2018-04-03 13:22:50 -070044
45 // Names of modules to be overridden. Listed modules can only be other binaries
46 // (in Make or Soong).
47 // This does not completely prevent installation of the overridden binaries, but if both
48 // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed
49 // from PRODUCT_PACKAGES.
50 Overrides []string
Colin Cross4d9c2d12016-07-29 12:48:20 -070051}
52
53func init() {
Colin Cross798bfce2016-10-12 14:28:16 -070054 android.RegisterModuleType("cc_binary", binaryFactory)
55 android.RegisterModuleType("cc_binary_host", binaryHostFactory)
Colin Cross4d9c2d12016-07-29 12:48:20 -070056}
57
58// Module factory for binaries
Colin Cross36242852017-06-23 15:06:31 -070059func binaryFactory() android.Module {
Colin Crossb916a382016-07-29 17:28:03 -070060 module, _ := NewBinary(android.HostAndDeviceSupported)
Colin Cross4d9c2d12016-07-29 12:48:20 -070061 return module.Init()
62}
63
64// Module factory for host binaries
Colin Cross36242852017-06-23 15:06:31 -070065func binaryHostFactory() android.Module {
Colin Crossb916a382016-07-29 17:28:03 -070066 module, _ := NewBinary(android.HostSupported)
Colin Cross4d9c2d12016-07-29 12:48:20 -070067 return module.Init()
68}
69
70//
71// Executables
72//
73
Colin Crossb916a382016-07-29 17:28:03 -070074type binaryDecorator struct {
75 *baseLinker
Colin Cross1e7d3702016-08-24 15:25:47 -070076 *baseInstaller
Colin Cross4d9c2d12016-07-29 12:48:20 -070077 stripper
78
79 Properties BinaryLinkerProperties
80
Dan Willemsen4aa75ca2016-09-28 16:18:03 -070081 toolPath android.OptionalPath
Colin Cross9b09f242016-12-07 13:37:42 -080082
Colin Crossb60190a2018-09-04 16:28:17 -070083 // Location of the linked, unstripped binary
84 unstrippedOutputFile android.Path
85
Colin Cross9b09f242016-12-07 13:37:42 -080086 // Names of symlinks to be installed for use in LOCAL_MODULE_SYMLINKS
87 symlinks []string
Dan Willemsen581341d2017-02-09 16:16:31 -080088
89 // Output archive of gcno coverage information
90 coverageOutputFile android.OptionalPath
Colin Cross4d9c2d12016-07-29 12:48:20 -070091}
92
Colin Crossb916a382016-07-29 17:28:03 -070093var _ linker = (*binaryDecorator)(nil)
Colin Cross4d9c2d12016-07-29 12:48:20 -070094
Colin Crossb916a382016-07-29 17:28:03 -070095func (binary *binaryDecorator) linkerProps() []interface{} {
Colin Cross42742b82016-08-01 13:20:05 -070096 return append(binary.baseLinker.linkerProps(),
Colin Cross4d9c2d12016-07-29 12:48:20 -070097 &binary.Properties,
98 &binary.stripper.StripProperties)
99
100}
101
Colin Crossb916a382016-07-29 17:28:03 -0700102func (binary *binaryDecorator) getStem(ctx BaseModuleContext) string {
Colin Crossce75d2c2016-10-06 16:12:58 -0700103 stem := ctx.baseModuleName()
Nan Zhang0007d812017-11-07 10:57:05 -0800104 if String(binary.Properties.Stem) != "" {
105 stem = String(binary.Properties.Stem)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700106 }
107
Nan Zhang0007d812017-11-07 10:57:05 -0800108 return stem + String(binary.Properties.Suffix)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700109}
110
Colin Cross37047f12016-12-13 17:06:13 -0800111func (binary *binaryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
Colin Cross42742b82016-08-01 13:20:05 -0700112 deps = binary.baseLinker.linkerDeps(ctx, deps)
Dan Willemsen2e47b342016-11-17 01:02:25 -0800113 if ctx.toolchain().Bionic() {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700114 if !Bool(binary.baseLinker.Properties.Nocrt) {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700115 if !ctx.useSdk() {
Colin Crossb916a382016-07-29 17:28:03 -0700116 if binary.static() {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700117 deps.CrtBegin = "crtbegin_static"
118 } else {
119 deps.CrtBegin = "crtbegin_dynamic"
120 }
121 deps.CrtEnd = "crtend_android"
122 } else {
Dan Albertebedf672016-11-08 15:06:22 -0800123 // TODO(danalbert): Add generation of crt objects.
124 // For `sdk_version: "current"`, we don't actually have a
125 // freshly generated set of CRT objects. Use the last stable
126 // version.
127 version := ctx.sdkVersion()
128 if version == "current" {
Jayant Chowdhary6e8115a2017-05-09 10:21:52 -0700129 version = getCurrentNdkPrebuiltVersion(ctx)
Dan Albertebedf672016-11-08 15:06:22 -0800130 }
131
Colin Crossb916a382016-07-29 17:28:03 -0700132 if binary.static() {
Dan Albertebedf672016-11-08 15:06:22 -0800133 deps.CrtBegin = "ndk_crtbegin_static." + version
Colin Cross4d9c2d12016-07-29 12:48:20 -0700134 } else {
Colin Crossb916a382016-07-29 17:28:03 -0700135 if binary.static() {
Dan Albertebedf672016-11-08 15:06:22 -0800136 deps.CrtBegin = "ndk_crtbegin_static." + version
Colin Cross4d9c2d12016-07-29 12:48:20 -0700137 } else {
Dan Albertebedf672016-11-08 15:06:22 -0800138 deps.CrtBegin = "ndk_crtbegin_dynamic." + version
Colin Cross4d9c2d12016-07-29 12:48:20 -0700139 }
Dan Albertebedf672016-11-08 15:06:22 -0800140 deps.CrtEnd = "ndk_crtend_android." + version
Colin Cross4d9c2d12016-07-29 12:48:20 -0700141 }
142 }
143 }
144
Colin Crossb916a382016-07-29 17:28:03 -0700145 if binary.static() {
Dan Albertdc2597d2017-01-26 17:44:26 -0800146 if ctx.selectedStl() == "libc++_static" {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700147 deps.StaticLibs = append(deps.StaticLibs, "libm", "libc", "libdl")
148 }
149 // static libraries libcompiler_rt, libc and libc_nomalloc need to be linked with
150 // --start-group/--end-group along with libgcc. If they are in deps.StaticLibs,
151 // move them to the beginning of deps.LateStaticLibs
152 var groupLibs []string
153 deps.StaticLibs, groupLibs = filterList(deps.StaticLibs,
154 []string{"libc", "libc_nomalloc", "libcompiler_rt"})
155 deps.LateStaticLibs = append(groupLibs, deps.LateStaticLibs...)
156 }
Dan Willemsenc77a0b32017-09-18 23:19:12 -0700157
158 if ctx.Os() == android.LinuxBionic && !binary.static() {
Dan Willemsena0790e32018-10-12 00:24:23 -0700159 deps.DynamicLinker = "linker"
160 deps.LinkerFlagsFile = "host_bionic_linker_flags"
Dan Willemsenc77a0b32017-09-18 23:19:12 -0700161 }
Colin Cross4d9c2d12016-07-29 12:48:20 -0700162 }
163
Colin Crossb916a382016-07-29 17:28:03 -0700164 if !binary.static() && inList("libc", deps.StaticLibs) {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700165 ctx.ModuleErrorf("statically linking libc to dynamic executable, please remove libc\n" +
166 "from static libs or set static_executable: true")
167 }
Colin Cross2383f3b2018-02-06 14:40:13 -0800168
Colin Cross4d9c2d12016-07-29 12:48:20 -0700169 return deps
170}
171
Colin Crossb916a382016-07-29 17:28:03 -0700172func (binary *binaryDecorator) isDependencyRoot() bool {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700173 return true
174}
175
Colin Crossb916a382016-07-29 17:28:03 -0700176func NewBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecorator) {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700177 module := newModule(hod, android.MultilibFirst)
Colin Crossb916a382016-07-29 17:28:03 -0700178 binary := &binaryDecorator{
Dan Albert61f32122018-07-26 14:00:24 -0700179 baseLinker: NewBaseLinker(module.sanitize),
Colin Cross1e7d3702016-08-24 15:25:47 -0700180 baseInstaller: NewBaseInstaller("bin", "", InstallInSystem),
Colin Cross4d9c2d12016-07-29 12:48:20 -0700181 }
Colin Crossb916a382016-07-29 17:28:03 -0700182 module.compiler = NewBaseCompiler()
183 module.linker = binary
Colin Cross1e7d3702016-08-24 15:25:47 -0700184 module.installer = binary
Colin Crossb916a382016-07-29 17:28:03 -0700185 return module, binary
Colin Cross4d9c2d12016-07-29 12:48:20 -0700186}
187
Colin Crossb916a382016-07-29 17:28:03 -0700188func (binary *binaryDecorator) linkerInit(ctx BaseModuleContext) {
Colin Cross42742b82016-08-01 13:20:05 -0700189 binary.baseLinker.linkerInit(ctx)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700190
Dan Willemsen2e47b342016-11-17 01:02:25 -0800191 if !ctx.toolchain().Bionic() {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700192 if ctx.Os() == android.Linux {
Dan Willemsen3fb1fae2018-03-12 15:30:26 -0700193 if binary.Properties.Static_executable == nil && ctx.Config().HostStaticBinaries() {
Nan Zhang0007d812017-11-07 10:57:05 -0800194 binary.Properties.Static_executable = BoolPtr(true)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700195 }
196 } else {
197 // Static executables are not supported on Darwin or Windows
Colin Crossb916a382016-07-29 17:28:03 -0700198 binary.Properties.Static_executable = nil
Colin Cross4d9c2d12016-07-29 12:48:20 -0700199 }
200 }
Colin Cross4d9c2d12016-07-29 12:48:20 -0700201}
202
Colin Crossb916a382016-07-29 17:28:03 -0700203func (binary *binaryDecorator) static() bool {
204 return Bool(binary.Properties.Static_executable)
205}
206
207func (binary *binaryDecorator) staticBinary() bool {
208 return binary.static()
209}
210
211func (binary *binaryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
Colin Cross42742b82016-08-01 13:20:05 -0700212 flags = binary.baseLinker.linkerFlags(ctx, flags)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700213
Colin Cross446c6662018-09-14 16:00:16 -0700214 if ctx.Host() && !ctx.Windows() && !binary.static() {
Colin Cross6510f912017-11-29 00:27:14 -0800215 if !ctx.Config().IsEnvTrue("DISABLE_HOST_PIE") {
Colin Cross7a108bc2017-01-30 22:44:19 -0800216 flags.LdFlags = append(flags.LdFlags, "-pie")
Colin Cross4d9c2d12016-07-29 12:48:20 -0700217 }
218 }
219
220 // MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because
221 // all code is position independent, and then those warnings get promoted to
222 // errors.
Colin Cross3edeee12017-04-04 12:59:48 -0700223 if !ctx.Windows() {
Vishwath Mohane87b7682017-04-17 16:21:41 -0700224 flags.CFlags = append(flags.CFlags, "-fPIE")
Colin Cross4d9c2d12016-07-29 12:48:20 -0700225 }
226
Dan Willemsen2e47b342016-11-17 01:02:25 -0800227 if ctx.toolchain().Bionic() {
Colin Crossb916a382016-07-29 17:28:03 -0700228 if binary.static() {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700229 // Clang driver needs -static to create static executable.
230 // However, bionic/linker uses -shared to overwrite.
231 // Linker for x86 targets does not allow coexistance of -static and -shared,
232 // so we add -static only if -shared is not used.
233 if !inList("-shared", flags.LdFlags) {
234 flags.LdFlags = append(flags.LdFlags, "-static")
235 }
236
237 flags.LdFlags = append(flags.LdFlags,
238 "-nostdlib",
239 "-Bstatic",
240 "-Wl,--gc-sections",
241 )
Colin Cross4d9c2d12016-07-29 12:48:20 -0700242 } else {
243 if flags.DynamicLinker == "" {
Colin Cross522e3732016-09-07 13:14:06 -0700244 if binary.Properties.DynamicLinker != "" {
245 flags.DynamicLinker = binary.Properties.DynamicLinker
246 } else {
Dan Willemsen01a405a2016-06-13 17:19:03 -0700247 switch ctx.Os() {
248 case android.Android:
249 flags.DynamicLinker = "/system/bin/linker"
Dan Willemsena0790e32018-10-12 00:24:23 -0700250 if flags.Toolchain.Is64Bit() {
251 flags.DynamicLinker += "64"
252 }
Dan Willemsen01a405a2016-06-13 17:19:03 -0700253 case android.LinuxBionic:
Dan Willemsenc77a0b32017-09-18 23:19:12 -0700254 flags.DynamicLinker = ""
Dan Willemsen01a405a2016-06-13 17:19:03 -0700255 default:
256 ctx.ModuleErrorf("unknown dynamic linker")
257 }
Dan Willemsena0790e32018-10-12 00:24:23 -0700258 }
259
260 if ctx.Os() == android.LinuxBionic {
261 // Use the dlwrap entry point, but keep _start around so
262 // that it can be used by host_bionic_inject
263 flags.LdFlags = append(flags.LdFlags,
264 "-Wl,--entry=__dlwrap__start",
265 "-Wl,--undefined=_start",
266 )
Colin Cross4d9c2d12016-07-29 12:48:20 -0700267 }
268 }
269
270 flags.LdFlags = append(flags.LdFlags,
271 "-pie",
272 "-nostdlib",
273 "-Bdynamic",
274 "-Wl,--gc-sections",
275 "-Wl,-z,nocopyreloc",
276 )
277 }
278 } else {
Colin Crossb916a382016-07-29 17:28:03 -0700279 if binary.static() {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700280 flags.LdFlags = append(flags.LdFlags, "-static")
281 }
282 if ctx.Darwin() {
283 flags.LdFlags = append(flags.LdFlags, "-Wl,-headerpad_max_install_names")
284 }
285 }
286
287 return flags
288}
289
Colin Crossb916a382016-07-29 17:28:03 -0700290func (binary *binaryDecorator) link(ctx ModuleContext,
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700291 flags Flags, deps PathDeps, objs Objects) android.Path {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700292
293 fileName := binary.getStem(ctx) + flags.Toolchain.ExecutableSuffix()
294 outputFile := android.PathForModuleOut(ctx, fileName)
295 ret := outputFile
Colin Cross4d9c2d12016-07-29 12:48:20 -0700296
297 var linkerDeps android.Paths
298
299 sharedLibs := deps.SharedLibs
300 sharedLibs = append(sharedLibs, deps.LateSharedLibs...)
301
Dan Willemsena0790e32018-10-12 00:24:23 -0700302 if deps.LinkerFlagsFile.Valid() {
303 flags.LdFlags = append(flags.LdFlags, "$$(cat "+deps.LinkerFlagsFile.String()+")")
304 linkerDeps = append(linkerDeps, deps.LinkerFlagsFile.Path())
Dan Willemsenc77a0b32017-09-18 23:19:12 -0700305 }
306
Colin Cross4d9c2d12016-07-29 12:48:20 -0700307 if flags.DynamicLinker != "" {
Dan Willemsena0790e32018-10-12 00:24:23 -0700308 flags.LdFlags = append(flags.LdFlags, "-Wl,-dynamic-linker,"+flags.DynamicLinker)
309 } else if ctx.toolchain().Bionic() && !binary.static() {
310 flags.LdFlags = append(flags.LdFlags, "-Wl,--no-dynamic-linker")
Colin Cross4d9c2d12016-07-29 12:48:20 -0700311 }
312
313 builderFlags := flagsToBuilderFlags(flags)
314
315 if binary.stripper.needsStrip(ctx) {
Chih-Hung Hsieh30485c92018-06-04 10:37:43 -0700316 // b/80093681, GNU strip/objcopy bug.
317 // Use llvm-{strip,objcopy} when clang lld is used.
Dan Willemsen8536d6b2018-10-07 20:54:34 -0700318 builderFlags.stripUseLlvmStrip = binary.baseLinker.useClangLld(ctx)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700319 strippedOutputFile := outputFile
320 outputFile = android.PathForModuleOut(ctx, "unstripped", fileName)
321 binary.stripper.strip(ctx, outputFile, strippedOutputFile, builderFlags)
322 }
323
Colin Crossb60190a2018-09-04 16:28:17 -0700324 binary.unstrippedOutputFile = outputFile
325
Nan Zhang0007d812017-11-07 10:57:05 -0800326 if String(binary.Properties.Prefix_symbols) != "" {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700327 afterPrefixSymbols := outputFile
328 outputFile = android.PathForModuleOut(ctx, "unprefixed", fileName)
Nan Zhang0007d812017-11-07 10:57:05 -0800329 TransformBinaryPrefixSymbols(ctx, String(binary.Properties.Prefix_symbols), outputFile,
Colin Cross4d9c2d12016-07-29 12:48:20 -0700330 flagsToBuilderFlags(flags), afterPrefixSymbols)
331 }
332
Colin Cross86803cf2018-02-15 14:12:26 -0800333 if Bool(binary.baseLinker.Properties.Use_version_lib) && ctx.Host() {
334 versionedOutputFile := outputFile
335 outputFile = android.PathForModuleOut(ctx, "unversioned", fileName)
336 binary.injectVersionSymbol(ctx, outputFile, versionedOutputFile)
337 }
338
Dan Willemsena0790e32018-10-12 00:24:23 -0700339 if ctx.Os() == android.LinuxBionic && !binary.static() {
340 injectedOutputFile := outputFile
341 outputFile = android.PathForModuleOut(ctx, "prelinker", fileName)
342
343 if !deps.DynamicLinker.Valid() {
344 panic("Non-static host bionic modules must have a dynamic linker")
345 }
346
347 binary.injectHostBionicLinkerSymbols(ctx, outputFile, deps.DynamicLinker.Path(), injectedOutputFile)
348 }
349
Colin Cross26c34ed2016-09-30 17:10:16 -0700350 linkerDeps = append(linkerDeps, deps.SharedLibsDeps...)
351 linkerDeps = append(linkerDeps, deps.LateSharedLibsDeps...)
Dan Willemsena03cf6d2016-09-26 15:45:04 -0700352 linkerDeps = append(linkerDeps, objs.tidyFiles...)
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700353 linkerDeps = append(linkerDeps, flags.LdFlagsDeps...)
Colin Cross26c34ed2016-09-30 17:10:16 -0700354
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700355 TransformObjToDynamicBinary(ctx, objs.objFiles, sharedLibs, deps.StaticLibs,
Colin Cross4d9c2d12016-07-29 12:48:20 -0700356 deps.LateStaticLibs, deps.WholeStaticLibs, linkerDeps, deps.CrtBegin, deps.CrtEnd, true,
357 builderFlags, outputFile)
358
Dan Willemsen581341d2017-02-09 16:16:31 -0800359 objs.coverageFiles = append(objs.coverageFiles, deps.StaticLibObjs.coverageFiles...)
360 objs.coverageFiles = append(objs.coverageFiles, deps.WholeStaticLibObjs.coverageFiles...)
361 binary.coverageOutputFile = TransformCoverageFilesToLib(ctx, objs, builderFlags, binary.getStem(ctx))
362
Colin Cross4d9c2d12016-07-29 12:48:20 -0700363 return ret
364}
365
Dan Willemsen4aa75ca2016-09-28 16:18:03 -0700366func (binary *binaryDecorator) install(ctx ModuleContext, file android.Path) {
367 binary.baseInstaller.install(ctx, file)
Colin Cross9b09f242016-12-07 13:37:42 -0800368 for _, symlink := range binary.Properties.Symlinks {
369 binary.symlinks = append(binary.symlinks,
Nan Zhang0007d812017-11-07 10:57:05 -0800370 symlink+String(binary.Properties.Suffix)+ctx.toolchain().ExecutableSuffix())
Colin Cross9b09f242016-12-07 13:37:42 -0800371 }
372
Nan Zhang0007d812017-11-07 10:57:05 -0800373 if Bool(binary.Properties.Symlink_preferred_arch) {
374 if String(binary.Properties.Stem) == "" && String(binary.Properties.Suffix) == "" {
Colin Cross9b09f242016-12-07 13:37:42 -0800375 ctx.PropertyErrorf("symlink_preferred_arch", "must also specify stem or suffix")
376 }
377 if ctx.TargetPrimary() {
378 binary.symlinks = append(binary.symlinks, ctx.baseModuleName())
379 }
380 }
381
382 for _, symlink := range binary.symlinks {
383 ctx.InstallSymlink(binary.baseInstaller.installDir(ctx), symlink, binary.baseInstaller.path)
384 }
385
Dan Willemsen4aa75ca2016-09-28 16:18:03 -0700386 if ctx.Os().Class == android.Host {
387 binary.toolPath = android.OptionalPathForPath(binary.baseInstaller.path)
388 }
389}
390
391func (binary *binaryDecorator) hostToolPath() android.OptionalPath {
392 return binary.toolPath
Colin Cross4d9c2d12016-07-29 12:48:20 -0700393}
Dan Willemsena0790e32018-10-12 00:24:23 -0700394
395func init() {
396 pctx.HostBinToolVariable("hostBionicSymbolsInjectCmd", "host_bionic_inject")
397}
398
399var injectHostBionicSymbols = pctx.AndroidStaticRule("injectHostBionicSymbols",
400 blueprint.RuleParams{
401 Command: "$hostBionicSymbolsInjectCmd -i $in -l $linker -o $out",
402 CommandDeps: []string{"$hostBionicSymbolsInjectCmd"},
403 }, "linker")
404
405func (binary *binaryDecorator) injectHostBionicLinkerSymbols(ctx ModuleContext, in, linker android.Path, out android.WritablePath) {
406 ctx.Build(pctx, android.BuildParams{
407 Rule: injectHostBionicSymbols,
408 Description: "inject host bionic symbols",
409 Input: in,
410 Implicit: linker,
411 Output: out,
412 Args: map[string]string{
413 "linker": linker.String(),
414 },
415 })
416}