Age | Commit message (Collapse) | Author |
|
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>
|
|
Thomas has repored failure building ARM 32-bit systems for ARMv8 cores
CC libpthread/linuxthreads/mutex.os
/tmp/ccn8SFKU.s: Assembler messages:
/tmp/ccn8SFKU.s:162: Error: swp{b} use is obsoleted for ARMv8 and later
/tmp/ccn8SFKU.s:186: Error: swp{b} use is obsoleted for ARMv8 and later
/tmp/ccn8SFKU.s:203: Error: swp{b} use is obsoleted for ARMv8 and later
/tmp/ccn8SFKU.s:224: Error: swp{b} use is obsoleted for ARMv8 and later
make[1]: *** [Makerules:369: libpthread/linuxthreads/mutex.os] Error 1
This is due to libpthread/linuxthreads/sysdeps/arm/pt-machine.h which
uses the swp instruction that is not allowed on ARMv8.
All __ARM_ARCH >= 7 support ldrex/strex instructions, so unlock
testandset() varaint for them.
Reported-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
|
|
O0 build result in the following codegen
00000000 <ldrex>:
0: b480 push {r7}
2: b085 sub sp, #20
4: af00 add r7, sp, #0
6: 6078 str r0, [r7, #4]
8: 687b ldr r3, [r7, #4]
a: e853 3f00 ldrex r3, [r3]
e: 60fb str r3, [r7, #12]
10: 68fb ldr r3, [r7, #12]
12: 4618 mov r0, r3
14: 3714 adds r7, #20
16: 46bd mov sp, r7
18: f85d 7b04 ldr.w r7, [sp], #4
1c: 4770 bx lr
0000001e <strex>:
1e: b480 push {r7}
20: b085 sub sp, #20
22: af00 add r7, sp, #0
24: 6078 str r0, [r7, #4]
26: 6039 str r1, [r7, #0]
28: 687b ldr r3, [r7, #4]
2a: 683a ldr r2, [r7, #0]
2c: e842 3300 strex r3, r3, [r2]
30: 60fb str r3, [r7, #12]
32: 68fb ldr r3, [r7, #12]
34: 4618 mov r0, r3
36: 3714 adds r7, #20
38: 46bd mov sp, r7
3a: f85d 7b04 ldr.w r7, [sp], #4
3e: 4770 bx lr
00000040 <testandset>:
40: b590 push {r4, r7, lr}
42: b083 sub sp, #12
44: af00 add r7, sp, #0
46: 6078 str r0, [r7, #4]
48: 6878 ldr r0, [r7, #4]
4a: f7ff fffe bl 0 <ldrex>
4e: 4603 mov r3, r0
50: 461c mov r4, r3
52: 6879 ldr r1, [r7, #4]
54: 2001 movs r0, #1
56: f7ff fffe bl 1e <strex>
5a: 4603 mov r3, r0
5c: 2b00 cmp r3, #0
5e: d1f3 bne.n 48 <testandset+0x8>
60: 4623 mov r3, r4
62: 4618 mov r0, r3
64: 370c adds r7, #12
66: 46bd mov sp, r7
68: bd90 pop {r4, r7, pc}
ARM ARM suggests that LoadExcl/StoreExcl loops are guaranteed to make
forward progress only if, for any LoadExcl/StoreExcl loop within a
single thread of execution, the software meets all of the following
conditions:
1 Between the Load-Exclusive and the Store-Exclusive, there are no
explicit memory accesses, preloads, direct or indirect System
register writes, address translation instructions, cache or TLB
maintenance instructions, exception generating instructions,
exception returns, or indirect branches.
...
Obviously condition is not met for O0 builds.
O2 build (which is highly likely the most common setting) able to do
the right thing resulting in
00000000 <ldrex>:
0: e850 0f00 ldrex r0, [r0]
4: 4770 bx lr
6: bf00 nop
00000008 <strex>:
8: e841 0000 strex r0, r0, [r1]
c: 4770 bx lr
e: bf00 nop
00000010 <testandset>:
10: 2101 movs r1, #1
12: 4603 mov r3, r0
14: e853 0f00 ldrex r0, [r3]
18: e843 1200 strex r2, r1, [r3]
1c: 2a00 cmp r2, #0
1e: d1f9 bne.n 14 <testandset+0x4>
20: 4770 bx lr
22: bf00 nop
Rather than depending on level of optimisation implement whole
ldrex/strex loop in inline assembly.
Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
|
|
Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
|
|
TLS)
Create timer thread with sufficiant stack size (take into account
allocated space for thread-local-storage), for this backport glibc
commit 'Create internal threads with sufficient stack size' ([1],
[2]) introducing __pthread_get_minstack() and use it in
__start_helper_thread().
Fixes timer_create() in case of linking with library using large
TLS area (e.g openblas, see [3]).
[1] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=2c1094bd700e63a8d7f547b3f5495bedb55c0a08
[2] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=630f4cc3aa019ede55976ea561f1a7af2f068639
[3] http://lists.busybox.net/pipermail/buildroot/2021-April/308281.html
Signed-off-by: Peter Seiderer <ps.report@gmx.net>
|
|
This commit adds support for Kalray VLIW family (kvx)
Kalray kv3 core is embedded in Kalray Coolidge SoC. This core which is the
third of the KV family has the following features:
32/64 bits execution mode
6-issue VLIW architecture
64 x 64bits general purpose registers
SIMD instructions
little-endian
In order to build a usable toolchain, build scripts are provided at the
following address: https://github.com/kalray/build-scripts.
Kalray uses FOSS which is available at https://github.com/kalray
This includes Linux kernel, uClibc-ng, gcc, binutils, etc.
Signed-off-by: Clément Léger <cleger@kalray.eu>
Signed-off-by: Guillaume Thouvenin <gthouvenin@kalray.eu>
Signed-off-by: Laurent Thevenoux <lthevenoux@kalray.eu>
Signed-off-by: Marc Poulhies <mpoulhies@kalray.eu>
Signed-off-by: Marius Gligor <mgligor@kalray.eu>
Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
|
|
Fixes this:
In file included from libpthread/nptl/pthread_create.c:48:0:
libpthread/nptl/allocatestack.c: In function 'allocate_stack':
libpthread/nptl/allocatestack.c:602:6: warning: label 'mprot_error' defined but not used [-Wunused-label]
mprot_error:
^~~~~~~~~~~
Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
|
|
This reverts commit 5b58a1ebd89a4f05778441814e81817c82193fa3.
This breaks all static builds earlier to gcc 10 :(
Bad testing on my side.
|
|
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.
|
|
Add XCHAL definitions for S32C1I and EXCLUSIVE options to
xtensa-config.h, include it in places that implement atomic operations
and add implementations with exclusive access option opcodes.
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
|
|
Replace "a" constraints with "+m" to avoid forcing atomic variable
address into a register and let the compiler use non-zero offset in
load/store opcodes.
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
|
|
Rename various spare fields in structs to include a namespace
This should avoid accidental clashes with uses of the __unused symbol
in upstream projects. eg currently it causes a compile error in dhcpcd 8.x
due to their re-use of the __unused symbol as a macro
This follows the style of glibc which does something equivalent
|
|
|
|
Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
|
|
basically from or1k port of uClibc-ng, with fixes for structures in
pthreadtypes.h from 64 bit architectures.
18 testsuite failures counted.
|
|
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>
|
|
This patch seems needed in builds where
- SHARED is not defined (no shared lib support)
- and USE_TLS is set
Without this patch, static_dtv is free'ed.
See the following backtrace:
0 __do_check_chunk (p=0x52638 <fork_handler_pool+2296>) at libc/stdlib/malloc-standard/malloc.c:80
1 0x0000000000017fa0 in __do_check_inuse_chunk (p=0x52638 <fork_handler_pool+2296>) at libc/stdlib/malloc-standard/malloc.c:143
2 0x0000000000017354 in free (mem=0x52648 <static_dtv>) at libc/stdlib/malloc-standard/free.c:293
3 0x000000000002d5b0 in _dl_deallocate_tls (tcb=0x58690, dealloc_tcb=false) at libpthread/nptl/sysdeps/generic/dl-tls.c:588
4 0x0000000000021c0c in __deallocate_stack (pd=0x58000) at libpthread/nptl/allocatestack.c:717
5 0x0000000000024408 in __free_tcb (pd=0x58000) at libpthread/nptl/pthread_create.c:217
6 0x00000000000200ac in pthread_join (threadid=360448, thread_return=0x0 <k1c_start>) at libpthread/nptl/pthread_join.c:109
7 0x0000000000010354 in tf (a=0x58000) at tst-basic3.c:42
8 0x00000000000247c8 in start_thread (arg=0x4000200960) at libpthread/nptl/pthread_create.c:285
9 0x0000000000026560 in ?? ()
This backtrace is obtained while debugging tst-basic3 from the uclibc-ng nptl testsuite.
It aborts because of the assert in malloc:
https://elixir.bootlin.com/uclibc-ng/v1.0.31/source/libc/stdlib/malloc-standard/malloc.c#L80
Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
|
|
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.
|
|
Replace sbrk with mmap since this commit disables sbrk area
for FDPIC MMU-less platform:
fs/binfmt_elf_fdpic.c: fix brk area overlap with stack on NOMMU
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/fs/binfmt_elf_fdpic.c?id=4ac313111018cb44ecc250445de5ccb93026a980
* libpthread/nptl/sysdeps/generic/libc-tls.c (__libc_setup_tls):
Handle __FDPIC__.
Signed-off-by: Mickaël Guêné <mickael.guene@st.com>
Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
|
|
busybox init checks it has pid 1, but getpid() returns another value
when building busybox statically. This is because the corresponding
area is not cleared when allocated (it is allocated with
MAP_UNINITIALIZED, whose behavior depends on the Linux kernel's
CONFIG_MMAP_ALLOW_UNINITIALIZED).
This patch fixes the problem by explicitly clearing the memory area.
* libpthread/nptl/sysdeps/generic/libc-tls.c (__libc_tls_setup):
Clear tlsblock.
Signed-off-by: Mickaël Guêné <mickael.guene@st.com>
Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
|
|
* libpthread/nptl/Makefile.in (libpthread-routines-): Remove
pthread_mutex_getprioceiling.c and pthread_mutex_setprioceiling.c.
Signed-off-by: Mickaël Guêné <mickael.guene@st.com>
Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
|
|
Allow both tmpfs and ramfs for shm devices.
* libpthread/nptl/linux_fsinfo.h (SHMFS_SUPER_MAGIC_WITH_MMU): Define.
(SHMFS_SUPER_MAGIC_WITHOUT_MMU): Define.
* libpthread/nptl/sem_open.c (__where_is_shmfs): Add support for
SHMFS_SUPER_MAGIC_WITHOUT_MMU.
Signed-off-by: Mickaël Guêné <mickael.guene@st.com>
Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
|
|
phdr->p_vaddr of TLS segment is not a valid value for FDPIC so we can
either translate phdr->p_vaddr using loadmap (not easy here) or use a
new linker script defined symbol, whih this patch does.
* libpthread/nptl/sysdeps/generic/libc-tls.c (__tdata_start): Declare.
(__libc_setup_tls): Support __FDPIC__.
Signed-off-by: Mickaël Guêné <mickael.guene@st.com>
Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
|
|
start_thread() uses it, but it is not supported on MMU-less systems.
* libpthread/nptl/pthread_create.c (start_thread): Call madvise
only if __ARCH_USE_MMU__ is defined.
Signed-off-by: Mickaël Guêné <mickael.guene@st.com>
Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
|
|
They do not work on MMU-less systems.
For atfork, implement a hidden function that always returns EPERM.
* libpthread/nptl/sysdeps/unix/sysv/linux/fork.c: Disable if
__ARCH_USE_MMU__ is not defined.
* libpthread/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c
(__libc_pthread_init): Handle __ARCH_USE_MMU__.
* libpthread/nptl/sysdeps/unix/sysv/linux/register-atfork.c: Likewise.
* libpthread/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c: Likewise.
Signed-off-by: Mickaël Guêné <mickael.guene@st.com>
Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
|
|
Since mprotect does not work on MMU-less systems, disable it if
__ARCH_USE_MMU__ is not defined.
* libpthread/nptl/allocatestack.c (change_stack_perm): Call
mprotect only if __ARCH_USE_MMU__ is defined.
(allocate_stack): Likewise.
Signed-off-by: Mickaël Guêné <mickael.guene@st.com>
Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
|
|
More applications are using pthread_condattr_setclock()/
pthread_condattr_getclock() in their code. Port these two
functions from NPTL over to be more compatible.
|
|
|
|
In libc/sysdeps/linux/common/bits/uClibc_pthread.h:
extern void weak_function _pthread_cleanup_push_defer(...)
This *weak_function* declaration will cause nptl/cleanup_defer_compat.c:
strong_alias (...) !!!FAIL!!!, because it include pthreadP.h->pthread.h
->uClibc_pthread.h
That means:
Readelf -s libpthread/nptl/cleanup_defer_compat.o you will get:
18: 00000000 198 FUNC WEAK DEFAULT 1 _pthread_cleanup_push_def
Readelf -s libc/misc/internals/__uClibc_main.o you will also get:
32: 00000038 58 FUNC WEAK DEFAULT 1 _pthread_cleanup_push_def
Final: gcc malloc_pthread_test.c -lpthread
The libc/stdlib/malloc-standard/malloc.c:839 (__MALLOC_LOCK->
_pthread_cleanup_push_def) will use the one in __uClibc_main.o
!!!not in cleanup_defer_compat.o!!!, becasue two cleanup_defer_compat in
libc.a with the same weak declarations and the __uClibc_main.o is close
to front.
====
All of malloc/free will failed in muti-threads' race conditions
probabilistic.
As it happens, uClibc-0.9.33.2 is OK, Becasue:
It's seperated in libpthread.a and libc.a, and the libc.a is the
last lib for ld internal-cmd, and malloc will get right cleanup_defer_compat
from libpthread.a.
This BUG is from 2016-09-24 to now:
>>>
commit 29ff9055c80efe77a7130767a9fcb3ab8c67e8ce
Author: Waldemar Brodkorb <wbx@uclibc-ng.org>
Date: Sat Sep 24 02:55:31 2016 +0200
use a single libc and deduplicate threading code
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
<<<
Perharps we need carefully check all of the impact about that commit.
Signed-off-by: Guo Ren <ren_guo@c-sky.com>
|
|
Only mips/x86/x86_64 needs a special version of lowlevellock.h.
No regressions found.
|
|
Newer binutils is creating a section INIT_ARRAY from any .init_array
and .ctors in the code. When ld.so runs initialization functions for
loaded objects with _dl_run_init_array() it crashes on Bfin FDPIC
system. It is trying to execute the function in pthread.c, which is
no longer useful with the combined C library approach.
Gcc -Wl,-M debugging output was very useful to find the reason for
the INIT_ARRAY section.
|
|
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.
|
|
Signed-off-by: Guo Ren <ren_guo@c-sky.com>
|
|
|
|
From or1k-glibc from blueCmd, his commit "Fix TLS, removed too much in
rebase".
Signed-off-by: Stafford Horne <shorne@gmail.com>
|
|
|
|
Fix iteration over signals, synced with GNU C library code and
pending patches. Issues found when running dhcpcd with hook
scripts. (exit status 127)
Reported-By: kapeka <kapeka@bering-uclibc.de>
|
|
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>
|
|
For noMMU targets we need a pthread_atfork dummy, otherwise
libraries like libressl using pthread_atfork, but not fork()
for itself, can not be used. But software like curl with
ssl support linking against libressl still work fine on noMMU
targets.
|
|
Signed-off-by: Stafford Horne <shorne@gmail.com>
|
|
Signed-off-by: Stafford Horne <shorne@gmail.com>
|
|
|
|
warning: unused variable 'self' [-Wunused-variable]
Signed-off-by: Guo Ren <ren_guo@c-sky.com>
|
|
The recvmmsg and sendmmsg is very important for UDP stream application.
If we only use recvmsg for UDP stream, it will only copy one mtu size
of data in a syscall. And recvmmsg copy as many as you want in a syscall.
So recvmmsg is more efficient,and some applications will depends on the
recvmmsg and sendmmsg, eg: UDP media stream player.
Signed-off-by: Guo Ren <ren_guo@c-sky.com>
|
|
Pthread pid caching was removed recently but an assert is still
present which checks pthread->pid, and this breaks the build when
debugging is enabled.
Reported-By: Bogdan Harjoc <harjoc@gmail.com>
|
|
GDB 8.0 is compiled and linked with g++, but the
linking of static targets (f.e. coldfire) fails,
without declaring the functions in thread_db.h
extern C.
The compilation of gdb errors out with:
thread-db.o: In function `thread_db_init()':
thread-db.c:(.text+0x5b6): undefined reference to `td_ta_new(ps_prochandle*, td_thragent**)'
thread-db.c:(.text+0x61e): undefined reference to `td_thr_get_info(td_thrhandle const*, td_thrinfo*)'
thread-db.c:(.text+0x632): undefined reference to `td_symbol_list()'
..
|
|
Similar to a changeset planned in GNU C library remove
any assembly code from sysdep-cancel.h. This allows
to port to new architectures in a simpler way.
|
|
|
|
Following glibc commit a358c805300e358e30d4788a6f19c69988623a5c
|
|
|