From 2061d658b3d199ec84976e6a573f68424369be69 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 22 Jan 2023 16:54:20 +0000 Subject: [dhcp] Simplify platform-specific client architecture definitions Move the platform-specific DHCP client architecture definitions to header files of the form . This simplifies the directory structure and allows the otherwise unused arch/$(ARCH)/include/$(PLATFORM) to be removed from the include directory search path, which avoids the confusing situation in which a header file may potentially be accessed through more than one path. For Linux userspace binaries on any architecture, use the EFI values for that architecture by delegating to the EFI header file. This avoids the need to explicitly select values for Linux userspace binaries for each architecture. Signed-off-by: Michael Brown --- src/arch/arm32/include/efi/ipxe/dhcp_arch.h | 40 ----------------------------- src/arch/arm32/include/ipxe/efi/dhcparch.h | 20 +++++++++++++++ 2 files changed, 20 insertions(+), 40 deletions(-) delete mode 100644 src/arch/arm32/include/efi/ipxe/dhcp_arch.h create mode 100644 src/arch/arm32/include/ipxe/efi/dhcparch.h (limited to 'src/arch/arm32') diff --git a/src/arch/arm32/include/efi/ipxe/dhcp_arch.h b/src/arch/arm32/include/efi/ipxe/dhcp_arch.h deleted file mode 100644 index 29a235944..000000000 --- a/src/arch/arm32/include/efi/ipxe/dhcp_arch.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2015 Michael Brown . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - * - * You can also choose to distribute this program under the terms of - * the Unmodified Binary Distribution Licence (as given in the file - * COPYING.UBDL), provided that you have satisfied its requirements. - */ - -#ifndef _DHCP_ARCH_H -#define _DHCP_ARCH_H - -/** @file - * - * Architecture-specific DHCP options - */ - -FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); - -#include - -#define DHCP_ARCH_CLIENT_ARCHITECTURE DHCP_CLIENT_ARCHITECTURE_ARM32 - -#define DHCP_ARCH_CLIENT_NDI 1 /* UNDI */ , 3, 10 /* v3.10 */ - -#endif diff --git a/src/arch/arm32/include/ipxe/efi/dhcparch.h b/src/arch/arm32/include/ipxe/efi/dhcparch.h new file mode 100644 index 000000000..0b669992c --- /dev/null +++ b/src/arch/arm32/include/ipxe/efi/dhcparch.h @@ -0,0 +1,20 @@ +#ifndef _IPXE_EFI_DHCPARCH_H +#define _IPXE_EFI_DHCPARCH_H + +/** @file + * + * DHCP client architecture definitions + * + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include + +/** DHCP client architecture */ +#define DHCP_ARCH_CLIENT_ARCHITECTURE DHCP_CLIENT_ARCHITECTURE_ARM32 + +/** DHCP client network device interface */ +#define DHCP_ARCH_CLIENT_NDI 1 /* UNDI */ , 3, 10 /* v3.10 */ + +#endif /* _IPXE_EFI_DHCPARCH_H */ -- cgit v1.2.3-55-g7522 From 9de6c45dd3019c7074dc34954e008633409b38df Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 23 Jan 2023 01:26:46 +0000 Subject: [arm] Use -fno-short-enums for all 32-bit ARM builds The EFI ABI requires the use of -fno-short-enums, and the EDK2 headers will perform a compile-time check that enums are 32 bits. The EDK2 headers may be included even in builds for non-EFI platforms, and so the -fno-short-enums flag must be used in all 32-bit ARM builds. Fortunately, nothing else currently cares about enum sizes. Signed-off-by: Michael Brown --- src/arch/arm32/Makefile | 5 +++++ src/arch/arm32/Makefile.efi | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/arch/arm32') diff --git a/src/arch/arm32/Makefile b/src/arch/arm32/Makefile index 3a7c09230..d32ab6a40 100644 --- a/src/arch/arm32/Makefile +++ b/src/arch/arm32/Makefile @@ -13,6 +13,11 @@ ASFLAGS += -mthumb -mcpu=cortex-a15 # CFLAGS += -fshort-wchar +# EFI requires that enums are always 32 bits, and nothing else +# currently cares +# +CFLAGS += -fno-short-enums + # Include common ARM Makefile MAKEDEPS += arch/arm/Makefile include arch/arm/Makefile diff --git a/src/arch/arm32/Makefile.efi b/src/arch/arm32/Makefile.efi index e139a055a..a06354f1d 100644 --- a/src/arch/arm32/Makefile.efi +++ b/src/arch/arm32/Makefile.efi @@ -1,9 +1,5 @@ # -*- makefile -*- : Force emacs to use Makefile mode -# UEFI requires that enums are always 32 bits -# -CFLAGS += -fno-short-enums - # Specify EFI image builder # ELF2EFI = $(ELF2EFI32) -- cgit v1.2.3-55-g7522 From c5e1f007ac33fc09943ba99b742f599a0cfca0c5 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 23 Jan 2023 01:32:14 +0000 Subject: [arm] Use -mfloat-abi=soft only for EFI builds The EFI ABI requires the use of -mfloat-abi=soft, but other platforms may require -mfloat-abi=hard. Allow for this by using -mfloat-abi=soft only for EFI builds. Signed-off-by: Michael Brown --- src/arch/arm32/Makefile | 2 +- src/arch/arm32/Makefile.efi | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/arch/arm32') diff --git a/src/arch/arm32/Makefile b/src/arch/arm32/Makefile index d32ab6a40..0c1cf99d1 100644 --- a/src/arch/arm32/Makefile +++ b/src/arch/arm32/Makefile @@ -5,7 +5,7 @@ SRCDIRS += arch/arm32/libgcc # ARM32-specific flags # -CFLAGS += -mthumb -mcpu=cortex-a15 -mabi=aapcs -mfloat-abi=soft +CFLAGS += -mthumb -mcpu=cortex-a15 -mabi=aapcs CFLAGS += -mword-relocations ASFLAGS += -mthumb -mcpu=cortex-a15 diff --git a/src/arch/arm32/Makefile.efi b/src/arch/arm32/Makefile.efi index a06354f1d..d720f34f0 100644 --- a/src/arch/arm32/Makefile.efi +++ b/src/arch/arm32/Makefile.efi @@ -1,5 +1,9 @@ # -*- makefile -*- : Force emacs to use Makefile mode +# EFI uses the soft float ABI +# +CFLAGS += -mfloat-abi=soft + # Specify EFI image builder # ELF2EFI = $(ELF2EFI32) -- cgit v1.2.3-55-g7522 From fcfb70bfb2a9aae78e86a2505669068e7e511f79 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 23 Jan 2023 12:30:41 +0000 Subject: [arm] Inhibit linker warnings about an implied executable stack Some versions of the 32-bit ARM linker seem to treat the absence of a .note.GNU-stack section as implying an executable stack, and will print a warning that this is deprecated behaviour. Silence the warning by adding a .note.GNU-stack section to each assembly file and retaining the sections in the Linux linker script. Signed-off-by: Michael Brown --- src/arch/arm32/core/setjmp.S | 1 + src/arch/arm32/libgcc/lldivmod.S | 1 + src/arch/arm32/libgcc/llshift.S | 1 + src/scripts/linux.lds | 5 +---- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/arch/arm32') diff --git a/src/arch/arm32/core/setjmp.S b/src/arch/arm32/core/setjmp.S index 7e7b0fe58..1e9e82029 100644 --- a/src/arch/arm32/core/setjmp.S +++ b/src/arch/arm32/core/setjmp.S @@ -1,5 +1,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) + .section ".note.GNU-stack", "", %progbits .text .arm diff --git a/src/arch/arm32/libgcc/lldivmod.S b/src/arch/arm32/libgcc/lldivmod.S index 910be4b78..746fa8fde 100644 --- a/src/arch/arm32/libgcc/lldivmod.S +++ b/src/arch/arm32/libgcc/lldivmod.S @@ -1,5 +1,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) + .section ".note.GNU-stack", "", %progbits .text .thumb diff --git a/src/arch/arm32/libgcc/llshift.S b/src/arch/arm32/libgcc/llshift.S index cc16e2615..c1b51e778 100644 --- a/src/arch/arm32/libgcc/llshift.S +++ b/src/arch/arm32/libgcc/llshift.S @@ -1,5 +1,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) + .section ".note.GNU-stack", "", %progbits .text .arm diff --git a/src/scripts/linux.lds b/src/scripts/linux.lds index afc0128f8..53e884ec5 100644 --- a/src/scripts/linux.lds +++ b/src/scripts/linux.lds @@ -81,16 +81,13 @@ SECTIONS { _assert = ASSERT ( ( _weak == _eweak ), ".weak is non-zero length" ); /* - * Dispose of the comment and note sections to make the link map - * easier to read + * Dispose of unwanted sections to make the link map easier to read * */ /DISCARD/ : { *(.comment) *(.comment.*) - *(.note) - *(.note.*) *(.rel) *(.rel.*) *(.discard) -- cgit v1.2.3-55-g7522 From c6901792f009cfd824707724b687e99edd4c8ecd Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 5 Feb 2023 23:55:14 +0000 Subject: [build] Allow for per-architecture unprefixed constant operand modifier Over the years, the undocumented operand modifier used to produce the unprefixed constant values in __einfo_error() has varied from "%c0" to "%a0" in commit 1a77466 ("[build] Fix use of inline assembly on GCC 4.8 ARM64 builds") and back to "%c0" in commit 3fb3ffc ("[build] Fix use of inline assembly on GCC 8 ARM64 builds"), according to the evolving demands of the toolchain. LoongArch64 suffers from a similar issue: GCC 13 will allow either, but the currently released GCC 12 allows only the "%a0" form. Introduce a macro ASM_NO_PREFIX, defined in bits/compiler.h, to abstract away this difference and allow different architectures to use different operand modifiers. Signed-off-by: Michael Brown --- src/arch/arm32/include/bits/compiler.h | 3 +++ src/arch/arm64/include/bits/compiler.h | 3 +++ src/arch/i386/include/bits/compiler.h | 3 +++ src/arch/x86_64/include/bits/compiler.h | 3 +++ src/include/errno.h | 4 ++-- 5 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src/arch/arm32') diff --git a/src/arch/arm32/include/bits/compiler.h b/src/arch/arm32/include/bits/compiler.h index e420cf922..e119f0445 100644 --- a/src/arch/arm32/include/bits/compiler.h +++ b/src/arch/arm32/include/bits/compiler.h @@ -8,6 +8,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #ifndef ASSEMBLY +/** Unprefixed constant operand modifier */ +#define ASM_NO_PREFIX "c" + #define __asmcall #define __libgcc diff --git a/src/arch/arm64/include/bits/compiler.h b/src/arch/arm64/include/bits/compiler.h index 3b129c2fd..b3e1b30a5 100644 --- a/src/arch/arm64/include/bits/compiler.h +++ b/src/arch/arm64/include/bits/compiler.h @@ -8,6 +8,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #ifndef ASSEMBLY +/** Unprefixed constant operand modifier */ +#define ASM_NO_PREFIX "c" + #define __asmcall #define __libgcc diff --git a/src/arch/i386/include/bits/compiler.h b/src/arch/i386/include/bits/compiler.h index 87201135f..78c600428 100644 --- a/src/arch/i386/include/bits/compiler.h +++ b/src/arch/i386/include/bits/compiler.h @@ -8,6 +8,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #ifndef ASSEMBLY +/** Unprefixed constant operand modifier */ +#define ASM_NO_PREFIX "c" + /** Declare a function with standard calling conventions */ #define __asmcall __attribute__ (( cdecl, regparm(0) )) diff --git a/src/arch/x86_64/include/bits/compiler.h b/src/arch/x86_64/include/bits/compiler.h index 5129f90d0..1c04a7b30 100644 --- a/src/arch/x86_64/include/bits/compiler.h +++ b/src/arch/x86_64/include/bits/compiler.h @@ -8,6 +8,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #ifndef ASSEMBLY +/** Unprefixed constant operand modifier */ +#define ASM_NO_PREFIX "c" + /** Declare a function with standard calling conventions */ #define __asmcall __attribute__ (( regparm(0) )) diff --git a/src/include/errno.h b/src/include/errno.h index decde38ed..ac012a691 100644 --- a/src/include/errno.h +++ b/src/include/errno.h @@ -262,10 +262,10 @@ static inline void eplatform_discard ( int dummy __unused, ... ) {} ".balign 8\n\t" \ "\n1:\n\t" \ ".long ( 4f - 1b )\n\t" \ - ".long %c0\n\t" \ + ".long %" ASM_NO_PREFIX "0\n\t" \ ".long ( 2f - 1b )\n\t" \ ".long ( 3f - 1b )\n\t" \ - ".long %c1\n\t" \ + ".long %" ASM_NO_PREFIX "1\n\t" \ "\n2:\t.asciz \"" __einfo_desc ( einfo ) "\"\n\t" \ "\n3:\t.asciz \"" __FILE__ "\"\n\t" \ ".balign 8\n\t" \ -- cgit v1.2.3-55-g7522