Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: Ben Wolsieffer <ben.wolsieffer@hefring.com>
Cc: Vladimir Murzin <vladimir.murzin@arm.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	buildroot@buildroot.org, Romain Naour <romain.naour@gmail.com>,
	Giulio Benetti <giulio.benetti@benettiengineering.com>,
	Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Subject: Re: [Buildroot] [PATCH v3 4/8] arch/arm: add support for FDPIC
Date: Sun, 16 Apr 2023 18:22:00 +0200	[thread overview]
Message-ID: <20230416162200.GC2819@scaer> (raw)
In-Reply-To: <20220819151734.926106-5-Ben.Wolsieffer@hefring.com>

Ben, All,

Sorry for the overly long delay, but as you can imagine, it is not
something that is trivial to review. Even so, here's an long overdue
review...

On 2022-08-19 11:17 -0400, Ben Wolsieffer spake thusly:
> Linux on ARM supports FDPIC binaries intended for use on no-MMU systems.
> This patch enables support for building a toolchain that produces FDPIC
> binaries.
> 
> The target name for an FDPIC toolchain must be
> arm-<vendor>-uclinuxfdpiceabi, which doesn't follow the standard format
> and requires a special case.
> 
> According to the kernel help for CONFIG_BINFMT_ELF_FDPIC, "It is also
> possible to run FDPIC ELF binaries on MMU linux," so FDPIC support is
> available on all ARM platforms, not just no-MMU.
> 
> Signed-off-by: Ben Wolsieffer <Ben.Wolsieffer@hefring.com>
> ---
>  arch/Config.in      | 1 +
>  package/Makefile.in | 6 ++++++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/arch/Config.in b/arch/Config.in
> index 4cd58041a4..c639738f5f 100644
> --- a/arch/Config.in
> +++ b/arch/Config.in
> @@ -39,6 +39,7 @@ config BR2_arceb
>  
>  config BR2_arm
>  	bool "ARM (little endian)"
> +	select BR2_ARCH_HAS_FDPIC_SUPPORT
>  	# MMU support is set by the subarchitecture file, arch/Config.in.arm
>  	help
>  	  ARM is a 32-bit reduced instruction set computer (RISC)
> diff --git a/package/Makefile.in b/package/Makefile.in
> index ff60f85092..81a7028275 100644
> --- a/package/Makefile.in
> +++ b/package/Makefile.in
> @@ -37,7 +37,13 @@ $(error BR2_TOOLCHAIN_BUILDROOT_VENDOR cannot be 'unknown'. \
>  endif
>  
>  # Compute GNU_TARGET_NAME
> +# FDPIC on ARM requires a special target name: it has no OS field and must
> +# use the suffix -uclinuxfdpiceabi.
> +ifeq ($(BR2_arm)$(BR2_armeb):$(BR2_BINFMT_FDPIC),y:y)
> +GNU_TARGET_NAME = $(ARCH)-$(TARGET_VENDOR)-uclinuxfdpiceabi

This looks weird: it looks like they coalesced OS and ABI, and dropped
the LIBC part...

> +else
>  GNU_TARGET_NAME = $(ARCH)-$(TARGET_VENDOR)-$(TARGET_OS)-$(LIBC)$(ABI)
> +endif

I am not too fond of this special casing. What about something along the
lines of (existing comments stripped):

    TARGET_NAME = $(ARCH)-$(TARGET_VENDOR)-$(TARGET_OS)$(LIBC)$(ABI)))
    # Note no dash between OS and LIBC  --------------^^

    ifeq ($(BR2_arm)$(BR2_armeb)$(BR2_BINFMT_FDPIC),yy)
    # For ARM FDPIC, there is no separation between OS and ABI
    TARGET_OS = uclinux
    else ifeq ($(BR2_BINFMT_FLAT):$(BR2_RISCV_64),y:)
    TARGET_OS = uclinux-
    else
    TARGET_OS = linux-
    endif

    ifeq ($(BR2_TOOLCHAIN_USES_UCLIBC),y)
    # For ARM FDPIC, there's no LIBC part
    ifneq ($(BR2_arm)$(BR2_armeb)$(BR2_BINFMT_FDPIC),yy)
    LIBC = uclibc
    endif
    else ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
    LIBC = musl
    else ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y)
    LIBC = gnu
    else ifeq ($(BR_BUILDING),y)
    $(error No C library enabled, this is not possible.)
    endif

    ifeq ($(BR2_arm)$(BR2_armeb),y)
    ifeq ($(LIBC),uclibc)
    ABI = $(if $(BR2_BINFMT_FDPIC),fdpic,gnu)eabi
    else
    ABI = eabi
    endif

    ifeq ($(BR2_ARM_EABIHF),y)
    # FDPIC is always HF, so don't append the hf suffix (FIXME!)
    ABI := $(ABI)$(if $(BR2_BINFMT_FDPIC),,hf)
    endif
    endif

Note that this is not perfect, as there are a few assumptions hard-coded
in there, but I'm afraid we can't do much much better...

Note that I have no idea about the HF part, so I wrote something for
illustration purposes only...

Regards,
Yann E. MORIN.

>  # FLAT binary format needs uclinux, except RISC-V 64-bits which needs
>  # the regular linux name.
> -- 
> 2.37.0
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  reply	other threads:[~2023-04-16 16:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-19 15:17 [Buildroot] [PATCH v3 0/8] Add support for FDPIC binaries on ARM Ben Wolsieffer
2022-08-19 15:17 ` [Buildroot] [PATCH v3 1/8] Revert "arch: drop now useless support for FDPIC" Ben Wolsieffer
2022-08-19 15:17 ` [Buildroot] [PATCH v3 2/8] arch: don't enable FDPIC binaries by default Ben Wolsieffer
2022-08-19 15:17 ` [Buildroot] [PATCH v3 3/8] arch: make FDPIC dependent on toolchain support Ben Wolsieffer
2022-08-19 15:17 ` [Buildroot] [PATCH v3 4/8] arch/arm: add support for FDPIC Ben Wolsieffer
2023-04-16 16:22   ` Yann E. MORIN [this message]
2022-08-19 15:17 ` [Buildroot] [PATCH v3 5/8] boot/uboot: pass -mno-fdpic if FDPIC is enabled Ben Wolsieffer
2023-09-30 20:36   ` Thomas Petazzoni via buildroot
2022-08-19 15:17 ` [Buildroot] [PATCH v3 6/8] linux: " Ben Wolsieffer
2022-08-19 15:17 ` [Buildroot] [PATCH v3 7/8] package/uclibc: enable NPTL on no-MMU ARM w/ FDPIC Ben Wolsieffer
2022-08-19 15:17 ` [Buildroot] [PATCH v3 8/8] package/pkg-autotools: patch libtool to support ARM FDPIC Ben Wolsieffer
2023-04-16 19:01   ` Yann E. MORIN
2022-08-22  9:52 ` [Buildroot] [PATCH v3 0/8] Add support for FDPIC binaries on ARM Waldemar Brodkorb
2022-08-26  3:22   ` Ben Wolsieffer
2022-09-22 13:18 ` Waldemar Brodkorb
2023-09-30 20:12 ` Thomas Petazzoni via buildroot
2023-10-02 14:18   ` Ben Wolsieffer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230416162200.GC2819@scaer \
    --to=yann.morin.1998@free.fr \
    --cc=ben.wolsieffer@hefring.com \
    --cc=buildroot@buildroot.org \
    --cc=giulio.benetti@benettiengineering.com \
    --cc=romain.naour@gmail.com \
    --cc=thomas.de_schampheleire@nokia.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=vladimir.murzin@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox