summaryrefslogtreecommitdiffstats
path: root/linker
Commit message (Collapse)AuthorAgeFilesLines
* Always use signed leb128 decoderDmitriy Ivanov2015-04-223-52/+11
| | | | | | | | Relocation packer no longer encodes relocation tables using unsigned leb128: https://android-review.googlesource.com/147745 Bug: http://b/18051137 Change-Id: I620b7188e5f3dd9d5123431aa1fc7feca76be607
* Add library name to error messageDmitriy Ivanov2015-04-201-1/+2
| | | | Change-Id: I079e6f1dd95fe9cae2135fcd7358c51f8b584ac9
* Support symbol versioningDmitriy Ivanov2015-04-165-43/+476
| | | | | Bug: http://b/20139821 Change-Id: I64122a0fb0960c20b2ce614161b7ab048456b681
* Add realpath for soinfoDmitriy Ivanov2015-04-064-115/+191
| | | | | | | | | | | | This change adds realpath to soinfo and extends limit on filenames from 128 to PATH_MAX. It also removes soinfo::name field, linker uses dt_soname instead. Bug: http://b/19818481 Bug: https://code.google.com/p/android/issues/detail?id=80336 Change-Id: I9cff4cb5bda3ee2bc74e1bbded9594ea7fbe2a08
* Merge "Add ANDROID_DLEXT_FORCE_LOAD flag"Dmitriy Ivanov2015-04-031-10/+12
|\
| * Add ANDROID_DLEXT_FORCE_LOAD flagDmitriy Ivanov2015-04-031-10/+12
| | | | | | | | | | | | | | | | | | This flag allows to force loading of the library in the case when for some reason multiple ELF files share the same filename (because the already-loaded library has been removed and overwritten, for example). Change-Id: I798d44409ee13d63eaa75d685e99c4d028d2b0c1
* | Merge "Look into local group on dlsym with RTLD_DEFAULT"Dmitriy Ivanov2015-04-023-15/+40
|\ \
| * | Look into local group on dlsym with RTLD_DEFAULTDmitriy Ivanov2015-04-023-15/+40
| |/ | | | | | | | | | | | | | | Fix dlsym to look into local group when called with RTLD_DEFAULT and RTLD_NEXT. Bug: 17512583 Change-Id: I541354e89539c712af2ea4ec751e546913027084
* | linker: never mark pages simultaneously writable / executableNick Kralevich2015-04-011-1/+7
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the Android dynamic linker handles a text relocation, it first relaxes the permissions on the segment being modified, performs the modifications, and then restores the page permissions. The relaxation worked by adding PROT_WRITE to whatever protection bits were set in the section. In effect, the pages were getting set to PROT_READ|PROT_WRITE|PROT_EXEC, modified, then restored to PROT_READ|PROT_EXEC The SELinux kernel code differentiates between 4 different kinds of executable memory: * Executable stack (execstack) * Executable heap (execheap) * File-based executable code which has been modified (execmod) * All other executable memory (execmem) The execmod capability is only triggered by the kernel when a dirty but non-executable mmap()ed page becomes executable. When that occurs, an SELinux policy check is done to see if the execmod capability is provided by policy. However, if the page is already executable, and PROT_WRITE is added to the page, it's considered an execmem permission check, not an execmod permission check. There are certain circumstances where we may want to distinguish between execmod and execmem. This change adjusts the dynamic linker to avoid using RWX pages, so that an RX -> RW -> RX transition will properly be detected as an execmod permission check instead of an execmem permission check. Bug: 20013628 Change-Id: I14d7be29170b156942f9809023f3b2fc1f37846c
* Revert "Remove text-relocation support for lp32"Dimitry Ivanov2015-04-014-4/+108
| | | | | | | | This reverts commit cb00add1b382d1e3045876d7e1ccbee2fdce976b. Bug: 20020312 Bug: 20013628 Change-Id: I8baa3d4b6c7fef50c9e2531257d5b96762099eb3
* Remove text-relocation support for lp32Dmitriy Ivanov2015-03-314-108/+4
| | | | | Bug: 20013628 Change-Id: Idaf8012f00ee1304d429c3b42f9ebc6b648c55b8
* Fix long lines and replace macros with functions.Dmitriy Ivanov2015-03-317-93/+153
| | | | Change-Id: I4e1cab488d5b2c8e4289da617350a86e72a4ba12
* linker_environ: clear MALLOC_CONF when AT_SECURE=1Nick Kralevich2015-03-271-0/+2
| | | | | | Clear JE_MALLOC_CONF and MALLOC_CONF Change-Id: Ia76e263783194ecaa362e8ccafbe13a28a4a1ba6
* Explain why we need objcopy for the linkerDmitriy Ivanov2015-03-261-1/+3
| | | | Change-Id: I646673abc6095b56f72add493b60925375b75b78
* Replace fixed arrays with vectorsDmitriy Ivanov2015-03-241-52/+70
| | | | | | | This effectively removes limit on length and count of LD_LIBRARY_PATH and LD_PRELOAD entries. Change-Id: Ie7ea34a50d99c4018f9dd1a33aaebc4049a7f424
* Limit soinfo compatibility fields to arm32Dmitriy Ivanov2015-03-191-2/+2
| | | | Change-Id: I3924cd68397c223c0d206295d587f9dd8ebdc086
* Implement lookup by DT_SONAMEDmitriy Ivanov2015-03-183-23/+39
| | | | | | | | | This CL also fixes SEARCH_NAME hack and resolves https://code.google.com/p/android/issues/detail?id=6670 once and for all. Bug: https://code.google.com/p/android/issues/detail?id=6670 Change-Id: I9b8d6a672cd722f30fbfbb40cdee8d9b39cfe56e
* Fix library lookup for filenames with slash.Dmitriy Ivanov2015-03-181-5/+1
| | | | | | | | If filename contains a slash, then it is interpreted as a (relative or absolute) pathname. Bug: https://code.google.com/p/android/issues/detail?id=6670 Change-Id: Iba57d638301f3089ad47ba083edca2dd36b801ed
* Support loading shared libraries from zip filesSimon Baldwin2015-03-162-15/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add code to support loading shared libraries directly from within APK files. Extends the linker's handling of LD_LIBRARY_PATH, DT_RUNPATH, etc to allow elements to be either directories as normal, or ZIP format files. For ZIP, the ZIP subdirectory string is separated from the path to file by '!'. For example, if DT_NEEDED is libchrome.so and Chrome.apk is the Android ARM APK then the path element /system/app/Chrome.apk!lib/armeabi-v7a would cause the linker to load lib/armeabi-v7a/libchrome.so directly from inside Chrome.apk. For loading to succeed, libchrome.so must be 'stored' and not compressed in Chrome.apk, and must be page aligned within the file. Motivation: Chromium tracking issue: https://code.google.com/p/chromium/issues/detail?id=390618 Bug: 8076853 Change-Id: Ic49046600b1417eae3ee8f37ee98c8ac1ecc19e7
* General purpose memory allocator for linker.Dmitriy Ivanov2015-03-168-20/+745
| | | | | | | | Add basic general purpose memory allocator to linker in order to enable usage of other libraries like libziparchive. Change-Id: I4a680ebb36ed5ba67c61249f81dba9f567808434
* Rename LinkerAllocator and LinkerAllocatorPageDmitriy Ivanov2015-03-104-22/+24
| | | | Change-Id: I87d80fbcd4ec26c0ee4f601b9c4c64f600418dd9
* Refactoring: rename linker_allocator filesDmitriy Ivanov2015-03-106-6/+6
| | | | Change-Id: Ifc08e64b3a85205f072b7abab1149c7ab71e2f75
* Store fields for gnu_hash separatelyDmitriy Ivanov2015-03-092-20/+29
| | | | | | | | | | | Kindle app relies on soinfo's sysv hash fields while linking native libraries. This change allows to keep sysv hash fields intact for the libraries linked with --hash-style=both. Bug: 19059885 Change-Id: I12528652955638f1a6586bda99e111bb1c8aa7a3
* linker: Allow an app to update it's own LD_LIBRARY_PATHNick Kralevich2015-03-071-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the kernel executes a program which is setuid, setgid, has file capabilities, or causes an SELinux domain transition, the AT_SECURE flag is set. This flag instructs the dynamic linker to prune any dangerous environment variables passed across security boundaries. For SELinux in particular, whether this flag is set depends on the the "noatsecure" process permission. If that permission does not exist, then AT_SECURE=1 whenever a domain transition occurs. In https://android-review.googlesource.com/129971 , Android stopped using noatsecure when executing init services. In https://android-review.googlesource.com/130610 , init was flipped back into SELinux enforcing mode, making ag/129971 active. The combination of those two changes ensured that AT_SECURE=1 was set when executing init spawned services. In particular, AT_SECURE=1 is set when init executes zygote. Due to the forking nature of zygote, AT_SECURE remains untouched when executing zygote's children. This causes problems for the code added in https://android-review.googlesource.com/48409 . Specifically, if AT_SECURE=1, an attempt to call android_update_LD_LIBRARY_PATH() is silently ignored. This causes problems when art tries to adjust the LD_LIBRARY_PATH for Android apps. Ultimately, apps are unable to find shared libraries they depend on. As discussed in bug 7896159, there's no security reason for preventing an application from updating it's own LD_LIBRARY_PATH. We only need to prune LD_LIBRARY_PATH when transitioning across security boundaries, but not when we're entirely within a security boundary. Remove the AT_SECURE check within do_android_update_LD_LIBRARY_PATH(). It's unneeded and prevents an application from modifying it's own LD_LIBRARY_PATH. This allows an application to specify a location where it's dlopen()ed shared libraries should be loaded from. There is no change to AT_SECURE handling in __sanitize_environment_variables(). We continue to honor it there to prevent using security sensitive environment variables across an exec boundary. Bug: 19559835 Change-Id: If4af2ee8e84265aaa0c93de8b281208b20d7942a
* Add support for packed relocations.Dmitriy Ivanov2015-03-066-7/+298
| | | | Change-Id: I796a4ce86d3fccb8361c19889419c96147ee3c9f
* Refactoring: introduce reloc_iteratorsDmitriy Ivanov2015-03-064-13/+67
| | | | | | Replace rel/rela array with reloc_iterators. Change-Id: I6165d062e0390b6bc60da2e8279aabbedf828ec9
* Fix: DT_DEBUG was acting as DT_REL on mips64Dmitriy Ivanov2015-02-131-1/+1
| | | | Change-Id: I88827aa07d75d06d606c987e6270fcca3ae6216f
* Merge "linker: Use load_bias to adjust search address in elf_addr_lookup"Dimitry Ivanov2015-02-051-2/+2
|\
| * linker: Use load_bias to adjust search address in elf_addr_lookupChris Dearman2015-02-041-2/+2
| | | | | | | | | | | | | | load_bias is the delta between a symbols address in memory and the value contained in the symbol table. Change-Id: I35c87b69025b64f7e4a1418ca766618f4533fb3e
* | Add missing includes.Elliott Hughes2015-01-284-0/+5
| | | | | | | | Change-Id: Ibf549266a19a67eb9158d341a69dddfb654be669
* | Only one crashing thread should contact debuggerd.Christopher Ferris2015-01-281-1/+20
| | | | | | | | | | | | | | | | | | | | If two or more threads crash at the same time, only let one talk to debuggerd. It's possible for a race to occur that two threads send data to debuggerd, the second one will cause errors in debuggerd since the process will die once debuggerd lets the crashing pid start again. Bug: 19183955 Change-Id: I17dfce46102117ab4a870f7381bd526488d37fb5
* | Fix mips64 build. Replace explicit cast with static_castNikola Veljkovic2015-01-281-2/+2
|/ | | | Change-Id: Ib08fbe8bb832884a3eb33904fe4d490759116cb2
* Remove obsolete BUILD_TINY_ANDROID.Elliott Hughes2015-01-241-4/+0
| | | | Change-Id: If2fc97134340fd09ec2583b666ace2f673cbdf66
* Merge "Minimize calls to mprotect"Dmitriy Ivanov2015-01-241-23/+43
|\
| * Minimize calls to mprotectDmitriy Ivanov2015-01-231-23/+43
| | | | | | | | | | | | | | | | | | | | Implement refcounter based data protection guard to avoid unnecessary calls to mprotect when dlopen/dlclose is called from a constructor. Bug: 19124318 Big: 7941716 Change-Id: Id221b84ce75443094f99756dc9950b0a1dc87222
* | Merge "Add comments about the -shared flag."Chih-Hung Hsieh2015-01-231-0/+3
|\ \ | |/ |/|
| * Add comments about the -shared flag.Chih-Hung Hsieh2015-01-221-0/+3
| | | | | | | | | | | | | | | | | | Must build this linker as a shared object. A statically linked module does not load during init. BUG: 18008984 Change-Id: I5f0411129024edcb9381c473ea4e741a075e9184
* | Add a log message to make the transition from linker to user code clear.Elliott Hughes2015-01-231-0/+2
| | | | | | | | | | | | | | | | Handy when looking at strace output for seeing "where does my code start?", though you'll need to set LD_DEBUG=1 (or greater) and constructors will already have run (but you can set LD_DEBUG to a higher value to track that). Change-Id: I82d53a7123b39febf5b2a956de83c8a30f229651
* | Enable -Wold-style-cast warnings for linkerDmitriy Ivanov2015-01-225-10/+15
|/ | | | | | And fix old style casts. Change-Id: I37e7a3e3fd852528ea76f02d967c7bd8cd5b06c9
* Contact proper debuggerd when crashing.Christopher Ferris2015-01-202-10/+11
| | | | | | | | | | Make the request structure match the new structure found in debuggerd code. On 64 bit systems, make sure that the 32 bit compiled linker is contacted. Bug: https://code.google.com/p/android/issues/detail?id=97024 Change-Id: I675b8ff222fcf836b05de4e9b5976ff91ca929bf
* Refactoring: move mips reloc to separate methodDmitriy Ivanov2015-01-145-123/+197
| | | | Change-Id: I712614853e3f0e515f5c2bdd8f0aaa5feeae8e55
* Refactoring: unify relocate functionDmitriy Ivanov2015-01-132-195/+99
| | | | | | Use one relocate for all platforms. Change-Id: I43e75162c5b29105e651defc11a511e168368736
* Refactoring: use generic reloc constantsDmitriy Ivanov2015-01-131-18/+9
| | | | Change-Id: I94dd6256b1b4509b6ea696a3aff17a3991529468
* Revert "Refactoring: use generic reloc constants"Dimitry Ivanov2015-01-131-10/+18
| | | | | | This reverts commit 265a60a0d285a733d9d98f53672bce668803b434. Change-Id: I6d46db0ac03cda44ed1e20f6084a552e0089eb14
* Refactoring: use generic reloc constantsDmitriy Ivanov2015-01-131-18/+10
| | | | Change-Id: I67918a1a926164a38a5a47f2264390632eb42905
* Merge changes I713800ce,I1dea46c3Dmitriy Ivanov2015-01-092-102/+113
|\ | | | | | | | | | | * changes: Refactor soinfo::relocate Add ARM_IRELATIVE relocation
| * Refactor soinfo::relocateDmitriy Ivanov2015-01-092-102/+113
| | | | | | | | | | | | Move common relocation types outside of ifdefs Change-Id: I713800ce123a18178b5ac80c0b3c7bd6b21a02c2
* | Revert "Must use Clang assembler for mips target."Duane Sand2015-01-091-7/+0
|/ | | | This reverts commit 6f96d58c0de191ac479d0fa83c3b9a514f4d3c48.
* Merge "Set linux 32bit personality for 32 bit processes"Dmitriy Ivanov2015-01-081-0/+7
|\
| * Set linux 32bit personality for 32 bit processesDmitriy Ivanov2015-01-071-0/+7
| | | | | | | | | | Bug: 18069809 Change-Id: Ie143d56b0f8f03510dc451649291067e1add1d2f