From 21fdd89b0c9b0c135c0febeacbae5f83e33a3c70 Mon Sep 17 00:00:00 2001 From: Joel Kitching Date: Thu, 9 Aug 2018 17:49:52 +0800 Subject: cbfstool: add unprocessed flag for file exporting Add an unprocessed flag (-U) which modifies how files are exported. In the case of a compressed raw file, extract without decompressing. In the case of a stage or payload, extract without decompressing or converting to an ELF. This can be useful for verifying the integrity of a stage or payload, since converting to an ELF may not be a deterministic process on different platforms or coreboot versions. BUG=b:111577108 TEST=USE=cb_legacy_tianocore emerge-eve edk2 coreboot-utils chromeos-bootimage cd /build/eve/firmware /build/eve/usr/bin/cbfstool image.bin extract -r RW_LEGACY \ -n payload -f /tmp/payload_1 -U START=$((16#`xxd -s 20 -l 4 -p tianocore.cbfs`)) SIZE=$((16#`xxd -s 8 -l 4 -p tianocore.cbfs`)) dd if=tianocore.cbfs skip=$START count=$SIZE bs=1 > /tmp/payload_2 diff /tmp/payload_1 /tmp/payload_2 rm /tmp/payload_1 /tmp/payload_2 Change-Id: I351d471d699daedd51adf4a860661877f25607e6 Signed-off-by: Joel Kitching Reviewed-on: https://review.coreboot.org/29616 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin Reviewed-by: Patrick Georgi Reviewed-by: Julius Werner --- util/cbfstool/cbfs_image.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'util/cbfstool/cbfs_image.h') diff --git a/util/cbfstool/cbfs_image.h b/util/cbfstool/cbfs_image.h index 5772b1ba15..1f8b162d7c 100644 --- a/util/cbfstool/cbfs_image.h +++ b/util/cbfstool/cbfs_image.h @@ -95,10 +95,11 @@ int cbfs_image_delete(struct cbfs_image *image); /* Returns a pointer to entry by name, or NULL if name is not found. */ struct cbfs_file *cbfs_get_entry(struct cbfs_image *image, const char *name); -/* Exports an entry to external file. +/* Exports an entry to external file. If do_processing is true, file contents + * will be decompressed, and also turned into an ELF if appropriate. * Returns 0 on success, otherwise (ex, not found) non-zero. */ int cbfs_export_entry(struct cbfs_image *image, const char *entry_name, - const char *filename, uint32_t arch); + const char *filename, uint32_t arch, bool do_processing); /* Adds an entry to CBFS image by given name and type. If content_offset is * non-zero, try to align "content" (CBFS_SUBHEADER(p)) at content_offset. -- cgit v1.2.3