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 to another, hence the need for a dedicated FDPIC
register holding the start address of the data segment. One of the
side effects is that function pointers require two words to be
represented: the address of the code, and the data segment start
address. These two words are designated as "Function Descriptor",
hence the "FD PIC" name.
On ARM, the FDPIC register is r9 [1], and the target name is
arm-uclinuxfdpiceabi. Note that arm-uclinux exists, but uses another
ABI and the BFLAT file format; it does not support code sharing.
This work was developed some time ago by STMicroelectronics, and was
presented during Linaro Connect SFO15 (September 2015). You can watch
the discussion and read the slides [2].
This presentation was related to the toolchain published on github [3],
which is based on binutils-2.22, gcc-4.7, uclibc-0.9.33.2, gdb-7.5.1
and qemu-2.3.0, and for which pre-built binaries are available [3].
The ABI itself is described in details in [1].
Our Linux kernel patches have been updated and committed by Nicolas
Pitre (Linaro) in July 2017. They are required so that the loader is
able to handle this new file type. Indeed, the ELF files are tagged
with ELFOSABI_ARM_FDPIC. This new tag has been allocated by ARM, as
well as the new relocations involved.
The binutils and QEMU patch series have been merged recently. [4][5]
The GCC patch series has been submitted and is under discussion. [6]
This patch series consists in the original uClibc-based patches, which
I have rebased and updated for uClibc-ng. Most of them are strictly
related to FDPIC on ARM, while a few others address generic issues.
Are the uClibc-ng patches OK for inclusion in master?
Thanks,
Christophe.
[1]
https://github.com/mickael-guene/fdpic_doc/blob/master/abi.txt
[2]
http://connect.linaro.org/resource/sfo15/sfo15-406-arm-fdpic-toolset-kernel…
[3]
https://github.com/mickael-guene/fdpic_manifest
[4]
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=f1ac0af…
[5]
https://git.qemu.org/?p=qemu.git;a=commit;h=e8fa72957419c11984608062c7dcb20…
[6]
https://gcc.gnu.org/ml/gcc-patches/2018-05/msg01439.html
Christophe Lyon (32):
[ARM][FDPIC] Allow to select FDPIC ELF for arm architecture
[FDPIC] rtld: Do not protect RELRO segments when we don't use an MMU.
[ARM][FDPIC] rtld: Add #if defined (__FDPIC__)
[ARM][FDPIC] rtld: Add FDPIC code for arm
[ARM][FDPIC] rtld: Avoid FUNCDESC relocation on _start
[ARM][FDPIC] rtld: Add startup code
[ARM] Fix bug in _dl_pread when using pread64 syscall
[ARM][FDPIC] Add application startup code for FDPIC
[ARM][FDPIC] Add runtime support needed for C++ exceptions
[ARM][FDPIC] Allow to generate PIE 'static' binary
[ARM][FDPIC] rtld: Add lazy binding support
[ARM][FDPIC] TLS: fix relocation computation
[ARM][FDPIC] rtld: Compile with -fno-unwind-tables
-fno-asynchronous-unwind-tables
[ARM][FDPIC] arm/clone.S: Fix threading support
[ARM][FDPIC] enable NPTL on TARGET_arm
[ARM][FDPIC] rtld: Use ELF_RTYPE_CLASS_DLSYM
[FDPIC] rtld: Initialize _dl_error_catch_tsd without FUNCDESC
relocation
[FDPIC] nptl: disable mprotect usage in stack protection
[FDPIC] nptl: Disable fork and atfork on MMU-less systems.
[FDPIC] nptl: Do not use madvise
[ARM][FDPIC] nptl: Use linker-defined symbol to find start of .tdata
section.
[FDPIC] nptl: Allow sem_open to work on MMU-less systems
[FDPIC] nptl: Add pthread_mutex_getprioceiling and
pthread_mutex_setprioceiling support
[FDPIC] nptl: Use vfork on MMU-less for system()
nptl: Clear TLS area for static binaries.
[FDPIC] nptl: Replace sbrk with mmap
nptl threads: Fix bug in using a weak variable.
Fix htab_delete loop counter
isnan: Add isnan weak alias to __isnan
mbtowc: Fix non compliant behavior for end of string
Fix shm_open posix compliance error code
[ARM] rtld: Avoid crash on R_ARM_NONE relocation
extra/Configs/Config.in | 2 +-
extra/Configs/Config.in.arch | 2 +-
include/elf.h | 2 +
include/link.h | 6 +-
ldso/include/dl-elf.h | 2 +-
ldso/include/dl-hash.h | 2 +-
ldso/include/dl-string.h | 3 +-
ldso/include/dl-syscall.h | 13 +-
ldso/include/inline-hashtab.h | 2 +-
ldso/ldso/Makefile.in | 2 -
ldso/ldso/arm/dl-inlines.h | 1 +
ldso/ldso/arm/dl-startup.h | 112 +++++++++++++-
ldso/ldso/arm/dl-sysdep.h | 63 ++++++--
ldso/ldso/arm/elfinterp.c | 166 +++++++++++++++++----
ldso/ldso/arm/resolve.S | 23 +++
ldso/ldso/dl-elf.c | 6 +-
ldso/ldso/dl-hash.c | 4 +-
ldso/ldso/dl-tls.c | 1 +
ldso/ldso/fdpic/dl-inlines.h | 2 +
ldso/ldso/fdpic/dl-sysdep.h | 2 +-
ldso/ldso/ldso.c | 23 ++-
libc/misc/elf/dl-iterate-phdr.c | 2 +-
libc/misc/internals/__uClibc_main.c | 47 +++++-
libc/stdlib/stdlib.c | 6 +-
libc/stdlib/system.c | 5 +
libc/sysdeps/linux/arm/Makefile.arch | 2 +-
libc/sysdeps/linux/arm/bits/elf-fdpic.h | 114 ++++++++++++++
libc/sysdeps/linux/arm/clone.S | 12 ++
libc/sysdeps/linux/arm/crt1.S | 66 ++++++++
libc/sysdeps/linux/arm/crtreloc.c | 144 ++++++++++++++++++
libc/sysdeps/linux/arm/find_exidx.c | 38 +++++
libc/sysdeps/linux/arm/find_got.c | 72 +++++++++
libm/s_isnan.c | 1 +
libpthread/nptl/Makefile.in | 1 -
libpthread/nptl/allocatestack.c | 6 +
libpthread/nptl/linux_fsinfo.h | 5 +-
libpthread/nptl/pthread_create.c | 4 +
libpthread/nptl/sem_open.c | 8 +-
libpthread/nptl/sysdeps/generic/libc-tls.c | 27 +++-
libpthread/nptl/sysdeps/unix/sysv/linux/fork.c | 3 +
.../sysdeps/unix/sysv/linux/libc_pthread_init.c | 4 +
.../nptl/sysdeps/unix/sysv/linux/register-atfork.c | 14 +-
.../sysdeps/unix/sysv/linux/unregister-atfork.c | 10 +-
librt/shm.c | 3 +
44 files changed, 958 insertions(+), 75 deletions(-)
create mode 100644 ldso/ldso/arm/dl-inlines.h
create mode 100644 libc/sysdeps/linux/arm/bits/elf-fdpic.h
create mode 100644 libc/sysdeps/linux/arm/crtreloc.c
create mode 100644 libc/sysdeps/linux/arm/find_got.c
--
2.6.3