[uclibc-ng-devel] [PATCH 32/32] [ARM] rtld: Avoid crash on R_ARM_NONE relocation

2018-07-04 Thread Christophe Lyon
R_ARM_NONE contains no data, so avoid dereferencing it. * ldso/ldso/arm/elfinterp.c (_dl_do_reloc): Handle R_ARM_NONE relocation (_dl_do_reloc_lazy): Likewise. Signed-off-by: Mickaël Guêné Signed-off-by: Christophe Lyon diff --git a/ldso/ldso/arm/elfinterp.c b/ldso/ldso

[uclibc-ng-devel] [PATCH 31/32] Fix shm_open posix compliance error code

2018-07-04 Thread Christophe Lyon
Handle EISDIR in shm_open like glibc does, and set EINVAL. * librt/shm.c (shm_open): Handle EISDIR error. Signed-off-by: Mickaël Guêné Signed-off-by: Christophe Lyon diff --git a/librt/shm.c b/librt/shm.c index 40e69fa..79c98a3 100644 --- a/librt/shm.c +++ b/librt/shm.c @@ -84,6 +84,9

[uclibc-ng-devel] [PATCH 30/32] mbtowc: Fix non compliant behavior for end of string

2018-07-04 Thread Christophe Lyon
Match glibc behavior. * libc/stdlib/stdlib.c (mbtowc): Fix end of string behavior. Signed-off-by: Mickaël Guêné Signed-off-by: Christophe Lyon diff --git a/libc/stdlib/stdlib.c b/libc/stdlib/stdlib.c index 075e6e5..f593663 100644 --- a/libc/stdlib/stdlib.c +++ b/libc/stdlib/stdlib.c @@

[uclibc-ng-devel] [PATCH 29/32] isnan: Add isnan weak alias to __isnan

2018-07-04 Thread Christophe Lyon
* libm/s_isnan.c: Add isnan weak alias. Signed-off-by: Mickaël Guêné Signed-off-by: Christophe Lyon diff --git a/libm/s_isnan.c b/libm/s_isnan.c index 1bc49cb..1aabb74 100644 --- a/libm/s_isnan.c +++ b/libm/s_isnan.c @@ -26,4 +26,5 @@ int __isnan(double x) hx = 0x7ff0 - hx;

[uclibc-ng-devel] [PATCH 28/32] Fix htab_delete loop counter

2018-07-04 Thread Christophe Lyon
dlclose can crash or stuck the system: When calling dlclose() then system can crash or freeze, because htab_delete() in ldso/ldso/fdpic/dl-inlines.h uses size_t for i which is a typedef to unsigned int. We exit the loop on negative value of i which can never occur since i is an unsigned int. This

[uclibc-ng-devel] [PATCH 26/32] [FDPIC] nptl: Replace sbrk with mmap

2018-07-04 Thread Christophe Lyon
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

[uclibc-ng-devel] [PATCH 27/32] nptl threads: Fix bug in using a weak variable.

2018-07-04 Thread 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. Signe

[uclibc-ng-devel] [PATCH 25/32] nptl: Clear TLS area for static binaries.

2018-07-04 Thread Christophe Lyon
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 p

[uclibc-ng-devel] [PATCH 24/32] [FDPIC] nptl: Use vfork on MMU-less for system()

2018-07-04 Thread Christophe Lyon
* libc/stdlib/system.c (FORK): Map to vfork if __ARCH_USE_MMU__ is defined. Signed-off-by: Mickaël Guêné Signed-off-by: Christophe Lyon diff --git a/libc/stdlib/system.c b/libc/stdlib/system.c index 771c30e..4c010bb 100644 --- a/libc/stdlib/system.c +++ b/libc/stdlib/system.c @@

[uclibc-ng-devel] [PATCH 22/32] [FDPIC] nptl: Allow sem_open to work on MMU-less systems

2018-07-04 Thread Christophe Lyon
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

[uclibc-ng-devel] [PATCH 23/32] [FDPIC] nptl: Add pthread_mutex_getprioceiling and pthread_mutex_setprioceiling support

2018-07-04 Thread Christophe Lyon
* libpthread/nptl/Makefile.in (libpthread-routines-): Remove pthread_mutex_getprioceiling.c and pthread_mutex_setprioceiling.c. Signed-off-by: Mickaël Guêné Signed-off-by: Christophe Lyon diff --git a/libpthread/nptl/Makefile.in b/libpthread/nptl/Makefile.in index a2f30ac..bd220

