aboutsummaryrefslogtreecommitdiff
path: root/libexec/rtld-elf
Commit message (Collapse)AuthorAgeFilesLines
* MFC r249525:Konstantin Belousov2013-05-061-72/+75
| | | | | | | | | | | | | Rewrite origin_subst_one() to get rid of the wrong limit on the length of the resulting string. MFC r250075: Properly terminate the result string for intermediate results. Approved by: re (jpaetzel) Notes: svn path=/releng/8.4/; revision=250305
* MFC r247396:Tijl Coosemans2013-03-051-1/+1
| | | | | | | | | | | | Map libraries linked with -Ttext-segment=base_addr at base_addr. Normal libraries have base address 0 and are unaffected by this change. PR: 176216 Submitted by: Damjan Jovanovic <damjan.jov@gmail.com> Reviewed by: kib Notes: svn path=/stable/8/; revision=247847
* MFC r211706:Konstantin Belousov2012-05-091-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | On shared object unload, in __cxa_finalize, call and clear all installed atexit and __cxa_atexit handlers that are either installed by unloaded dso, or points to the functions provided by the dso. Use _rtld_addr_phdr to locate segment information from the address of private variable belonging to the dso, supplied by crtstuff.c. Provide utility function __elf_phdr_match_addr to do the match of address against dso executable segment. Call back into libthr from __cxa_finalize using weak __pthread_cxa_finalize symbol to remove any atfork handler which function points into unloaded object. The rtld needs private __pthread_cxa_finalize symbol to not require resolution of the weak undefined symbol at initialization time. This cannot work, since rtld is relocated before sym_zero is set up. MFC r211894: Do not call __pthread_cxa_finalize with invalid struct dl_phdr_info. Requested and tested by: Peter Jeremy <peter rulingia com> Notes: svn path=/stable/8/; revision=235198
* MFC r211705:Konstantin Belousov2012-05-092-10/+38
| | | | | | | | | | | Introduce implementation-private rtld interface _rtld_addr_phdr, which fills struct dl_phdr_info for the shared object that contains the specified address, if any. Requested and tested by: Peter Jeremy <peter rulingia com> Notes: svn path=/stable/8/; revision=235191
* MFC r233041:Konstantin Belousov2012-03-191-2/+0
| | | | | | | Remove write-only variable. Notes: svn path=/stable/8/; revision=233172
* MFC r232777:Konstantin Belousov2012-03-171-8/+21
| | | | | | | Optimize tls_get_addr_common(). Notes: svn path=/stable/8/; revision=233067
* MFC r228375:Konstantin Belousov2011-12-301-1/+1
| | | | | | | Typo. Notes: svn path=/stable/8/; revision=229018
* MFC r226156:Konstantin Belousov2011-10-151-2/+7
| | | | | | | Handle the R_386_TLS_TPOFF32 relocation. Notes: svn path=/stable/8/; revision=226383
* MFC r226155:Konstantin Belousov2011-10-151-3/+14
| | | | | | | Set TLS block for the main thread after the relocations are processed. Notes: svn path=/stable/8/; revision=226382
* MFC r225699:Konstantin Belousov2011-10-041-2/+3
| | | | | | | | | Restore the writing of the .bss sections of the dsos. Revert the optimization of using mprotect(2) to establish .bss, overlap the section with mmap(2). Notes: svn path=/stable/8/; revision=225961
* MFC r225582:Konstantin Belousov2011-09-221-1/+1
| | | | | | | | | | Use the proper dynamic tls block to calculate the tls variable address in case tls data generation was updated. PR: misc/160721 Notes: svn path=/stable/8/; revision=225726
* MFC r220004: rtld: eliminate double call to close(2) that may occur in ↵Andriy Gapon2011-04-081-5/+2
| | | | | | | load_object Notes: svn path=/stable/8/; revision=220440
* MFC: r219340, r219531, r219533Marius Strobl2011-03-251-5/+90
| | | | | | | | | | | - Add support for TLS relocations. - Emitt an error when encountering an unsupported and in case of the kernel also for unaligned relocations. - Fix R_SPARC_HIX22 and R_SPARC_LOX10 relocations. Apparently these are hardly ever used. Notes: svn path=/stable/8/; revision=219996
* MFC: r219339, r219532Marius Strobl2011-03-231-103/+96
| | | | | | | | | | | | | | | | - Remove clause 3 and 4 from TNF licenses. [1] - Add the _RF_X committed in r212998 (merged to stable/8 in r213478) also to the tables in the sparc64 reloc.c in order reduce differences between the kernel and the userland source. This results in no functional change though. - Consistently abbreviate the names of the relocations. - End sentences with dots. - Fix whitespace. Obtained from: NetBSD [1] Notes: svn path=/stable/8/; revision=219940
* MFC r216489:Jaakko Heinonen2011-03-031-16/+38
| | | | | | | | | | | | | | | | | | | | If dlclose() is called recursively from a _fini() function, the inner dlclose() call may unload the object of the outer call prematurely because objects are unreferenced before _fini() calls. Fix this by unreferencing objects after calling objlist_call_fini() in dlclose(). Therefore objlist_call_fini() now calls the fini function if the reference count of an object is 1. In addition we must restart the list_fini traversal after every _fini() call because another dlclose() call might have modified the reference counts. Add an XXX comment to objlist_call_fini() about possible race with dlopen(). PR: 133246, 149464 Notes: svn path=/stable/8/; revision=219237
* MFC r218098:Konstantin Belousov2011-02-061-4/+13
| | | | | | | | | | Make ldd(1) work when versioned dependency file is cannot be loaded. MFC r218099: Fix grammar. Notes: svn path=/stable/8/; revision=218365
* MFC r218025:Sergey Kandaurov2011-01-311-1/+1
| | | | | | | | | Remove SuperH architecture from a comment. Approved by: kib (mentor) Notes: svn path=/stable/8/; revision=218126
* Merge MIPS platform support to 8-STABLE.Jayachandran C.2010-11-272-157/+328
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit merges the MIPS platform changes that was now stable in -CURRENT into 8-STABLE. The MIPS changesets are too many (~400) to list here. But the changesets merged in this commit that affect other platforms are summarized below: r204635 : (changes to sys/dev/hwpmc, lib/libpmc, sys/sys/pmc.h) Add support for hwpmc(4) on the MIPS 24K, 32 bit, embedded processor. r205845: (changes to sys/modules/Makefile) Fix for building modules on mips and arm. r204031: (changes to sys/kern/link_elf_obj.c) printf fix, as part of kernel module support for MIPS. r206404: (changes to sys/arm/include/bus.h) Add BUS_SPACE_UNRESTRICTED and define it to be ~0, just like all the other platforms - for arm and mips. r206819: (changes to sys/vm/) Add VMFS_TLB_ALIGNED_SPACE option and kmem_alloc_nofault_space(), which is used to allocate kernel stack address on MIPS. r208165, r211087: (sys/kern/subr_smp.c, sys/kern/sched_ule.c) Enable ULE scheduler for MIPS, Fix for an issue in SMP when 32 cpus are enabled. r208659: (sys/{ia64/ia64,mips/mips,sun4v/sun4v}/pmap.c) Simplify the inner loop of get_pv_entry() r208794: (changes to sys/vm/) Make vm_contig_grow_cache() extern, and use it when vm_phys_alloc_contig() fails to allocate MIPS page table pages. r210327: (changes to sys/vm/) Support for MIPS page table page allocation. Add a new function 'vm_page_t vm_page_alloc_freelist(int flind, int order, int req)' to vm/vm_page.c to allocate a page from a specified freelist, and other related changes. Reviewed by: alc(vm changes only) Approved by: kib(re), alc(vm), imp(mips), jmallett(mips), gnn(mips pmc) Notes: svn path=/stable/8/; revision=215938
* MFC r214728:Konstantin Belousov2010-11-102-2/+14
| | | | | | | | | | | | | | | | | | | | | If dlopen() is called for the dso that has been already loaded as a dependency, then the dso never has its DAG initialized. Empty DAG makes ref_dag() call in dlopen() a nop, and the dso refcount is off by one. Initialize the DAG on the first dlopen() call, using a boolean flag to prevent double initialization. MFC r214776: Fix style. MFC r214777: Change init_dag() to not increment DAG refcount. Unconditionally call both init_dag() and ref_dag() in dlopen() for the case when the object was already loaded. Notes: svn path=/stable/8/; revision=215084
* MFC r213406:Nathan Whitehorn2010-10-141-2/+5
| | | | | | | | | | | Fix two subtle problems in PPC32 RTLD. The first is a concurrency issue where long PLT calls in multi-threaded environments could end up with incorrect jmptab values. The second is that, after the addition of extended PLT support, I forgot to update the PLT icache synchronization code to cover the extended PLT instead of just the basic PLT. Notes: svn path=/stable/8/; revision=213833
* MFC r208763:Alexander Kabaev2010-06-181-1/+3
| | | | | | | | | Plug possible memory leak. Found by: Coverity Prevent Notes: svn path=/stable/8/; revision=209303
* MFC r205606Pietro Cerutti2010-03-311-1/+1
| | | | | | | | | Remove const'ness from dlerror(3) prototype, for consistency with POSIX. Approved by: cognet Notes: svn path=/stable/8/; revision=205979
* MFC r204211:Nathan Whitehorn2010-03-203-25/+67
| | | | | | | | Support the extended PLT format used when objects have more than 8192 PLT relocations on PPC32. Notes: svn path=/stable/8/; revision=205383
* MFC r199829:Konstantin Belousov2009-12-172-14/+35
| | | | | | | | | | | | | Implement rtld part of the support for -z nodlopen (see ld(1)). MFC r199877: Allow to load not-openable dso when tracing. This fixes ldd on such dso or dso linked to non-openable object. Remove '\n' at the end of error message. End comments with dot. Notes: svn path=/stable/8/; revision=200645
* Merge r199270 from head to stable/8:Robert Watson2009-12-141-1/+1
| | | | | | | Fix white space in rtld runtime error printf. Notes: svn path=/stable/8/; revision=200512
* Merge r197808 from head to stable/8:Robert Watson2009-12-141-1/+1
| | | | | | | | | | | | In rtld's map_object(), use pread(..., 0) rather than read() to read the ELF header from the front of the file. As all other I/O on the binary is done using mmap(), this avoids the need for seek privileges on the file descriptor during run-time linking. Sponsored by: Google Notes: svn path=/stable/8/; revision=200509
* MFC r199979: Fix local root vulnerability.Colin Percival2009-12-011-6/+6
| | | | Notes: svn path=/stable/8/; revision=199980
* MFC r199828:Konstantin Belousov2009-11-291-1/+1
| | | | | | | Flag controlling origin expansion in DT_FLAGS is DF_ORIGIN, not DF_1_ORIGIN. Notes: svn path=/stable/8/; revision=199907
* MFC r197931:Konstantin Belousov2009-10-201-14/+15
| | | | | | | | | Apply relocations for PIE binary ELF data structures pointers in rtld. Approved by: re (kensmith) Notes: svn path=/stable/8/; revision=198280
* Implement RTLD_NOLOAD flag for dlopen(3).Konstantin Belousov2009-07-171-6/+10
| | | | | | | | | Requested and tested by: jkim Reviewed by: kan Approved by: re (kensmith) Notes: svn path=/head/; revision=195745
* Only perform .bss mapping and cleaning operations when segment file sizeKonstantin Belousov2009-07-171-21/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | is not equal to its memory size. This eliminates unneeded clearing of the text segment that often happens due to text end not being page-aligned. For instance, $ readelf -l /lib/libedit.so.6 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x000000 0x00000000 0x00000000 0x139e1 0x139e1 R E 0x1000 LOAD 0x014000 0x00014000 0x00014000 0x00f04 0x00f14 RW 0x1000 DYNAMIC 0x014cc4 0x00014cc4 0x00014cc4 0x000d0 0x000d0 RW 0x4 $ procstat -v $$ (for /bin/sh) 68585 0x28097000 0x280aa000 r-x 6 0 21 14 CN vn /lib/libedit.so.6 68585 0x280aa000 0x280ab000 r-x 1 0 1 0 CN vn /lib/libedit.so.6 <== 68585 0x280ab000 0x280ac000 rwx 1 0 1 0 CN vn /lib/libedit.so.6 Note the splitted map entry marked by '<=='. Reviewed by: kan Approved by: re (kensmith) MFC after: 1 month Notes: svn path=/head/; revision=195743
* Second attempt at eliminating .text relocations in shared librariesAlexander Kabaev2009-07-141-1/+1
| | | | | | | | | | | | | | | | | compiled with stack protector. Use libssp_nonshared library to pull __stack_chk_fail_local symbol into each library that needs it instead of pulling it from libc. GCC generates local calls to this function which result in absolute relocations put into position-independent code segment, making dynamic loader do extra work every time given shared library is being relocated and making affected text pages non-shareable. Reviewed by: kib Approved by: re (kib) Notes: svn path=/head/; revision=195697
* Back out previous revision until better tested fix is ready.Alexander Kabaev2009-06-291-1/+1
| | | | | | | Approved by: re (impliciti, by approving previos check-in) Notes: svn path=/head/; revision=195152
* Eliminate .text relocations in shared libraries compiled with stack protector.Alexander Kabaev2009-06-281-1/+1
| | | | | | | | | | | | | | | Use libssp_nonshared library to pull __stack_chk_fail_local symbol into each library that needs it instead of pulling it from libc. GCC generates local calls to this function which result in absolute relocations put into position-independent code segment, making dynamic loader do extra work everys time given shared library is being relocated and making affected text pages non-shareable. Reviewed by: kib Approved by: re (kensmith) Notes: svn path=/head/; revision=195151
* Fix a typo in the same comment, one line below.Ed Schouten2009-06-231-1/+1
| | | | | | | Submitted by: bf1783 googlemail com Notes: svn path=/head/; revision=194705
* Fix typo in comment.Ed Schouten2009-06-231-1/+1
| | | | | | | Submitted by: Christoph Mallon Notes: svn path=/head/; revision=194689
* Allow order of initialization of loaded shared objects to beAlexander Kabaev2009-06-202-48/+47
| | | | | | | | | | | | | | | | | | | | altered through their .init code. This might happen if init vector calls dlopen on its own and that dlopen causes some not yet initialized object to be initialized earlier as part of that dlopened DAG. Do not reset module reference counts to zero on final fini vector run when process is exiting. Just add an additional parameter to force fini vector invocation regardless of current reference count value if object was not destructed yet. This allows dlclose called from fini vector to proceed normally instead of failing with handle validation error. Reviewed by: kib Reported by: venki kaps Notes: svn path=/head/; revision=194531
* FreeBSD returns main object handle from dlopen(NULL, ...) calls.Alexander Kabaev2009-06-161-0/+10
| | | | | | | | | | | | | dlsym seaches using this handle are expected to look for symbol definitions in all objects loaded at the program start time along with all objects currently in RTLD_GLOBAL scope. Discussed with: kib Reported by: Maho NAKATA MFC after: 2 weeks Notes: svn path=/head/; revision=194298
* Increase the size of the static TLS area slightly (required for the NVidia'sDoug Rabson2009-05-271-1/+1
| | | | | | | OpenGL driver on amd64). Notes: svn path=/head/; revision=192922
* Prefer <sys/param.h> to <machine/param.h> for the definition ofRobert Watson2009-04-201-1/+1
| | | | | | | | | | CACHE_LINE_SIZE. Submitted by: bde MFC after: 2 weeks Notes: svn path=/head/; revision=191303
* Explicitly include machine/param.h for CACHE_LINE_SIZE.Robert Watson2009-04-191-0/+2
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=191292
* Now that the kernel defines CACHE_LINE_SIZE in machine/param.h, useRobert Watson2009-04-197-14/+0
| | | | | | | | | | | that definition in the custom locking code for the run-time linker rather than local definitions. Pointed out by: tinderbox MFC after: 2 weeks Notes: svn path=/head/; revision=191291
* Currently, when mapping an object, rtld reserves the whole address spaceKonstantin Belousov2009-04-101-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | for the mapping by the object' file with the protection and mode of the first loadable segment over the whole region. Then, it maps other segments at the appropriate addresses inside the region. On amd64, due to default alignment of the segments being 1Gb, the subsequent segment mappings leave the holes in the region, that usually contain mapping of the object' file past eof. Such mappings prevent wiring of the address space, because the pages cannot be faulted in. Change the way the mapping of the ELF objects is constructed, by first mapping PROT_NONE anonymous memory over the whole range, and then mapping the segments of the object over it. Take advantage of this new order and allocate .bss by changing the protection of the range instead of remapping. Note that we cannot simply keep the holes between segments, because other mappings may be made there. Among other issues, when the dso is unloaded, rtld unmaps the whole region, deleting unrelated mappings. The kernel ELF image activator does put the holes between segments, but this is not critical for now because kernel loads only executable image and interpreter, both cannot be unloaded. This will be fixed later, if needed. Reported and tested by: Hans Ottevanger <fbsdhackers beasties demon nl> Suggested and reviewed by: kan, alc Notes: svn path=/head/; revision=190885
* Update comment to the reality, rtld supports any number of loadable segments.Konstantin Belousov2009-04-101-3/+2
| | | | | | | | | Fix spacing. Reviewed by: kan Notes: svn path=/head/; revision=190883
* Allow the NULL, RTLD_SELF and RTLD_NEXT handles to work with dlfunc(3).Konstantin Belousov2009-04-032-0/+15
| | | | | | | | | | | | | | | | | | | dlfunc() called dlsym() to do the work, and dlsym() determines the dso that originating the call by the return address. Due to this, dlfunc() operated as if the caller is always the libc. To fix this, move the dlfunc() to rtld, where it can call the internal implementation of dlsym, and still correctly fetch return address. Provide usual weak stub for the symbol from libc for static binaries. dlfunc is put to FBSD_1.0 symver namespace in the ld.so export to override dlfunc@FBSD_1.0 weak symbol, exported by libc. Reported, analyzed and tested by: Tijl Coosemans <tijl ulyssis org> PR: standards/133339 Reviewed by: kan Notes: svn path=/head/; revision=190673
* Document RTLD_NODELETE, -z nodelete and -z origin support.Konstantin Belousov2009-04-011-1/+20
| | | | Notes: svn path=/head/; revision=190624
* Implement support for RTLD_NODELETE flag for dlopen() and -z nodeleteKonstantin Belousov2009-03-302-4/+20
| | | | | | | | | | static linker option. Do it by incrementing reference count on the loaded object and its dependencies. Reviewed by: davidxu, kan Notes: svn path=/head/; revision=190543
* Do not dereference NULL pointer. refobj is NULL for the objects that areKonstantin Belousov2009-03-281-1/+1
| | | | | | | | | preloaded. Reported and tested by: ed Notes: svn path=/head/; revision=190505
* Support for a new environment variable, LD_ELF_HINTS_PATH for overridingXin LI2009-03-232-3/+15
| | | | | | | | | | | | | | the rtld hints file. This environment variable would be unset if the process is considered as tainted with setuid/setgid. This feature gives a convenient way of using a custom set of shared library that is not located in the default location and switch back. Feature requested by: iXsystems Original patch by: John Hixson MFC after: 2 weeks Notes: svn path=/head/; revision=190324
* Implement the dynamic string token substitution in the rpath andKonstantin Belousov2009-03-183-10/+148
| | | | | | | | | | | | | | | | | | soneeded pathes. The $ORIGIN, $OSNAME, $OSREL and $PLATFORM tokens are supported. Enabling the substitution requires DF_ORIGIN flag in DT_FLAGS or DF_1_ORIGIN if DF_FLAGS_1, that may be set with -z origin gnu ld flag. Translation is unconditionally disabled for setuid/setgid processes. The $ORIGIN translation relies on the AT_EXECPATH auxinfo supplied by kernel. Requested by: maho Tested by: maho, pho Reviewed by: kan Notes: svn path=/head/; revision=189959