* [BOOT-WRAPPER 0/3] Allow use of bare-metal toolchains
@ 2024-07-29 14:31 Mark Rutland
2024-07-29 14:31 ` [BOOT-WRAPPER 1/3] Makefile: rework test-dtc-option Mark Rutland
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Mark Rutland @ 2024-07-29 14:31 UTC (permalink / raw)
To: linux-arm-kernel
Cc: akos.denke, andre.przywara, luca.fancellu, mark.rutland, maz
Since the boot-wrapper build system was migrated to autoconf it hasn't
been possible to build the boot-wrapper with a bare-metal toolchain,
since the configure sscript checks for a hosted toolchain.
These patches make it possible to build the boot-wrapper with a
bare-metal toolchain.
Mark.
Mark Rutland (3):
Makefile: rework test-dtc-option
Makefile: suppress RWX segment warnings
configure: allow the use of bare-metal toolchains
Makefile.am | 20 +++++++++++++++-----
configure.ac | 3 +++
2 files changed, 18 insertions(+), 5 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [BOOT-WRAPPER 1/3] Makefile: rework test-dtc-option
2024-07-29 14:31 [BOOT-WRAPPER 0/3] Allow use of bare-metal toolchains Mark Rutland
@ 2024-07-29 14:31 ` Mark Rutland
2024-07-29 14:31 ` [BOOT-WRAPPER 2/3] Makefile: suppress RWX segment warnings Mark Rutland
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Mark Rutland @ 2024-07-29 14:31 UTC (permalink / raw)
To: linux-arm-kernel
Cc: akos.denke, andre.przywara, luca.fancellu, mark.rutland, maz
Currently we have the test-dtc-option helepr to check whether dtc
supports an option. In subsequent patches we'll want similar for ld, and
it seems likely that we'll want this for other commands in future.
This patch adds a new test-cmd helper that can be used to check whether
a command succeeds (based on its return value), and can be used to
choose between a value if the comand succeeds and a value if the command
fails.
The existing test-dtc-option helper is reworked to use test-cmd. The
helpers are added near the start of the file so that they'll be defined
prior to usage whetever they're used within the file. This is purely for
human comprehension as Make itself does not care about their location
within the Makefile.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Andre Przywara <andre.przywara@arm.com>
Cc: Akos Denke <akos.denke@arm.com>
Cc: Luca Fancellu <luca.fancellu@arm.com>
Cc: Marc Zyngier <maz@kernel.org>
---
Makefile.am | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 6ebece2..6ab5cfd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,6 +9,16 @@
SCRIPT_DIR := $(top_srcdir)/scripts
+# test-cmd cmd,val-if-success,val-if-success,val-if-failure
+define test-cmd
+$(if $(shell { $(1); } >/dev/null 2>&1 && echo "success"),$(2),$(3))
+endef
+
+# Run dtc with an given command line option to check support for it.
+define test-dtc-option
+$(call test-cmd,echo "/dts-v1/;/{};" | $(DTC) $(1) -o /dev/null,$(1),)
+endef
+
# VE
PHYS_OFFSET := $(shell perl -I $(SCRIPT_DIR) $(SCRIPT_DIR)/findmem.pl $(KERNEL_DTB))
UART_BASE := $(shell perl -I $(SCRIPT_DIR) $(SCRIPT_DIR)/findbase.pl $(KERNEL_DTB) 0 'arm,pl011')
@@ -162,11 +172,6 @@ $(COMMON_SRC):
model.lds: $(LD_SCRIPT) Makefile
$(CPP) $(CPPFLAGS) -ansi -DPHYS_OFFSET=$(PHYS_OFFSET) -DMBOX_OFFSET=$(MBOX_OFFSET) -DKERNEL_OFFSET=$(KERNEL_OFFSET) -DFDT_OFFSET=$(FDT_OFFSET) -DFS_OFFSET=$(FS_OFFSET) $(XEN) -DXEN_OFFSET=$(XEN_OFFSET) -DKERNEL=$(KERNEL_IMAGE) -DFILESYSTEM=$(FILESYSTEM) -DTEXT_LIMIT=$(TEXT_LIMIT) -P -C -o $@ $<
-# Run dtc with an given command line option to check support for it.
-define test-dtc-option
-$(if $(shell echo "/dts-v1/;/{};" | $(DTC) $(1) -o /dev/null 2>&1),,$(1))
-endef
-
DTC_NOWARN = $(call test-dtc-option,-Wno-clocks_property)
DTC_NOWARN += $(call test-dtc-option,-Wno-gpios_property)
--
2.30.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [BOOT-WRAPPER 2/3] Makefile: suppress RWX segment warnings
2024-07-29 14:31 [BOOT-WRAPPER 0/3] Allow use of bare-metal toolchains Mark Rutland
2024-07-29 14:31 ` [BOOT-WRAPPER 1/3] Makefile: rework test-dtc-option Mark Rutland
@ 2024-07-29 14:31 ` Mark Rutland
2024-07-29 14:31 ` [BOOT-WRAPPER 3/3] configure: allow the use of bare-metal toolchains Mark Rutland
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Mark Rutland @ 2024-07-29 14:31 UTC (permalink / raw)
To: linux-arm-kernel
Cc: akos.denke, andre.przywara, luca.fancellu, mark.rutland, maz
Contemporary versions of GNU LD warn about segments with RWX
permissions, which can occur when building the boot-wrapper, e.g.
| aarch64-linux-ld: warning: linux-system.axf has a LOAD segment with RWX permissions
This is due to sections with RW- and R-X being adjacent, and getting combined
into a single segment with RWX permissions:
| [mark@lakrids:~/src/boot-wrapper-aarch64]% readelf -l linux-system.axf
|
| Elf file type is EXEC (Executable file)
| Entry point 0x80000000
| There are 4 program headers, starting at offset 64
|
| Program Headers:
| Type Offset VirtAddr PhysAddr
| FileSiz MemSiz Flags Align
| LOAD 0x0000000000010000 0x0000000080000000 0x0000000080000000
| 0x0000000000010000 0x0000000000010000 RWE 0x10000
| LOAD 0x0000000000020000 0x0000000080200000 0x0000000080200000
| 0x000000000331b200 0x000000000331b200 RW 0x10000
| LOAD 0x0000000003340000 0x0000000088000000 0x0000000088000000
| 0x0000000000002e05 0x0000000000002e05 RW 0x10000
| GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
| 0x0000000000000000 0x0000000000000000 RW 0x10
|
| Section to Segment mapping:
| Segment Sections...
| 00 .boot .mbox
| 01 .kernel
| 02 .dtb
| 03
Since the bootwrapper runs with the MMU off, the RWX permissions aren't
a problem, and the simplest solution is to suppress the warning with the
'--no-warn-rwx-segments' option to LD.
Add the necessary logic to suprress the warning when supported by LD.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Andre Przywara <andre.przywara@arm.com>
Cc: Akos Denke <akos.denke@arm.com>
Cc: Luca Fancellu <luca.fancellu@arm.com>
Cc: Marc Zyngier <maz@kernel.org>
---
Makefile.am | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Makefile.am b/Makefile.am
index 6ab5cfd..6ee6afa 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,6 +19,10 @@ define test-dtc-option
$(call test-cmd,echo "/dts-v1/;/{};" | $(DTC) $(1) -o /dev/null,$(1),)
endef
+define test-ld-option
+$(call test-cmd,$(LD) $(1) --help,$(1),)
+endef
+
# VE
PHYS_OFFSET := $(shell perl -I $(SCRIPT_DIR) $(SCRIPT_DIR)/findmem.pl $(KERNEL_DTB))
UART_BASE := $(shell perl -I $(SCRIPT_DIR) $(SCRIPT_DIR)/findbase.pl $(KERNEL_DTB) 0 'arm,pl011')
@@ -141,6 +145,7 @@ CFLAGS += -fno-stack-protector
CFLAGS += -ffunction-sections -fdata-sections
CFLAGS += -fno-pic -fno-pie
LDFLAGS += --gc-sections
+LDFLAGS += $(call test-ld-option,--no-warn-rwx-segments)
OBJ := $(addprefix $(ARCH_SRC),$(ARCH_OBJ)) $(addprefix $(COMMON_SRC),$(COMMON_OBJ))
--
2.30.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [BOOT-WRAPPER 3/3] configure: allow the use of bare-metal toolchains
2024-07-29 14:31 [BOOT-WRAPPER 0/3] Allow use of bare-metal toolchains Mark Rutland
2024-07-29 14:31 ` [BOOT-WRAPPER 1/3] Makefile: rework test-dtc-option Mark Rutland
2024-07-29 14:31 ` [BOOT-WRAPPER 2/3] Makefile: suppress RWX segment warnings Mark Rutland
@ 2024-07-29 14:31 ` Mark Rutland
2024-08-02 9:21 ` [BOOT-WRAPPER 0/3] Allow " Marc Zyngier
2024-08-02 10:10 ` Mark Rutland
4 siblings, 0 replies; 6+ messages in thread
From: Mark Rutland @ 2024-07-29 14:31 UTC (permalink / raw)
To: linux-arm-kernel
Cc: akos.denke, andre.przywara, luca.fancellu, mark.rutland, maz
Currently it is not possible to build the boot-wrapper with a bare-metal
toolchain, as the configure script tries to build a hosted object. For
example, trying to build with the bare-metal aarch64-linux GCC 13.2.0
toolchain from kernel.org fails with:
| [mark@lakrids:~/src/boot-wrapper-aarch64]% usekorg 13.2.0 ./configure --enable-gicv3 --host=aarch64-linux --with-kernel-dir=../linux --with-cmdline="console=ttyAMA0 earlycon=pl011,0x1c090000 root=/dev/vda kvm_arm.mode=vhe"
| checking for a BSD-compatible install... /usr/bin/install -c
| checking whether build environment is sane... yes
| checking for aarch64-linux-strip... aarch64-linux-strip
| checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
| checking for gawk... gawk
| checking whether make sets $(MAKE)... yes
| checking whether make supports nested variables... yes
| checking whether DTB file exists... yes
| checking whether kernel image exists... yes
| checking for aarch64-linux-gcc... aarch64-linux-gcc
| checking whether the C compiler works... no
| configure: error: in `/home/mark/src/boot-wrapper-aarch64':
| configure: error: C compiler cannot create executables
| See `config.log' for more details
This behaviour was an unintentional side-effect of moving to autotools
in commit:
bae4ae6a834cd15b ("Add autotools configuration.")
... as the default CFLAGS end up trying to build a hosted object.
Pass the necessary CFLAGS to build a bare-metal object. matching what we
do in Makefile.am, so that the configure script doesn't reject
bare-metal toolchains.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Andre Przywara <andre.przywara@arm.com>
Cc: Akos Denke <akos.denke@arm.com>
Cc: Luca Fancellu <luca.fancellu@arm.com>
Cc: Marc Zyngier <maz@kernel.org>
---
configure.ac | 3 +++
1 file changed, 3 insertions(+)
diff --git a/configure.ac b/configure.ac
index ce41dae..1f2f4f6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -128,6 +128,9 @@ AC_ARG_ENABLE([gicv3],
AM_CONDITIONAL([GICV3], [test "x$USE_GICV3" = "xyes"])
AS_IF([test "x$USE_GICV3" = "xyes"], [], [USE_GICV3=no])
+# Ensure AC_PROG_CC tries to build a bare-metal object
+CFLAGS="${CFLAGS} -ffreestanding -nostdlib"
+
# Ensure that we have all the needed programs
AC_PROG_CC
AC_PROG_CPP
--
2.30.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [BOOT-WRAPPER 0/3] Allow use of bare-metal toolchains
2024-07-29 14:31 [BOOT-WRAPPER 0/3] Allow use of bare-metal toolchains Mark Rutland
` (2 preceding siblings ...)
2024-07-29 14:31 ` [BOOT-WRAPPER 3/3] configure: allow the use of bare-metal toolchains Mark Rutland
@ 2024-08-02 9:21 ` Marc Zyngier
2024-08-02 10:10 ` Mark Rutland
4 siblings, 0 replies; 6+ messages in thread
From: Marc Zyngier @ 2024-08-02 9:21 UTC (permalink / raw)
To: Mark Rutland; +Cc: linux-arm-kernel, akos.denke, andre.przywara, luca.fancellu
On Mon, 29 Jul 2024 15:31:13 +0100,
Mark Rutland <mark.rutland@arm.com> wrote:
>
> Since the boot-wrapper build system was migrated to autoconf it hasn't
> been possible to build the boot-wrapper with a bare-metal toolchain,
> since the configure sscript checks for a hosted toolchain.
>
> These patches make it possible to build the boot-wrapper with a
> bare-metal toolchain.
>
> Mark.
>
> Mark Rutland (3):
> Makefile: rework test-dtc-option
> Makefile: suppress RWX segment warnings
> configure: allow the use of bare-metal toolchains
>
> Makefile.am | 20 +++++++++++++++-----
> configure.ac | 3 +++
> 2 files changed, 18 insertions(+), 5 deletions(-)
All looks reasonable to me.
Acked-by: Marc Zyngier <maz@kernel.org>
M.
--
Without deviation from the norm, progress is not possible.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [BOOT-WRAPPER 0/3] Allow use of bare-metal toolchains
2024-07-29 14:31 [BOOT-WRAPPER 0/3] Allow use of bare-metal toolchains Mark Rutland
` (3 preceding siblings ...)
2024-08-02 9:21 ` [BOOT-WRAPPER 0/3] Allow " Marc Zyngier
@ 2024-08-02 10:10 ` Mark Rutland
4 siblings, 0 replies; 6+ messages in thread
From: Mark Rutland @ 2024-08-02 10:10 UTC (permalink / raw)
To: linux-arm-kernel; +Cc: akos.denke, andre.przywara, luca.fancellu, maz
On Mon, Jul 29, 2024 at 03:31:13PM +0100, Mark Rutland wrote:
> Since the boot-wrapper build system was migrated to autoconf it hasn't
> been possible to build the boot-wrapper with a bare-metal toolchain,
> since the configure sscript checks for a hosted toolchain.
>
> These patches make it possible to build the boot-wrapper with a
> bare-metal toolchain.
>
> Mark.
>
> Mark Rutland (3):
> Makefile: rework test-dtc-option
> Makefile: suppress RWX segment warnings
> configure: allow the use of bare-metal toolchains
>
> Makefile.am | 20 +++++++++++++++-----
> configure.ac | 3 +++
> 2 files changed, 18 insertions(+), 5 deletions(-)
I've applied this series to the boot-wrapper-aarch64 master branch:
https://git.kernel.org/pub/scm/linux/kernel/git/mark/boot-wrapper-aarch64.git/commit/?id=1fea854771f9aee405c4ae204c0e0f912318da6f
Mark.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-08-02 10:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-29 14:31 [BOOT-WRAPPER 0/3] Allow use of bare-metal toolchains Mark Rutland
2024-07-29 14:31 ` [BOOT-WRAPPER 1/3] Makefile: rework test-dtc-option Mark Rutland
2024-07-29 14:31 ` [BOOT-WRAPPER 2/3] Makefile: suppress RWX segment warnings Mark Rutland
2024-07-29 14:31 ` [BOOT-WRAPPER 3/3] configure: allow the use of bare-metal toolchains Mark Rutland
2024-08-02 9:21 ` [BOOT-WRAPPER 0/3] Allow " Marc Zyngier
2024-08-02 10:10 ` Mark Rutland
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox