Support prefix_symbols for prebuilt libraries
Add support for prefix_symbols from binary and object targets to allow
rules to prefix symbols from a checked-in library before linking against
it, namespacing the resulting symbols and avoiding potential clashes.
Bug: 237371962
Test: Android.bp with cc_prebuilt_library_static::prefix_symbols
Change-Id: Iaf9cdd12637d5a259ae4c4827ff20e4f911699a4
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index 8c404d3..b431f96 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -51,6 +51,9 @@
// symbols, etc), default true.
Check_elf_files *bool
+ // if set, add an extra objcopy --prefix-symbols= step
+ Prefix_symbols *string
+
// Optionally provide an import library if this is a Windows PE DLL prebuilt.
// This is needed only if this library is linked by other modules in build time.
// Only makes sense for the Windows target.
@@ -130,6 +133,13 @@
in := android.PathForModuleSrc(ctx, srcs[0])
+ if String(p.prebuiltLinker.properties.Prefix_symbols) != "" {
+ prefixed := android.PathForModuleOut(ctx, "prefixed", srcs[0])
+ transformBinaryPrefixSymbols(ctx, String(p.prebuiltLinker.properties.Prefix_symbols),
+ in, flagsToBuilderFlags(flags), prefixed)
+ in = prefixed
+ }
+
if p.static() {
depSet := android.NewDepSetBuilder(android.TOPOLOGICAL).Direct(in).Build()
ctx.SetProvider(StaticLibraryInfoProvider, StaticLibraryInfo{