platform_bionic/linker
dimitry 965d06da1e Fix logic in loading dependencies crossing namespace boundaries
This change addresses multiple problems introduced by
02586a2a34

1. In the case of unsuccessful dlopen the failure guard is triggered
for two namespaces which leads to double unload.

2. In the case where load_tasks includes libraries from 3 and more
namespaces it results in incorrect linking of libraries shared between
second and third/forth and so on namespaces.

The root cause of these problems was recursive call to find_libraries.
It does not do what it is expected to do. It does not form new load_tasks
list and immediately jumps to linking local_group. Not only this skips
reference counting it also will include unlinked but accessible library
from third (and fourth and fifth) namespaces in invalid local group. The
best case scenario here is that for 3 or more namesapces this will
fail to link. The worse case scenario it will link the library
incorrectly with will lead to very hard to catch bugs.

This change removes recursive call and replaces it with explicit list of
local_groups which should be linked. It also revisits the way we do
reference counting - with this change the reference counts are updated after
after libraries are successfully loaded.

Also update soinfo_free to abort in case when linker tries to free same
soinfo for the second time - this makes linker behavior less undefined.

Test: bionic-unit-tests
Bug: http://b/69787209
Change-Id: Iea25ced181a98c6503cce6e2b832c91d697342d5
2017-12-10 22:04:55 +01:00
..
arch Force _start to be the top frame for the linker. 2017-10-16 14:43:34 -07:00
tests Allow property += value in ld.config.txt 2017-12-01 10:58:10 +09:00
Android.bp Merge "Rename target.linux[_x86[_64]] to target.linux_glibc[_x86[_64]]" 2017-10-03 02:30:05 +00:00
Android.mk Convert linker from Android.mk to Android.bp 2016-07-15 13:39:29 -07:00
dlfcn.cpp Replace artificial symbol table with proper one 2017-08-29 18:18:28 +02:00
ld.config.format.md Load namespace configuration from ld.config.txt 2017-03-24 15:50:45 -07:00
linked_list.h Unify linker files under one license (BSD) 2017-02-15 15:35:33 -08:00
linker.arm.map Replace artificial symbol table with proper one 2017-08-29 18:18:28 +02:00
linker.cpp Fix logic in loading dependencies crossing namespace boundaries 2017-12-10 22:04:55 +01:00
linker.generic.map Replace artificial symbol table with proper one 2017-08-29 18:18:28 +02:00
linker.h Replace artificial symbol table with proper one 2017-08-29 18:18:28 +02:00
linker_allocator.cpp Always log errno when aborting. 2017-09-15 16:18:49 -07:00
linker_allocator.h Add missing includes. 2017-10-11 11:25:52 -07:00
linker_block_allocator.cpp Always log errno when aborting. 2017-09-15 16:18:49 -07:00
linker_block_allocator.h Unify linker files under one license (BSD) 2017-02-15 15:35:33 -08:00
linker_cfi.cpp Unify linker files under one license (BSD) 2017-02-15 15:35:33 -08:00
linker_cfi.h Unify linker files under one license (BSD) 2017-02-15 15:35:33 -08:00
linker_common_types.h Extract soinfo and globals to separate files. 2016-08-08 16:12:53 -07:00
linker_config.cpp Merge "Allow property += value in ld.config.txt" 2017-12-04 01:43:27 +00:00
linker_config.h Use ld.config.$VER.txt when current VNDK version is $VER 2017-12-03 23:26:53 +09:00
linker_debug.h Move libc_log code into libasync_safe. 2017-05-03 08:50:43 -07:00
linker_dlwarning.cpp Unify linker files under one license (BSD) 2017-02-15 15:35:33 -08:00
linker_dlwarning.h Unify linker files under one license (BSD) 2017-02-15 15:35:33 -08:00
linker_exidx_static.c Implement __gnu_Unwind_Find_exidx/__cxa_type_match 2017-08-29 18:18:27 +02:00
linker_gdb_support.cpp Unify linker files under one license (BSD) 2017-02-15 15:35:33 -08:00
linker_gdb_support.h Unify linker files under one license (BSD) 2017-02-15 15:35:33 -08:00
linker_globals.cpp Extract soinfo and globals to separate files. 2016-08-08 16:12:53 -07:00
linker_globals.h linker: fix error message for inaccessible libs 2017-10-23 15:14:01 +02:00
linker_libc_support.c Unify linker files under one license (BSD) 2017-02-15 15:35:33 -08:00
linker_libcxx_support.cpp Implement __gnu_Unwind_Find_exidx/__cxa_type_match 2017-08-29 18:18:27 +02:00
linker_logger.cpp Move libc_log code into libasync_safe. 2017-05-03 08:50:43 -07:00
linker_logger.h Add support for disabling the greylist. 2017-04-06 10:59:24 -07:00
linker_main.cpp Fix logic in loading dependencies crossing namespace boundaries 2017-12-10 22:04:55 +01:00
linker_main.h Fix logic in loading dependencies crossing namespace boundaries 2017-12-10 22:04:55 +01:00
linker_mapped_file_fragment.cpp Unify linker files under one license (BSD) 2017-02-15 15:35:33 -08:00
linker_mapped_file_fragment.h Unify linker files under one license (BSD) 2017-02-15 15:35:33 -08:00
linker_memory.cpp Move libc_log code into libasync_safe. 2017-05-03 08:50:43 -07:00
linker_mips.cpp MIPS: Fix MIPS linker VDSO issues 2017-10-13 12:08:30 +02:00
linker_namespaces.cpp linker: the global group is added to all built-in namespaces 2017-08-04 14:14:09 +09:00
linker_namespaces.h linker: the global group is added to all built-in namespaces 2017-08-04 14:14:09 +09:00
linker_phdr.cpp linker: the global group is added to all built-in namespaces 2017-08-04 14:14:09 +09:00
linker_phdr.h Check alignment along with range of mapped file fragments 2016-08-10 10:52:55 -07:00
linker_reloc_iterators.h Unify linker files under one license (BSD) 2017-02-15 15:35:33 -08:00
linker_relocs.h Unify linker files under one license (BSD) 2017-02-15 15:35:33 -08:00
linker_sdk_versions.cpp Unify linker files under one license (BSD) 2017-02-15 15:35:33 -08:00
linker_sleb128.h Move libc_log code into libasync_safe. 2017-05-03 08:50:43 -07:00
linker_soinfo.cpp Fix logic in loading dependencies crossing namespace boundaries 2017-12-10 22:04:55 +01:00
linker_soinfo.h Fix logic in loading dependencies crossing namespace boundaries 2017-12-10 22:04:55 +01:00
linker_utils.cpp Extract format_string function. 2017-03-13 16:25:51 -07:00
linker_utils.h Load namespace configuration from ld.config.txt 2017-03-24 15:50:45 -07:00
linker_wrapper.cpp Use an embedded linker for host bionic 2017-09-20 13:59:13 -07:00
MODULE_LICENSE_BSD Unify linker files under one license (BSD) 2017-02-15 15:35:33 -08:00
rt.cpp More dynamic linker cleanup. 2012-10-30 16:35:38 -07:00