From e20ec3e33b494235b7daa48b609f7eca2cf8a8d9 Mon Sep 17 00:00:00 2001 From: Myles Watson Date: Mon, 25 Feb 2008 18:32:23 +0000 Subject: [PATCH] This is the part of the parse ELF patch that affects the coreboot build. It makes the default to parse the ELF, but leaves ELF parsing available. It doesn't include the removal of the per-file option "nocompress". Signed-off-by: Myles Watson The coreboot part looks OK and is Acked-by: Carl-Daniel Hailfinger git-svn-id: svn://coreboot.org/repository/coreboot-v3@620 f3766cd6-281f-0410-b1cd-43a5c92072e9 --- Kconfig | 48 +++++++++++++++++++++++------------------------ arch/x86/Makefile | 33 +++++++++++++++++--------------- 2 files changed, 42 insertions(+), 39 deletions(-) diff --git a/Kconfig b/Kconfig index f55ffd99e7..295c30a0c0 100644 --- a/Kconfig +++ b/Kconfig @@ -96,29 +96,6 @@ choice prompt "Payload type" default PAYLOAD_NONE -config PAYLOAD_PREPARSE_ELF - bool "Pre-parse ELF file and convert ELF segments to LAR entries" - depends EXPERT - default n - help - Until now, coreboot has used ELF for the payload. There are many - problems with this, not least being the inefficiency -- the ELF has - to be decompressed to memory and then the segments have to be - copied. Plus, lar can't see the segments in the ELF -- to see all - segments, you have to extract the ELF and run readelf on it. - - There are problems with collisions of the decompressed ELF - location in memory and the segment locations in memory. - Finally, validation of the ELF is done at run time, once you have - flashed the FLASH and rebooted the machine. Boot time is really - not the time you want to find out your ELF payload is broken. - - With this option, coreboot will direct lar to break each ELF - segment into a LAR entry. ELF will not be used at all. Note that - (for now) coreboot is backward compatible -- if you put an ELF - payload in, coreboot can still parse it. We hope to remove ELF - entirely in the future. - config PAYLOAD_ELF bool "An ELF executable payload file" help @@ -143,10 +120,33 @@ endchoice config PAYLOAD_FILE string "Payload path and filename" - depends PAYLOAD_ELF || PAYLOAD_PREPARSE_ELF + depends PAYLOAD_ELF default "payload.elf" help The path and filename of the ELF executable file to use as payload. +config PAYLOAD_PREPARSE_ELF + bool "Pre-parse ELF file and convert ELF segments to LAR entries" + depends PAYLOAD_ELF + default y + help + Until now, coreboot has used ELF for the payload. There are many + problems with this, not least being the inefficiency -- the ELF has + to be decompressed to memory and then the segments have to be + copied. Plus, lar can't see the segments in the ELF -- to see all + segments, you have to extract the ELF and run readelf on it. + + There are problems with collisions of the decompressed ELF + location in memory and the segment locations in memory. + Finally, validation of the ELF is done at run time, once you have + flashed the FLASH and rebooted the machine. Boot time is really + not the time you want to find out your ELF payload is broken. + + With this option, coreboot will direct lar to break each ELF + segment into a LAR entry. ELF will not be used at all. Note that + (for now) coreboot is not backward compatible -- if you put an ELF + payload in, coreboot can not parse it. We hope to remove ELF + entirely in the future. + endmenu diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 0d0f48bd61..f95d465674 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -36,10 +36,8 @@ SILENT := >/dev/null 2>&1 ROM_SIZE := $(shell expr $(CONFIG_COREBOOT_ROMSIZE_KB) \* 1024) -LARFILES := nocompress:normal/initram normal/stage2 nocompress:normal/option_table -ifneq ($(CONFIG_PAYLOAD_NONE),y) -LARFILES += normal/payload -endif +LARFILES_NOCOMPRESS := normal/initram normal/option_table +LARFILES_COMPRESSIBLE := normal/stage2 DECOMPRESSORS := ifeq ($(CONFIG_COMPRESSION_LZMA),y) @@ -64,24 +62,31 @@ $(obj)/coreboot.rom $(obj)/coreboot.map: $(obj)/coreboot.bootblock $(obj)/util/l $(Q)cp $(obj)/coreboot.initram $(obj)/lar.tmp/normal/initram $(Q)cp $(obj)/coreboot.stage2 $(obj)/lar.tmp/normal/stage2 $(Q)cp $(obj)/option_table $(obj)/lar.tmp/normal/option_table + $(Q)printf " LAR $(subst $(shell pwd)/,,$(@))\n" + $(Q)rm -f $(obj)/coreboot.rom + $(Q)cd $(obj)/lar.tmp && \ + ../util/lar/lar -e -c \ + ../coreboot.rom \ + $(LARFILES_NOCOMPRESS) \ + -s $(ROM_SIZE) -b $(obj)/coreboot.bootblock + $(Q)cd $(obj)/lar.tmp && \ + ../util/lar/lar -e $(COMPRESSFLAG) -a \ + ../coreboot.rom \ + $(LARFILES_COMPRESSIBLE) ifeq ($(CONFIG_PAYLOAD_NONE),y) $(Q)printf " PAYLOAD none (as specified by user)\n" else - $(Q)# TODO: Print sth. other than $(CONFIG_PAYLOAD_FILE) if compressed. $(Q)if [ -r $(CONFIG_PAYLOAD_FILE) ]; then \ - printf " PAYLOAD $(CONFIG_PAYLOAD_FILE)\n"; \ + printf " PAYLOAD $(CONFIG_PAYLOAD_FILE) $(COMPRESSFLAG)\n"; \ cp $(CONFIG_PAYLOAD_FILE) $(obj)/lar.tmp/normal/payload; \ else \ printf "Error: payload file '$(CONFIG_PAYLOAD_FILE)' not found.\n"; \ exit 1; \ fi + $(Q)cd $(obj)/lar.tmp && \ + ../util/lar/lar $(PARSEELF) $(COMPRESSFLAG) -a \ + ../coreboot.rom normal/payload; endif - $(Q)printf " LAR $(subst $(shell pwd)/,,$(@))\n" - $(Q)rm -f $(obj)/coreboot.rom - $(Q)cd $(obj)/lar.tmp && ../util/lar/lar $(PARSEELF) $(COMPRESSFLAG) -c \ - ../coreboot.rom \ - $(LARFILES) \ - -s $(ROM_SIZE) -b $(obj)/coreboot.bootblock $(Q)# QEMU wants bios.bin: $(Q)# Run "qemu -L build/ -serial stdio -hda /dev/zero". $(Q)printf " CP $(subst $(shell pwd)/,,$(obj)/bios.bin)\n" @@ -123,12 +128,10 @@ else endif endif - -# We now parse initram as ELF, so we need PARSEELF enabled unconditionally. ifeq ($(CONFIG_PAYLOAD_PREPARSE_ELF), y) PARSEELF = -e else - PARSEELF = -e + PARSEELF = endif STAGE0_OBJ := $(patsubst %,$(obj)/lib/%,$(STAGE0_LIB_OBJ)) \