On 8/12/10 9:27 PM, Patrick Georgi wrote: > 1. _bogus = ASSERT((SIZEOF(.bss) + SIZEOF(.data)) == 0, "Do not use > global variables in romstage"); > > This one looks for the size of .bss and .data (initialized and > uninitialized globals) and breaks the build if it finds any. It doesn't > tell, which global variables are involved. > > > 2. Add .bss and .data to /DISCARD/. > > That way, the linker complains about "missing" symbols (as they were > discarded), but only if they were used by any surviving code. This > means, it's no problem that the global is defined. If you use it > later-on, it "mysteriously" breaks. The error message is rather cryptic, > too: > `variable' referenced in section `.rom.text' of > coreboot-builds/kontron_986lcd-m/mainboard/kontron/986lcd-m/crt0.initobj.o: > defined in discarded section > `.data' of > coreboot-builds/kontron_986lcd-m/mainboard/kontron/986lcd-m/crt0.initobj.o > collect2: ld returned 1 exit status > > > I tend to prefer the first option, but it doesn't give _any_ clues which > variable is responsible (except for "look for globals"), but at least it > does tell the user what the real problem is.
I prefer option one, too, as - it catches all global variables, not just the used ones. We want to be sure that no such code sneaks in even if it's not used. - it provides a clear error message on what is wrong, inszead of the more cryptic one saying that a variable is defined in a discarded section. > There might also be a good opportunity for some naming cleanup: > Rename and move ldscript_fallback_cbfs.lb to > src/arch/i386/coreboot_rom.ld. Or better call it "romstage.ld" (and > adapt coreboot_ram.ld in arch/i386 in the same way)? I like the latter. Fixes to both issues are: Acked-by: Stefan Reinauer <[email protected]> Stefan -- coreboot mailing list: [email protected] http://www.coreboot.org/mailman/listinfo/coreboot

