From 3ddd6e83a31451d4e29dbdfc6a640d65147d67a4 Mon Sep 17 00:00:00 2001 From: Daniel Lublin Date: Tue, 7 Mar 2023 14:17:23 +0100 Subject: [PATCH] Refuse to produce a .bin if .elf has non-empty data or bss section Signed-off-by: Daniel Lublin --- hw/application_fpga/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/application_fpga/Makefile b/hw/application_fpga/Makefile index ed36d34..1fa7883 100644 --- a/hw/application_fpga/Makefile +++ b/hw/application_fpga/Makefile @@ -144,6 +144,8 @@ testfw.hex: testfw.bin testfw_size_mismatch %.bin: %.elf $(SIZE) $< + @test "$$($(SIZE) $< | awk 'NR==2{print $$2, $$3}')" = "0 0" \ + || { printf "Non-empty data or bss section!\n"; false; } $(OBJCOPY) --input-target=elf32-littleriscv --output-target=binary $< $@ chmod -x $@