[PATCH v1 2/8] arm: Fix "file truncated" linker errors from empty built-in.a in SPL/TPL/VPL builds
alif.zakuan.yuslaimi at altera.com
alif.zakuan.yuslaimi at altera.com
Tue Nov 25 09:13:10 CET 2025
From: Tien Fong Chee <tien.fong.chee at intel.com>
When building 32-bit ARM SPL (e.g. Arria 10), linking may fail with:
arch/arm/cpu/built-in.a: file not recognized: File truncated
cmd/built-in.a: file not recognized: File truncated
dts/built-in.a: file not recognized: File truncated
This happens when a directory (such as arch/arm/cpu/, cmd/, or dts/)
produces no object files under SPL. GNU `ar` still creates a zero-length
archive, which older ARM 32-bit linkers (arm-linux-gnueabihf-ld) treat as
invalid. The final link step then aborts with the "file truncated" error.
By contrast, 64-bit SoCFPGA (Agilex 5) builds use aarch64 linkers that
tolerate empty thin archives, so the same condition does not cause an
error.
To make XPL (SPL/TPL/VPL) builds consistent across architectures, this
patch ensures each affected directory always contributes at least one valid
object:
* `arch/arm/cpu/Makefile` — add a persistent `dummy.o`
* `cmd/Makefile` — add `dummy.o` only when CONFIG_XPL_BUILD=y
* `dts/Makefile` — add `dummy.o` only when CONFIG_XPL_BUILD=y
These dummy objects define no functional code and do not affect runtime
behavior. They only guarantee a valid archive for the linker, preventing
false "file truncated" errors on strict toolchains.
Signed-off-by: Tien Fong Chee <tien.fong.chee at altera.com>
Signed-off-by: Alif Zakuan Yuslaimi <alif.zakuan.yuslaimi at altera.com>
---
arch/arm/cpu/Makefile | 2 +-
arch/arm/cpu/dummy.c | 7 +++++++
cmd/Makefile | 4 +++-
cmd/dummy.c | 7 +++++++
disk/Makefile | 5 +++++
disk/dummy.c | 7 +++++++
dts/Makefile | 5 +++++
dts/dummy.c | 7 +++++++
env/Makefile | 5 +++++
env/dummy.c | 7 +++++++
10 files changed, 54 insertions(+), 2 deletions(-)
create mode 100644 arch/arm/cpu/dummy.c
create mode 100644 cmd/dummy.c
create mode 100644 disk/dummy.c
create mode 100644 dts/dummy.c
create mode 100644 env/dummy.c
diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile
index a0e1c2a651d..fc409bc5a90 100644
--- a/arch/arm/cpu/Makefile
+++ b/arch/arm/cpu/Makefile
@@ -1,3 +1,3 @@
# SPDX-License-Identifier: GPL-2.0+
-obj- += dummy.o
+obj-y += dummy.o
diff --git a/arch/arm/cpu/dummy.c b/arch/arm/cpu/dummy.c
new file mode 100644
index 00000000000..a7a55a02c20
--- /dev/null
+++ b/arch/arm/cpu/dummy.c
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2025 Altera Corporation <www.altera.com>
+ */
+
+void __arch_arm_cpu_dummy(void) { }
+
diff --git a/cmd/Makefile b/cmd/Makefile
index 25479907797..104e8a770e7 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -3,7 +3,9 @@
# (C) Copyright 2004-2006
# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
-ifndef CONFIG_XPL_BUILD
+ifdef CONFIG_XPL_BUILD
+obj-y += dummy.o
+else
# core command
obj-y += boot.o
obj-$(CONFIG_CMD_BOOTM) += bootm.o
diff --git a/cmd/dummy.c b/cmd/dummy.c
new file mode 100644
index 00000000000..a4d10f413bc
--- /dev/null
+++ b/cmd/dummy.c
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2025 Altera Corporation <www.altera.com>
+ */
+
+void __cmd_dummy_placeholder(void) {}
+
diff --git a/disk/Makefile b/disk/Makefile
index 2248a659f8b..eb17dac8b67 100644
--- a/disk/Makefile
+++ b/disk/Makefile
@@ -18,3 +18,8 @@ obj-$(CONFIG_$(PHASE_)ISO_PARTITION) += part_iso.o
obj-$(CONFIG_$(PHASE_)AMIGA_PARTITION) += part_amiga.o
obj-$(CONFIG_$(PHASE_)EFI_PARTITION) += part_efi.o
endif
+
+# Avoid empty dts/built-in.a during SPL/TPL/VPL builds
+ifdef CONFIG_XPL_BUILD
+obj-y += dummy.o
+endif
diff --git a/disk/dummy.c b/disk/dummy.c
new file mode 100644
index 00000000000..0d7d99f744e
--- /dev/null
+++ b/disk/dummy.c
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2025 Altera Corporation <www.altera.com>
+ */
+
+void __disk_dummy_placeholder(void) {}
+
diff --git a/dts/Makefile b/dts/Makefile
index fd4ae31a533..1bf5577b403 100644
--- a/dts/Makefile
+++ b/dts/Makefile
@@ -89,3 +89,8 @@ subdir- += ../arch/arc/dts ../arch/arm/dts ../arch/m68k/dts ../arch/microblaze/d
../arch/mips/dts ../arch/nios2/dts ../arch/powerpc/dts ../arch/riscv/dts \
../arch/sandbox/dts ../arch/sh/dts ../arch/x86/dts ../arch/xtensa/dts \
./upstream/src/arm64 ./upstream/src/$(ARCH)
+
+# Avoid empty dts/built-in.a during SPL/TPL/VPL builds
+ifdef CONFIG_XPL_BUILD
+obj-y += dummy.o
+endif
diff --git a/dts/dummy.c b/dts/dummy.c
new file mode 100644
index 00000000000..8007239d3f6
--- /dev/null
+++ b/dts/dummy.c
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2025 Altera Corporation <www.altera.com>
+ */
+
+void __dts_dummy_placeholder(void) {}
+
diff --git a/env/Makefile b/env/Makefile
index d11b87702c1..4ebb6018b4a 100644
--- a/env/Makefile
+++ b/env/Makefile
@@ -31,3 +31,8 @@ obj-$(CONFIG_$(PHASE_)ENV_IS_IN_FLASH) += flash.o
obj-$(CONFIG_$(PHASE_)ENV_IS_IN_SCSI) += scsi.o
CFLAGS_embedded.o := -Wa,--no-warn -DENV_CRC=$(shell tools/envcrc 2>/dev/null)
+
+# Avoid empty dts/built-in.a during SPL/TPL/VPL builds
+ifdef CONFIG_XPL_BUILD
+obj-y += dummy.o
+endif
diff --git a/env/dummy.c b/env/dummy.c
new file mode 100644
index 00000000000..dc23f8439d0
--- /dev/null
+++ b/env/dummy.c
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2025 Altera Corporation <www.altera.com>
+ */
+
+void __env_dummy_placeholder(void) {}
+
--
2.43.7
More information about the U-Boot
mailing list