v3 does not handle .data and .bss sections in stage1 and initram. We simply hope they are unused/empty and will get runtime crashes/corruption/malfunction if they are not empty.
Check for the emptiness of these sections and abort the build on error. This triggers on all stage1/initram global variables which are not declared the right way.
This found a long-standing bug introduced in r729 and fixed in r576. It also breaks the build of every Geode target in the v3 tree because they have multiple bugs. And it breaks the build of the K8 code because of a bug there.
Tested for all possible variations of .data and .bss usage.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: corebootv3-check_illegal_global_vars/arch/x86/Makefile =================================================================== --- corebootv3-check_illegal_global_vars/arch/x86/Makefile (revision 789) +++ corebootv3-check_illegal_global_vars/arch/x86/Makefile (working copy) @@ -143,9 +143,22 @@ $(Q)# 0x4000 - 0x100, we will end up with a 4 gig file. $(Q)# I wonder if that behavior is on purpose.
+ $(Q)# .data and .bss must be empty because they aren't handled + $(Q)printf " CHECK stage0 (non-empty .data sections)\n" + $(Q)objdump -h $(STAGE0_OBJ)| grep "^$(obj)/|.data"|\ + grep -v ".data[[:blank:]]+00000000[[:blank:]]"|\ + grep -B1 ".data"| grep "^$(obj)/"|\ + cut -f 1 -d:| grep "^$(obj)/"; test $$? -ne 0 + $(Q)printf " CHECK stage0 (non-empty .bss sections)\n" + $(Q)objdump -h $(STAGE0_OBJ)| grep "^$(obj)/|.bss"|\ + grep -v ".bss[[:blank:]]+00000000[[:blank:]]"|\ + grep -B1 ".bss"| grep "^$(obj)/"|\ + cut -f 1 -d:| grep "^$(obj)/"; test $$? -ne 0 + $(Q)# Note: we invoke gcc (instead of ld directly) here, as we hit $(Q)# strange problems in the past. It seems that only gcc knows how $(Q)# to properly invoke ld. + $(Q)#printf "STAGE0_OBJ is $(STAGE0_OBJ)\n" $(Q)printf " CC $(subst $(shell pwd)/,,$(@))\n" $(Q)$(CC) -nostdlib -static -T $(src)/arch/x86/ldscript.ld \ $(STAGE0_OBJ) -o $(obj)/stage0.o @@ -264,6 +277,19 @@ $(obj)/coreboot.initram $(obj)/coreboot.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(INITRAM_SRC) $(Q)printf " CC $(subst $(shell pwd)/,,$(@)) (XIP)\n" $(Q)$(CC) $(INITCFLAGS) -fPIE -c -combine $(INITRAM_SRC) -o $(obj)/coreboot.initram_partiallylinked.o + + $(Q)# .data and .bss must be empty because they aren't handled + $(Q)printf " CHECK initram (non-empty .data sections)\n" + $(Q)objdump -h $(obj)/coreboot.initram_partiallylinked.o|\ + grep ".data"|\ + grep -vq ".data[[:blank:]]+00000000[[:blank:]]";\ + test $$? -ne 0 + $(Q)printf " CHECK initram (non-empty .bss sections)\n" + $(Q)objdump -h $(obj)/coreboot.initram_partiallylinked.o|\ + grep ".bss"|\ + grep -vq ".bss[[:blank:]]+00000000[[:blank:]]";\ + test $$? -ne 0 + $(Q)printf " WRAP $(subst $(shell pwd)/,,$(@)) (PIC->non-PIC)\n" $(Q)$(NM) --undefined-only $(obj)/coreboot.initram_partiallylinked.o |\ grep -v _GLOBAL_OFFSET_TABLE_ | grep " U " | sed "s/^ *U //" |\