summaryrefslogtreecommitdiff
path: root/libc/misc
AgeCommit message (Collapse)Author
2022-08-08Added support for creation of Static Position-Independent Executables (PIE) ↵linted
on aarch64 Updated config to allow compilation of rcrt1.o for aarch64 and modified it's crt1.S to relocate dynamic section prior to __uClibc_main. Disabled stack protector when compiling reloc_static_pie.c to avoid TLS access prior to it being setup. Signed-off-by: linted <linted@users.noreply.github.com>
2022-07-26Added support for creation of Static Position-Independent Executables (PIE) ↵linted
on i386, x86_64, and arm. This patch adds the generation of rcrt1.o which is used by gcc when compiling with the --static-pie flag. rcrt1.o differs from crt1.o and Scrt1.o in that it the executable has a dynamic section but no relocations have been performed prior to _start being called. crt1.o assumes there to be no dynamic relocations, and Scrt1.o has all relocations performed prior to execution by lsdo. The new reloc_static_pie function handles parsing the dynamic section, and performing the relocations in a architecture agnostic method. It also sets _dl_load_base which is used when initalizing TLS to ensure loading from the proper location. This allows for easier porting of static-pie support to additional architectures as only modifications to crt1.S to find the load address are required. Signed-off-by: linted <linted@users.noreply.github.com>
2022-05-23libc/misc/getloadavg: Add getloadavg support to uClibc-nglancethepants
This borrows getloadavg.c from musl. getloadavg pops up often. Recently llvm and rust are dependent on it. glibc and musl have it and no-one actually checks if it's available in your libc. It's just become way easier to add it in uclibc-ng rather than patch everything else. Signed-off-by: Lance Fredrickson <lancethepants@gmail.com>
2021-12-24Fix -Wundef related warningsYann Sionneau
Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
2020-10-19hasmntopt: better option matchingYann Sionneau
Previous implementation was respecting the man page description of what the function should do. Also the function does not seem to be defined by POSIX. But... to be really useful the function needs to handle option matching and not just substring matching. This is copy pasted from glibc. This fixes issue reported by https://github.com/wbx-github/uclibc-ng/issues/8 that can happen for instance there: https://github.com/frida/glib/blob/master/gio/gunixmounts.c#L622 Signed-off-by: Yann Sionneau <yann@sionneau.net>
2020-09-22Fix warning about macro redefinitionYann Sionneau
Fixes this: libc/misc/internals/tempname.c: In function 'brain_damaged_fillrand': libc/misc/internals/tempname.c:155:0: warning: "L" redefined #define L ((UINT32_MAX % NUM_LETTERS + 1) % NUM_LETTERS) In file included from ./libpthread/nptl/sysdeps/unix/sysv/linux/lowlevellock.h:24:0, from ./include/bits/libc-lock.h:35, from ./include/bits/stdio-lock.h:22, from ./include/bits/uClibc_mutex.h:73, from ./include/bits/uClibc_stdio.h:83, from ./include/stdio.h:71, from libc/misc/internals/tempname.c:35: ./libc/sysdeps/linux/kvx/sysdep.h:40:0: note: this is the location of the previous definition # define L(name) $L##name Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
2020-09-22Fix warning about missing const qualifierYann Sionneau
Fixes this: In file included from libc/misc/fnmatch/fnmatch.c:235:0: libc/misc/fnmatch/fnmatch_loop.c: In function 'internal_fnmatch': libc/misc/fnmatch/fnmatch_loop.c:207:21: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] CHAR *p_init = p; ^ libc/misc/fnmatch/fnmatch_loop.c:208:21: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] CHAR *n_init = n; Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
2020-09-02Revert "Fix static linking with GCC-10"Waldemar Brodkorb
This reverts commit 5b58a1ebd89a4f05778441814e81817c82193fa3. This breaks all static builds earlier to gcc 10 :( Bad testing on my side.
2020-08-11Fix static linking with GCC-10Lance Fredrickson
Starting with GCC-10 multiple definitions of global variables by will be rejected. https://gcc.gnu.org/gcc-10/porting_to.html This fixes multiple definitions of _dl_pagesize and _dl_tls_static_size while attempting static linking. Of course this only occurs when compiling something that requires these symbols. First patch submission so hopefully all done correctly. thanks, Lance Fredrickson From e0686f7c03ce8e51ccffefeb6365e50311e6dd10 Mon Sep 17 00:00:00 2001 From: lancethepants <lancethepants@gmail.com> Date: Wed, 15 Jul 2020 13:09:26 -0600 Subject: [PATCH] Starting with GCC-10 multiple definitions of global variables by will be rejected. This fixes multiple definitions of _dl_pagesize and _dl_tls_static_size while attempting static linking.
2019-11-06riscv64: lazy relocations do not work like sparc/m68kWaldemar Brodkorb
2019-11-01riscv64: add shared library supportWaldemar Brodkorb
2019-06-21fix opendir, fpathconf and ttyname_r to use fstat64(), not fstat()Denys Vlasenko
There is no opendir64(), thus even programs built for 64-bit off_t use opendir(). Before this change, internally opendir() uses fstat(), with the following breakage if some of struct stat fields are too narrow: $ strace ls -l execve("/busybox/ls", ["ls", "-l"], 0x7ffcdc43ede8 /* 16 vars */) = 0 ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0 ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0 getuid32() = 0 time([1551486393 /* 2019-03-02T00:26:33+0000 */]) = 1551486393 (2019-03-02T00:26:33+0000) ioctl(0, TIOCGWINSZ, {ws_row=38, ws_col=120, ws_xpixel=0, ws_ypixel=0}) = 0 ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0 brk(NULL) = 0x9768000 brk(0x9769000) = 0x9769000 lstat64(".", 0xffa6e374) = 0 open(".", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3 fstat(3, 0xffa6e378) = -1 EOVERFLOW (Value too large for defined data type) See https://bugs.busybox.net/show_bug.cgi?id=11651 Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2019-04-14Fix TLS allocation and loading in !SHARED caseYann Sionneau
For ARCH where shared lib are not supported: - SHARED is not set (!SHARED is true) - __ARCH_HAS_NO_LDSO__ is set so code inside #if !defined __ARCH_HAS_NO_LDSO__ && !defined SHARED is compiled-out. But without a call do _dl_aux_init(), _dl_phdr stays NULL and __libc_setup_tls won't be able to allocate memory for the in-executable TLS and also won't be able to load the initimage from ELF TLS segment. This results in segfault when doing things like "errno = 0" like in tst-cancel15.c for instance in uClibc-ng testsuite. Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
2018-09-21wordexp: Fix the usage of the internal _itoa functionSegev Finer
The original from glibc received the end of the buffer and worked backwards. Ours needs the beginning of the buffer. Signed-off-by: Segev Finer <segev208@gmail.com>
2018-08-10nptl threads: Fix bug in using a weak variable.Christophe Lyon
In case __nptl_nthreads is not defined in the final binary then avoid dereferencing the address since it's null. Anyway this means there is no other thread and so we must exit. * libc/misc/internals/__uClibc_main.c (__uClibc_main): Handle case where &__nptl_nthreads is null. Signed-off-by: Mickaël Guêné <mickael.guene@st.com> Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
2018-08-10Allow to generate PIE 'static' binaryChristophe Lyon
* libc/misc/internals/__uClibc_main.c (funcdesc_value): New. (fdpic_init_array_jump): New. (__uClibc_fini): Support __FDPIC__. (__uClibc_main): Likewise. 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-02-03add libc version compatibilityWaldemar Brodkorb
2017-11-25Only emulate fstatfs64 if __NR_fstatfs64 is not definedEugene Rudoy
Follow-up of e3d6c8bffe79b2c070bc7a3aabc9d9c65f6b099e Signed-off-by: Eugene Rudoy <gene.devel@gmail.com> Signed-off-by: Ralf Friedl <Ralf.Friedl@online.de>
2017-11-03Only emulate statfs64 if __NR_statfs64 is not definedWaldemar Brodkorb
After discussions on the busybox mailinglist. Reported-by: Ralf Friedl <Ralf.Friedl@online.de> Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2017-10-01statfs: bugfix statfs02 fstatfs02 failed in ltp-testsuiteGuo Ren
In the test-case of statfs from ltp-testsuite, it pass -1 to 2th argument. eg: fstatfs(fd , -1) When uclibc-ng parse the buf32 to buf will cause illegal address access, the kernel will signal the process with SIGSEGV. If we pass the -1 directly to the syscall of statfs/fstatfs, kernel use copy_to_user() to prevent the signal of SIGSEGV and just return EINVAL. This is the ltp-testsuite expect. Signed-off-by: Guo Ren <ren_guo@c-sky.com>
2017-07-28fix tolower and localesEugene Yudin
The function towlower doesn't work with locales different from C. Issue was introduced in commit: 8cde3a9bf2856dcb9a759dec7ecb04a68e712254 Call to setlocale is needed for correct generation of the table uplow_diff. Otherwise you receive compile time error "range assumption error" after uncommenting the call. Similar problem described here: http://lists.uclibc.org/pipermail/uclibc/2015-March/048852.html This commit fix the problem by using int32_t values.
2017-06-21remove editor hints for viWaldemar Brodkorb
2017-04-17remove old regex implementationWaldemar Brodkorb
2017-04-17remove old fnmatch implementationWaldemar Brodkorb
2017-02-01g/c __libc_errnomirabilos
Signed-off-by: mirabilos <m@mirbsd.org> Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2017-01-14fts: fix gcc compiler warningWaldemar Brodkorb
Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
2017-01-14fnmatch: fix gcc compiler warningsWaldemar Brodkorb
Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
2016-12-21remove misc/gnu, cleanup commentWaldemar Brodkorb
2016-12-21remove obstack supportWaldemar Brodkorb
Remove __UCLIBC_HAS_OBSTACK__ as it isn't very uptodate and maintained part. It shouldn't be required for any software and mostly shipped with stuff which use it. (f.e. binutils-gdb)
2016-12-10threads: optimize single threaded applicationsWaldemar Brodkorb
Revert the removal of the weak pthread functions and guarantee a link order so that single threaded applications doesn't link in all the pthread functions they don't use. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> Tested-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2016-12-03fix obstack compile issue after libintl/gettext removalWaldemar Brodkorb
2016-12-02remove libintl stub and libintl.h headerWaldemar Brodkorb
As __UCLIBC_HAS_GETTEXT_AWARENESS__ is never defined, this is mostly dead code. It is planned to integrate libiconv-tiny and gettext-tiny into uClibc-ng after the next release, so that more software packages can be used without modification. Remove any _/_N macro usage.
2016-11-27remove UCLIBC_HAS_LFSWaldemar Brodkorb
2016-11-27Fix handling of unterminated [ expression in fnmatch.Waldemar Brodkorb
Originally fixed in GNU libc by: commit 794c3ad3a405697e2663b00f616e319383b9bb7d Author: Ulrich Drepper <drepper@gmail.com> Date: Fri Jan 14 08:06:22 2011 -0500 Reported-by: Denys Vlasenko <vda.linux@googlemail.com> via busybox mailinglist.
2016-10-20Fix nftw when called with FTW_CHDIR and FTW_DEPTHJohn Ata
Change directory back to the parent before processing the directory (after the contents have already been processed). Signed-off-by: John Ata <john.ata@baesystems.com>
2016-09-26locale: cleanup supportWaldemar Brodkorb
Enable locale application to be build when utils are build. Remove useless compile and link warnings. Default to minimal locale builds. Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
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-06-07ssp: remove SSP legacy codeWaldemar Brodkorb
Nobody should use gcc 3.3 nowadays.
2016-06-01remove MJN only debug messagesWaldemar Brodkorb
2016-04-03Provide an alias to _obstack_freeAlexey Neyman
GDB 7.11 does not build if compiled against uclibc-ng (1.0.12 was used, but the problematic code exists in 1.0.13 as well). The reason is that GDB release includes its own obstack implementation, but elides the code if <gnu-versions.h> declares a compatible obstack implementation in libc. uclibc-ng does claim compatible obstack interface (GDB expects version 2, but accepts version 1 if sizeof(int) == sizeof(size_t)), however, uclibc-ng does not provide the _obstack_free symbol that is a part of the interface (glibc does provide this symbol). This later causes a link failure. The attached patch makes uclibc-ng enables an alias _obstack_free -> obstack_free. Signed-off-by: Alexey Neyman <stilor@att.net>
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-03libc: getpass,getutent: allocate buffer dynamicallyWaldemar Brodkorb
Saves 0.6k bss with default buffer size(256). text data bss dec hex filename - 1172 8 408 1588 634 libc/misc/utmp/utent.os - 429 0 256 685 2ad libc/unistd/getpass.os + 1208 8 28 1244 4dc libc/misc/utmp/utent.os + 471 0 4 475 1db libc/unistd/getpass.os ================================================================ +78 -632 Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com>
2015-12-17Fix syslog messages lost if syslogd is temporary busyVladislav Grishenko
Commit 4139fe5aec935ba3f462dcaf6aafb6e5eadf1ab9 fixes SIGSTOPed syslogd issue. but introduced new one - messages will be lost when socket buffer gets full, not only if syslogd is stalled, but even if it accepts message slower than someone sends and possibly leads to security hole, when important messages get lost as result of attacker flooding. Patch adds 1 second waiting for socket buffer can accept the message, helps when syslogd is working hard. If it's stalled/SIGSTOPed, message will be sent to errout as before. After that, further non-blocking /dev/log connect attempts will fail immediately with EAGAIN error until syslogd reads some from it. function old new delta openlog_intern 259 355 +96 static.tv - 8 +8 .rodata 151 159 +8 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/0 up/down: 112/0) Total: 112 bytes Signed-off-by: Vladislav Grishenko <themiron@mail.ru>
2015-12-17Fix syslog messages lost after syslogd restartsVladislav Grishenko
If syslogd is stopped and restarted while a process has the log open, the next message that process produces will be logged to the console and not to the new instance of syslogd. Further messages will be routed correctly, but not the first one. Based on original patch Bug 3889 - syslog loses messages when syslogd restarted https://bugs.busybox.net/show_bug.cgi?id=3889 function old new delta openlog 33 68 +35 __vsyslog 851 848 -3 openlog_intern 318 259 -59 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 35/-62) Total: -27 bytes Signed-off-by: Vladislav Grishenko <themiron@mail.ru>
2015-12-17fix readdir_r returns success code while it in fact failedWaldemar Brodkorb
Taken from Freetz.org. Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com> Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2015-10-12fix static binaries linked with pthread and compiled with sspWaldemar Brodkorb
Move TLS initialization for static builds up to the calling function as suggested by Daniel Fahlgren. Reported-By: Daniel Fahlgren <daniel@fahlgren.se>
2015-08-14add mkstemps, mkstemps64 and mkostemps, mkostemps64 functionsRomain Naour
Change __gen_tempname() prototype in order to pass the additional suffix lenght. In __gen_tempname() add a new check for suffixlen. Update some comments in the code. Signed-off-by: Romain Naour <romain.naour@openwide.fr> Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2015-06-10strftime: comment on %0xY %+nY %-nYBernhard Reutner-Fischer
Would fix: date -u +%4Y%2m%2d%2H%2M%2S Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2015-04-24merge uClibc changesWaldemar Brodkorb