summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2025-04-02 14:34:08 -0600
committerTom Rini <trini@konsulko.com>2025-04-02 14:34:08 -0600
commit8b0fe584ae91b588227d69eb7572f72d8b86a83c (patch)
treef2af05046eddfcec18790346e3131596ee88d343
parentd6cc404b5f8d95b8c84537eac097eb5bcca08d78 (diff)
parent358d1cc232c30091767ce192e74169e7861ae58a (diff)
Merge patch series "Various toolchain compatibility fixes/improvements"
Sam Edwards <cfsworks@gmail.com> says: This is v2 of my "misc. fixes" series, sent to prepare the codebase for more direct LLVM support in the near future. This series contains several fixes that I found in the process of preparing that support and which address issues independent of any future feature or enhancement. I am sending these now, both so that their inclusion is not delayed by discussion on my upcoming series and to make the latter more manageable. Link: https://lore.kernel.org/r/20250315221813.1265193-1-CFSworks@gmail.com
-rw-r--r--Makefile14
-rw-r--r--arch/arm/cpu/u-boot.lds29
-rw-r--r--arch/arm/lib/Makefile1
-rw-r--r--arch/arm/lib/crt0_arm_efi.S3
-rw-r--r--arch/arm/lib/eabi_compat.c17
-rw-r--r--arch/x86/cpu/i386/call64.S2
-rw-r--r--common/spl/spl_fit.c2
-rw-r--r--common/spl/spl_opensbi.c5
8 files changed, 45 insertions, 28 deletions
diff --git a/Makefile b/Makefile
index 620996862e6..1024ac33be7 100644
--- a/Makefile
+++ b/Makefile
@@ -406,6 +406,7 @@ LDR = $(CROSS_COMPILE)ldr
STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
+READELF = $(CROSS_COMPILE)readelf
LEX = flex
YACC = bison
AWK = awk
@@ -820,6 +821,7 @@ KBUILD_AFLAGS += $(KAFLAGS)
KBUILD_CFLAGS += $(KCFLAGS)
KBUILD_LDFLAGS += -z noexecstack
+KBUILD_LDFLAGS += -z norelro
KBUILD_LDFLAGS += $(call ld-option,--no-warn-rwx-segments)
KBUILD_HOSTCFLAGS += $(if $(CONFIG_TOOLS_DEBUG),-g)
@@ -1065,7 +1067,7 @@ quiet_cmd_objcopy = OBJCOPY $@
cmd_objcopy = $(OBJCOPY) --gap-fill=0xff $(OBJCOPYFLAGS) \
$(OBJCOPYFLAGS_$(@F)) $< $@
-# Provide a version which does not do this, for use by EFI
+# Provide a version which does not do this, for use by EFI and hex/srec
quiet_cmd_zobjcopy = OBJCOPY $@
cmd_zobjcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
@@ -1280,7 +1282,7 @@ OBJCOPYFLAGS_u-boot.hex := -O ihex
OBJCOPYFLAGS_u-boot.srec := -O srec
u-boot.hex u-boot.srec: u-boot FORCE
- $(call if_changed,objcopy)
+ $(call if_changed,zobjcopy)
OBJCOPYFLAGS_u-boot-elf.srec := $(OBJCOPYFLAGS_u-boot.srec)
@@ -1294,12 +1296,12 @@ OBJCOPYFLAGS_u-boot-elf.srec += --change-addresses=0x50000000
endif
u-boot-elf.srec: u-boot.elf FORCE
- $(call if_changed,objcopy)
+ $(call if_changed,zobjcopy)
OBJCOPYFLAGS_u-boot-spl.srec = $(OBJCOPYFLAGS_u-boot.srec)
spl/u-boot-spl.srec: spl/u-boot-spl FORCE
- $(call if_changed,objcopy)
+ $(call if_changed,zobjcopy)
%.scif: %.srec
$(Q)$(MAKE) $(build)=arch/arm/mach-renesas $@
@@ -1434,7 +1436,7 @@ OBJCOPYFLAGS_u-boot.ldr.hex := -I binary -O ihex
OBJCOPYFLAGS_u-boot.ldr.srec := -I binary -O srec
u-boot.ldr.hex u-boot.ldr.srec: u-boot.ldr FORCE
- $(call if_changed,objcopy)
+ $(call if_changed,zobjcopy)
ifdef CONFIG_SPL_LOAD_FIT
MKIMAGEFLAGS_u-boot.img = -f auto -A $(ARCH) -T firmware -C none -O u-boot \
@@ -2175,7 +2177,7 @@ System.map: u-boot
# ARM relocations should all be R_ARM_RELATIVE (32-bit) or
# R_AARCH64_RELATIVE (64-bit).
checkarmreloc: u-boot
- @RELOC="`$(CROSS_COMPILE)readelf -r -W $< | cut -d ' ' -f 4 | \
+ @RELOC="`$(READELF) -r -W $< | cut -d ' ' -f 4 | \
grep R_A | sort -u`"; \
if test "$$RELOC" != "R_ARM_RELATIVE" -a \
"$$RELOC" != "R_AARCH64_RELATIVE"; then \
diff --git a/arch/arm/cpu/u-boot.lds b/arch/arm/cpu/u-boot.lds
index 2f50087f57a..817e7a983ae 100644
--- a/arch/arm/cpu/u-boot.lds
+++ b/arch/arm/cpu/u-boot.lds
@@ -169,15 +169,6 @@ SECTIONS
_end = .;
_image_binary_end = .;
- /*
- * Deprecated: this MMU section is used by pxa at present but
- * should not be used by new boards/CPUs.
- */
- . = ALIGN(4096);
- .mmutable : {
- *(.mmutable)
- }
-
/*
* These sections occupy the same memory, but their lifetimes do
* not overlap: U-Boot initializes .bss only after applying dynamic
@@ -190,14 +181,14 @@ SECTIONS
__bss_end = .;
}
- .dynsym _image_binary_end : { *(.dynsym) }
- .dynbss : { *(.dynbss) }
- .dynstr : { *(.dynstr*) }
- .dynamic : { *(.dynamic*) }
- .plt : { *(.plt*) }
- .interp : { *(.interp*) }
- .gnu.hash : { *(.gnu.hash) }
- .gnu : { *(.gnu*) }
- .ARM.exidx : { *(.ARM.exidx*) }
- .gnu.linkonce.armexidx : { *(.gnu.linkonce.armexidx.*) }
+ /DISCARD/ : { *(.dynsym) }
+ /DISCARD/ : { *(.dynbss) }
+ /DISCARD/ : { *(.dynstr*) }
+ /DISCARD/ : { *(.dynamic*) }
+ /DISCARD/ : { *(.plt*) }
+ /DISCARD/ : { *(.interp*) }
+ /DISCARD/ : { *(.gnu.hash) }
+ /DISCARD/ : { *(.gnu*) }
+ /DISCARD/ : { *(.ARM.exidx*) }
+ /DISCARD/ : { *(.gnu.linkonce.armexidx.*) }
}
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index 1c95dd6fed2..74cd5051552 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -92,6 +92,7 @@ obj-$(CONFIG_GENERATE_ACPI_TABLE) += acpi_table.o
# For EABI conformant tool chains, provide eabi_compat()
ifneq (,$(findstring -mabi=aapcs-linux,$(PLATFORM_CPPFLAGS)))
extra-y += eabi_compat.o
+CFLAGS_REMOVE_eabi_compat.o := $(LTO_CFLAGS)
endif
# some files can only build in ARM or THUMB2, not THUMB1
diff --git a/arch/arm/lib/crt0_arm_efi.S b/arch/arm/lib/crt0_arm_efi.S
index 1e7de5c3343..593ee1e194a 100644
--- a/arch/arm/lib/crt0_arm_efi.S
+++ b/arch/arm/lib/crt0_arm_efi.S
@@ -150,7 +150,8 @@ _start:
adr r1, .L_DYNAMIC
ldr r0, [r1]
add r1, r0, r1
- adrl r0, image_base
+ sub r0, pc, #((.+8-image_base) & 0xff)
+ sub r0, r0, #((.+4-image_base) & 0xff00)
bl _relocate
teq r0, #0
bne 0f
diff --git a/arch/arm/lib/eabi_compat.c b/arch/arm/lib/eabi_compat.c
index 602efe04c04..e6cafcc5f2b 100644
--- a/arch/arm/lib/eabi_compat.c
+++ b/arch/arm/lib/eabi_compat.c
@@ -33,7 +33,24 @@ void __aeabi_memcpy(void *dest, const void *src, size_t n)
(void) memcpy(dest, src, n);
}
+void __aeabi_memcpy4(void *dest, const void *src, size_t n) __alias(__aeabi_memcpy);
+
+void __aeabi_memcpy8(void *dest, const void *src, size_t n) __alias(__aeabi_memcpy);
+
void __aeabi_memset(void *dest, size_t n, int c)
{
(void) memset(dest, c, n);
}
+
+void __aeabi_memset4(void *dest, size_t n, int c) __alias(__aeabi_memset);
+
+void __aeabi_memset8(void *dest, size_t n, int c) __alias(__aeabi_memset);
+
+void __aeabi_memclr(void *dest, size_t n)
+{
+ (void) memset(dest, 0, n);
+}
+
+void __aeabi_memclr4(void *dest, size_t n) __alias(__aeabi_memclr);
+
+void __aeabi_memclr8(void *dest, size_t n) __alias(__aeabi_memclr);
diff --git a/arch/x86/cpu/i386/call64.S b/arch/x86/cpu/i386/call64.S
index d81bcc6f8f4..424732fa3fa 100644
--- a/arch/x86/cpu/i386/call64.S
+++ b/arch/x86/cpu/i386/call64.S
@@ -10,7 +10,7 @@
#include <asm/processor-flags.h>
.code32
-.section .text_call64
+.section .text_call64, "ax"
.globl cpu_call64
cpu_call64:
/*
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 49b4df60560..86506d6905c 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -397,7 +397,7 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
* Use the address following the image as target address for the
* device tree.
*/
- image_info.load_addr = spl_image->load_addr + spl_image->size;
+ image_info.load_addr = ALIGN(spl_image->load_addr + spl_image->size, 8);
/* Figure out which device tree the board wants to use */
node = spl_fit_get_image_node(ctx, FIT_FDT_PROP, index++);
diff --git a/common/spl/spl_opensbi.c b/common/spl/spl_opensbi.c
index 5a26d7c31a4..0ed6afeacc6 100644
--- a/common/spl/spl_opensbi.c
+++ b/common/spl/spl_opensbi.c
@@ -57,6 +57,11 @@ void __noreturn spl_invoke_opensbi(struct spl_image_info *spl_image)
hang();
}
+ if (!IS_ALIGNED((uintptr_t)spl_image->fdt_addr, 8)) {
+ pr_err("SPL image loaded an improperly-aligned device tree\n");
+ hang();
+ }
+
/*
* Originally, u-boot-spl will place DTB directly after the kernel,
* but the size of the kernel did not include the BSS section, which