[uclibc-ng-devel] [PATCH 21/32] [ARM][FDPIC] nptl: Use linker-defined symbol to find start of .tdata section.

2018-07-04 Thread Christophe Lyon
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_t

[uclibc-ng-devel] [PATCH 20/32] [FDPIC] nptl: Do not use madvise

2018-07-04 Thread Christophe Lyon
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é Signed-off-by: Christophe Lyon diff --git a/libpthread/nptl/pthread_create.c b/

[uclibc-ng-devel] [PATCH 19/32] [FDPIC] nptl: Disable fork and atfork on MMU-less systems.

2018-07-04 Thread Christophe Lyon
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 (__l

[uclibc-ng-devel] [PATCH 18/32] [FDPIC] nptl: disable mprotect usage in stack protection

2018-07-04 Thread Christophe Lyon
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é Signed-off-b

[uclibc-ng-devel] [PATCH 16/32] [ARM][FDPIC] rtld: Use ELF_RTYPE_CLASS_DLSYM

2018-07-04 Thread Christophe Lyon
rtld must call _dl_find_hash() with ELF_RTYPE_CLASS_DLSYM since we want a function descriptor. * ldso/ldso/ldso.c (_dl_get_ready_to_run): Support __FDPIC__. Signed-off-by: Mickaël Guêné Signed-off-by: Christophe Lyon diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c index 06b0ac8..b3354

[uclibc-ng-devel] [PATCH 17/32] [FDPIC] rtld: Initialize _dl_error_catch_tsd without FUNCDESC relocation

2018-07-04 Thread Christophe Lyon
Make _dl_initial_error_catch_tsd hidden, such that we do not need a FUNCDESC relocation when initializing _dl_error_catch_tsd. * ldso/ldso/dl-tls.c (_dl_initial_error_catch_tsd): Declare hidden. Signed-off-by: Mickaël Guêné Signed-off-by: Christophe Lyon diff --git a/ldso/ldso/dl-tls.c

[uclibc-ng-devel] [PATCH 14/32] [ARM][FDPIC] arm/clone.S: Fix threading support

2018-07-04 Thread Christophe 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é Signed-off-by: Christophe Lyon diff --git a/libc/sysdeps/linux/arm/clone.S b/libc/sysd

[uclibc-ng-devel] [PATCH 15/32] [ARM][FDPIC] enable NPTL on TARGET_arm

2018-07-04 Thread Christophe Lyon
* extra/Configs/Config.in: enable UCLIBC_HAS_THREADS_NATIVE on TARGET_arm. Signed-off-by: Christophe Lyon diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in index 7443903..f96511f 100644 --- a/extra/Configs/Config.in +++ b/extra/Configs/Config.in @@ -541,7 +541,7 @@ c

[uclibc-ng-devel] [PATCH 13/32] [ARM][FDPIC] rtld: Compile with -fno-unwind-tables -fno-asynchronous-unwind-tables

2018-07-04 Thread Christophe Lyon
Otherwise we have link errors because of unresolved refs in libgcc.a: ld: /lib/gcc/arm-none-uclinuxfdpiceabi/9.0.0/libgcc.a(pr-support.o): in function `_Unwind_GetDataRelBase': /libgcc/config/arm/pr-support.c:378: undefined reference to `abort' ld: /lib/gcc/arm-none-uclinuxfdpiceabi/9.0.0/libgcc.

[uclibc-ng-devel] [PATCH 12/32] [ARM][FDPIC] TLS: fix relocation computation

2018-07-04 Thread Christophe Lyon
* ldso/ldso/dl-elf.c (_dl_load_elf_shared_library): Fix l_tls_initimage computation. * ldso/ldso/ldso.c (_dl_get_ready_to_run): Likewise. Signed-off-by: Mickaël Guêné Signed-off-by: Christophe Lyon diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c index 1768b5b..9cb46

[uclibc-ng-devel] [PATCH 10/32] [ARM][FDPIC] Allow to generate PIE 'static' binary

2018-07-04 Thread Christophe 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é Signed-off-by: Christophe Lyon diff --git a/libc/misc/internals/__uClibc_main.c

[uclibc-ng-devel] [PATCH 11/32] [ARM][FDPIC] rtld: Add lazy binding support

2018-07-04 Thread Christophe Lyon
Add support for R_ARM_FUNCDESC_VALUE and implement _dl_linux_resolver for FDPIC on ARM. * ldso/ldso/arm/elfinterp.c (_dl_linux_resolver): Support __FDPIC__. (_dl_do_lazy_reloc): Likewise. * ldso/ldso/arm/resolve.S (_dl_linux_resolve): Likewise. Signed-off-by: Mickaël Guêné

[uclibc-ng-devel] [PATCH 09/32] [ARM][FDPIC] Add runtime support needed for C++ exceptions

2018-07-04 Thread Christophe 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é Signed-off-by: Christophe Lyon diff --git a/libc/sysdeps/

[uclibc-ng-devel] [PATCH 07/32] [ARM] Fix bug in _dl_pread when using pread64 syscall

2018-07-04 Thread Christophe Lyon
In ARM_EABI mode, the pread64 syscall parameters are aligned on 64-bits. This syscall is used in rtld when processing FDPIC relocations. * ldso/include/dl-syscall.h (__syscall_pread): Fix definition. (__dl_pread): Fix syscall invocation. * ldso/ldso/fdpic/dl-sysdep.h (__DL_

[uclibc-ng-devel] [PATCH 08/32] [ARM][FDPIC] Add application startup code for FDPIC

2018-07-04 Thread Christophe Lyon
* libc/sysdeps/linux/arm/crt1.S: Define _start for __FDPIC__. Signed-off-by: Mickaël Guêné Signed-off-by: Christophe Lyon diff --git a/libc/sysdeps/linux/arm/crt1.S b/libc/sysdeps/linux/arm/crt1.S index ab3b0d2..f74cf3b 100644 --- a/libc/sysdeps/linux/arm/crt1.S +++ b/libc/sysdeps/linux

[uclibc-ng-devel] [PATCH 06/32] [ARM][FDPIC] rtld: Add startup code

2018-07-04 Thread Christophe Lyon
Implement _start: compute parameters for __self_reloc, and give control to the user program. * ldso/ldso/arm/dl-startup.h: Implement _start for __FDPIC__. Signed-off-by: Mickaël Guêné Signed-off-by: Christophe Lyon diff --git a/ldso/ldso/arm/dl-startup.h b/ldso/ldso/arm/dl-startup.h in

[uclibc-ng-devel] [PATCH 05/32] [ARM][FDPIC] rtld: Avoid FUNCDESC relocation on _start

2018-07-04 Thread Christophe Lyon
* ldso/ldso/ldso.c (_start): Fix definition for __FDPIC__. Signed-off-by: Mickaël Guêné Signed-off-by: Christophe Lyon diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c index 17818b5..c625757 100644 --- a/ldso/ldso/ldso.c +++ b/ldso/ldso/ldso.c @@ -109,7 +109,13 @@ static unsigned char *

[uclibc-ng-devel] [PATCH 04/32] [ARM][FDPIC] rtld: Add FDPIC code for arm

2018-07-04 Thread Christophe 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

[uclibc-ng-devel] [PATCH 03/32] [ARM][FDPIC] rtld: Add #if defined (__FDPIC__)

2018-07-04 Thread 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

[uclibc-ng-devel] [PATCH 01/32] [ARM][FDPIC] Allow to select FDPIC ELF for arm architecture

2018-07-04 Thread Christophe Lyon
* extra/Configs/Config.in.arch: Add TARGET_arm to the target list for UCLIBC_FORMAT_FDPIC_ELF. Signed-off-by: Mickaël Guêné Signed-off-by: Christophe Lyon diff --git a/extra/Configs/Config.in.arch b/extra/Configs/Config.in.arch index b51ed81..91b6394 100644 --- a/extra/Configs/C

[uclibc-ng-devel] [PATCH 02/32] [FDPIC] rtld: Do not protect RELRO segments when we don't use an MMU.

2018-07-04 Thread Christophe Lyon
Without MMU, we cannot mark memory regions as read-only. * ldso/ldso/dl-elf.c (_dl_protect_relro): Do nothing if __ARCH_USE_MMU__ is defined. Signed-off-by: Christophe Lyon diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c index d264e6a..1768b5b 100644 --- a/ldso/ldso

[uclibc-ng-devel] [PATCH 00/32] FDPIC ABI for ARM

2018-07-04 Thread Christophe Lyon
Hello, This patch series implements the uClibc-ng contribution of the FDPIC ABI for ARM targets. This ABI enables to run Linux on ARM MMU-less cores and supports shared libraries to reduce the memory footprint. Without MMU, text and data segments relative distances are different from one process