summaryrefslogtreecommitdiff
path: root/libc/sysdeps
AgeCommit message (Collapse)Author
2020-04-01statx: make include conditional, fixes non-csky arch buildroot buildsWaldemar Brodkorb
2020-02-07aarch64/bits: provide sigstack.hVladimir Murzin
It fixes tst-signal6 and friends. Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
2020-02-07aarch64/sys: update ucontext.hVladimir Murzin
It fixes tst-cancel1 and friends. Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
2020-02-07common/bits: Fix ipc_perm and semid_ds definitions for 64-bit archesVladimir Murzin
It fixes: FAIL sem got 1 expected 0 failed: incorrect sem_nsems! semget(IPC_CREAT) = 0 semctl(k) = 0 sem_nsems = 0 for aarch64. Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
2020-02-03csky: add statx conditionalsWaldemar Brodkorb
Similar to glibc commit https://sourceware.org/git/?p=glibc.git;a=commit;h=6bbfc5c09fc5b5e3d4a0cddbbd4e2e457767dae7 we need to handle Linux kernel change, which removed stat64 family from default syscall set. Signed-off-by: Waldemar Brodkorb <wbx@openadk.org> Signed-off-by: Waldemar Brodkorb <wbrodkorb@conet.de>
2020-01-30poll: avoid calling select with empty sets which hangs the processYann Sionneau
Avoid calling select with empty sets which hangs the process This makes uClibc-ng act like glibc and musl Without this fix the test_poll of python3 testsuite hangs forever Scenario of the issue: If you call poll with only invalid file descriptors, like in python3 testsuite (https://github.com/python/cpython/blob/master/Lib/test/test_poll.py#L83) You will go through uClibc poll emulation code, which is based on select syscall. Your first call to select will fail, it will return -1 and errno will be set to EBADF: https://github.com/wbx-github/uclibc-ng/blob/master/libc/sysdeps/linux/common/poll.c#L120 Then you will go through the for loop which tests individually each file descriptor by calling select on each one: https://github.com/wbx-github/uclibc-ng/blob/master/libc/sysdeps/linux/common/poll.c#L163 each call will also return -1 with errno being equal to EBADF. Therefore all pollfd will have the POLLNVAL flag in their respective revents field. And, the most important, rset/wset/xset will stay empty. Then the for loop ends, the "continue" makes the while loop run again. The following select() is run again: https://github.com/wbx-github/uclibc-ng/blob/master/libc/sysdeps/linux/common/poll.c#L120 But this time the sets are empty. If the poll was called with timeout set to -1, this select will hang forever because there is no timeout and the sets are empty so no event will ever wake it up. test program: int main(void) { struct pollfd pfd; int ret; int pipe_fds[2]; pipe(pipe_fds); close(pipe_fds[0]); close(pipe_fds[1]); pfd.fd = pipe_fds[0]; pfd.events = POLLIN | POLLOUT | POLLPRI; pfd.revents = 0; ret = poll(&pfd, 1, -1); printf("ret: %d\n", ret); if (ret < 0) printf("error: %s", strerror(errno)); else { puts("revents: "); if (pfd.revents & POLLERR) printf(" POLLERR"); if (pfd.revents & POLLHUP) printf(" POLLHUP"); if (pfd.revents & POLLNVAL) printf(" POLLNVAL"); puts(""); } return 0; } This hangs on uClibc-ng aarch64 and Kalray's arch (kv3) but does the following on musl and glibc: " ret: 1 revents: POLLNVAL " strace output of this program with uClibc *without* the patch applied: pselect6(4, [3], [3], [3], NULL, NULL) = -1 EBADF (Bad file descriptor) pselect6(4, [3], [3], [3], {tv_sec=0, tv_nsec=0}, NULL) = -1 EBADF (Bad file descriptor) pselect6(0, 0x7ffffffb80, 0x7ffffffb68, 0x7ffffffb50, NULL, NULL (never finishes) strace output of this program with uClibc *with* the patch applied: pselect6(4, [3], [3], [3], NULL, NULL) = -1 EBADF (Bad file descriptor) pselect6(4, [3], [3], [3], {tv_sec=0, tv_nsec=0}, NULL) = -1 EBADF (Bad file descriptor) write(1, "ret: 1\n", 7ret: 1 ) = 7 write(1, "revents: \n", 10revents: ) = 10 write(1, " POLLNVAL\n", 10 POLLNVAL ) = 10 exit_group(0) = ? +++ exited with 0 +++
2019-11-17fix PTRAVE_EVENT_SECCOMP typo in ptrace.hJoris Vink
Hi, This diff fixes a typo in the PTRACE_EVENT_SECCOMP event code. The typo itself was introduced in 2012 when syncing with glibc header files and was itself fixed in 2013 in the glibc headers.
2019-11-08riscv64: implement NPTL/TLSWaldemar Brodkorb
basically from or1k port of uClibc-ng, with fixes for structures in pthreadtypes.h from 64 bit architectures. 18 testsuite failures counted.
2019-11-06riscv64: lazy relocations do not work like sparc/m68kWaldemar Brodkorb
2019-11-05implement fexecve from glibcWaldemar Brodkorb
2019-11-01riscv64: add shared library supportWaldemar Brodkorb
2019-10-30Make __syscall_error return long, as expected by syscall() callersCarlos Santos
The return type of syscall() is long so __syscall_error, which is jumped to by syscall handlers to stash an error number into errno, must return long too otherwhise it returs 4294967295L instead of -1L. For example, syscall for x86_64 is defined in libc/sysdeps/linux/x86_64/syscall.S as syscall: movq %rdi, %rax /* Syscall number -> rax. */ movq %rsi, %rdi /* shift arg1 - arg5. */ movq %rdx, %rsi movq %rcx, %rdx movq %r8, %r10 movq %r9, %r8 movq 8(%rsp),%r9 /* arg6 is on the stack. */ syscall /* Do the system call. */ cmpq $-4095, %rax /* Check %rax for error. */ jae __syscall_error /* Branch forward if it failed. */ ret /* Return to caller. */ In libc/sysdeps/linux/x86_64/__syscall_error.c, __syscall_error is defined as int __syscall_error(void) attribute_hidden; int __syscall_error(void) { register int err_no __asm__ ("%rcx"); __asm__ ("mov %rax, %rcx\n\t" "neg %rcx"); __set_errno(err_no); return -1; } So __syscall_error returns -1 as a 32-bit int in a 64-bit register, %rax (0x00000000ffffffff, whose decimal value is decimal 4294967295) and a test like this always returns false: if (syscall(number, ...) == -1) foo(); Fix the error by making __syscall_error return a long, like syscall(). The problem can be circumvented by the caller by coercing the returned value to int before comparing it to -1: if ((int) syscall(number, ...) == -1) foo(); The same problem probably occurs on other 64-bit systems but so far only x86_64 was tested, so this change must be considered experimental. Signed-off-by: Carlos Santos <unixmania@gmail.com>
2019-10-15Fix value for O_mask_was_saved based on gdb observationmirabilos
(gdb) print offsetof(struct __jmp_buf_tag, __mask_was_saved) $12 = (int *) 0x1f0 using https://stackoverflow.com/a/39663128/2171120
2019-10-15sparc64: Make structure match kernel uapimirabilos
Update from linux/arch/sparc/include/uapi/asm/uctx.h
2019-10-15sparc64: Use the jmpbuf-offsets.h header instead of duplicating itmirabilos
2019-10-10aarch64: sync with glibc code to see any differences in a better wayWaldemar Brodkorb
2019-10-05or1k: Fix compiling with PIC and latest binutils use PLT for __syscall_errorStafford Horne
This symbol was causing a build failure with the new toolchain. It looks like it has always been wrong. The main issue was checking for PIC rather than __PIC__. Remove all PSEUDO_* macros and ther SYSCALL_ERROR_NAME macro as they are not needed by uclibc-ng, they are used in glibc for building up syscalls there, but not here. Fixes error: /opt/shorne/software/or1k-linux/bin/../lib/gcc/or1k-linux/9.0.1/../../../../or1k-linux/bin/ld: libc/libc_so.a(or1k_clone.os): pc-relative relocation against dynamic symbol __syscall_error /opt/shorne/software/or1k-linux/bin/../lib/gcc/or1k-linux/9.0.1/../../../../or1k-linux/bin/ld: final link failed: bad value Signed-off-by: Stafford Horne <shorne@gmail.com>
2019-09-30PowerPC: Fix termios definitionsAdhemerval Zanella
This patch fixes the incorrect guard by __USE_MISC of struct winsize and struct termio in powerpc termios header. Current states leads to build failures if the program defines _XOPEN_SOURCE, but not _DEFAULT_SOURCE or either _BSD_SOURCE or _SVID_SOURCE. Without any definition, __USE_MISC will not be defined and neither the struct definitions. This patch copies the default Linux ioctl-types.h by adjusting only the character control field (c_cc) size in struct termio. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> [Vadim: adopted for uclibc ]
2019-07-05riscv: clear a3/a4 in crt1Christoph Hellwig
We don't support shared libraries and thus _init/_fini. But loading nommu binaries blows they aren't cleared, so do that. Signed-off-by: Christoph Hellwig <hch@lst.de>
2019-07-05riscv: add the MAP_UNINITIALIZED definitionChristoph Hellwig
This avoids a nommu build failure. Signed-off-by: Christoph Hellwig <hch@lst.de>
2019-05-27sparc: remove asm constraintRomain Naour
uClibc-ng don't build with gcc 9.1 [1] due to a new check that "catch illegal asm constraint usage" [2]. gcc 9.1 print this error: "invalid hard register usage between earlyclobber operand and input operand" The asm constraint is present in uClibc since it support sparc (back in 2002)[3]. Note: There is no such constraint is Glibc counterpart code [4]. [1] https://gitlab.com/kubu93/toolchains-builder/-/jobs/205435757 [2] https://github.com/gcc-mirror/gcc/commit/b782636f28f5c378897c238081d28d7a4a6ca578 [3] https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/commit/?id=3b6d086531102b6d09ce852feb1e370d5dca3ce9 [4] +https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/sparc/sysdep.h;h=981b2a26b7a91093f821c97876 +e55bc4be2d9f8a;hb=HEAD
2019-05-13preadv/pwritev: fix offset argument typeMax Filippov
preadv/pwritev don't provide separate version for 64-bit wide off_t, and default to 32-bit wide off_t, which results in a mismatch between declaration and definition for user programs built with -D_FILE_OFFSET_BITS=64. Make offset argument of both functions __off64_t. This fixes test misc/tst-preadvwritev on xtensa. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2018-12-14xtensa: add custom bits/poll.hMax Filippov
Definitions of POLLWRNORM, POLLWRBAND and POLLREMOVE in xtensa linux kernel are non-standard. Provide bits/poll.h with correct values for these constants. This fixes the following strace build errors: In file included from xlat/pollflags.h:4:0, from poll.c:34: ./static_assert.h:40:24: error: static assertion failed: "POLLWRBAND != 0x0100" # define static_assert _Static_assert ^ xlat/pollflags.h:75:1: note: in expansion of macro ‘static_assert’ static_assert((POLLWRBAND) == (0x0100), "POLLWRBAND != 0x0100"); ^~~~~~~~~~~~~ ./static_assert.h:40:24: error: static assertion failed: "POLLREMOVE != 0x0800" # define static_assert _Static_assert ^ xlat/pollflags.h:117:1: note: in expansion of macro ‘static_assert’ static_assert((POLLREMOVE) == (0x0800), "POLLREMOVE != 0x0800"); ^~~~~~~~~~~~~ Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2018-12-14several patches for uclibc nghan_mao@c-sky.com
I've got several patches to fix ltp/openmp/uclibc-ng-test testcase fail on c-sky. - fix a ltp testcase. - fix the problem that pthread creat will fail when libomp is linked before libc, the variable pagesize is not init. - fix tst-cancel4 and tst-cancel16. tst-cancelx4 and tst-cancelx16 still fail with this patch applied, cleanup handler is not called for open/creat/fcntl, seems some thing wrong with unwind, I haven't check the rootcause yet.
2018-11-27statfs.h: sync generic header with glibcWaldemar Brodkorb
Fix issues with aarch64 and df with mismatching header between kernel and libc.
2018-11-23Defined INLINE_SYSCALL_NOERR_NCS in mips/bits/syscalls.hVolodymyr Boyko
On Linux/MIPS (O32 ABI) for system call we have two result registers - v0 and a3. v0 contains actual syscall result on success or error number on fail, a3 set to 0/1 for indicating syscall success/fail. (if a3 == 1, v0 contains errno). Now as we can see from definition of handle_sys (arch/mips/kernel/scall32-o32.S), handler treats returned by syscall function (let's call "original") values in range [-EMAXERRNO; 0[ as -errno, a3 is set to 1 and final returned (to userspace) value is (-original). INLINE_SYSCALL_NOERR_NCS defined in mips/bits/syscalls.h will handle this behaviour. Signed-off-by: Volodymyr Boyko <boyko.cxx@gmail.com>
2018-11-01Add support for Thumb-only processors.Christophe Lyon
* ldso/ldso/arm/aeabi_read_tp.S: Add Thumb version. * ldso/ldso/arm/dl-startup.h: Do not force ARM encoding, adjust for Thumb. * ldso/ldso/arm/resolve.S: Force Thumb encoding on Thumb-only processors. * libc/sysdeps/linux/arm/crt1.S: Do not force ARM encoding, adjust for Thumb. Signed-off-by: Mickaël Guêné <mickael.guene@st.com> Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
2018-11-01time.h: Add CLOCK_TAIPetr Vorel
Added in kernel in kernel 3.10 in 1ff3c9677bff ("timekeeping: Add CLOCK_TAI clockid") NOTE: CLOCK_SGI_CYCLE was not added, as it has been lately removed. Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
2018-10-20do not expose recvmmsg/sendmmsg for unsupported kernelsWaldemar Brodkorb
2018-09-21bugfix renameat2 wrong implement.Guo Ren
Signed-off-by: Guo Ren <ren_guo@c-sky.com>
2018-08-16sched_setaffinity: use the same style with glibc'sGuo Ren
Call getpid() in INTERNAL_SYSCALL will break the argument regs, because gcc couldn't save destoryed regs for system call asm. Ref to glibc, we could just remove all the check code. Signed-off-by: Guo Ren <ren_guo@c-sky.com>
2018-08-10arm/clone.S: Fix threading supportChristophe Lyon
Change clone.S so that in FDPIC case we take into account the fact that we are given a function descriptor. * libc/sysdeps/linux/arm/clone.S (__clone): Support __FDPIC__. Signed-off-by: Mickaël Guêné <mickael.guene@st.com> Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
2018-08-10Add runtime support needed for C++ exceptionsChristophe Lyon
Implements __gnu_Unwind_Find_got(), which is called from libgcc while unwinding. * libc/sysdeps/linux/arm/Makefile.arch (CSRC): Add find._got.c. * libc/sysdeps/linux/arm/find_got.c: New file. Signed-off-by: Mickaël Guêné <mickael.guene@st.com> Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
2018-08-10Add application startup code for FDPICChristophe Lyon
* libc/sysdeps/linux/arm/crt1.S: Define _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: 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-06-10risc-v: initial 64 bit port, static only (no TLS/NPTL)Waldemar Brodkorb
Only a simple hello world is tested in qemu system emulation.
2018-04-17common/sendfile.c: bugfix can't support offset is NULLGuo Ren
In ltp testcase sendfile08.c, it use offset=NULL to test the api. PATCH V2: fixup the stupid missing check in the end. Sorry for lose test. See "man sendfile" and it really support offset is NULL. Signed-off-by: Guo Ren <ren_guo@c-sky.com>
2018-04-17Revert "common/sendfile.c: bugfix can't support offset is NULL"Waldemar Brodkorb
This reverts commit b00fd230ed0b49b9f23d829ad5d09859f34bb754.
2018-04-13lseek.c: bugfix ltp lseek01.cGuo Ren
Ref the implement from the glibc and high=0 seems so bad. Signed-off-by: Guo Ren <ren_guo@c-sky.com>
2018-04-13common/sendfile.c: bugfix can't support offset is NULLGuo Ren
In ltp testcase sendfile08.c, it use offset=NULL to test the api. See "man sendfile" and it really support offset is NULL. Signed-off-by: Guo Ren <ren_guo@c-sky.com>
2018-04-13or1k: add F_{DUPFD_CLOEXEC, SETPIPE_SZ, GETPIPE_SZ}Thomas Petazzoni
Those definitions exist on all other architectures, but were not present in or1k specific headers when or1k support was merged. On the kernel side, their support is completely architecture independent, so we just need those definitions to make those fcntl() calls available on or1k. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2018-04-02use __NR_newfstatat only for modern Linux architecturesWaldemar Brodkorb
Otherwise it breaks mips64 n64. Should be used for aarch64/tilegx only.
2018-03-22hppa: fix runtime issuesWaldemar Brodkorb
Sync clone()/vfork() with GNU C Library. Allow CFI and fix strsignal() / tcsetattr().
2018-03-15csky: support bsd-setjmp and bsd-_setjmp.Guo Ren
Signed-off-by: Guo Ren <ren_guo@c-sky.com>
2018-03-12tile: add basic support for tilegxWaldemar Brodkorb
This adds basic support for tile architecture. Only static binaries, no ld.so or threading support. Tested with qemu-tilegx only.
2018-03-09sparc32: Add nop before __startcontext to stop unwindingWaldemar Brodkorb
From glibc commit 9aa5c222b9e0409143410a02b6364a3b25dbf028 [BZ #22919]
2018-02-26stat.h: fix issue with aarch64Waldemar Brodkorb
2018-02-17bits/socket.h: add missing definesWaldemar Brodkorb
Newer iproute2 package make use of some of defines. Sync missing defines with GNU C library.
2018-02-12uClibc-ng does not implement name_to_handle_atAlexey Neyman
... so don't declare it. Otherwise, eudev finds it declared and tries to link with it - and fails. Signed-off-by: Alexey Neyman <stilor@att.net>
2018-02-04mman: disable memfd_create declarationWaldemar Brodkorb