cbfstool: provide structure to linux payload builder
This change started with tracking down a bug where the trampoline size was not being taken into account for sizing the output buffer leading to a heap corruption. I was having a hard time keeping track of what num_segments actually tracked as well as what parts were being placed in the output buffer. Here's my attempt at hopefully providing more clarity. This change doesn't crash when adding a bzImage: $ dd if=/dev/zero of=bb.bin bs=64 count=1 $ ./cbfstool tmp.rom create -s 4M -B bb.bin -m x86 -a 64 $ ./cbfstool tmp.rom add-payload -f ~/Downloads/bzImage -C "1" -n "fallback"/payload Change-Id: Ib1de1ddfec3c7102facffc5815c52b340fcdc628 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/5408 Tested-by: build bot (Jenkins) Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com> Reviewed-by: Marc Jones <marc.jones@se-eng.com>
This commit is contained in:
committed by
Aaron Durbin
parent
2164831671
commit
4f3bb801ed
@@ -63,6 +63,15 @@ static inline void buffer_set_size(struct buffer *b, size_t size)
|
||||
b->size = size;
|
||||
}
|
||||
|
||||
/* Initialize a buffer with the given constraints. */
|
||||
static inline void buffer_init(struct buffer *b, char *name, void *data,
|
||||
size_t size)
|
||||
{
|
||||
b->name = name;
|
||||
b->data = data;
|
||||
b->size = size;
|
||||
}
|
||||
|
||||
/*
|
||||
* Splice a buffer into another buffer. If size is zero the entire buffer
|
||||
* is spliced while if size is non-zero the buffer is spliced starting at
|
||||
@@ -71,9 +80,7 @@ static inline void buffer_set_size(struct buffer *b, size_t size)
|
||||
static inline void buffer_splice(struct buffer *dest, const struct buffer *src,
|
||||
size_t offset, size_t size)
|
||||
{
|
||||
dest->name = src->name;
|
||||
dest->data = src->data;
|
||||
dest->size = src->size;
|
||||
buffer_init(dest, src->name, src->data, src->size);
|
||||
if (size != 0) {
|
||||
dest->data += offset;
|
||||
buffer_set_size(dest, size);
|
||||
|
Reference in New Issue
Block a user