Some Linux kernel verification mechanisms have caught compiler bugs in the past. That's why I considered the possibility to do this as well.
The only ones that I am aware of are *generic* sanity checks in the kernel, that manage to trip on something that turned out to be a compiler bug. Adding specific sanity checks for every piece of code that only checks for compiler bugs is foolishness (hint: it's impossible to ever get even 1% cover; and that check code itself is run through that same compiler anyway!)
Well, possibly catching compiler bugs would have been a nice (yet improbable) side effect. The decompression of a large chunk of data is probably taxing memory a bit more than our current simple memtest implementation and checksumming the result may have uncovered bugs in RAM configuration. But we can postpone/skip that.
IMHO opinion, if you want to test RAM, it is better to test RAM explicitly than to hope some simple checksum of <some random data> will catch this. It's also a lot cleaner design, of course.
Unless you fork gcc, having the entry point at the beginning of initram is not possible. It worked by accident in the past and I'm pretty sure Segher will confirm that we can't rely on that.
No, I confirm you *can* rely on that: just set up your linker script and your crt.o so this works. Something like
.start : { crt0.o(*) } .text : { *(.text) } .data : { *(.data) }
will guarantee that all of crt0 ends up before anything else (and there is no need to make it a separate section, FWIW).
Hm. Does that really apply to the initram binary we produce in v3?
I don't know what the current v3 code does. I'm just replying to your "cannot be done, it's GCC's fault", while GCC isn't even in the picture if your code is sane at all.
AFAIK we don't link any crt0 into that binary.
You have *some* equivalent code, for sure. Some startup code that initialises things to conform to the ABI environment expected by the compiler (initial stack frame, segments, GOT/TOC/PLT/TLS pointers, etc -- that kind of thing).
Here are the commands used to generate coreboot.initram:
$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c -combine $(INITRAM_OBJ) -o $(obj)/coreboot.initram_partiallylinked.o $(LD) -Ttext 0 --entry main -N -R $(obj)/stage0-prefixed.o $(obj)/coreboot.initram_partiallylinked.o -o $(obj)/coreboot.initram
The entry point(main) has to end up at byte 0 of coreboot.initram if we want to avoid storing it outside the file.
That doesn't seem to be guaranteed by these commands, indeed.
Segher