From 484219c3173e502328dfca4324773ee0e6a1b00a Mon Sep 17 00:00:00 2001 From: Logan Chien Date: Thu, 8 Jun 2017 21:14:15 +0800 Subject: [PATCH 1/8] vndk-def: Fix vndk-indirect computation bug This commit replaces a vndk_indirect with vndk because we are computing the indirect dependencies of vndk (i.e. closure(vndk) - vndk). Bug: 37867089 Test: vndk-indirect libs are printed with sailfish images. Change-Id: I218333c7dbb2a372cc9d170f34674510cc01aa0e --- vndk/tools/definition-tool/vndk_definition_tool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vndk/tools/definition-tool/vndk_definition_tool.py b/vndk/tools/definition-tool/vndk_definition_tool.py index aeefd2cbc..4cf588aa8 100755 --- a/vndk/tools/definition-tool/vndk_definition_tool.py +++ b/vndk/tools/definition-tool/vndk_definition_tool.py @@ -1398,7 +1398,7 @@ class ELFLinker(object): vndk.add(dep) vndk_indirect = self.compute_closure(vndk, is_not_vndk) - vndk_indirect -= vndk_indirect + vndk_indirect -= vndk # Compute the extended usages from vendor partition. # FIXME: DAUX libraries won't be found by the following algorithm. From 2a5a2dd52414e8dd0e69b1deae0b51d88c4ed58f Mon Sep 17 00:00:00 2001 From: Logan Chien Date: Thu, 8 Jun 2017 21:50:33 +0800 Subject: [PATCH 2/8] vndk-def: Parse actions for ineligible libs This commit extracts the code to parse the action when ineligible vndk-sp or vndk libs occur. Bug: 37867089 Test: All --action-ineligible-vndk-sp options worked as usual. Test: All --action-ineligible-vndk options worked as usual. Change-Id: Ifc06598b1acff828479d804323711ae0da6e7215 --- .../definition-tool/vndk_definition_tool.py | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/vndk/tools/definition-tool/vndk_definition_tool.py b/vndk/tools/definition-tool/vndk_definition_tool.py index 4cf588aa8..90b9083b0 100755 --- a/vndk/tools/definition-tool/vndk_definition_tool.py +++ b/vndk/tools/definition-tool/vndk_definition_tool.py @@ -1261,6 +1261,21 @@ class ELFLinker(object): new_path = lib.path.replace('/system/', '/vendor/') self.rename_lib(lib, PT_VENDOR, new_path) + @staticmethod + def _parse_action_on_ineligible_lib(arg): + follow = False + warn = False + for flag in arg.split(','): + if flag == 'follow': + follow = True + elif flag == 'warn': + warn = True + elif flag == 'ignore': + continue + else: + raise ValueError('unknown action \"{}\"'.format(flag)) + return (follow, warn) + def compute_degenerated_vndk(self, sp_lib, generic_refs, tagged_paths=None, action_ineligible_vndk_sp='follow,warn', @@ -1310,7 +1325,8 @@ class ELFLinker(object): return lib.is_ll_ndk or lib.is_sp_ndk or lib in sp_hal or \ lib in sp_hal_dep - action_ineligible_vndk_sp = set(action_ineligible_vndk_sp.split(',')) + follow_ineligible_vndk_sp, warn_ineligible_vndk_sp = \ + self._parse_action_on_ineligible_lib(action_ineligible_vndk_sp) predefined_vndk_sp = self.compute_predefined_vndk_sp() vndk_sp = set() for lib in itertools.chain(sp_hal, sp_hal_dep): @@ -1320,11 +1336,11 @@ class ELFLinker(object): if dep in predefined_vndk_sp: vndk_sp.add(dep) continue - if 'warn' in action_ineligible_vndk_sp: + if warn_ineligible_vndk_sp: print('error: SP-HAL {} depends on non vndk-sp ' 'library {}.'.format(lib.path, dep.path), file=sys.stderr) - if 'follow' in action_ineligible_vndk_sp: + if follow_ineligible_vndk_sp: vndk_sp.add(dep) # Add other predefined VNDK-SP even if they are not actually used by @@ -1380,7 +1396,8 @@ class ELFLinker(object): return False return not generic_refs.has_same_name_lib(lib) - action_ineligible_vndk = set(action_ineligible_vndk.split(',')) + follow_ineligible_vndk, warn_ineligible_vndk = \ + self._parse_action_on_ineligible_lib(action_ineligible_vndk) vndk = set() for lib in self.lib_pt[PT_VENDOR].values(): for dep in lib.deps: @@ -1390,11 +1407,11 @@ class ELFLinker(object): tagged_paths.is_path_visible(lib.path, dep.path): vndk.add(dep) continue - if 'warn' in action_ineligible_vndk: + if warn_ineligible_vndk: print('warning: vendor lib/exe {} depends on ineligible ' 'framework shared lib {}.' .format(lib.path, dep.path), file=sys.stderr) - if 'follow' in action_ineligible_vndk: + if follow_ineligible_vndk: vndk.add(dep) vndk_indirect = self.compute_closure(vndk, is_not_vndk) From 05a13ae43fce1a06e5d72e1fb0040d748bc68bc8 Mon Sep 17 00:00:00 2001 From: Logan Chien Date: Thu, 8 Jun 2017 22:01:03 +0800 Subject: [PATCH 3/8] vndk-def: Exclude vndk-sp/vndk from ndk-indirect This commit excludes VNDK-SP and VNDK libs from LL-NDK-INDIRECT and SP-NDK-INDIRECT libs because in the degenerated VNDK design, FWK-ONLY libs and VNDK libs share the same file. Bug: 37867089 Test: All eligible VNDK libs are not tagged with LL-NDK-Indirect and SP-NDK-Indirect with sailfish image. Change-Id: I05b20e9d21543d63c1e75896f20e49c3dc0d70de --- .../definition-tool/vndk_definition_tool.py | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/vndk/tools/definition-tool/vndk_definition_tool.py b/vndk/tools/definition-tool/vndk_definition_tool.py index 90b9083b0..1997ad5af 100755 --- a/vndk/tools/definition-tool/vndk_definition_tool.py +++ b/vndk/tools/definition-tool/vndk_definition_tool.py @@ -1282,21 +1282,8 @@ class ELFLinker(object): action_ineligible_vndk='follow,warn'): # Find LL-NDK and SP-NDK libs. ll_ndk = set(lib for lib in self.all_libs() if lib.is_ll_ndk) - - def is_not_ll_ndk_indirect(lib): - return lib.is_ll_ndk - - ll_ndk_indirect = self.compute_closure(ll_ndk, is_not_ll_ndk_indirect) - ll_ndk_indirect -= ll_ndk - sp_ndk = set(lib for lib in self.all_libs() if lib.is_sp_ndk) - def is_not_sp_ndk_indirect(lib): - return lib.is_ll_ndk or lib.is_sp_ndk or lib in ll_ndk_indirect - - sp_ndk_indirect = self.compute_closure(sp_ndk, is_not_sp_ndk_indirect) - sp_ndk_indirect -= sp_ndk - # Find SP-HAL libs. sp_hal = self.compute_predefined_sp_hal() @@ -1383,6 +1370,12 @@ class ELFLinker(object): extra_vndk_sp_indirect = vndk_sp - predefined_vndk_sp - \ predefined_vndk_sp_indirect + def is_vndk_sp(lib): + return lib in vndk_sp or lib in vndk_sp_unused or \ + lib in vndk_sp_indirect or \ + lib in vndk_sp_indirect_unused or \ + lib in vndk_sp_indirect_private + # Find VNDK libs (a.k.a. system shared libs directly used by vendor # partition.) def is_not_vndk(lib): @@ -1417,6 +1410,9 @@ class ELFLinker(object): vndk_indirect = self.compute_closure(vndk, is_not_vndk) vndk_indirect -= vndk + def is_vndk(lib): + return lib in vndk or lib in vndk_indirect + # Compute the extended usages from vendor partition. # FIXME: DAUX libraries won't be found by the following algorithm. vndk_ext = set() @@ -1435,6 +1431,21 @@ class ELFLinker(object): vndk_ext |= candidates candidates = collect_vndk_ext(candidates) + # Compute LL-NDK-Indirect and SP-NDK-Indirect. + def is_not_ll_ndk_indirect(lib): + return lib.is_ll_ndk or is_vndk_sp(lib) or is_vndk(lib) + + ll_ndk_indirect = self.compute_closure(ll_ndk, is_not_ll_ndk_indirect) + ll_ndk_indirect -= ll_ndk + + def is_not_sp_ndk_indirect(lib): + return lib.is_ll_ndk or lib.is_sp_ndk or lib in ll_ndk_indirect or \ + is_vndk_sp(lib) or is_vndk(lib) + + sp_ndk_indirect = self.compute_closure(sp_ndk, is_not_sp_ndk_indirect) + sp_ndk_indirect -= sp_ndk + + # Return the VNDK classifications. return VNDKResult( ll_ndk=ll_ndk, ll_ndk_indirect=ll_ndk_indirect, From 6582daf969b430a3462e4fec830ee30bfba637b9 Mon Sep 17 00:00:00 2001 From: Logan Chien Date: Fri, 9 Jun 2017 00:02:16 +0800 Subject: [PATCH 4/8] vndk-def: Add (vndk-sp)? to fwk-only-rs matching This commit adds (?:vndk-sp)? to FWK-ONLY-RS matching because some targets have a copy of libft2.so in /system/lib[64]/vndk-sp but we still want to treat it as FWK-ONLY-RS. Bug: 37867089 Test: libft2.so is not labeled as vndk-sp-indirect in sailfish image. Change-Id: Iad5db6417573f3e25bad5c027cb547d9df4be23a --- vndk/tools/definition-tool/vndk_definition_tool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vndk/tools/definition-tool/vndk_definition_tool.py b/vndk/tools/definition-tool/vndk_definition_tool.py index 1997ad5af..cbd86697b 100755 --- a/vndk/tools/definition-tool/vndk_definition_tool.py +++ b/vndk/tools/definition-tool/vndk_definition_tool.py @@ -1098,8 +1098,8 @@ class ELFLinker(object): def compute_predefined_fwk_only_rs(self): """Find all fwk-only-rs libraries.""" path_patterns = ( - '^/system/lib(?:64)?/libft2\\.so$', - '^/system/lib(?:64)?/libmediandk\\.so', + '^/system/lib(?:64)?/(?:vndk-sp/)?libft2\\.so$', + '^/system/lib(?:64)?/(?:vndk-sp/)?libmediandk\\.so', ) return self.compute_path_matched_lib(path_patterns) From 55a41a3dd966ae375eb57083db7843f43a83dc2e Mon Sep 17 00:00:00 2001 From: Logan Chien Date: Fri, 9 Jun 2017 00:15:12 +0800 Subject: [PATCH 5/8] vndk-sp: Fix vndk-sp-unused computation This commit removes vndk-sp-indirect libs from vndk-sp-unused. They are actually being used (although indirectly). Bug: 37867089 Test: libhwbinder.so is removed from vndk-sp-unused given sailfish images. Change-Id: I7a3b253408c53f1d81d1fea39f79e3fe09f6fb75 --- vndk/tools/definition-tool/vndk_definition_tool.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/vndk/tools/definition-tool/vndk_definition_tool.py b/vndk/tools/definition-tool/vndk_definition_tool.py index cbd86697b..82c770a2b 100755 --- a/vndk/tools/definition-tool/vndk_definition_tool.py +++ b/vndk/tools/definition-tool/vndk_definition_tool.py @@ -1330,11 +1330,6 @@ class ELFLinker(object): if follow_ineligible_vndk_sp: vndk_sp.add(dep) - # Add other predefined VNDK-SP even if they are not actually used by - # SP-HAL libs. - vndk_sp_unused = set(lib for lib in predefined_vndk_sp - if self._is_in_vndk_sp_dir(lib.path)) - vndk_sp - # Find VNDK-SP-Indirect libs. def is_not_vndk_sp_indirect(lib): return lib.is_ll_ndk or lib.is_sp_ndk or lib in vndk_sp or \ @@ -1344,6 +1339,13 @@ class ELFLinker(object): vndk_sp, is_not_vndk_sp_indirect) vndk_sp_indirect -= vndk_sp + # Find unused predefined VNDK-SP libs. + vndk_sp_unused = set(lib for lib in predefined_vndk_sp + if self._is_in_vndk_sp_dir(lib.path)) + vndk_sp_unused -= vndk_sp + vndk_sp_unused -= vndk_sp_indirect + + # Find dependencies of unused predefined VNDK-SP libs. def is_not_vndk_sp_indirect_unused(lib): return is_not_vndk_sp_indirect(lib) or lib in vndk_sp_indirect vndk_sp_indirect_unused = self.compute_closure( From 89015efb13ce13d1e2a7f99d488e526dc193ff32 Mon Sep 17 00:00:00 2001 From: Logan Chien Date: Fri, 9 Jun 2017 00:20:12 +0800 Subject: [PATCH 6/8] vndk-def: Exclude vndk-sp from vndk This commit excludes vndk-sp libraries from vndk result sets. This CL eliminates several false warnings on vendor usages on libhwbinder.so Bug: 37867089 Test: Warnings on libhwbinder.so usages disappeared given sailfish images. Change-Id: Icc3b07bc6a57e41a3fcbaf116c1316f77e7a439d --- .../definition-tool/vndk_definition_tool.py | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/vndk/tools/definition-tool/vndk_definition_tool.py b/vndk/tools/definition-tool/vndk_definition_tool.py index 82c770a2b..7ea7b4b92 100755 --- a/vndk/tools/definition-tool/vndk_definition_tool.py +++ b/vndk/tools/definition-tool/vndk_definition_tool.py @@ -1369,19 +1369,41 @@ class ELFLinker(object): vndk_sp_ext, is_not_vndk_sp_indirect_ext) vndk_sp_indirect_ext -= vndk_sp_ext - extra_vndk_sp_indirect = vndk_sp - predefined_vndk_sp - \ + vndk_sp_closure = vndk_sp | vndk_sp_indirect + extra_vndk_sp_indirect = vndk_sp_closure - predefined_vndk_sp - \ predefined_vndk_sp_indirect - def is_vndk_sp(lib): + def is_vndk_sp_public(lib): return lib in vndk_sp or lib in vndk_sp_unused or \ lib in vndk_sp_indirect or \ - lib in vndk_sp_indirect_unused or \ - lib in vndk_sp_indirect_private + lib in vndk_sp_indirect_unused + + def is_vndk_sp(lib): + return is_vndk_sp_public(lib) or lib in vndk_sp_indirect_private + + def is_vndk_sp_unused(lib): + return lib in vndk_sp_unused or lib in vndk_sp_indirect_unused + + def relabel_vndk_sp_as_used(lib): + assert is_vndk_sp_unused(lib) + + if lib in vndk_sp_unused: + vndk_sp_unused.remove(lib) + vndk_sp.add(lib) + else: + vndk_sp_indirect_unused.remove(lib) + vndk_sp_indirect.add(lib) + + closure = self.compute_closure({lib}, is_not_vndk_sp_indirect) + closure -= vndk_sp + vndk_sp_indirect_unused.difference_update(closure) + vndk_sp_indirect.update(closure) # Find VNDK libs (a.k.a. system shared libs directly used by vendor # partition.) def is_not_vndk(lib): - if lib.is_ll_ndk or lib.is_sp_ndk or lib in vndk_sp: + if lib.is_ll_ndk or lib.is_sp_ndk or is_vndk_sp_public(lib) or \ + lib in fwk_only_rs: return True if lib.partition != PT_SYSTEM: return True @@ -1396,6 +1418,9 @@ class ELFLinker(object): vndk = set() for lib in self.lib_pt[PT_VENDOR].values(): for dep in lib.deps: + if is_vndk_sp_unused(dep): + relabel_vndk_sp_as_used(dep) + continue if is_not_vndk(dep): continue if not tagged_paths or \ From 6a2fcac08dc9ae08ca6b0fe09fde8c3fdc46e3e9 Mon Sep 17 00:00:00 2001 From: Logan Chien Date: Fri, 9 Jun 2017 01:04:56 +0800 Subject: [PATCH 7/8] vndk-def: Collect non-AOSP libs must be copied This commit collects all non-AOSP system libraries that are used by vendor modules and add them to vndk-ext so that they are copied into vendor partition. Bug: 37867089 Test: Some vendor HIDL interface libs are tagged with vndk-ext given sailfish images. Change-Id: I77d8f66d97b403991593d5b1f88573411e96d679 --- .../definition-tool/vndk_definition_tool.py | 80 ++++++++++++------- 1 file changed, 50 insertions(+), 30 deletions(-) diff --git a/vndk/tools/definition-tool/vndk_definition_tool.py b/vndk/tools/definition-tool/vndk_definition_tool.py index 7ea7b4b92..a5e678dbe 100755 --- a/vndk/tools/definition-tool/vndk_definition_tool.py +++ b/vndk/tools/definition-tool/vndk_definition_tool.py @@ -1293,13 +1293,17 @@ class ELFLinker(object): self.normalize_partition_tags(sp_hal, generic_refs) # Find SP-HAL-Dep libs. + def is_aosp_lib(lib): + if not generic_refs: + # If generic reference is not available, then assume all system + # libs are AOSP libs. + return lib.partition == PT_SYSTEM + return generic_refs.has_same_name_lib(lib) + def is_not_sp_hal_dep(lib): if lib.is_ll_ndk or lib.is_sp_ndk or lib in sp_hal: return True - if not generic_refs: - # Use simple heuristic when generic reference is not available. - return lib.partition == PT_SYSTEM - return generic_refs.has_same_name_lib(lib) + return is_aosp_lib(lib) sp_hal_dep = self.compute_closure(sp_hal, is_not_sp_hal_dep) sp_hal_dep -= sp_hal @@ -1405,34 +1409,46 @@ class ELFLinker(object): if lib.is_ll_ndk or lib.is_sp_ndk or is_vndk_sp_public(lib) or \ lib in fwk_only_rs: return True - if lib.partition != PT_SYSTEM: - return True - if not generic_refs: - # If generic reference is not available, we assume all system - # libs are eligible vndk. - return False - return not generic_refs.has_same_name_lib(lib) + return lib.partition != PT_SYSTEM + + def is_eligible_lib_access(lib, dep): + return not tagged_paths or \ + tagged_paths.is_path_visible(lib.path, dep.path) follow_ineligible_vndk, warn_ineligible_vndk = \ self._parse_action_on_ineligible_lib(action_ineligible_vndk) vndk = set() - for lib in self.lib_pt[PT_VENDOR].values(): - for dep in lib.deps: - if is_vndk_sp_unused(dep): - relabel_vndk_sp_as_used(dep) - continue - if is_not_vndk(dep): - continue - if not tagged_paths or \ - tagged_paths.is_path_visible(lib.path, dep.path): - vndk.add(dep) - continue - if warn_ineligible_vndk: - print('warning: vendor lib/exe {} depends on ineligible ' - 'framework shared lib {}.' - .format(lib.path, dep.path), file=sys.stderr) - if follow_ineligible_vndk: - vndk.add(dep) + extra_vendor_libs = set() + def collect_vndk(vendor_libs): + next_vendor_libs = set() + for lib in vendor_libs: + for dep in lib.deps: + if is_vndk_sp_unused(dep): + relabel_vndk_sp_as_used(dep) + continue + if is_not_vndk(dep): + continue + if not is_aosp_lib(dep): + # The dependency should be copied into vendor partition + # as an extra vendor lib. + if dep not in extra_vendor_libs: + next_vendor_libs.add(dep) + extra_vendor_libs.add(dep) + continue + if is_eligible_lib_access(lib, dep): + vndk.add(dep) + continue + if warn_ineligible_vndk: + print('warning: vendor lib/exe {} depends on ' + 'ineligible framework shared lib {}.' + .format(lib.path, dep.path), file=sys.stderr) + if follow_ineligible_vndk: + vndk.add(dep) + return next_vendor_libs + + candidates = collect_vndk(self.lib_pt[PT_VENDOR].values()) + while candidates: + candidates = collect_vndk(candidates) vndk_indirect = self.compute_closure(vndk, is_not_vndk) vndk_indirect -= vndk @@ -1440,7 +1456,10 @@ class ELFLinker(object): def is_vndk(lib): return lib in vndk or lib in vndk_indirect - # Compute the extended usages from vendor partition. + # Find VNDK-EXT libs (VNDK libs with extended definitions and the + # extended definitions are used by the vendor modules (including + # extra_vendor_libs). + # FIXME: DAUX libraries won't be found by the following algorithm. vndk_ext = set() @@ -1453,6 +1472,7 @@ class ELFLinker(object): return result candidates = collect_vndk_ext(self.lib_pt[PT_VENDOR].values()) + candidates |= collect_vndk_ext(extra_vendor_libs) while candidates: vndk_ext |= candidates @@ -1490,7 +1510,7 @@ class ELFLinker(object): sp_hal=sp_hal, sp_hal_dep=sp_hal_dep, # vnd_only=vnd_only, - vndk_ext=vndk_ext, + vndk_ext=vndk_ext | extra_vendor_libs, # vndk_sp_ext=vndk_sp_ext, # vndk_sp_indirect_ext=vndk_sp_indirect_ext, extra_vndk_sp_indirect=extra_vndk_sp_indirect) From 489dabb2785420797988f6383ada27da31948fb2 Mon Sep 17 00:00:00 2001 From: Logan Chien Date: Fri, 9 Jun 2017 02:08:14 +0800 Subject: [PATCH 8/8] vndk-def: Implement VNDK-SP-Ext collection This commit implements the VNDK-SP-Ext properly so that the output will copy missing VNDK-SP-Indirect to /vendor/lib[64]/vndk-sp. Bug: 37867089 Bug: 37940694 Test: Add/remove generic reference dump and make sure vndk-sp libs will be listed as extra_vndk_sp_indirect. Change-Id: I76bc41e189e566c66c6f96db9555d366921b7995 --- .../definition-tool/vndk_definition_tool.py | 70 ++++++++++++++----- 1 file changed, 51 insertions(+), 19 deletions(-) diff --git a/vndk/tools/definition-tool/vndk_definition_tool.py b/vndk/tools/definition-tool/vndk_definition_tool.py index a5e678dbe..7ab84ae2e 100755 --- a/vndk/tools/definition-tool/vndk_definition_tool.py +++ b/vndk/tools/definition-tool/vndk_definition_tool.py @@ -1359,24 +1359,7 @@ class ELFLinker(object): # TODO: Compute VNDK-SP-Indirect-Private. vndk_sp_indirect_private = set() - predefined_vndk_sp_indirect = self.compute_predefined_vndk_sp_indirect() - - # TODO: Compute VNDK-SP-Ext and VNDK-SP-Indirect-Ext. - vndk_sp_ext = set() - - def is_not_vndk_sp_indirect_ext(lib): - return lib.is_ll_ndk or lib.is_sp_ndk or lib in vndk_sp_ext or \ - lib in predefined_vndk_sp or \ - lib in predefined_vndk_sp_indirect - - vndk_sp_indirect_ext = self.compute_closure( - vndk_sp_ext, is_not_vndk_sp_indirect_ext) - vndk_sp_indirect_ext -= vndk_sp_ext - - vndk_sp_closure = vndk_sp | vndk_sp_indirect - extra_vndk_sp_indirect = vndk_sp_closure - predefined_vndk_sp - \ - predefined_vndk_sp_indirect - + # Define helper functions for vndk_sp sets. def is_vndk_sp_public(lib): return lib in vndk_sp or lib in vndk_sp_unused or \ lib in vndk_sp_indirect or \ @@ -1403,6 +1386,55 @@ class ELFLinker(object): vndk_sp_indirect_unused.difference_update(closure) vndk_sp_indirect.update(closure) + # Find VNDK-SP-Ext libs. + vndk_sp_ext = set() + def collect_vndk_ext(libs): + result = set() + for lib in libs: + for dep in lib.imported_ext_symbols: + if dep in vndk_sp and dep not in vndk_sp_ext: + result.add(dep) + return result + + candidates = collect_vndk_ext(self.lib_pt[PT_VENDOR].values()) + while candidates: + vndk_sp_ext |= candidates + candidates = collect_vndk_ext(candidates) + + # Find VNDK-SP-Indirect-Ext libs. + predefined_vndk_sp_indirect = self.compute_predefined_vndk_sp_indirect() + vndk_sp_indirect_ext = set() + def collect_vndk_sp_indirect_ext(libs): + result = set() + for lib in libs: + exts = set(lib.imported_ext_symbols.keys()) + for dep in lib.deps: + if not is_vndk_sp_public(dep): + continue + if dep in vndk_sp_ext or dep in vndk_sp_indirect_ext: + continue + # If lib is using extended definition from deps, then we + # have to make a copy of dep. + if dep in exts: + result.add(dep) + continue + # If lib is using non-predefined VNDK-SP-Indirect, then we + # have to make a copy of dep. + if dep not in predefined_vndk_sp and \ + dep not in predefined_vndk_sp_indirect: + result.add(dep) + continue + return result + + def is_not_vndk_sp_indirect(lib): + return lib.is_ll_ndk or lib.is_sp_ndk or lib in vndk_sp or \ + lib in fwk_only_rs + + candidates = collect_vndk_sp_indirect_ext(vndk_sp_ext) + while candidates: + vndk_sp_indirect_ext |= candidates + candidates = collect_vndk_sp_indirect_ext(candidates) + # Find VNDK libs (a.k.a. system shared libs directly used by vendor # partition.) def is_not_vndk(lib): @@ -1513,7 +1545,7 @@ class ELFLinker(object): vndk_ext=vndk_ext | extra_vendor_libs, # vndk_sp_ext=vndk_sp_ext, # vndk_sp_indirect_ext=vndk_sp_indirect_ext, - extra_vndk_sp_indirect=extra_vndk_sp_indirect) + extra_vndk_sp_indirect=vndk_sp_ext | vndk_sp_indirect_ext) def compute_vndk_cap(self, banned_libs): # ELF files on vendor partitions are banned unconditionally. ELF files