Furquan Shaikh (furquan@google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7306
-gerrit
commit 33ae80d7ec76f1f4dfda5297ea00804baebffea1 Author: Furquan Shaikh furquan@google.com Date: Thu Oct 30 11:53:38 2014 -0700
x86: Update the check for Forbidden global variables
Add a section .illegal_globals to romstage and check that the section does not contain any variables while creating romstage.
Change-Id: I866681f51a44bc21770d32995c281b556a90c153 Signed-off-by: Furquan Shaikh furquan@google.com --- src/arch/x86/Makefile.inc | 5 +++-- src/arch/x86/init/romstage.ld | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc index f99ea15..7ca3ca4 100644 --- a/src/arch/x86/Makefile.inc +++ b/src/arch/x86/Makefile.inc @@ -214,9 +214,10 @@ ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y) else $(CC_romstage) $(CFLAGS_romstage) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(objgenerated)/romstage_null.ld -Wl,--wrap,__divdi3 -Wl,--wrap,__udivdi3 -Wl,--wrap,__moddi3 -Wl,--wrap,__umoddi3 -Wl,--start-group $(romstage-objs) $(romstage-libs) $(LIBGCC_FILE_NAME_romstage) -Wl,--end-group endif - $(NM_romstage) $@ | grep -q " [DdBb] "; if [ $$? -eq 0 ]; then \ + $(OBJCOPY_romstage) --only-section .illegal_globals $(@) $(objcbfs)/romstage_null.offenders && \ + $(NM_romstage) $(objcbfs)/romstage_null.offenders | grep -q ""; if [ $$? -eq 0 ]; then \ echo "Forbidden global variables in romstage:"; \ - $(NM_romstage) $@ | grep " [DdBb] "; test "$(CONFIG_CPU_AMD_AGESA)" = y; \ + $(NM_romstage) $(objcbfs)/romstage_null.offenders; test "$(CONFIG_CPU_AMD_AGESA)" = y; \ else true; fi
$(objcbfs)/romstage_xip.debug: $$(romstage-objs) $(objgenerated)/romstage_xip.ld $$(romstage-libs) diff --git a/src/arch/x86/init/romstage.ld b/src/arch/x86/init/romstage.ld index d6eb511..f4a4dde 100644 --- a/src/arch/x86/init/romstage.ld +++ b/src/arch/x86/init/romstage.ld @@ -43,6 +43,19 @@ SECTIONS _erom = .; }
+ /* Global variables are not allowed in romstage + * This section is checked during stage creation to ensure + * that there are no global variables present + */ + .illegal_globals . : { + *(.data) + *(.data.*) + *(.bss) + *(.bss.*) + *(.sbss) + *(.sbss.*) + } + /DISCARD/ : { *(.comment) *(.note)