summaryrefslogtreecommitdiff
path: root/libc
AgeCommit message (Collapse)Author
26 hoursFix Sysvipc for ARM, AARCH64, RISCV64, KVX and m68kHEADmasterWaldemar Brodkorb
26 hourstime64: fix *ctl functions in mips32eb/mips64yliu
26 hourstime64: fixed msgctl/semctl/shmctl result errors for for MIPS32/RISCV32yliu
26 hoursmips32: Define __IPC_64 according to kernel versionyliu
In later kernel versions, IPC_64 is no longer required in the *ctl function, so it is defined as 0.
26 hoursmips32: Preventing FORCE_FRAME_POINTER from being optimized awayyliu
In functions that modify sp, debug and unwind information should be located by fp instead of sp, and the conversion is completed through FORCE_FRAME_POINTER. With gcc -Os, FORCE_FRAME_POINTER is optimized away, and the modified sp is still used, causing a segmentation fault in the recvfrom(). Adding a meaningless assembly instruction to use the return value of FORCE_FRAME_POINTER to prevent it from being deleted.
4 daysmalloc-standard: Fix truncation problem in mallocMarius Melzer
This fixes a bug that can lead to the calculation of a wrong bin `idx`, which in turn leads to a too small chunk of memory being chosen for the number of bytes (`nb`) to be allocated. This leads to a fault (or possibly to memory being written in the wrong location) when using the offset `nb` on top of the chunk for a write operation. malloc() takes the number of bytes to allocate as size_t, but the calculation of the global bin index idx is done via malloc_largebin_index() which takes as parameter and calculates internally with unsigned int. This leads, for large allocations, to a truncation of the value and consequently to the idx being wrongly calculated. idx is an index into the bins which are sorted in ascending order of size range of its including chunks (e.g. 8-16, 16-32, 32-64,...). The malloc() algorithm depends on the idx being calculated such that we begin searching only at a bin whose chunks are always large enough to include the memory size to be allocated (nb). If the idx is too small (as can happen due to the described integer overflow), this code will lead to a write to a wrong address (remainder->bk resp. remainder->fd) (lines from malloc.c): 1086 size = chunksize(victim); 1087 1088 /* We know the first chunk in this bin is big enough to use. */ 1089 assert((unsigned long)(size) >= (unsigned long)(nb)); 1108 remainder = chunk_at_offset(victim, nb); 1111 remainder->bk = remainder->fd = unsorted_chunks(av); The chunk victim should normally be from a bin of a range where each chunk is at least of the size nb. Since it's not, its size may be smaller than nb. With assertions enabled the assertion in 1089 would fail. Without assertions we add nb as an offset to the chunk but since the size of the chunk is a lot smaller than nb, this will point to an address somewhere else. Signed-off-by: Marcus Haehnel <marcus.haehnel@kernkonzept.com>
2025-07-25utimes: force to use 64-bit implementation if available and requested (part II)Peter Seiderer
- fix dependency for libc_hidden_def(utimes) statement, fixes (on ARM-64bit): ./include/libc-symbols.h:431:32: error: '__EI_utimes' aliased to undefined symbol '__GI_utimes' 431 | extern __typeof (name) __EI_##name __attribute__((alias (__hidden_asmname1 (,#local)))) \ | ^~~~~ ./include/libc-symbols.h:435:41: note: in expansion of macro '__hidden_ver1' 435 | # define hidden_def(name) __hidden_ver1(__GI_##name, name, name); | ^~~~~~~~~~~~~ ./include/libc-symbols.h:503:32: note: in expansion of macro 'hidden_def' 503 | # define libc_hidden_def(name) hidden_def (name) | ^~~~~~~~~~ libc/sysdeps/linux/common/utimes.c:54:1: note: in expansion of macro 'libc_hidden_def' 54 | libc_hidden_def(utimes) | ^~~~~~~~~~~~~~~ - fix dependency for 64-bit implementation, fixes (on ARM-64bit): .../build/busybox-1.37.0/libbb/copy_file.c:433:(.text.copy_file+0x2b0): undefined reference to `utimes' Fixes: 48591e2a2 ("Provide fixups for riscv32.") Fixes: 5aee86ed3 ("utimes: force to use 64-bit implementation if available and requested") Signed-off-by: Peter Seiderer <ps.report@gmx.net>
2025-07-25fix getentropy()Waldemar Brodkorb
Add missing header in commit 19fe75f0ab09c9661ff03738579171624fc35018 Reported-By: Ronald Wahl <ronald.wahl@legrand.com>
2025-07-19utimes: force to use 64-bit implementation if available and requestedPeter Seiderer
Fixes 64-/32-bit time_t regression on ARM32 (reported for buildroot, see [1] for details). [1] https://gitlab.com/buildroot.org/buildroot/-/issues/128 Fixes: 48591e2a2 ("Provide fixups for riscv32.") Signed-off-by: Peter Seiderer <ps.report@gmx.net>
2025-06-30inet/netdb: fix getnameinfo signatureMarcus Haehnel
According to POSIX the getnameinfo flags parameter is int and not unsigned. Adapt accordingly. Glibc has also fixed this in commit e4ecafe004b3d4270b3a9dace8f970047400ed38 in 2001. Signed-off-by: Marcus Haehnel <marcus.haehnel@kernkonzept.com>
2025-06-11arc: add missing files for fenv supportWaldemar Brodkorb
2025-04-28csky: add fenv support from glibcWaldemar Brodkorb
2025-04-28sh: add fenv support from glibcWaldemar Brodkorb
2025-04-27sparc: add fenv support from glibcWaldemar Brodkorb
2025-04-27or1k: add fenv support from glibcWaldemar Brodkorb
2025-04-27m68k: add fenv support from glibcWaldemar Brodkorb
2025-04-27fix build for coldfire with FPUWaldemar Brodkorb
2025-04-24riscv: add fenv support from glibcWaldemar Brodkorb
2025-04-23mips/mips64: add fenv support from glibcWaldemar Brodkorb
2025-04-11getentropy: guard syscall to getrandomWaldemar Brodkorb
2025-04-07add getentropy(), fix return value of getrandom()Thorsten Glaser
Signed-off-by: Thorsten Glaser <tg@debian.org>
2025-04-01arm: add fenv support from glibcWaldemar Brodkorb
2025-03-31aarch64: add fenv support from glibcWaldemar Brodkorb
2025-03-22Use __ehdr_start as known zero link address symbolJan Klötzke
The _start symbol does not necessarily have to be on the first page of the application. But the __ehdr_start symbol is always at address zero for PIE binaries. Signed-off-by: Marcus Haehnel <marcus.haehnel@kernkonzept.com>
2025-03-22Do not rely on unrelocated GOT entriesJan Klötzke
The LLVM linker seems to be quite clever. When resolving relocations, accesses to the GOT are potentially replaced by PC relative addressing to the requested symbol. This breaks the old method of calculating the load address by using an unrelocated GOT entry value. Instead, rely on __ehdr_start having a link address of zero. Signed-off-by: Marcus Haehnel <marcus.haehnel@kernkonzept.com>
2025-03-08ldso.h: factor out _dl_auxvt from ldso.hMarcus Haehnel
The _dl_auxvt is also used on non shared builds to access the values of the vector from getauxval. Putting the definitions in ldso.h leads to issues because that header also implements fcntl.h functionality making it incompatible with files that include that header directly. Factor out the _dl_auxvt related declarations to a new header dl-auxvt.h and include from ldso.h as well as include it directly from __uClibc_main.c to make the definitions available. Signed-off-by: Marcus Haehnel <marcus.haehnel@kernkonzept.com>
2025-03-06Fix missing include in __uClibc_mainMarcus Haehnel
Commit 227b7c825b6c79479f7222be03e83991b927da26 introduced a dependency on _dl_auxvt but missed to include the header defining the symbol. Include the ldso.h header that defines this and safeguard other parts of that header that do not play nice if fcntl.h has already been included. The latter is the case only for __uClibc_main.c. Reviewed-by: Georg Kotheimer <georg.kotheimer@kernkonzept.com> Signed-off-by: Marcus Haehnel <marcus.haehnel@kernkonzept.com>
2025-03-04Support non-cached entries in getauxvalGeorg Kotheimer
Previously the getauxval implementation was limited to the auxiliary vector entries cached in _dl_auxvt. To also support entries outside of that cached subset, store the start address of the auxiliary vector, and if an uncached entry type is encountered search the entire auxiliary vector. Signed-off-by: Marcus Haehnel <marcus.haehnel@kernkonzept.com>
2025-03-04Make getauxval work with static linkingGeorg Kotheimer
While for dynamic linking the _dl_auxvt array is provided in dl-startup.c as part of the ldso, is was undefined for statically linked binaries. This resulted in a corresponding linker error if a statically linked program used getauxval. To provide _dl_auxvt also for statically linked binaries, a definition of _dl_auxvt is added to dl-support.c and initialized by _dl_aux_init(). Signed-off-by: Marcus Haehnel <marcus.haehnel@kernkonzept.com>
2025-02-27libc/string/x86_64: fix p2align max number of bytes to skipFrank Mehnert
In a .p2align directive, the maximum number of bytes to skip shall be at most the intended alignment minus 1. Certain assemblers warn otherwise: spn.S:97:14: warning: maximum bytes expression exceeds alignment and has no effect .p2align 3,,8 ^ Change-Id: I5ad48f6f3c3036d8d33d3710ed8d5b5a35bf1fea Signed-off-by: Marcus Haehnel <marcus.haehnel@kernkonzept.com>
2025-02-12inet/resolv.c: set h_errnop if /etc/hosts cannot be openedJan Klötzke
If gethostent_r fails, the h_errnop error code should be set. Signed-off-by: Marcus Haehnel <marcus.haehnel@kernkonzept.com>
2025-02-10nan.h: define NAN only if not already definedFrank Mehnert
Clang-19 defines NAN in <float.h>. Check if NAN is already defined to prevent a compiler warning. Change-Id: I29ebcb2a7a0c1eade46a73074a1701ea67869128 Signed-off-by: Marcus Haehnel <marcus.haehnel@kernkonzept.com>
2025-01-14clock_adjtime: warn instead of error outWaldemar Brodkorb
2025-01-07fix possible overflow in pointer arithmetics strnlen()Frank Mehnert
It is undefined behavior to compare two pointers belonging to different objects. This includes the case where the addition overflows. Clang-20 seems to follow this rule more eagerly and optimizes away the old test. Fix the test by performing the addition on uintptr_t values rather than on on char pointers. See also https://github.com/llvm/llvm-project/issues/121909. Signed-off-by: Marcus Haehnel <marcus.haehnel@kernkonzept.com>
2025-01-07prevent warning about setting an unused variableFrank Mehnert
Signed-off-by: Marcus Haehnel <marcus.haehnel@kernkonzept.com>
2025-01-06uclibc: prevent warning about declaring an unused functionFrank Mehnert
Signed-off-by: Marcus Haehnel <marcus.haehnel@kernkonzept.com>
2025-01-06uclibc: prevent warning about setting an unused variableFrank Mehnert
This variable is used either if __UCLIBC_HAS_FLOATS__ is defined or if __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__ is defined. Instead of adding more complicated #ifdef magic, just mark this variable as possibly unused to satisfy the compiler. Signed-off-by: marcus.haehnel@kernkonzept.com
2024-08-14add process_vm_{read,write}v syscall wrapper from glibcWaldemar Brodkorb
2024-08-13getrandom: remove __USE_GNU / add GRND_INSECUREWaldemar Brodkorb
Neither glibc nor musl use __GNU macro to hide getrandom. While there sync with glibc and add GRND_INSECURE flag.
2024-08-11add memfd_create syscall wrapperWaldemar Brodkorb
2024-08-11riscv: remove incomplete context implementation, use libucontextWaldemar Brodkorb
2024-08-09bits/stat.h: Declare st_mtim if defined(__USE_XOPEN2K8), add missingWaldemar Brodkorb
d0c8c185b439187b12644457bb2aa0326f25aaf7 was not complete, add missing architectures.
2024-08-09lseek: allow SEEK_DATA/SEEK_HOLE to be usedWaldemar Brodkorb
2024-07-27bits/stat.h: Declare st_mtim if defined(__USE_XOPEN2K8), everywhereJ. Neuschäfer
While building software that sets _POSIX_C_SOURCE=200809L and uses stat.st_mtim for ARM, it was noticed that st_mtim was not defined. This seems to be because common/bits/stat.h was picked up, which does not take __USE_XOPEN2K8 as a reason to enable st_mtim and related fields. This appears to be an oversight, and porting the check from common-generic/bits/stat.h to other architectures does indeed fix the build issue. This patch is based on commit 50bd6d06e ("Fix memory corruption due to struct stat field"). Signed-off-by: J. Neuschäfer <j.neuschaefer@gmx.net>
2024-07-21Fix compilation with 4.x kernel headersDmitry Chestnykh
- Fallback to __NR_stat syscall in ld.so if we use 4.x kernel headers. 4.x kernel doesn't support 64-bit time so we can use old syscall - Add preprocessor conditions to have fstat64 and fstatat64 in libc with old kernel headers Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
2024-07-19arm: Replace deprecated asm instructions for ARMv8 AArch32Valentin Gehrke
ARMv8 has particular restrictions which coprocessor can be used and as such these instructions, which were likely used for backwards compatibility purposes, cannot be used on ARMv8. We solve this by checking for ARMv8 and then using the corresponding mnemonics which were placed in comments alongside the instructions causing issues. Fixes the following errors: .../setjmp.S:59:6: error: invalid operand for instruction stc p11, cr8, [r12], #68 ^ .../setjmp.S:62:6: error: invalid operand for instruction mrc p10, 7, r2, cr1, cr0, 0 ^ .../__longjmp.S:69:6: error: invalid operand for instruction ldc p11, cr8, [r12], #68 ^ .../__longjmp.S:73:6: error: invalid operand for instruction mcr p10, 7, r1, cr1, cr0, 0 ^ Signed-off-by: Marcus Haehnel <marcus.haehnel@kernkonzept.com>
2024-07-09uclibc: Fix double promotion warningMarcus Haehnel
Add casts where necessary to convince clang that the promotion of float to double is intentional. Co-authored-by: Sven Linker <sven.linker@kernkonzept.com> Signed-off-by: Marcus Haehnel <marcus.haehnel@kernkonzept.com>
2024-06-15libc: cast free() argument to void * in wchar.cYuriy Kolerov
iconv_close() accepts iconv_t type (which is void *) and passes it to free() which accepts void *. However, GCC 14 raises a -Wint-conversion warning if it is not casted to void * because GCC cannot unwind typedef of iconv_t. Signed-off-by: Yuriy Kolerov <ykolerov@synopsys.com>
2024-06-10m68k: fix for m68000 cpuWaldemar Brodkorb
See here for details: https://github.com/wbx-github/uclibc-ng/issues/15
2024-06-04xtensa: add FDPIC supportMax Filippov
This change implements Xtensa FDPIC ABI as specified in the first version of the following document: https://github.com/jcmvbkbc/xtensa-abi/blob/master/fdpic-xtensa.txt Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>