cbfstool: honor larger-than-usual header sizes in cbfs_add_entry_at()

If an earlier stage built a larger header, cbfs_add_entry_at() shouldn't
decide to go with the most boring, least featureful header type (and its size)
instead.

Change-Id: Icc5dcd9a797a0f3c42f91cddd21b3b3916095b63
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: http://review.coreboot.org/11217
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Patrick Georgi 2015-08-11 15:55:16 +02:00
parent f820497938
commit 7fd14184fb
1 changed files with 5 additions and 4 deletions

View File

@ -457,13 +457,13 @@ static int cbfs_add_entry_at(struct cbfs_image *image,
const char *name,
uint32_t type,
const void *data,
uint32_t content_offset)
uint32_t content_offset,
uint32_t header_size)
{
struct cbfs_file *next = cbfs_find_next_entry(image, entry);
uint32_t addr = cbfs_get_entry_addr(image, entry),
addr_next = cbfs_get_entry_addr(image, next);
uint32_t header_size = cbfs_calculate_file_header_size(name),
min_entry_size = cbfs_calculate_file_header_size("");
uint32_t min_entry_size = cbfs_calculate_file_header_size("");
uint32_t len, target;
uint32_t align = image->has_header ? image->header.align :
CBFS_ENTRY_ALIGNMENT;
@ -635,7 +635,8 @@ int cbfs_add_entry(struct cbfs_image *image, struct buffer *buffer,
addr, addr_next - addr, content_offset);
if (cbfs_add_entry_at(image, entry, buffer->size, name, type,
buffer->data, content_offset) == 0) {
buffer->data, content_offset,
header_size) == 0) {
return 0;
}
break;