mbox series

[ARM/FDPIC,00/21] FDPIC ARM for ARM

Message ID 20180525080354.13295-1-christophe.lyon@st.com
Headers show
Series FDPIC ARM for ARM | expand

Message

Christophe Lyon May 25, 2018, 8:03 a.m. UTC
Hello,

This patch series implements the GCC 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.
The -mfdpic option is enabled by default, and -mno-fdpic should be
used to build the Linux kernel.

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]

To build such a toolchain, you'd also need to use my uClibc branch[6].

I am currently working on updating the patches for the remaining
toolchain components: uclibc and gdb.

This series provides support for ARM v7 architecture and has been
tested on arm-linux-gnueabi without regression, as well as
arm-uclinuxfdpiceabi, using QEMU. arm-uclinuxfdpiceabi has more
failures than arm-linux-gnueabi, but is quite functional.

GCC test results:
          arm-linux-gnueabi   arm-uclinuxfdpiceabi
GCC PASS      111743            105869
GCC FAIL          19                32
GCC XFAIL        298               296
GCC UNRES          9                11 
GCC UNSUPP      5843              5506
G++ PASS      115776            109442
G++ FAIL          14                14
G++ XFAIL        484               484
G++ UNRES          1                 1
G++ UNSUPP      5289              4954
LIBSTDC++ PASS 11378             11158
LIBSTDC++ FAIL    10                 8
LIBSTDC++ XPASS    0                 5
LIBSTDC++ XFAIL   71                81
LIBSTDC++ UNRES    2                 2
LIBSTDC++ UNSUPP 601               667

Are the GCC 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-libraries-for-cortex-m-cortex-r-mmuless-cores/
[3] https://github.com/mickael-guene/fdpic_manifest
[4] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=f1ac0afe481e83c9a33f247b81fa7de789edc4d9
[5] https://git.qemu.org/?p=qemu.git;a=commit;h=e8fa72957419c11984608062c7dcb204a6003a06
[6] https://git.linaro.org/people/christophe.lyon/uclibc.git/log/?h=uClibc-0.9.33.2-fdpic-upstream

