Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6f630ae6 authored by Pierre-Clément Tosi's avatar Pierre-Clément Tosi
Browse files

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
parent 3a4088df
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -51,6 +51,9 @@ type prebuiltLinkerProperties struct {
	// 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 @@ func (p *prebuiltLibraryLinker) link(ctx ModuleContext,

		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{