Friends, I need your help. While trying to improve SeaBIOS I got stuck at this very strange problem - which does not appear when you do a standalone build of SeaBIOS but it happens when you try building a coreboot together with SeaBIOS. Steps to reproduce:
add this innocent looking function to the beginning of ./coreboot/payloads/external/SeaBIOS/seabios/src/fw/coreboot.c :
int // doesn't matter if static or not testfunc(void) { int *c = malloc_tmp(sizeof(int)); // doesn't matter if _tmp or _tmphigh // free(c); // <--- commented out because doesn't affect the results return 0; }
and try calling it from "cbfs_copyfile" function of the same file:
static int cbfs_copyfile(struct romfile_s *file, void *dst, u32 maxlen) { ... void *temp = malloc_tmphigh(size); ... int ret = ulzma(dst, maxlen, temp, size); testfunc(); // <--- added ... }
Then I get this problem while building a coreboot with together SeaBIOS : ... Compiling whole program out/code32seg.o Compiling whole program out/ccode16.o Compiling to assembler out/src/asm-offsets.s Generating offset file out/asm-offsets.h Compiling (16bit) out/romlayout.o Building ld scripts
ERROR: .data.varinit.. is VARVERIFY32INIT but used from ['.text.runtime..', '.text.do_boot', '.text.malloc_tmp'] Makefile:162: recipe for target 'out/romlayout16.lds' failed make[2]: *** [out/romlayout16.lds] Error 1 Makefile:80: recipe for target 'build' failed make[1]: *** [build] Error 2 payloads/external/Makefile.inc:73: recipe for target 'payloads/external/SeaBIOS/seabios/out/bios.bin.elf' failed make: *** [payloads/external/SeaBIOS/seabios/out/bios.bin.elf] Error 2
However, if I try adding this function to the end of "coreboot_cbfs_init" function I don't get such an error:
void coreboot_cbfs_init(void) { ... process_links_file(); testfunc(); // <--- works OK there }
What is a difference between "cbfs_copyfile" and "coreboot_cbfs_init" that affects this behaviour? And why it is OK to call "malloc_" from inside the "cbfs_copyfile" function --- void *temp = malloc_tmphigh(size); --- but we couldn't call there our testfunc() which calls "malloc_" without running into this problem?
Best regards, Mike Banon