Christophe Lyon (21):
  [ARM] FDPIC: Add -mfdpic option support
  [ARM] FDPIC: Handle arm*-*-uclinuxfdpiceabi in configure scripts
  [ARM] FDPIC: Force FDPIC related options unless -mno-fdpic is provided
  [ARM] FDPIC: Add support for FDPIC for arm architecture
  [ARM] FDPIC: Fix __do_global_dtors_aux and frame_dummy generation
  [ARM] FDPIC: Add support for c++ exceptions
  [ARM] FDPIC: Avoid saving/restoring r9 on stack since it is RO
  [ARM] FDPIC: Fix corner case of weak symbol
  [ARM] FDPIC: Add support for taking address of nested function
  [ARM] FDPIC: Implement legitimize_tls_address_fdpic
  [ARM] FDPIC: Add support to unwind FDPIC signal frame
  [ARM] FDPIC: Restore r9 after we call __aeabi_read_tp
  [ARM] FDPIC: Support unwinding across thumb2 signal trampoline
  [ARM] FDPIC: Force LSB bit for PC in Cortex-M architecture
  [ARM][testsuite] FDPIC: Skip unsupported tests
  [ARM][testsuite] FDPIC: Adjust scan-assembler patterns.
  [ARM][testsuite] FDPIC: Skip v8-m and v6-m tests that currently
    produce an ICE
  [ARM][testsuite] FDPIC: Skip tests that don't work in PIC mode
  [ARM][testsuite] FDPIC: Handle *-*-uclinux*
  [ARM][testsuite] FDPIC: Enable tests on pie_enabled targets
  [ARM][testsuite] FDPIC: Adjust pr43698.c to avoid clash with uclibc.

 config/futex.m4                                    |   2 +-
 config/tls.m4                                      |   2 +-
 gcc/config.gcc                                     |  13 +-
 gcc/config/arm/arm-c.c                             |   2 +
 gcc/config/arm/arm-protos.h                        |   1 +
 gcc/config/arm/arm.c                               | 510 +++++++++++++++++++--
 gcc/config/arm/arm.h                               |   6 +-
 gcc/config/arm/arm.md                              | 121 ++++-
 gcc/config/arm/arm.opt                             |   4 +
 gcc/config/arm/bpabi.h                             |   4 +-
 gcc/config/arm/linux-eabi.h                        |   7 +-
 gcc/config/arm/uclinuxfdpiceabi.h                  |  53 +++
 gcc/config/arm/unspecs.md                          |   1 +
 gcc/ginclude/unwind-arm-common.h                   |   2 +-
 gcc/testsuite/g++.dg/abi/forced.C                  |   2 +-
 gcc/testsuite/g++.dg/abi/guard2.C                  |   2 +-
 gcc/testsuite/g++.dg/cpp0x/noexcept03.C            |   2 +-
 gcc/testsuite/g++.dg/ext/cleanup-10.C              |   2 +-
 gcc/testsuite/g++.dg/ext/cleanup-11.C              |   2 +-
 gcc/testsuite/g++.dg/ext/cleanup-8.C               |   2 +-
 gcc/testsuite/g++.dg/ext/cleanup-9.C               |   2 +-
 gcc/testsuite/g++.dg/ext/sync-4.C                  |   2 +-
 gcc/testsuite/g++.dg/ipa/comdat.C                  |   2 +-
 gcc/testsuite/g++.dg/ipa/devirt-c-7.C              |   3 +-
 gcc/testsuite/g++.dg/ipa/ivinline-1.C              |   2 +-
 gcc/testsuite/g++.dg/ipa/ivinline-2.C              |   2 +-
 gcc/testsuite/g++.dg/ipa/ivinline-3.C              |   2 +-
 gcc/testsuite/g++.dg/ipa/ivinline-4.C              |   2 +-
 gcc/testsuite/g++.dg/ipa/ivinline-5.C              |   2 +-
 gcc/testsuite/g++.dg/ipa/ivinline-7.C              |   2 +-
 gcc/testsuite/g++.dg/ipa/ivinline-8.C              |   2 +-
 gcc/testsuite/g++.dg/ipa/ivinline-9.C              |   2 +-
 gcc/testsuite/g++.dg/other/anon5.C                 |   1 +
 gcc/testsuite/g++.dg/tls/pr79288.C                 |   2 +-
 gcc/testsuite/gcc.dg/20020312-2.c                  |   1 +
 gcc/testsuite/gcc.dg/20041106-1.c                  |   2 +-
 gcc/testsuite/gcc.dg/addr_equal-1.c                |   3 +-
 gcc/testsuite/gcc.dg/cleanup-10.c                  |   2 +-
 gcc/testsuite/gcc.dg/cleanup-11.c                  |   2 +-
 gcc/testsuite/gcc.dg/cleanup-8.c                   |   2 +-
 gcc/testsuite/gcc.dg/cleanup-9.c                   |   2 +-
 gcc/testsuite/gcc.dg/const-1.c                     |   2 +-
 gcc/testsuite/gcc.dg/fdata-sections-1.c            |   2 +-
 gcc/testsuite/gcc.dg/fdata-sections-2.c            |   2 +-
 gcc/testsuite/gcc.dg/ipa/pure-const-1.c            |   2 +-
 gcc/testsuite/gcc.dg/noreturn-8.c                  |   2 +-
 gcc/testsuite/gcc.dg/pr33826.c                     |   3 +-
 gcc/testsuite/gcc.dg/pr39323-1.c                   |   2 +-
 gcc/testsuite/gcc.dg/pr39323-2.c                   |   2 +-
 gcc/testsuite/gcc.dg/pr39323-3.c                   |   2 +-
 gcc/testsuite/gcc.dg/pr65780-1.c                   |   2 +-
 gcc/testsuite/gcc.dg/pr65780-2.c                   |   2 +-
 gcc/testsuite/gcc.dg/pr67338.c                     |   2 +-
 gcc/testsuite/gcc.dg/pr78185.c                     |   2 +-
 gcc/testsuite/gcc.dg/pr83100-1.c                   |   2 +-
 gcc/testsuite/gcc.dg/pr83100-4.c                   |   2 +-
 gcc/testsuite/gcc.dg/strlenopt-12g.c               |   2 +-
 gcc/testsuite/gcc.dg/strlenopt-14g.c               |   2 +-
 gcc/testsuite/gcc.dg/strlenopt-14gf.c              |   2 +-
 gcc/testsuite/gcc.dg/strlenopt-16g.c               |   2 +-
 gcc/testsuite/gcc.dg/strlenopt-17g.c               |   2 +-
 gcc/testsuite/gcc.dg/strlenopt-18g.c               |   2 +-
 gcc/testsuite/gcc.dg/strlenopt-1f.c                |   2 +-
 gcc/testsuite/gcc.dg/strlenopt-22g.c               |   2 +-
 gcc/testsuite/gcc.dg/strlenopt-2f.c                |   2 +-
 gcc/testsuite/gcc.dg/strlenopt-31g.c               |   2 +-
 gcc/testsuite/gcc.dg/strlenopt-33g.c               |   2 +-
 gcc/testsuite/gcc.dg/strlenopt-4g.c                |   2 +-
 gcc/testsuite/gcc.dg/strlenopt-4gf.c               |   2 +-
 gcc/testsuite/gcc.dg/strncmp-2.c                   |   2 +-
 gcc/testsuite/gcc.dg/struct-ret-3.c                |   2 +-
 gcc/testsuite/gcc.dg/torture/ipa-pta-1.c           |   2 +-
 gcc/testsuite/gcc.dg/torture/pr69760.c             |   2 +-
 gcc/testsuite/gcc.dg/tree-ssa/alias-2.c            |   2 +-
 gcc/testsuite/gcc.dg/tree-ssa/ipa-split-5.c        |   2 +-
 gcc/testsuite/gcc.dg/tree-ssa/loadpre6.c           |   2 +-
 gcc/testsuite/gcc.dg/uninit-19.c                   |   4 +-
 gcc/testsuite/gcc.target/arm/20051215-1.c          |   1 +
 .../arm/atomic-comp-swap-release-acquire-3.c       |   1 +
 gcc/testsuite/gcc.target/arm/atomic-op-acq_rel-3.c |   1 +
 gcc/testsuite/gcc.target/arm/atomic-op-acquire-3.c |   1 +
 gcc/testsuite/gcc.target/arm/atomic-op-char-3.c    |   1 +
 gcc/testsuite/gcc.target/arm/atomic-op-consume-3.c |   1 +
 gcc/testsuite/gcc.target/arm/atomic-op-int-3.c     |   1 +
 gcc/testsuite/gcc.target/arm/atomic-op-relaxed-3.c |   1 +
 gcc/testsuite/gcc.target/arm/atomic-op-release-3.c |   1 +
 gcc/testsuite/gcc.target/arm/atomic-op-seq_cst-3.c |   1 +
 gcc/testsuite/gcc.target/arm/atomic-op-short-3.c   |   1 +
 gcc/testsuite/gcc.target/arm/data-rel-2.c          |   1 +
 gcc/testsuite/gcc.target/arm/data-rel-3.c          |   1 +
 gcc/testsuite/gcc.target/arm/div64-unwinding.c     |   2 +-
 gcc/testsuite/gcc.target/arm/eliminate.c           |   2 +-
 gcc/testsuite/gcc.target/arm/interrupt-1.c         |   6 +-
 gcc/testsuite/gcc.target/arm/interrupt-2.c         |   6 +-
 gcc/testsuite/gcc.target/arm/ivopts-2.c            |   2 +-
 gcc/testsuite/gcc.target/arm/ivopts-3.c            |   2 +-
 gcc/testsuite/gcc.target/arm/ivopts-4.c            |   2 +-
 gcc/testsuite/gcc.target/arm/ivopts-5.c            |   2 +-
 gcc/testsuite/gcc.target/arm/mmx-1.c               |   1 +
 gcc/testsuite/gcc.target/arm/pr19599.c             |   1 +
 gcc/testsuite/gcc.target/arm/pr40887.c             |   1 +
 gcc/testsuite/gcc.target/arm/pr43597.c             |   2 +-
 gcc/testsuite/gcc.target/arm/pr43698.c             |   4 +-
 gcc/testsuite/gcc.target/arm/pr43920-2.c           |   2 +-
 gcc/testsuite/gcc.target/arm/pr45701-1.c           |   4 +-
 gcc/testsuite/gcc.target/arm/pr45701-2.c           |   4 +-
 gcc/testsuite/gcc.target/arm/pr61948.c             |   1 +
 gcc/testsuite/gcc.target/arm/pr65647.c             |   1 +
 gcc/testsuite/gcc.target/arm/pr66912.c             |   2 +-
 gcc/testsuite/gcc.target/arm/pr70830.c             |   3 +-
 gcc/testsuite/gcc.target/arm/pr77933-1.c           |   1 +
 gcc/testsuite/gcc.target/arm/pr77933-2.c           |   1 +
 gcc/testsuite/gcc.target/arm/sibcall-1.c           |   1 +
 gcc/testsuite/gcc.target/arm/stack-checking.c      |   2 +-
 gcc/testsuite/gcc.target/arm/stack-red-zone.c      |   2 +-
 gcc/testsuite/gcc.target/arm/synchronize.c         |   2 +-
 gcc/testsuite/gcc.target/arm/tail-long-call.c      |   1 +
 gcc/testsuite/gcc.target/arm/tlscall.c             |   1 +
 gcc/testsuite/gcc.target/arm/vfp-longcall-apcs.c   |   1 +
 gcc/testsuite/lib/target-supports.exp              |   4 +
 libatomic/configure                                |   8 +-
 libatomic/configure.tgt                            |   2 +-
 libgcc/config.host                                 |   4 +-
 libgcc/config/arm/linux-atomic.c                   |  86 ++++
 libgcc/config/arm/unwind-arm.c                     |   5 +
 libgcc/config/arm/unwind-arm.h                     |  26 +-
 libgcc/crtstuff.c                                  |  16 +
 libgcc/unwind-arm-common.inc                       | 215 +++++++++
 libgcc/unwind-pe.h                                 |  15 +
 libitm/configure                                   |  20 +-
 libitm/configure.tgt                               |   2 +-
 libsanitizer/configure.tgt                         |   3 +
 libstdc++-v3/acinclude.m4                          |  12 +-
 libstdc++-v3/configure                             |  36 +-
 libstdc++-v3/configure.host                        |   6 +-
 libstdc++-v3/libsupc++/eh_personality.cc           |   8 +-
 libtool.m4                                         |  14 +-
 137 files changed, 1227 insertions(+), 187 deletions(-)
 create mode 100644 gcc/config/arm/uclinuxfdpiceabi.h

-- 
2.6.3