Sol Boucher (solb@chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/9938
-gerrit
commit eb9b793d65d0b7e8b19b6de7f752dd6d2910276a Author: Sol Boucher solb@chromium.org Date: Thu Apr 2 20:58:26 2015 -0700
cbfstool: Fix ability to add files at offsets near the end of empty spaces
Because cbfs_add_entry_at() previously *assumed* it would have to create a trailing empty entry, it was impossible to add files at exact offsets close enough to the end of an existing empty entry that they occupied the remainder of its space. This addresses the problem by skipping the step of creating the trailing empty entry if doing so would place it at the start offset of whatever already followed the original empty section.
BUG=chromium:473511 TEST=Run the following commands: $ ./cbfstool test.image create -s 0x100000 -m arm $ dd if=/dev/zero of=twok.bin bs=1 count=2048 $ ./cbfstool test.image add -t 0x50 -f twok.bin -n at_end -b 0xff7c0 $ ./cbfstool test.image add -t 0x50 -f twok.bin -n near_end -b 0xfef80 $ ./cbfstool test.image print There shouldn't be any assertions, and the output should be: test.image: 1024 kB, bootblocksize 0, romsize 1048576, offset 0x40 alignment: 64 bytes, architecture: arm
Name Offset Type Size (empty) 0x40 null 1044184 near_end 0xfef40 raw 2048 at_end 0xff780 raw 2048 BRANCH=None
Change-Id: Ic8a6c3dfa4f82346a067c0804afb6c5a5e89e6c8 Signed-off-by: Sol Boucher solb@chromium.org Original-Commit-Id: 1bbd353fddc818f725e488e8f2fb6e967033539d Original-Change-Id: I15d25df80787a8e34c2237262681720203509c72 Original-Signed-off-by: Sol Boucher solb@chromium.org Original-Reviewed-on: https://chromium-review.googlesource.com/263809 Original-Reviewed-by: Hung-Te Lin hungte@chromium.org Original-Reviewed-by: Stefan Reinauer reinauer@google.com --- util/cbfstool/cbfs_image.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c index b64f78e..e61664c 100644 --- a/util/cbfstool/cbfs_image.c +++ b/util/cbfstool/cbfs_image.c @@ -456,8 +456,10 @@ static int cbfs_add_entry_at(struct cbfs_image *image, // Process buffer AFTER entry. entry = cbfs_find_next_entry(image, entry); addr = cbfs_get_entry_addr(image, entry); - assert(addr < addr_next); + if (addr == addr_next) + return 0;
+ assert(addr < addr_next); if (addr_next - addr < min_entry_size) { DEBUG("No space after content to keep CBFS structure.\n"); return -1;