summaryrefslogtreecommitdiffstats
path: root/linker
Commit message (Collapse)AuthorAgeFilesLines
* linker: Avoid logcat spam with some blobsMarcin Chojnacki2016-08-041-0/+4
| | | | | | | | | Many of pre-kitkat blobs would emit a "text relocations" warning which makes logcat completely unreadable. This commit will hide this warning to prevent it. Change-Id: I8f32b5bbfea33d732320b3ac29da6b0027fbd521 Reworked-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
* Do not depend on host bits to get the right size to write.Junichi Uekawa2016-06-281-3/+3
| | | | | | | | | | x86_64 32-bit or 64-bit relocations do not depend on ELF bit size, they are 32-bit or 64-bit respectively. Known compiler that emits such code is nacl-clang which emits R_X86_64_PC32 which should write 32 bits but ended up writing 64 bits. Change-Id: Ibb6b484c0fea6a7e291362148e8ac749d6674529
* linker: Allow text-relocs for x86 (only)Christopher R. Palmer2016-03-101-0/+2
| | | | | | | | | | | | | | | This effectively reverts https://android.googlesource.com/platform/bionic/+/e4ad91f86a47b39612e030a162f4793cb3421d31%5E%21/#F0 for x86 platforms. Unfortunately, this seems like it is required if we are going to support ffmpeg. The ffmpeg team decreed that they require text relocations for x86 (only) and that they would not fix the fact that android 6.0 makes ffmpeg unusable on x86: https://trac.ffmpeg.org/ticket/4928 Change-Id: I68397f4d62f4f6acd8e0d41b7ecdc115969b890a
* bionic: linker: Load shim libs *before* the self-linked libsChristopher R. Palmer2016-02-141-4/+4
| | | | | | | | | | | | | | | | | | | | | By loading them earlier, this allows us to override a symbol in a library that is being directly linked. I believe this explains why some people have had problems shimming one lib but when the changet he shim to be against a different lib it magically works. It also makes it possible to override some symbols that were nearly impossible to override before this change. For example, it is pretty much impossible to override a symbol in libutils without this change because it's loaded almost everywhere so no matter where you try to place the shimming, it will be too late and the other symbol will have priority. In particularly, this is necessary to be able to correctly shim the VectorImpl symbols for dlx. Change-Id: I461ca416bc288e28035352da00fde5f34f8d9ffa
* Make shim lib load failure non-fatal.Danny Baumann2015-12-121-10/+12
| | | | | | | | | | Instead, print an appropriate warning message. Aborting symbol resolution on shim lib load failure leads to weird symbol lookup failures, because symbols in libraries referenced after the one loading the shim won't be loaded anymore without a log message stating why that happened. Change-Id: Ic3ad7095ddae7ea1039cb6a18603d5cde8a16143
* Merge tag 'android-6.0.1_r3' of ↵Steve Kondik2015-12-071-3/+13
|\ | | | | | | | | | | https://android.googlesource.com/platform/bionic into cm-13.0 Android 6.0.1 release 3
| * Ensure that readlink has access to /proc/self/fdDmitriy Ivanov2015-10-141-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | /proc/self/fd is not available when PR_DUMPABLE is set to 0 which is default for the user builds. It leads to permission denials on readlink. This change fixes the problem by setting PR_DUMPABLE flag to 1 for readlink and restoring it's previous value after the call. Bug: http://b/24912743 Change-Id: I3fd179c5c6b56af96d6a15ee597024ccb15e1a13
| * Log dlopen failures caused by text relocationsDmitriy Ivanov2015-10-131-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Some apps will fail to load native libraries with text relocations when switching target sdk version to M. It could be hard to diagnose because some of them suppress dlerror and/or UnsatisfiedLinkError. This change unconditionally logs the error message making the cause of the failure more visible to developers. Bug: http://b/24876001 Change-Id: I0477a0d1307d0879000f3a3a43b974b4cf34bdb2
| * linker: don't pass dlextinfo to dependent loads.Torne (Richard Coles)2015-10-081-3/+4
| | | | | | | | | | | | | | | | | | | | Don't pass the parent load's dlextinfo to dependent loads, since this causes the linker to try to load the dependencies using the same addresses/relro/fds/etc as the main library, which is never going to work. This was how it worked before ae69a95 which broke this. Bug: 23742664 Change-Id: I53d8cdf0982d8758e6d2ced4864c704cdf74118f
* | Revert "Revert "linker: Reset the active shim libs each time we do a dlopen""Christopher R. Palmer2015-12-011-2/+8
| | | | | | | | | | | | This reverts commit fd0140b028dedabc572f4659cc015edfeee3cd60. Change-Id: I42b3acfcdc6b84251a396b9e42604bb5685196bd
* | linker: Don't try to walk the g_active_shim_libs when doing dlsymChristopher R. Palmer2015-12-011-3/+4
| | | | | | | | | | | | | | | | This is a bug in the original shim_lib implementation which was doing the shim lib resolution both when loading the libraries and when doing the dynamic symbol resolution. Change-Id: Ib2df0498cf551b3bbd37d7c351410b9908eb1795
* | Revert "linker: Reset the active shim libs each time we do a dlopen"Ethan Chen2015-11-301-8/+2
| | | | | | | | | | | | This reverts commit ad21814c21f40f0e0a4f62e03619e274de9f6983. Change-Id: I205bcbaae6c1494601f9245fe360a088d5b745e9
* | linker: Reset the active shim libs each time we do a dlopenChristopher R. Palmer2015-11-291-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | We use the active libs to avoid recursively trying to load the same library: A -> shimlibs add B -> depends on A -> shimlibs add B -> ... However, when we repeatedly dlopen the same library we need to reset the active shim libs to avoid failing to add B the second time we dlopen A. Change-Id: I27580e3d6a53858e8bca025d6c85f981cffbea06
* | linker: Fix the fact that shim libs do not properly call constructorsChristopher R. Palmer2015-11-151-0/+1
| | | | | | | | Change-Id: I34333e13443a154e675b853fa41442351bc4243a
* | linker: Add support for dynamic "shim" libsChristopher R. Palmer2015-11-071-0/+63
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new environment variable LD_SHIM_LIBS that is a colon (":") separated list of vertical bar ("|") separated pairs. The pairs are the name for a soinfo reference (executable or shared library) followed by the name of the shim library to load. For example: LD_SHIM_LIBS=rmt_storage|libshim_ioprio.so:/system/lib/libicuuv.so|libshim_icu53.so will instruct the linker to load the dynamic library libshim_ioprio.so whenver rmt_storage is executed [*] and will load libshim_icu53.so whenever any executable or other shared library links against /system/lib/libicuuv.so. There are no restrictions against circular references. In this example, libshim_icu53.so can link against libicuuv.so which provides a simple and convenient means of adding compatibility symbols. [*] Note that the absolute path is not available to the linker and therefore using the name of executables does depend on the invocation and therefore should only be used if absolutely necessary. That is, running /system/bin/rmt_storage would not load any shim libs in this example because it does not match the name of the invocation of the command. If you have trouble determining the sonames being loaded, you can also set the environment variable LD_DEBUG=1 which will cause additional information to be logged to help trace the detection of the shim libs. Change-Id: I0ef80fa466167f7bcb7dac90842bef1c3cf879b6
* Restore protection flags for ifunc during relocs.Dmitriy Ivanov2015-07-261-3/+51
| | | | | | | | | | | | IFUNC relocations require executable flag for the load segment containing .text. When dso has text relocs linker removes exec which causes crash during ifunc relocations. This patch fixes this problem by restoring segments protection for ifunc relocs. Bug: http://b/22611399 Change-Id: Icbf3be0fec0e42bf805bcad7533e2032a2e11b9c
* Fix memory-leak on soinfo_free()Dmitriy Ivanov2015-07-091-0/+1
| | | | | | Bug: http://b/22290728 Change-Id: I00747056db2cd3ff8b33936278464daed7236536 (cherry picked from commit 609f11b31ecedc4e9f2a1f6017b60b1f51b15c22)
* Improve personality initializationDmitriy Ivanov2015-06-301-7/+0
| | | | | | | | | | 1. Personality parameter should be unsigned int (not long) 2. Do not reset bits outside of PER_MASK when setting personality value. 3. Set personality for static executables. Bug: http://b/21900686 Change-Id: I4c7e34079cbd59b818ce221eed325c05b9bb2303
* Lock on dl_interate_phdrDmitriy Ivanov2015-06-293-1/+8
| | | | | | | | | | There is possibility of someone dlclosing a library while dl_iterate_phdr in progress which can lead to dl_iterate_phdr calling callback with invalid address if it was unmapped by dlclose. Bug: http://b/22047255 Change-Id: I3fc0d9fd2c51fb36fd34cb035f37271fa893a7be
* Fix crash when trying to load invalid ELF file.Dmitriy Ivanov2015-06-253-4/+19
| | | | | | Bug: http://b/22047255 Bug: http://b/22091640 Change-Id: I6c51cff43287a6ac4b25fa9ce6a6fc3d232fd047
* Revert "[MIPS] Support FR=0 emulation on FR=1 64-bit FP registers"Dimitry Ivanov2015-06-243-153/+6
| | | | | | | This reverts commit 40d9e7bf842423e328cda58e21ff5fc0cbab5c8a. Bug: http://b/22045439 Change-Id: Ia9c56f65d35e404332a462f46460335cef39f0a4
* [MIPS] Support FR=0 emulation on FR=1 64-bit FP registersDuane Sand2015-06-233-6/+153
| | | | | | | | | | Enables running of older MIPS NDK-built apps on mips64r6. Works with kernel supporting FRE emulation, and old kernels. Bug: http://b/21555893 Change-Id: I13923fe62cd83ad1d337f13a50f2eda2dfdd906f (cherry picked from commit d02ec08427b006e80191ce60690ce48a788fb832)
* Merge "Remove text-relocs support for apps targeting M+" into mnc-devDmitriy Ivanov2015-06-221-0/+7
|\
| * Remove text-relocs support for apps targeting M+Dmitriy Ivanov2015-06-121-0/+7
| | | | | | | | | | | | | | Remove support of text-relocations for apps targeting sdk version > 22 Bug: http://b/20013628 Change-Id: I2127739544480c747315e32df15dfbd1b79de4f5
* | Merge "Add flag that makes linker honor min(p_vaddr)" into mnc-devDavid Srbecky2015-06-191-1/+7
|\ \
| * | Add flag that makes linker honor min(p_vaddr)Dmitriy Ivanov2015-06-181-1/+7
| |/ | | | | | | | | | | | | | | (cherry picked from commit 8a1162835597be38705b381ac34c07da17932568) Bug: 21924613 Bug: http://b/21523078 Change-Id: I3f944a08dd2ed1df4d8a807da4fee423fdd35eb7
* | Improve library lookup logicDmitriy Ivanov2015-06-172-8/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | Linker tries to open a library even if it can be found by soname. This only happens if the library was previously opened under different target sdk version. Bug: http://b/21876587 Bug: http://b/21153477 Bug: http://b/21171302 Bug: https://code.google.com/p/android/issues/detail?id=160921 Change-Id: I7dbbcc3b49933bffd89ca0af55371e1a1f2bf4c2
* | Revert "Improve library lookup logic"Dimitry Ivanov2015-06-172-16/+0
| | | | | | | | | | | | | | | | | | | | This reverts commit ea4ef52fa46602a5853df0e5b1ddd71b194d54ce. Bug: http://b/21876587 Bug: http://b/21153477 Bug: http://b/21171302 Bug: https://code.google.com/p/android/issues/detail?id=160921 Change-Id: I23ddbd69294023c56c9cbabad29d26c8f736ab43
* | Improve library lookup logicDmitriy Ivanov2015-06-162-0/+16
|/ | | | | | | | | | | | | Linker tries to open a library even if it can be found by soname. This only happens if the library was previously opened under different target sdk version. Bug: http://b/21876587 Bug: http://b/21153477 Bug: http://b/21171302 Bug: https://code.google.com/p/android/issues/detail?id=160921 Change-Id: I769a04b6b1368a107d43f399297be14050338bbc
* Merge "Make path to apk compliant with jar url format" into mnc-devDmitriy Ivanov2015-06-111-4/+4
|\
| * Make path to apk compliant with jar url formatDmitriy Ivanov2015-06-091-4/+4
| | | | | | | | | | | | Bug: http://b/21726698 Bug: http://b/8076853 Change-Id: I8c1942a98fe3119746b4dc9f60a7ff215ea7009c
* | Fix l_addr for the linkerDmitriy Ivanov2015-06-101-1/+1
| | | | | | | | | | | | Bug: http://b/21765603 Change-Id: I97710ef2436eac2160e29ba3e4521f6e63a1907c (cherry picked from commit 175dae92d78cc6338125a49ea8dbabbd2f22ddf0)
* | Statically linked executables should honor AT_SECURE.Elliott Hughes2015-06-104-325/+9
| | | | | | | | | | | | Bug: http://b/19647373 Change-Id: I10e7682d9cec26a523f1a3597ca5326c3ca42ebe (cherry picked from commit 1801db3d3fe17df543e721b9fb355e5c882dc6cc)
* | Check if strtab exists before using itDmitriy Ivanov2015-06-101-11/+11
|/ | | | | | Bug: http://b/21696087 Change-Id: I1e22d5fd6fe2faead332249493123c9a085081e9 (cherry picked from commit 624b8f17a1ce9b968f11e73231733442a07ac001)
* Backward compatibility for dlsym(RTLD_DEFAULT, ...)Dmitriy Ivanov2015-06-024-9/+34
| | | | | | | | | Do not skip RTLD_LOCAL libraries in dlsym(RTLD_DEFAULT, ...) if the library is opened by application with target api level <= 22 Bug: http://b/21565766 Bug: http://b/17512583 Change-Id: Ic45ed1e4f53e84cba9d74cab6b0049c0c7aa8423
* Work around for libraries without dt_sonameDmitriy Ivanov2015-06-021-0/+13
| | | | | | | Applies only for apps targeting sdk version <= 22 Bug: http://b/21565766 Change-Id: If0bf2229dc1341e9ca09f9a05d0890515273d5a2
* Fix dlsym(handle_of_main_executable, ...)Dmitriy Ivanov2015-06-011-0/+11
| | | | | | | | | | | | | | According to man dlopen(3) and posix docs in the case when si is handle of the main executable we need to search not only in the executable and its dependencies but also in all libraries loaded with RTLD_GLOBAL. see also: http://pubs.opengroup.org/onlinepubs/9699919799/functions/dlopen.html Bug: http://b/21528224 Bug: http://b/17512583 Bug: https://code.google.com/p/android/issues/detail?id=173822 Change-Id: Ib2801367ba48b6f3704da89a6d9f5e6911430013 (cherry picked from commit f439b5a3186ca0fef1092f45770abc716da9d87a)
* Improve some of error/warning messagesDmitriy Ivanov2015-05-281-2/+3
| | | | | | Bug: http://b/20464031 Change-Id: I948141c46f9e054fc45f5934153dee56ce3cd558 (cherry picked from commit 087005f37e02b48809746947159d824493885b1e)
* Work around incorrect dt_needed entriesDmitriy Ivanov2015-05-282-1/+19
| | | | | | | | | This applies for apps targeting sdk<=22 and only for lp32 platforms. Bug: http://b/21364029 Change-Id: I903e81c9ccda2a8beaba1d132d68c77d30a4cdb2 (cherry picked from commit d974e8804689058714dc4fe9adcb57ee9a6996a8)
* Add functions to provide target sdk versionDmitriy Ivanov2015-05-274-14/+59
| | | | | | Bug: http://b/21364029 Change-Id: I8648d1bff6c8fd6e7cd12da7f128e048b9f2829a (cherry picked from commit 79fd668bb4ddb22432eeda2ebd8d10359013d9a8)
* Fix RTLD_NEXT lookup for the local_groupDmitriy Ivanov2015-05-221-1/+1
| | | | | | | | | | Linker used to skip RTLD_NEXT within local_group when caller->next is nullptr (which represents load order but not the order within local_group dependency tree) Bug: http://b/21380474 Change-Id: I178fc4657b19bceb871635b177c1df67855b1708 (cherry picked from commit b96ac41b32e61799c48f3fd07831cc168b95068d)
* Merge "Apply work around b/19059885 to x86" into mnc-devDmitriy Ivanov2015-05-163-9/+12
|\
| * Apply work around b/19059885 to x86Dmitriy Ivanov2015-05-153-9/+12
| | | | | | | | | | | | Bug: http://b/19059885 Bug: http://b/21203348 Change-Id: Ic375e9f877d68de8f866d17362879a7dde638465
* | Don't use TEMP_FAILURE_RETRY on close in bionic.Elliott Hughes2015-05-151-2/+1
|/ | | | | | Bug: http://b/20501816 Change-Id: Id64b5109cc2b165fa0351b6edbb865a5e5058008 (cherry picked from commit 4e8ef698d0d76be3f8d75de32701e6e6327c1fbd)
* Fix regression in crash reportingJohn Reck2015-05-151-9/+0
| | | | | | | | Bug: 19532651 Partial revert of be0e43b77676338fd5e6a82c9cc2b6302d579de2 Change-Id: I99e220328aff985facb920ebcd84ac1a016759b5
* ScopedFd: Don't use TEMP_FAILURE_RETRY() with close()Spencer Low2015-05-131-22/+25
| | | | | | | | | | | | | | According to the comments in Posix_close(), TEMP_FAILURE_RETRY() should not be used with close(): https://android.googlesource.com/platform/libcore/+/462bdac45c10f43d88d8f07f6994e272a27c14a2%5E%21/#F12 Kill ScopedFd by simplifying the single caller. Bug: http://b/20501816 Change-Id: I248c40b8c2fc95f1938a6edfc245c81847fc44af Signed-off-by: Spencer Low <CompareAndSwap@gmail.com> (cherry picked from commit 0346ad7a4fb6e253317577ee8b9cc79d958f4349)
* Improved dlsym tests and fixes to linkerDmitriy Ivanov2015-05-121-27/+20
| | | | | | | | | | | Answers the question: what if dependent library was preloaded with RTLD_LOCAL flag. Also add test for RTLD_NEXT within local_group. Bug: http://b/17512583 Change-Id: I79e081e68b3a8c0ed8980d4275a06515fea94ec9 (cherry picked from commit 697bd9fd38ab078a117ad9a5777cf286c467b9b9)
* Update NOTICE files (the second time today).Elliott Hughes2015-05-121-28/+0
| | | | | Change-Id: Ifb031d29ee697ee0682bd651e0081493e8016e67 (cherry picked from commit f58ac87182da214c7cdd697a4fa09aeb7b995305)
* Simplify three copyright headers.Elliott Hughes2015-05-121-1/+1
| | | | | | | | | There's no reason to have multiple years in our own copyright headers, and given the stupidity of our NOTICE file generation, it just creates more junk. Change-Id: I065a3811c2e2584e3b649a18ad9460286bc72b92 (cherry picked from commit c69ace87ec110a91005bdf19dbafeb355f399c06)
* Merge "Update NOTICE files." into mnc-devElliott Hughes2015-05-121-22/+38
|\