summaryrefslogtreecommitdiff
path: root/ldso
AgeCommit message (Collapse)Author
2018-08-10rtld: Add startup codeChristophe Lyon
Implement _start: compute parameters for __self_reloc, and give control to the user program. * ldso/ldso/arm/dl-startup.h: Implement _start for __FDPIC__. Signed-off-by: Mickaël Guêné <mickael.guene@st.com> Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
2018-08-10rtld: Avoid FUNCDESC relocation on _startChristophe Lyon
* ldso/ldso/ldso.c (_start): Fix definition for __FDPIC__. Signed-off-by: Mickaël Guêné <mickael.guene@st.com> Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
2018-08-10rtld: Add FDPIC code for armChristophe Lyon
Add FDPIC dynamic relocations support, similar to what other FDPIC targets do. Lazy binding is implemented in a folllow-up patch. Disable the SEND* macros because they involve relocations to access constant strings that are unsupported by the existing arm version. Define DL_START, START, ARCH_NEEDS_BOOTSTRAP_RELOCS, DL_CHECK_LIB_TYPE similarly to what other FDPIC targets do. Define raise() because _dl_find_hash references __aeabi_uidivmod, which uses __aeabi_idiv0 which in turn references raise. * include/elf.h (R_ARM_FUNCDESC): Define. (R_ARM_FUNCDESC_VALUE): Define. * ldso/include/dl-string.h (SEND_STDERR, SEND_ADDRESS_STDERR) (SEND_NUMBER_STDERR): Define empty for __FDPIC__. * ldso/ldso/arm/dl-inlines.h: New file. * ldso/ldso/arm/dl-startup.h (PERFORM_BOOTSTRAP_RELOC): Fix type of load_addr. Fix handling of R_ARM_RELATIVE, add support for R_ARM_FUNCDESC_VALUE. (DL_START, START): Define for __FDPIC__. (raise): Define. * ldso/ldso/arm/dl-sysdep.h (ARCH_NEEDS_BOOTSTRAP_RELOCS): Define. (DL_CHECK_LIB_TYPE): Define. (elf_machine_type_class): Take into account FDPIC related relocations. (elf_machine_load_address): Support __FDPIC__. (elf_machine_relative): Likewise. * ldso/ldso/arm/elfinterp.c (_dl_linux_resolver): Dummy support for __FDPIC__, implemented in a later patch. (_dl_do_reloc): Fix reloc_adr computation for __FDPIC__, fix handling of local symbols. Fix handling of R_ARM_RELATIVE, add support for R_ARM_FUNCDESC_VALUE, R_ARM_FUNCDESC. * ldso/ldso/arm/resolve.S: Make _dl_linux_resolve hidden. * ldso/ldso/fdpic/dl-inlines.h (htab_delete): Declare. * libc/sysdeps/linux/arm/bits/elf-fdpic.h: New file, similar to bfin's. * libc/sysdeps/linux/arm/crtreloc.c: Likewise. * libc/sysdeps/linux/arm/find_exidx.c (__dl_addr_in_loadaddr) Define. (find_exidx_callback): Support __FDPIC__. Signed-off-by: Mickaël Guêné <mickael.guene@st.com> Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
2018-08-10rtld: Add #if defined (__FDPIC__)Christophe Lyon
Like for other FDPIC targets, add defined(__FDPIC__) where needed. * include/link.h: Include bits/elf-fdpic.h if __FDPIC__ is defined. (link_map): Use elf32_fdpic_loadaddr if __FDPIC__ is defined. (dl_phdr_info): Likewise. * ldso/include/dl-elf.h (__dl_parse_dynamic_info): Support __FDPIC__. * ldso/include/dl-hash.h (elf_resolve): Add funcdesc_ht field if __FDPIC__ is defined. * ldso/ldso/dl-hash.c (_dl_find_hash): Support __FDPIC__. * libc/misc/elf/dl-iterate-phdr.c (dl_iterate_phdr): Support __FDPIC__. Signed-off-by: Mickaël Guêné <mickael.guene@st.com> Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
2018-08-10rtld: Do not protect RELRO segments when we don't use an MMU.Christophe Lyon
Without MMU, we cannot mark memory regions as read-only. * ldso/ldso/dl-elf.c (_dl_protect_relro): Do nothing if __ARCH_USE_MMU__ is defined. Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
2018-06-29ldso/arc: fix LD_DEBUG segv when printing R_ARC_NONEVineet Gupta
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
2018-06-06remove unused assembler functions for armFlorian La Roche
These assembler functions seem to be unused/referenced, so we can remove them completely. Signed-off-by: Florian La Roche <Florian.LaRoche@googlemail.com>
2018-04-27libdl: first execute all destructors, then munmap libraryWaldemar Brodkorb
Fix problem which might exist since 2011. We need to execute the destructors for all dependant libraries, before munmap the shared libraries, otherwise running destructor of a dependent library might cause a segfault, trying to access an already unmapped memory. This fixes for example segfaults while running php -m with ldap module. Reported-By: Dave Flogeras <dflogeras2@gmail.com> Tested-By: Dave Flogeras <dflogeras2@gmail.com>
2018-04-27libdl: calculate the length for second parameter of munmap.Dave Flogeras
Revert 35105679b9a900d58dadd0852e679c235f8176ba and add some debug code.
2018-04-22libdl: end must be bigger than startWaldemar Brodkorb
2018-04-22libdl: remove gcc warningsWaldemar Brodkorb
2018-04-17libdl: fix problem with unmappingWaldemar Brodkorb
The munmap was still called with broken length, as sometimes start was empty. This finally solves segfaults when running php -m with ldap module activated.
2018-04-17libdl: better checking and logging for ctors/dtorsWaldemar Brodkorb
2018-04-17libdl: remove dead codeWaldemar Brodkorb
2018-04-17libdl: remove LDSO_NO_CLEANUPWaldemar Brodkorb
2018-04-17Revert "libdl: fix dlclose() issue"Waldemar Brodkorb
This reverts commit bf4c2d242f587700e3eb2ffd5721ddaf3cdbc7e5.
2018-03-15libdl: fix dlclose() issueWaldemar Brodkorb
There is a patch included in https://bugs.busybox.net/show_bug.cgi?id=6158 from 2013, which was never applied. This really fixes the php -m segfaults.
2018-03-14Revert "Revert "libdl: fix size parameter when unmap library in dlclose""Waldemar Brodkorb
This reverts commit 952bb00f0b2eb576b0bf48c4f87018429a42e28d. And adds this fix for 64 Bit systems. http://lists.busybox.net/pipermail/uclibc/2014-December/048737.html
2018-02-03bits/mman.h: consolidate header fileWaldemar Brodkorb
Sync with GNU C library and consolidate duplicate non architecture specific defines. MAP_UNINITIALIZED is only defined to 0x4000000 and used by the Linux kernel when CONFIG_MMAP_ALLOW_UNINITIALIZED is enabled. CONFIG_MMAP_ALLOW_UNINITIALIZED is only available for nommu. See Documentation/nommu-mmap.txt.
2018-01-21xtensa: fix R_XTENSA_TLSDESC_ARG handling in _dl_do_relocMax Filippov
R_XTENSA_TLSDESC_ARG is a true RELA relocation, the addend is in the relocation record itself, not in place. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2018-01-21xtensa: fix _dl_tlsdesc_dynamicMax Filippov
There are multiple errors in _dl_tlsdesc_dynamic: - the reference C implementation should return pointer to the thread-local variable, not offset from the thread pointer, because the xtensa ABI expects TLSDESC_FN to return pointer to the TLS variable; - addx8 used for indexing into dtv has its second and third registers in wrong order, the index must be multiplied by 8, not the base; - the same addx8 uses wrong base: instead of dtv it adds the offset to the threadptr; - the return value in the fast path is calculated as td->tlsinfo.ti_offset - __builtin_thread_pointer, not what was intended; - both fast and slow paths should not subtract __builtin_thread_pointer from the result. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2018-01-06ld.so: Rewrite elf_machine_load_address using _DYNAMIC symbolWaldemar Brodkorb
Sync with GNU C library commit: commit a68ba2f3cd3cbe32c1f31e13c20ed13487727b32 Author: Szabolcs Nagy <szabolcs.nagy@arm.com> Date: Wed Oct 18 17:26:23 2017 +0100 Fixes issues with binutils version > 2.29.1.
2017-12-31m68k: add NPTL/TLS supportWaldemar Brodkorb
Port over NPTL/TLS support from GNU C Library. In the first step only the slower syscall is used for TLS access. The uClibc-ng testsuite shows 79 errors, so their is room for bugfixes and improvements.
2017-12-28csky: add Copyright.Guo Ren
Signed-off-by: Guo Ren <ren_guo@c-sky.com>
2017-11-19csky: port to uclibc-ngGuo Ren
Follow the steps to build c-sky uclibc linux system: 1. git clone https://github.com/c-sky/buildroot.git 2. cd buildroot 3. make qemu_csky_ck810_uclibc_defconfig 4. make Follow the buildroot/board/qemu/csky/readme.txt to run. This buildroot toolchain is pre-build, But you can rebuild the c-sky uclibc-ng alone and install it to the buildroot sysroot manually. We'll try our best to improve the uclibc-ng continuously. Signed-off-by: Guo Ren <ren_guo@c-sky.com>
2017-11-03fix multilib dirWaldemar Brodkorb
Signed-off-by: Alex Potapenko <opotapenko@gmail.com> Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2017-08-06microblaze: handle R_MICROBLAZE_NONE for ld.so bootstrapWaldemar Brodkorb
Latest binutils 2.29 release emits a R_MICROBLAZE_NONE relocation, which breaks shared library loader bootstrap relocation.
2017-07-28aarch64: finetuning, sync with glibcWaldemar Brodkorb
2017-07-20Revert "libdl: fix size parameter when unmap library in dlclose"Waldemar Brodkorb
This reverts commit 9b42da7d0558884e2a3cc9a8674ccfc752369610. This fixes a long standing bug in dlclose(). Can be seen with apache and mod_php or just by executing php -m to list all modules. Reported-by: Bernd Kuhls <bernd.kuhls@t-online.de>
2017-06-21remove the not useful disclaimerWaldemar Brodkorb
2017-06-21remove editor hints for viWaldemar Brodkorb
2017-06-11remove outdated manpages and README's for ld.so/linuxthreadsWaldemar Brodkorb
2017-05-14or1k: add NPTL/TLS supportWaldemar Brodkorb
Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
2017-04-17aarch64: handle lazy relocation of TLSDESCWaldemar Brodkorb
Binutils emits by default lazy relocations for TLSDESC and ld.so need to handle that. Fixes problems like: can't handle reloc type 0x407
2017-04-08Same iteration variable used for inner and outer loopCupertino Miranda
Inner loop was using same counter variable (i) as the outer loop, therefore making outer loop terminate before it visited all of the ELF program segments. Surrounding code in this inner loop clearly shows the intention that this loop should not affect the outer one, therefore leading me to the conclusion that this should be a bug an not expected code. This bug was detected due to some other bug in ARC binutils that kept setting TEXTREL for any PIE application. Apart from the but, I have also moved the debug message inside of the TEXTREL condition as mprotect is only really called if TELTREL is set.
2017-04-08ldso: exit if zalloc can't alloc memoryVineet Gupta
_dl_zalloc callers don't check for allocaton failure. It kind of makes sense since such early allocations are unlikely to fail, and even if they do, ldso would segv anyways thus bringing the issue to attention. However there's a gcc nuance which led to this patch. It seems gcc at -O2 (for DODEBUG build), does additional coge gen analysis for pointer dereference from erroneous paths and it "isolates" such code paths with a intrinsic abort/trap etc. The ldso code fragment which was triggering this: | add_ldso(struct dyn_elf *rpnt) | if (rpnt) | ... | else | rpnt = _dl_zalloc() | | rpnt->dyn = tpnt <---- potential NULL pointer deref ARC gcc currently generates an abort() call which doesn't exist in ldso, causing link errors (with a newer vrsion of binutils). ARM gcc 6.2.1 behaves similarly, altough instead of abort, it generates a trap inducing UDF instruction | 367c: ebfffb79 bl 2468 <_dl_malloc> | 3680: e51b2068 ldr r2, [fp, #-104] ; 0xffffff98 | 3684: e3500000 cmp r0, #0 | 3688: 0a000006 beq 36a8 <_dl_add_elf_hash_table+0x280> | ... | 36a8: e5862000 str r2, [r6] | 36ac: e7f000f0 udf # So add an explict dl_exit() in dl_zalloc error case to beat the compiler. Note that this error propagagtion analysis stops if the function in consideration (_dl_zalloc) is NOT inlined. Hence the reason it only shows up for DODEBUG builds which builds ldso at -O2 which is more aggressive about inlining. If this patch is not considered worth applying then the workaround suggested by Claudiu is to to build ldso with -fno-isolate-erroneous-paths-dereference Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
2017-04-08ldso/arc: fix debug printsVineet Gupta
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
2017-04-01nios2: allow to hack on experimenting ld.so supportWaldemar Brodkorb
2017-04-01ldso: don't discard sysmbols for DODEBUG buildsVineet Gupta
the --discard-* toggles take away the symbols which comes in the way when staring at objdumps for debugging low level issues So don't discard symbols for DODEBUG builds before ----- 3388: j_s.d [blink] 338a: add_s sp,sp,0x18 338c: b.d 332c <_dl_add_elf_hash_table+0x50> 3390: mov_s r2,0 3392: nop_s 3394: push_s blink <--- function not called out 3396: st.aw r13,[sp,-20] 339a: std r14r15,[sp,4] 339e: std r16r17,[sp,12] after ----- 3388: j_s.d [blink] 338a: add_s sp,sp,0x18 338c: b.d 332c <_dl_add_elf_hash_table+0x50> 3390: mov_s r2,0 3392: nop_s 00003394 <add_ldso.isra.9>: 3394: push_s blink 3396: st.aw r13,[sp,-20] 339a: std r14r15,[sp,4] 339e: std r16r17,[sp,12] Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
2017-03-17Search the configured multilibAlexey Neyman
... before falling back to ld.so installation path (it is not the same - gcc uses /lib/ld-uClibc-x86-64.so.0 for uClibc) or default /lib:/usr/lib. This matches glibc behavior (see trusted-dirs.h generated during glibc build). Signed-off-by: Alexey Neyman <stilor@att.net>
2017-02-01add experimental aarch64 supportWaldemar Brodkorb
Ported over from GNU C Library and runtime tested in Qemu.
2017-01-29use safe, even if possibly a few cycles slower, six-argument syscall ↵mirabilos
implementation Signed-off-by: mirabilos <m@mirbsd.org> Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
2017-01-22nds32: add NPTL/TLS, *context function, libm changes and code cleanupVincent Ren-Wei Chen
This commit includes following features. 1. Support NPTL/TLS 2. Add libm function which is used to handle FP rounding and excpetions (ex: fclrexcpt,fedisblxcpti,feenablxcpt... ) 3. Add *context function for operating user context (ex: setcontext,getcontext,makecontext... ) 4. Change the return flow from signal handler 5. Cleanup of old code The testsuite only has 2 errors, tst-cpuclock1 and tst-cputimer1, which are related to timing accuracy. (math and locale tests are disabled) Signed-off-by: Vincent Ren-Wei Chen <vincentc@andestech.com>
2017-01-15ARC: ldso: don't use _DYNAMIC@gotpc construct #2Vineet Gupta
This removes _DYNAMIC@gotpc from elf_machine_load_address() This is a seperate commit to callout the fact that old code was actually broken but was NOT caught since it never gets called (and will never be) since ld.so only calls it if kernel doesn't pass AT_BASE auxvt, which is not true for Linux. if (!auxvt[AT_BASE].a_un.a_val) auxvt[AT_BASE].a_un.a_val = elf_machine_load_address(); So while the intent was to remove _DYNAMIC@gotpc construct, we need to come up with something which works. The build time address computation of .dynamic which works well is: - "ld %1, [pcl, _DYNAMIC@gotpc] \n" + "ld %1, [pcl, _GLOBAL_OFFSET_TABLE_@pcl] \n" However the runtime address of .dynamic can only be generated with "add %0, pcl, _DYNAMIC@pcl \n" which unfortunately is what is currently broken as it is converted to i_GLOBAL_OFFSET_TABLE_t and thus refers to runtime address of .got and not .dyanmic Thus we resort to using an arbit symbol _dl_start at the expense of an extra GOT entry and a bogus R_ARC_NONE relo in ldso itself which now needs to be ignored. Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
2017-01-15ARC: ldso: don't use _DYNAMIC@gotpc construct #1Vineet Gupta
This converts elf_machine_dynamic() to not use the _DYNAMIC@xx construct which was historically converted by assembler into _GLOBAL_OFFSET_TABLE Now that "hack" is being removed from assembler, we need to make sure that no code relies on that magic "conversion". Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
2017-01-14ldso: do not resolve relocations for debug, dig them up when debuggingWaldemar Brodkorb
Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
2017-01-05ld.so: fix mips{32,64}r6 supportWaldemar Brodkorb
Signed-off-by: Matthew Fortune <Matthew.Fortune@imgtec.com>
2016-12-10fix static linking for FDPIC toolchainsWaldemar Brodkorb
Fixes following problem, when trying to compile a simple C application statically with a FDPIC toolchain (for example with Blackfin architecture): lib/libc.a(libdl.os): In function `do_dlclose': (.text+0x6be): undefined reference to `_dl_free' ..
2016-12-10bfin: fix a gcc warningWaldemar Brodkorb
2016-11-04nios2: sync support with glibcWaldemar Brodkorb
Only static linking is supported for now. More debugging and analyzing for ld.so, TLS and NPTL is required. But at least you can bootup a static root fileystem in Qemu.