summaryrefslogtreecommitdiff
path: root/apex/apex_test.go
diff options
context:
space:
mode:
author Jiyong Park <jiyong@google.com> 2020-03-11 16:03:09 +0900
committer Jiyong Park <jiyong@google.com> 2020-05-07 16:20:00 +0900
commit45b90e79c9b0807221f9d4584bd2524cac16369b (patch)
tree2462e4f6ca429c876ea3ff8b9e787da1c642f86d /apex/apex_test.go
parent1c7e962957a8f93db17d4bd1dcedfdac5fc4a52e (diff)
Prevent statically linking to a lib providing stable C APIs
A lib providing stable C APIs should be available only to the APEX containing the library. It shouldn't be available to other APEXes, especially via static linking. This change also fixes a bug that llndkImplDep (the dependency from llndk stub to its implementation library) was recognized as being in the same APEX. Bug: 151051671 Test: m Change-Id: Ifda7f4a367f68afcde93c86cda45a28cacd91f99
Diffstat (limited to 'apex/apex_test.go')
-rw-r--r--apex/apex_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/apex/apex_test.go b/apex/apex_test.go
index ce39b39e4..e89ebe07c 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -4774,6 +4774,42 @@ func TestTestFor(t *testing.T) {
ensureNotContains(t, ldFlags, "mylib/android_arm64_armv8-a_shared_1/mylib.so")
}
+func TestNoStaticLinkingToStubsLib(t *testing.T) {
+ testApexError(t, `.*required by "mylib" is a native library providing stub.*`, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ native_shared_libs: ["mylib"],
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+
+ cc_library {
+ name: "mylib",
+ srcs: ["mylib.cpp"],
+ static_libs: ["otherlib"],
+ system_shared_libs: [],
+ stl: "none",
+ apex_available: [ "myapex" ],
+ }
+
+ cc_library {
+ name: "otherlib",
+ srcs: ["mylib.cpp"],
+ system_shared_libs: [],
+ stl: "none",
+ stubs: {
+ versions: ["1", "2", "3"],
+ },
+ apex_available: [ "myapex" ],
+ }
+ `)
+}
+
func TestMain(m *testing.M) {
run := func() int {
setUp()