summaryrefslogtreecommitdiffstats
path: root/linker/linker.h
Commit message (Collapse)AuthorAgeFilesLines
* Remove 32-bit assumptions from the ELF code.Elliott Hughes2013-09-301-11/+15
| | | | Change-Id: I2c1f3d34c33685799aade8866eec44479ff9f963
* Make LD_PRELOAD failures just warnings.Elliott Hughes2013-06-181-1/+10
| | | | | | | | This matches glibc and makes life easier for developers who want to sometimes preload a library from init (which has no conditionals); they can simply move/remove the library to disable. Change-Id: I579b8633f958235af6e46bb53b378b9e363afb1f
* Make abort messages available to debuggerd.Elliott Hughes2013-04-051-0/+1
| | | | | | | | | | | | | This adds __libc_fatal, cleans up the internal logging code a bit more, and switches suitable callers over to __libc_fatal. In addition to logging, __libc_fatal stashes the message somewhere that the debuggerd signal handler can find it before calling abort. In the debuggerd signal handler, we pass this address to debuggerd so that it can come back with ptrace to read the message and present it to the user. Bug: 8531731 Change-Id: I416ec1da38a8a1b0d0a582ccd7c8aaa681ed4a29
* Clean up internal libc logging.Elliott Hughes2013-03-151-1/+1
| | | | | | | | | | | We only need one logging API, and I prefer the one that does no allocation and is thus safe to use in any context. Also use O_CLOEXEC when opening the /dev/log files. Move everything logging-related into one header file. Change-Id: Ic1e3ea8e9b910dc29df351bff6c0aa4db26fbb58
* Use more types than just 'unsigned' in the linker.Elliott Hughes2013-03-121-25/+28
| | | | | | | | | | | | | Still chipping away at the situation where every variable in the linker was of type 'unsigned'. This patch switches counts over to being size_t and adds an explicit type for init/fini function pointers and arrays of function pointers. Also improve logging from CallArray. Also remove trailing "\n"s from log messages. Change-Id: Ie036d2622caac50f4d29f0570888bb527661d77e
* Use Elf32_Addr instead of unsigned in linkerKito Cheng2013-03-121-2/+2
| | | | Change-Id: I52dcbb4b0ff0a4052e0ad7a9bbeb2df65c9d2f66
* More linker cleanup.Elliott Hughes2013-03-051-1/+12
| | | | Change-Id: I9fb3c7c0d4b4ffef0eeaf092d4e30ffe63a08671
* Minor linker cleanup, primarily to use Elf32_DynBrian Carlstrom2013-03-051-8/+8
| | | | Change-Id: Ifa9408e9859c6f79444715bed4808b7c13fdced5
* Remove partial implementation of MIPS non-PIC support.Elliott Hughes2013-02-061-14/+0
| | | | Change-Id: I3c287e52aae10559508174e73113367aea40e5c2
* Use the NetBSD <sys/exec_elf.h>.Elliott Hughes2013-01-291-31/+2
| | | | | | | | Replace a kernel header file dependency with files from NetBSD. They're more complete, and ELF is ELF, whether you're on Linux or a BSD. Bug: 7973611 Change-Id: I83ee719e7efdf432ec2ddbe8be271d05b2f558d7
* Support System.loadLibrary for libraries with transitive dependencies.Elliott Hughes2012-12-201-1/+1
| | | | | | | | | Also fix the FLAG_ERROR annoyance --- it's not helpful to cache failures. Bug: 7896159 Bug: http://code.google.com/p/android/issues/detail?id=34416 Bug: http://code.google.com/p/android/issues/detail?id=22143 Change-Id: I60f235edb4ea4756e1f7ce56f7739f18e8a50789
* Check for unknown flags passed to dlopen(3).Elliott Hughes2012-12-181-1/+1
| | | | Change-Id: I56f4aab0e5a1487bc32d2c4d231e8bd15c4ac8da
* Keep the dynamic linker's soinfo pools mostly read-only.Elliott Hughes2012-11-011-77/+82
| | | | | | | We'll need a lot more refactoring of this code before we can reduce the granularity, but this is a step forward. Change-Id: I07061720e734b571a8399c1d5b4f2f35cd681307
* Stop defining our own PAGE_SIZE and PAGE_MASK, and test dlclose(3) too.Elliott Hughes2012-11-011-20/+6
| | | | | | Also remove an unnecessary #include and a now-obsolete TODO. Change-Id: I36d923721e349a286934b9534090a67ce0786e7b
* Dynamically allocate soinfo-structs in linkerMagnus Malmborn2012-11-011-1/+0
| | | | | | | | Request memory from the system when needed instead of having a fixed array for soinfo structs. Note that malloc() et al can't be used in linker, so use mmap() instead. Change-Id: I4b495995931d7752b0e8c944e64d1fe41b9f7144
* linker: handle R_ARM_COPY relocations in a proper wayArd Biesheuvel2012-10-301-1/+3
| | | | | | | | | | | | | | If an executable contain copy relocations, other references to the symbol it points to should be preempted and made to point to the copy instead. Also, the linker should make sure the target area has sufficient space to contain the copy. It also checks whether the library that supplies the symbol is built with -Bsymbolic, and errors out if this is the case. Change-Id: If135c83590092741cfd8f82f54816f363a4a4a3b Signed-off-by: Ard Biesheuvel <ard.biesheuvel@gmail.com>
* More dynamic linker cleanup.Elliott Hughes2012-10-301-10/+2
| | | | | | | | I still want to break linker_format out into its own library so we can reuse it for malloc debugging and so forth. (There are many similar pieces of code in bionic, but the linker's one seems to be the most complete/functional.) Change-Id: If3721853d28937c8e821ca1d23cf200e228a409a
* Add link.h for all platforms with dl_phdr_infoPavel Chupin2012-08-171-17/+1
| | | | | | | | | | | | This header is used on bionic build and should be propagated into sysroot on toolchain rebuild. Discussion re. this header is here: http://gcc.gnu.org/ml/gcc-patches/2012-08/msg00936.html It is available already in mips NDK platforms: development/ndk/platforms/android-9/arch-mips/include/link.h Change-Id: I39ff467cdac9f448e31c11ee3e14a6200e82ab57 Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
* More cleanup.Elliott Hughes2012-08-141-2/+1
| | | | | | Make more stuff static, remove some dead code, and fix a few typos. Change-Id: I010b0eadeaf61e2899c37014ad1e7082c70bd510
* linker: don't perform unnecessary mprotectsNick Kralevich2012-08-131-0/+1
| | | | | | | | | | | | | The linker only needs to mark the text segment as writable iff the file has text relocations. Unnecessarily calling mprotect when it isn't necessary is slow, and some security enhanced kernels don't like it. Pages which are simultaneously writable and executable are considered a no-no. The vast majority of executables / shared libraries on Android do NOT have text relocations. Change-Id: Ic38ce30a99b7e33ecf21efd9c108547a58eafa35
* Clean up the linker a bit, remove prelinking support.Elliott Hughes2012-08-071-1/+9
| | | | | | | | | | | | | | Also make the errors more readable, since none of us seemed to know what they actually meant. The new style is still as verbose as the old, but that's probably necessary in the absence of chained exceptions in C. Here's what you'd see if you try to boot after removing libsurfaceflinger.so: 32267 32267 E AndroidRuntime: java.lang.UnsatisfiedLinkError: Cannot load library: (linker.c:1629, pid 32259) soinfo_link_image: could not load library "libsystem_server.so" needed by "libandroid_servers.so"; caused by (linker.c:1629, pid 32259) soinfo_link_image: could not load library "libsurfaceflinger.so" needed by "libsystem_server.so"; caused by (linker.c:709, pid 32259) load_library: library "libsurfaceflinger.so" not found This patch also fixes almost all of the compiler warnings. Change-Id: I64bb59aed6d4e039c15ea45be2367f319ef879f8
* MIPS support to the linkerRaghu Gandham2012-08-021-16/+26
| | | | | | | Change-Id: I37ec2d6c51d82bb9e9dbfef4b38c85366bead255 Signed-off-by: Chris Dearman <chris@mips.com> Signed-off-by: Raghu Gandham <raghu@mips.com> Signed-off-by: Bhanu Chetlapalli <bhanu@mips.com>
* linker: improve loadable segment protection.David 'Digit' Turner2012-06-261-6/+3
| | | | | | | | | | | | | | | | | | | | | Use the functions in linker_phdr.c to load the PT_LOAD segments in memory, and toggle their mapping's writable protection bit as needed. In particular: - when loading a library, load the segments then unprotected them to allow relocations to work. - when relocating the linker of the executable, unprotect the segments loaded by the kernel to make relocations work too. - after all relocations are done, re-protect the segments, and apply GNU RELRO protection if needed. - just before calling the destructors, undo the GNU RELRO protection. Change-Id: I50e709f03958204b8d6140c0f51ebe24fe089a1b
* linker: rename load_offset to load_bias.David 'Digit' Turner2012-06-251-4/+3
| | | | | | | | | | | | | This patch changes the definition of the 'load_offset' field in struct soinfo. The field is renamed because it is not the basic load bias to add to every p_vaddr value read from the ELF file to get the corresponding memory address. This also slightly simplifies the relocation code. + Fix for proper load_bias computation for relocatable executables. Change-Id: I72502c75a70751cba324deee7d313ae61f96609e
* linker: New sources to manage the ELF program header table.David 'Digit' Turner2012-06-251-1/+17
| | | | | | | | | | | | This patch introduces two new source files containing a set of functions to manage the program header table in an ELF binary, including the ability to load PT_LOAD segments, and apply PT_GNU_RELRO protection. Note: the files are not used currently, this will appear in a series of future patches that will gradually modify linker.c to use the phdr_table_xxx functions properly. Change-Id: Ia3d4c1ff5fc3e265d8258b64b492f4e643f51bdc
* linker: small code-cleanupDavid 'Digit' Turner2012-06-131-4/+5
| | | | | | | | | | | | | This patch adds to make the linker a little bit easier to understand by making all functions that acts on a sofino object with a soinfo_ prefix. This is to more easily distinguish functions that operate on global state, and those that operate on individual libraries. This should be purely stylistic, i.e. no feature/behaviour change. Change-Id: Ie510d13d743aa4317644caefa9910b8af7e84f44
* Support non-zero p_vaddr in first PT_LOAD segmentJi-Hwan Lee2012-06-041-0/+4
| | | | | | | | | | | | | | | | | | | | | | Before changing mmap() permission to PROT_NONE in alloc_mem_region(), such libraries once worked with a bug that uses mmap'ed region outside of memory region allocated by alloc_mem_region(). This possibly incurs SIGSEGV because it can overwrite memory region of previously loaded library, but it sometimes worked, depending on loading order. After PROT_NONE, this caused SIGSEGV earlier during calculation of si->phdr in load_library(), but this was fixed by: 75917c84d16c35b8fceff6977fa717a3de9ef65d Use mmap to read an ... Now the behaviour is the same as before applying PROT_NONE in alloc_mem_region(). This CL fixed the original issue, supporting shared libraries that have non-zero p_vaddr in first (= with lowest p_vaddr) PT_LOAD segment. Bug: 6561258 Change-Id: Ib6176dd3e44c4d99a340eb1cbd16fb037586b0bc
* Add relro supportNick Kralevich2012-03-051-1/+6
| | | | | | | | | | | | | | | Add support for PT_GNU_RELRO. This allows the static linker to indicate that certain regions of memory should be marked as "read-only" after dynamic linking is complete. See: * http://www.akkadia.org/drepper/nonselsec.pdf (section 6) * http://tk-blog.blogspot.com/2009/02/relro-not-so-well-known-memory.html Note that this change has no effect on Android right now, because we don't compile our code with relro enabled. Change-Id: I6541f8775367e8558b4388f7d105b1ae6e8f046b
* Merge c4cb87f3Jean-Baptiste Queru2012-02-011-18/+2
|\ | | | | | | Change-Id: I4cc14eba43fde75a7702fdc7ad07d3d949e9c092
| * remove obsolete SuperH supportDavid 'Digit' Turner2012-01-311-18/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't have a toolchain anymore, we don't have working original kernel headers, and nobody is maintaining this so there is really no point in keeping this here. Details of the patch: - removed code paths from Android.mk files related to the SuperH architecture ("sh") - removed libc/arch-sh, linker/arch-sh, libc/kernel/arch-sh - simplified libc/SYSCALLS.TXT - simplified the scripts in libc/tools/ and libc/kernel/tools Change-Id: I26b0e1422bdc347489e4573e2fbec0e402f75560 Signed-off-by: David 'Digit' Turner <digit@android.com>
* | Execute .preinit_array before any shared object initialization functions.Evgeniy Stepanov2012-01-101-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | This change makes linker handling of .preinit_array compliant with the System V ABI: "These [pre-initialization] functions are executed after the dynamic linker has built the process image and performed relocations but before any shared object initialization functions." http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#init_fini Change-Id: Iebfee22bb1ebe1d7c7e69cb4686e4ebae0dfc4bb
* | Make the linker relocatable.Nick Kralevich2011-11-111-0/+1
| | | | | | | | | | | | | | | | | | Previously, the linker always loaded itself into the same location in memory, which inhibited the effectiveness of Android's ASLR implementation. Modify the linker code so it can be relocatable and link itself at runtime. Change-Id: Ia80273d7a00ff648b4da545f4b69debee6343968
* | Revert "Make the linker relocatable."Nick Kralevich2011-11-031-1/+0
| | | | | | | | | | | | This reverts commit 994e9a5ed1c4e9f23a8bed79caea684eaa270027. Broke x86 build.
* | Make the linker relocatable.Nick Kralevich2011-11-021-0/+1
|/ | | | | | | | | Previously, the linker always loaded itself into the same location in memory, which inhibited the effectiveness of Android's ASLR implementation. Modify the linker code so it can be relocatable and link itself at runtime. Change-Id: I90d064743abdd29450ac0482ed28752b2196286c
* fix prototype of dladdrMathias Agopian2011-09-281-2/+2
| | | | | | this breaks C++ source code in particular. Change-Id: Ie06b5d31d23b5455e6950c470adc64dd5e7784df
* linker.h: don't change the soinfo structureNick Kralevich2011-08-291-0/+2
| | | | | | | | | | | In 48527c3f740a80b45acb5a6efc217f771ae50143, we modified the soinfo structure to remove an unnecessary variable. However, third party programs seem to be relying on the structure not changing. Add a dummy variable back into place to preserve structure. Bug: 5064106 Change-Id: I3014dda1a46e624644b09e156c3e9381ba3729bd
* Revert "Revert "linker: get rid of the buddy allocator""Shih-wei Liao2011-07-171-14/+0
| | | | | This reverts commit f9a9cda23a6afc1c2dfdfd624cde23b61941eb5e. This revert is promised once b/5039224, b/5036755, b/5036610 are resolved.
* Revert "linker: get rid of the buddy allocator"Nick Kralevich2011-07-151-0/+14
| | | | | This reverts commit 7059b1f02ea9197728c851edd9ae0dd7688fa700. Bug: 5036610
* linker: get rid of the buddy allocatorNick Kralevich2011-07-141-14/+0
| | | | | | | | | | | | | | Currently, the Android linker is placing shared libraries into a well-known spot in memory. This is interfering with the kernel's ASLR support. This change stops forcing non-prelinked libraries into a particular address space. Also, get rid of FLAG_PRELINKED. As best I can tell, this flag is never used. Change-Id: I527af12fb54f821c2b5ca7693dbf63d022f8f4ae
* Fixed support for RTLD_NEXT in dlsym()Matt Fischer2010-04-081-1/+1
| | | | | | | | | The previous implementation of this flag was broken--it behaved identically to RTLD_DEFAULT. This adds a proper implementation, which examines the address of the calling function, and uses it to determine which library to use to begin the symbol search process. Change-Id: I2ad2b46363f68932af63a3828a22f9c7987eea67
* Added support for dladdr()Matt Fischer2010-03-171-0/+2
| | | | | | | | dladdr() is a GNU extension function, which allows the caller to retrieve symbol information for a specified memory address. It is useful for things like generating backtrace information at runtime. Change-Id: I3a1def1a6c9c666d93e1e97b7d260dfa5b9b79a9
* am fe62de1a: Add support for R_ARM_REL32 to the dynamic linker.David 'Digit' Turner2009-12-021-6/+7
|\ | | | | | | | | | | | | Merge commit 'fe62de1ad036a1417df44b7b1a7c65cc79dc7091' into eclair-plus-aosp * commit 'fe62de1ad036a1417df44b7b1a7c65cc79dc7091': Add support for R_ARM_REL32 to the dynamic linker.
| * Add support for R_ARM_REL32 to the dynamic linker.David 'Digit' Turner2009-12-021-6/+7
| | | | | | | | Merged from eclair-mr2
* | merge from open-source masterJean-Baptiste Queru2009-11-081-2/+22
|\ \ | |/ |/|
| * added and modified linker to support SuperH architectureShin-ichiro KAWASAKI2009-11-061-2/+22
| |
* | bionic/linker: change lookup() to return soinfo, not baseIliyan Malchev2009-09-291-1/+1
|/
* linker: Make the errors reported by dlopen/dlsym be more useful.Dima Zavin2009-05-271-0/+1
| | | | | | | | | | | | | Changed it so that when the linker generates error messages, they are scribbled away into a buffer that dlfcn and friends can read from. Since the error messages are generetad with snprintf, and snprintf MAY call malloc during some code paths, we now link against a version of libc that does not contain malloc/free/realloc/calloc. We then define malloc and friends in the dynamic loader, and make them abort() if they are ever called. Signed-off-by: Dima Zavin <dima@android.com>
* auto import from //depot/cupcake/@135843The Android Open Source Project2009-03-031-0/+215
|
* auto import from //depot/cupcake/@135843The Android Open Source Project2009-03-031-213/+0
|
* auto import from //depot/cupcake/@132589The Android Open Source Project2009-03-031-2/+0
|