From a2268635f4f05cffb360b6c000b04e76c50c4fed Mon Sep 17 00:00:00 2001 From: Ivan Lozano Date: Thu, 22 Jul 2021 10:52:06 -0400 Subject: rust: Add support for bootstrap linker. Adds the 'bootstrap' property to Rust modules to set the linker to the bootstrap linker. Bug: 194276829 Test: set bootstrap: true on module, checked .interp section on output. Test: bootstrapped binary runs. Change-Id: I459c8194902cfea3c44b060e70d28a43fcba3ade --- rust/builder.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'rust/builder.go') diff --git a/rust/builder.go b/rust/builder.go index 6db508d64..523428db2 100644 --- a/rust/builder.go +++ b/rust/builder.go @@ -220,6 +220,15 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl linkFlags = append(linkFlags, flags.GlobalLinkFlags...) linkFlags = append(linkFlags, flags.LinkFlags...) + // Check if this module needs to use the bootstrap linker + if ctx.RustModule().Bootstrap() && !ctx.RustModule().InRecovery() && !ctx.RustModule().InRamdisk() && !ctx.RustModule().InVendorRamdisk() { + dynamicLinker := "-Wl,-dynamic-linker,/system/bin/bootstrap/linker" + if ctx.toolchain().Is64Bit() { + dynamicLinker += "64" + } + linkFlags = append(linkFlags, dynamicLinker) + } + libFlags := makeLibFlags(deps) // Collect dependencies -- cgit v1.2.3-59-g8ed1b