summaryrefslogtreecommitdiff
path: root/linker/linker.cpp
AgeCommit message (Collapse)Author
2016-05-24Correctly handle the case of empty LD_PRELOAD entriesDimitry Ivanov
Previous android versions ignored empty entries for LD_PRELOAD Bug: http://b/28936779 Change-Id: I757478fe0c604ee378186511cb13b757fd9a9864 (cherry picked from commit d799b2bb7e9335786ab4596757d871e4a7722ff0)
2016-05-24Correctly handle the case of empty LD_PRELOAD entriesDimitry Ivanov
Previous android versions ignored empty entries for LD_PRELOAD Bug: http://b/28936779 Change-Id: I757478fe0c604ee378186511cb13b757fd9a9864
2016-05-23Fix comments since we are keeping grey-list in NDimitry Ivanov
Also add warning about removing access to greylisted libs in the future Android releases. Bug: http://b/26427993 Change-Id: I1aaa94e3bde09ab0f6594e9170d479cdb3e77d42
2016-05-23Do not resolve caller_ns when it is not neededDimitry Ivanov
create_namespace resolves caller namespace only when caller did not explicitly specify parent namespace. This saves about 25 microseconds for the case when parent_namepsace is not null (for example when creating second classloader for the app). Bug: http://b/28801010 Change-Id: I50ded272c931db701e5a1d8c88ed5ffb13416539 (cherry picked from commit 5240863ed559cb4c2b121ddfbf6b3d78ac15e38f)
2016-05-23Do not resolve caller_ns when it is not neededDimitry Ivanov
create_namespace resolves caller namespace only when caller did not explicitly specify parent namespace. This saves about 25 microseconds for the case when parent_namepsace is not null (for example when creating second classloader for the app). Bug: http://b/28801010 Change-Id: I50ded272c931db701e5a1d8c88ed5ffb13416539
2016-05-19Do not check zip-entry validity on create_namespaceDimitry Ivanov
This operation is the most expensive one and since it is unlikely that the zip-entry name is invalid (given that it is constructed by the platform) - it can removed. The worst case scenario is dlopen() of non-existing libraries taking more time. And this use-case is not on the critical path. Bug: http://b/28801010 Change-Id: I10a6b0bf342404ab72f0f5102ebf19f6c06ee6bf (cherry picked from commit a5c1c8e820ec3057f798f675bf8af19a4a29b396)
2016-05-19Do not check zip-entry validity on create_namespaceDimitry Ivanov
This operation is the most expensive one and since it is unlikely that the zip-entry name is invalid (given that it is constructed by the platform) - it can removed. The worst case scenario is dlopen() of non-existing libraries taking more time. And this use-case is not on the critical path. Bug: http://b/28801010 Change-Id: I10a6b0bf342404ab72f0f5102ebf19f6c06ee6bf
2016-05-18Merge "Fix dlopen of main executable by absolute path" into nyc-devDimitry Ivanov
2016-05-17linker: Allow caller to specify parent namespaceDimitry Ivanov
This change enables apps to share libraries opened with RTLD_GLOBAL between different classloader namespaces. The new parameter to create_namespace allows native_loader to instruct the linker to share libraries belonging to global group from a specified namespace instead of using the caller_ns. Bug: http://b/28560538 Bug: https://code.google.com/p/android/issues/detail?id=208458 Change-Id: I5d0c62730bbed19cdeb16c7559c74aa262a2475f (cherry picked from commit fc2da53440383fe1026e0eb287d643b577c2707d)
2016-05-17Merge "linker: Allow caller to specify parent namespace"Treehugger Robot
2016-05-17Fix dlopen of main executable by absolute pathDimitry Ivanov
This CL adds initialization of inode for the main executable which enables linker to resolve the correct soinfo when application calls dlopen with absolute path to the main executable. Bug: http://b/28420266 Change-Id: I102e07bde454bd44c6e46075e3faeeb5092830d8 (cherry picked from commit 2ba1cf39ae6087249a839ec7b3793d4d4fa75438)
2016-05-17Fix dlopen of main executable by absolute pathDimitry Ivanov
This CL adds initialization of inode for the main executable which enables linker to resolve the correct soinfo when application calls dlopen with absolute path to the main executable. Bug: http://b/28420266 Change-Id: I102e07bde454bd44c6e46075e3faeeb5092830d8
2016-05-17linker: Allow caller to specify parent namespaceDimitry Ivanov
This change enables apps to share libraries opened with RTLD_GLOBAL between different classloader namespaces. The new parameter to create_namespace allows native_loader to instruct the linker to share libraries belonging to global group from a specified namespace instead of using the caller_ns. Bug: http://b/28560538 Bug: https://code.google.com/p/android/issues/detail?id=208458 Change-Id: I5d0c62730bbed19cdeb16c7559c74aa262a2475f
2016-05-06Fix linker crash on trying to unload main executableDimitry Ivanov
Linker crashed if linking of the main executable fails instead of aborting with readable error message. This patch modifies unload to soinfo_unload it all at once in this particular case. This helps avoid situations when one of the libraries on the DT_NEEDED list of main executable has gotten unloaded by previous library unload because it DT_NEEDED it too. Example (consider following dependency tree): main_executable |-> liba.so |-> libb.so |-> libb.so The list of the libraries need to be unloaded in this case is [liba.so, libb.so], but if linker does unload one by one by the time it gets to libb.so - the soinfo for the library is already unloaded (and the segments were unmapped). Passing everything as an array helps soinfo_unload to check if a library was already unloaded by looking into local_unload_list. Bug: http://b/28565608 Change-Id: I7199290e10a186057dcf3b7b68dbce954af7dba1 (cherry picked from commit 83fcb542088db7874a387f4f41caac2019821fd2)
2016-05-06Fix linker crash on trying to unload main executableDimitry Ivanov
Linker crashed if linking of the main executable fails instead of aborting with readable error message. This patch modifies unload to soinfo_unload it all at once in this particular case. This helps avoid situations when one of the libraries on the DT_NEEDED list of main executable has gotten unloaded by previous library unload because it DT_NEEDED it too. Example (consider following dependency tree): main_executable |-> liba.so |-> libb.so |-> libb.so The list of the libraries need to be unloaded in this case is [liba.so, libb.so], but if linker does unload one by one by the time it gets to libb.so - the soinfo for the library is already unloaded (and the segments were unmapped). Passing everything as an array helps soinfo_unload to check if a library was already unloaded by looking into local_unload_list. Bug: http://b/28565608 Change-Id: I7199290e10a186057dcf3b7b68dbce954af7dba1
2016-04-27Add libvorbisidec.so to the grey-listDimitry Ivanov
Bug: http://b/28403395 Change-Id: Ic718b1eea4616ca87b94eee211717c4475082cab
2016-04-21Improve error message for empty list of public libsDimitry Ivanov
Change-Id: I5a3cbc99d34e05559426b521a964d1407b67a6c4
2016-04-20Merge "Rename DT_MIPS_RLD_MAP2 flag to DT_MIPS_RLD_MAP_REL"Than McIntosh
2016-04-14Remove dangling links in secondary namespacesDimitry Ivanov
linker didn't remove link to the soinfo from shared namespaces on soinfo_unload, because it didn't keep record of all namespaces the library is added to. This change adds test for this and also fixes the problem by introducing list of secondary namespaces to soinfo, which is used to remove soinfo in soinfo::remove_all_links(). Bug: http://b/28115950 Change-Id: Ifbf6e54f92fa6e88f86b6a8dd6dc22d4553afd22 (cherry picked from commit aca299ac4721809d6fc61e25c505bb59acd23fbc)
2016-04-14Remove dangling links in secondary namespacesDimitry Ivanov
linker didn't remove link to the soinfo from shared namespaces on soinfo_unload, because it didn't keep record of all namespaces the library is added to. This change adds test for this and also fixes the problem by introducing list of secondary namespaces to soinfo, which is used to remove soinfo in soinfo::remove_all_links(). Bug: http://b/28115950 Change-Id: Ifbf6e54f92fa6e88f86b6a8dd6dc22d4553afd22
2016-04-13linker: remove unnecessary reset of constructors_called flagDimitry Ivanov
linker doesn't call d-tors for RTLD_NODELETE libraries. There is no need in reseting this flag in call_destructors (which is called from soinfo_unload). Change-Id: I3ed03fa7207b7acf598067276fbb8874e29b5e53
2016-04-13linker: unload RTLD_NODELETE libraries when loading failsDimitry Ivanov
Linker was not unloading libraries marked with RTLD_NODELETE even when there was a error on load. For example when one of dt_needed libraries was not found. Bug: http://b/27911891 Change-Id: Ibc0bf110aa41fbfdc9f327ad8c364f2e3600af71 (cherry picked from commit 79abce42146b27d523f309e0a1bc9f50175191cb)
2016-04-13linker: unload RTLD_NODELETE libraries when loading failsDimitry Ivanov
Linker was not unloading libraries marked with RTLD_NODELETE even when there was a error on load. For example when one of dt_needed libraries was not found. Bug: http://b/27911891 Change-Id: Ibc0bf110aa41fbfdc9f327ad8c364f2e3600af71
2016-04-12Add libgui.so to the grey-listDimitry Ivanov
Bug: http://b/28151000 Change-Id: I7ba8f78df7dbf32de4839cc5a95ef10e8444715c
2016-04-08Add libexpat.so to the grey-listDimitry Ivanov
Bug: http://b/28071598 Change-Id: I5545a06edfd8e0ab5b011392860ddccd6c04677f
2016-04-06Rename DT_MIPS_RLD_MAP2 flag to DT_MIPS_RLD_MAP_RELLazar Trsic
Change-Id: I2c0972f5ce3586c3f4f130034f7063f97557ab4e
2016-04-01Use consistent quoting in linker messages.Elliott Hughes
Using single quotes can be more convenient -- because there's no need to escape -- but the vast majority of existing quoting was done with double quotes, so move in that direction. Bug: http://b/27524191 Change-Id: I8f58593120e4c8aeaec45e16fc0178e9c162454d
2016-03-30CloseArchive() to free memory when OpenArchive fails.Yabin Cui
Bug: 26962895 Change-Id: I42418eee320ddae857b42572690316c53f638e85 (cherry picked from commit 722072d65abb1b9fa709f5c7ae8afd98ef5ab7af)
2016-03-29libc: implement kernel vdso syscalls for i386Mingwei Shi
This patch uses __kernel_vsyscall instead of "int 0x80" as the syscall entry point. AT_SYSINFO points to an adapter to mask the arch specific difference and gives a performance boost on i386 architecture. Bug: http://b/27533895 Change-ID: Ib340c604d02c6c25714a95793737e3cfdc3fc5d7 Signed-off-by: Mingwei Shi <mingwei.shi@intel.com> (cherry picked from commit be910529322b461148debefd50b9e0d67ae84f8e)
2016-03-28linker: hide the pointer to soinfoDimitry Ivanov
Handle no longer is a pointer to soinfo of a corresponding library. This is done to prevent access to linker internal fields. Bug: http://b/25593965 Change-Id: I62bff0d0e5b2dc842e6bf0babb30fcc4c000be24 (cherry picked from commit d88e1f350111b3dfd71c6492321f0503cb5540db)
2016-03-28Do not add linker the _r_debug.r_map on link_imageDimitry Ivanov
Bug: http://b/27533895 Change-Id: Idd0fb06a5d9f400c0608ae532cc4c575211810fa (cherry picked from commit e97d8ed70e44db619de9975a43ed2d1509653d74)
2016-03-28Improvements to dynamic linker messagesDimitry Ivanov
Error messages now include executable name, also linker doesn't abort if called on itself. Bug: http://b/27533895 Change-Id: Ia17dd540919544b28062ed71751a1d79ee865206 (cherry picked from commit 9f0a6954c602e63f85746237e1a333b4571d757d)
2016-03-28Move gdb support functions to a separate fileDimitry Ivanov
Move gdb support functions and variables to linker_gdb_support.h/cpp Bug: http://b/27533895 Change-Id: I96c6592a7055715b18f1137367470fe80987263f (cherry picked from commit 6b788eeff2ea0019849517e796b762ae790ca142)
2016-03-28Use insert_link_map_into_debug_map for executableDimitry Ivanov
Use insert_link_map_into_debug_map to insert the main executable's link_map to r_debug Bug: http://b/27533895 Change-Id: I0eacb3f030ea3eb16ed50ad2011d604beece2d03 (cherry picked from commit f3064e4bc7f4dee351bc2eb9272db3e9792dc683)
2016-03-28Update a comment for init_linker_info_for_gdbDimitry Ivanov
Bug: http://b/27533895 Change-Id: I8e2895ecfcc6f77a180c3735342afc93be5923d3 (cherry picked from commit 6400129628ef24adb57fc4822d4fd54b8967701b)
2016-03-28Initialize linker link_map for gdb directlyDimitry Ivanov
Remove unnecessary construction of soinfo when initializing linker link_map for gdb. Bug: http://b/27533895 Change-Id: Idf32cee56309aa9c9cf260efbd17a9deae9a756b (cherry picked from commit 8d22dd53feddcc7a84e1cc481f171fd4dfe095a1)
2016-03-28linker: hide the pointer to soinfoDimitry Ivanov
Handle no longer is a pointer to soinfo of a corresponding library. This is done to prevent access to linker internal fields. Bug: http://b/25593965 Change-Id: I62bff0d0e5b2dc842e6bf0babb30fcc4c000be24
2016-03-25libc: implement kernel vdso syscalls for i386Mingwei Shi
This patch uses __kernel_vsyscall instead of "int 0x80" as the syscall entry point. AT_SYSINFO points to an adapter to mask the arch specific difference and gives a performance boost on i386 architecture. Change-ID: Ib340c604d02c6c25714a95793737e3cfdc3fc5d7 Signed-off-by: Mingwei Shi <mingwei.shi@intel.com>
2016-03-22CloseArchive() to free memory when OpenArchive fails.Yabin Cui
Bug: 26962895 Change-Id: I42418eee320ddae857b42572690316c53f638e85
2016-03-15Remove missing DT_SONAME warning from the toastDimitry Ivanov
Bug: http://b/27613086 Change-Id: I9410f07dbde002d936319516313b27f9794dd597
2016-03-03Add libsqlite.so to the grey-listDimitry Ivanov
Bug: http://b/27152660 Bug: http://b/26394120 Change-Id: I9f8f6eb8cf0d81ddf1b7769e306c08b927f3dad1
2016-03-02Do not add linker the _r_debug.r_map on link_imageDimitry Ivanov
Change-Id: Idd0fb06a5d9f400c0608ae532cc4c575211810fa
2016-03-01linker: print "not accessible" error message to the logDimitry Ivanov
Print properties of the namespace on "library is not accessible" error to better diagnose problems with native library accessiblity Bug: http://b/27406143 Change-Id: Icf3d6c604f09dfa015de863fdb1267d343930d2a (cherry picked from commit 350bdad61cc6551db649fcaeb8642f4a1d6b139a)
2016-03-01linker: print "not accessible" error message to the logDimitry Ivanov
Print properties of the namespace on "library is not accessible" error to better diagnose problems with native library accessiblity Bug: http://b/27406143 Change-Id: Icf3d6c604f09dfa015de863fdb1267d343930d2a
2016-02-26Add android_dlwarning() methodDimitry Ivanov
This is temporary method intended to use for a toast message on preview and beta releases. Will be removed before the production release. Bug: http://b/27365747 Change-Id: I39cc716bb82863ae761b6821bcec77cce6db3781
2016-02-18Improvements to dynamic linker messagesDimitry Ivanov
Error messages now include executable name, also linker doesn't abort if called on itself. Change-Id: Ia17dd540919544b28062ed71751a1d79ee865206
2016-02-18Move gdb support functions to a separate fileDimitry Ivanov
Move gdb support functions and variables to linker_gdb_support.h/cpp Change-Id: I96c6592a7055715b18f1137367470fe80987263f
2016-02-18Revert "Move gdb support functions to a separate file"Nicolas Geoffray
Was reverted on internal master already. This reverts commit f8d051c81b7c22575ac940dea612fb3b880e6d7a. Change-Id: Ia432f83bcce91366fb23f1bb87603a093b7f074d
2016-02-17Move gdb support functions to a separate fileDimitry Ivanov
Move gdb support functions and variables to linker_gdb_support.h/cpp Change-Id: Id6e608617016383b68283760361c567e58e574bc
2016-02-17Use insert_link_map_into_debug_map for executableDimitry Ivanov
Use insert_link_map_into_debug_map to insert the main executable's link_map to r_debug Change-Id: I0eacb3f030ea3eb16ed50ad2011d604beece2d03