summaryrefslogtreecommitdiff
path: root/ldso/ldso
AgeCommit message (Collapse)Author
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-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-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
2016-04-15replace FSF addresses with URLsNikola Forró
License notices in most of the source files refer to an outdated FSF address. Replace it with URL, like in the rest of the source files.Signed-off-by: Nikola Forró <nforro@redhat.com>
2016-02-21arm: allow to build with DODEBUG=yWaldemar Brodkorb
Avoids following linking error: /usr/lib/gcc/arm-openadk-linux-uclibceabihf/5.3.0/libgcc.a(unwind-arm.o): In function `unwind_phase2': ../w-gcc-5.3.0-1/gcc-5.3.0/libgcc/unwind-arm-common.inc:289: undefined reference to `abort' /usr/lib/gcc/arm-openadk-linux-uclibceabihf/5.3.0/libgcc.a(unwind-arm.o): In function `unwind_phase2_forced': ../w-gcc-5.3.0-1/gcc-5.3.0/libgcc/unwind-arm-common.inc:346: undefined reference to `memcpy' collect2: error: ld returned 1 exit status
2016-02-21mips64: with n64 ABI mapping failedWaldemar Brodkorb
Booting on Lemote Yeelong with a page size != 4kb ld.so is crashing and failed to load libc.so. Do not hardcode the offset for n64 ABI.
2016-02-07frv: resurrect port somehow, totally untestedWaldemar Brodkorb
The FR-V port is really broken, and I have no emulator or hardware for this platform. I tried to get some hardware from RedHat, who made the FR-V port initially. Unfortunately Fujitsi didn't agreed to sent me some of their unused spare hardware lying @RedHat. As I invested some time to get stuff compiled, I decided to add the code and may be anytime later I can gain access to some emulator or hardware. GDB simulator for FR-V doesn't support booting Linux AFAIK.
2016-01-31ldso: Use single rtld_flags interpretation through all the callsLeonid Lisovskiy
Implement single rtld_flags interpretation through all the do_dlopen()/_dl_load_shared_library()/_dl_load_elf_shared_library() calls chain. This adds the ability to use the flags, passed to dlopen(), in all underlaying functions and implement rtld_flags inheritance. Saves a few bytes code. Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com> Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2016-01-31ldso: Fix fail of $ORIGIN expansion in case of RTLD_NOLOADLeonid Lisovskiy
$ORIGIN expansion in search_for_named_library() wrongly takes into account all bits of rflags. Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com> Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2015-12-23Replace bltzal with lapc for MIPS R6 builds.Steve Ellcey
The R6 version of MIPS does not support the bltzal instruction. This patch changes dl-startup.h and dl-sysdep.h to use lapc on R6 instead. lapc is a new R6 insruction so older systems need to continue to use bltzal in order to load register $31. Signed-off-by: Steve Ellcey <sellcey@imgtec.com>
2015-12-05remove sh64 supportWaldemar Brodkorb
No real hardware available. The project for sh64 with sh5 seems dead since 10 years. Gcc will remove support for it soon.
2015-11-23xtensa: remove ldso workaround by real pointer checkWaldemar Brodkorb
An abort() is only generated when gcc does not implement a trap handler for the target architecture. This fixes the abort() generation. Latest gcc git master also contains a trap handler for xtensa. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> Signed-off-by: Walemar Brodkorb <wbx@uclibc-ng.org>
2015-10-22ARC: With NPTL support, GP is no longer used for PICVineet Gupta
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
2015-10-09add new architecture support for or1kWaldemar Brodkorb
Information about Openrisc: http://opencores.org/or1k/Main_Page Integrated from: https://github.com/openrisc/uClibc-or1k
2015-10-08xtensa: support call0 ABIMax Filippov
Most changes are mechanical replacement of 'retw' instruction with 'abi_ret' macro, defined to 'retw' or 'ret' according to ABI. Assembly code that makes calls is duplicated for call0 ABI with changed register numbers for parameters/return value and call instruction. 'entry' instructions are replaced with 'abi_entry' macro. More interesting changes: - non-leaf assembly functions (e.g. _dl_tlsdesc_dynamic, _dl_linux_resolve, SYSCALL_ERROR_HANDLER, PSEUDO) now need to preserve registers around intermediate calls they make, use temporary stack frame for that; - setjmp/longjmp only need to save and restore return address, stack pointer and callee-saved registers in the jmpbuf; - __clone and syscall functions had hardcoded offsets to parameter passed on stack, on call0 ABI they don't need stack frame, so the offset is different. Replace these offsets with FRAMESIZE macro. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2015-08-22ldso: install backward compatibility symlink by defaultWaldemar Brodkorb
Simplify the switch from uClibc to uClibc-ng suggested by Alexey Brodkin <Alexey.Brodkin@synopsys.com>. Gcc always uses .0 ld.so link, so install it by default.
2015-08-19Revert "ldso: install backward compatibility symlink by default"Waldemar Brodkorb
This reverts commit f52fb21a7af0aa4e983b3e6c2ddd1b6a526b5169. Totally wrong patch.
2015-08-15ldso: install backward compatibility symlink by defaultWaldemar Brodkorb
Simplify the switch from uClibc to uClibc-ng suggested by Alexey Brodkin <Alexey.Brodkin@synopsys.com>. Gcc always uses .0 ld.so link, so install it by default.
2015-06-23add patch from ldso-future branchWaldemar Brodkorb
Fixes segfaults when gcc 5.1 is used for x86. http://git.uclibc.org/uClibc/commit/ldso/ldso/i386/dl-sysdep.h?h=ldso-future&id=7de778389d0040be4a21ffc326310e0eb361570a Mentioned in #uclibc.
2015-06-10h8300: Add new featureYoshinori Sato
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2015-04-24merge uClibc changesWaldemar Brodkorb
2015-04-22arm: Add BX and BXC macrosBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2015-04-22NPTL: Rename a variableBernhard Reutner-Fischer
There seems to be a bug in gold with static TLS at least on x86_64 (?) Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>