summaryrefslogtreecommitdiff
path: root/ldso
AgeCommit message (Collapse)Author
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.
2016-11-03microblaze: add NPTL/TLS support from GNU libcWaldemar Brodkorb
Not perfect, but a starting point. Some tests of the test suite are failing.
2016-10-31ldso: remove useless debug output, too much noiseWaldemar Brodkorb
2016-09-26use a single libc and deduplicate threading codeWaldemar Brodkorb
Similar to musl libc a single libc has many benefits and solves some open issues with uClibc-ng. - no pthread_mutex_* weak symbols exported anymore - applications no longer failing to link when either -lrt or -lpthread are missing for dynamic and static linking mode - smaller C library - slightly better runtime performance
2016-08-25mips: add NaN supportWaldemar Brodkorb
2016-07-31ARC: Update relocation syntax for old-thread model codeAndrew Burgess
This commit reverses a change introduced in commit 20554a78a9bba that split some of the ARC code into two based on whether uClibc was configured with native threads or not. The native thread code was updated to use the relocation syntax of modern binutils, while the non-native code path used a syntax only accepted in older versions of binutils. The problem with this is that the choice of old binutils or not is orthogonal to the choice of native threads or not, and so, inevitably a user with a recent version of binutils can make the choice to configure uClibc with non-native thread support, and run into code that will not assemble. The solution is either to abandon support for the old tools completely, or to add a new compile time flag for ARC that is set when the version of binutils being used is old; this new flag would allow the old relocation structure to be selected. In this commit I have simply dropped support for older versions of the tools.
2016-07-31ARC: Support R_ARC_JMP_SLOT relocations during bootstrapAndrew Burgess
This commit adds support for R_ARC_JMP_SLOT relocations during the bootstrap phase of the dynamic linker. These relocations will be generated if uClibc-ng is configured with 'DODEBUG=y'.
2016-06-30nds32: add support for new architectureWaldemar Brodkorb
Add support for Andes Technology NDS32 architecture. See here http://www.andestech.com/en/index/index.htm for more informaton. Verification of the port from an older uClibc port was done on a sponsored AG101p board. The testsuite only has 5 errors, three are related to an existing bug in dlclose() with LT.old, also happening on cris32 and m68k. Failures to fallocate/posix_fallocate are unresolved. Thanks to Andes Technology sponsoring the hardware and being very helpful while doing the uClibc-ng porting. Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2016-06-23libs: install backward compatibility symlinksAlexey Brodkin
Simplify the switch from uClibc to uClibc-ng. Apps already built against uClibc-0.9.x.y require .so.0 libs to present on target which in case of current uClibc-ng is not the case and those apps could not be run. This change creates symlinks from .so.1 to .so.0 for most of other libs in the same way as it was done by 23e96d89b6ab "ldso: install backward compatibility symlink by default" Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com> Cc: Waldemar Brodkorb <wbx@uclibc-ng.org> Cc: Vineet Gupta <vgupta@synopsys.com> Cc: Anton Kolesov <akolesov@synopsys.com>
2016-06-22ldso: fix dlsym hang when reloading DSOsLeonid Lisovskiy
It can happen under certain cases that the DSO had refcount 0, but was already loaded. (NODELETE flag is set, or it is pulled in via both NEEDED dependency and explicit dlopen()). Add extra reference count for NODELETE objects, this will ensure that the reference count never drops below one. It is improved version of http://lists.busybox.net/pipermail/uclibc/2013-June/047826.html Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com>
2016-06-22ldso: Consistently set & use DL_OPENED flag in both ld.so and libdlLeonid Lisovskiy
Previously, DL_OPENED flag was set in libdl only and never used. Set it centralized in _dl_load_elf_shared_library() & use it in both ld.so and libdl. Additionally, rename it to DL_OPENED2 for clarity. Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com>
2016-06-07ssp: remove SSP legacy codeWaldemar Brodkorb
Nobody should use gcc 3.3 nowadays.
2016-05-28ldso: Force disable -mlong-calls when compiling ldso for ARCAlexey Brodkin
Even though by default for ARC uClibc gets compiled with disabled long-calls user may provide UCLIBC_EXTRA_CFLAGS with "-mlong-calls". With this option uClibc will be successfully compiled but later it will fail in runtime because dynamic loader cannot deal with relocations at least very early on its start. In particular it will be seen as call to non-relocated symbol _dl_parse_dynamic_info() which ends-up as a segfault like this: ------------------------>8-------------------- potentially unexpected fatal signal 11. Path: /bin/test CPU: 0 PID: 63 Comm: test Not tainted 4.5.2 #7 task: 9f13f180 ti: 9f166000 task.ti: 9f166000 [ECR ]: 0x00040000 => Insn could not be fetched [EFA ]: 0x0000283c [BLINK ]: 0x2000407c [ERET ]: 0x283c @No matching VMA found [STAT32]: 0x8008009e : IE U BTA: 0x0000283c SP: 0x5fef5ccc FP: 0x00000000 LPS: 0x20004080 LPE: 0x20004064 LPC: 0x00000000 r00: 0x20006684 r01: 0x5fef5db0 r02: 0x00000000 r03: 0x20000000 r04: 0x80808080 r05: 0x2f2f2f2f r06: 0x41464d00 r07: 0x00000080 r08: 0x000000dd r09: 0x00000000 r10: 0x00000073 r11: 0x80808080 r12: 0x2000407c r13: 0x20000000 r14: 0x5fef5e74 r15: 0x000ceb3c r16: 0x5fef5e7c r17: 0x5fef5d44 r18: 0x000ceb0c r19: 0xffffffff r20: 0x000ceb1c r21: 0x00000000 r22: 0x00000000 r23: 0x000d08a5 r24: 0x00000000 r25: 0x80808080 Segmentation fault ------------------------>8-------------------- Solution to this issue is simple we make sure dynamic loader never gets compiled with "-mlong-calls" by forcing "-mno-long-calls" on it. Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com> Cc: Vineet Gupta <vgupta@synopsys.com> Cc: Anton Kolesov <akolesov@synopsys.com> Cc: linux-snps-arc@lists.infradead.org
2016-05-28ldso/ARC: fix DT_RELACOUNT handlingCupertino Miranda
With new binutils supporting DT_RELACOUNT, ldso was crashing as it was parsing relocs incorrectly. Apparently that code ran for first time and was never tested. Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
2016-05-24microblaze: fix ELF detection in ld.soWaldemar Brodkorb