cbfstool/extract: ignore compression field for some payload segments

When extracting a payload from CBFS, ignore compression fields for
these types of payload segments:
  - PAYLOAD_SEGMENT_ENTRY
  - PAYLOAD_SEGMENT_BSS
  - PAYLOAD_SEGMENT_PARAMS

These types of payload segments cannot be compressed, and in certain
cases are being erroneously labeled as compressed, causing errors
when extracting the payload.

For an example of this problem, see creation of PAYLOAD_SEGMENT_ENTRY
segments in cbfs-mkpayload.c, where the only field that is written to
is |load_addr|.

Also, add a linebreak to an ERROR line.

BUG=https://ticket.coreboot.org/issues/170
TEST=cbfstool tianocore.cbfs extract -m x86 -n payload -f /tmp/payload -v -v

Change-Id: I8c5c40205d648799ea577ad0c5bee6ec2dd7d05f
Signed-off-by: kitching@google.com
Reviewed-on: https://review.coreboot.org/27520
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Joel Kitching 2018-07-18 13:23:52 +08:00 committed by Julius Werner
parent 770b0346ff
commit 72d77a9a0c
1 changed files with 8 additions and 8 deletions

View File

@ -925,14 +925,6 @@ static int cbfs_payload_decompress(struct cbfs_payload_segment *segments,
struct buffer tbuff; struct buffer tbuff;
size_t decomp_size; size_t decomp_size;
/* The payload uses an unknown compression algorithm. */
decompress = decompression_function(segments[i].compression);
if (decompress == NULL) {
ERROR("Unknown decompression algorithm: %u",
segments[i].compression);
return -1;
}
/* Segments BSS and ENTRY do not have binary data. */ /* Segments BSS and ENTRY do not have binary data. */
if (segments[i].type == PAYLOAD_SEGMENT_BSS || if (segments[i].type == PAYLOAD_SEGMENT_BSS ||
segments[i].type == PAYLOAD_SEGMENT_ENTRY) { segments[i].type == PAYLOAD_SEGMENT_ENTRY) {
@ -947,6 +939,14 @@ static int cbfs_payload_decompress(struct cbfs_payload_segment *segments,
continue; continue;
} }
/* The payload uses an unknown compression algorithm. */
decompress = decompression_function(segments[i].compression);
if (decompress == NULL) {
ERROR("Unknown decompression algorithm: %u\n",
segments[i].compression);
return -1;
}
if (buffer_create(&tbuff, segments[i].mem_len, "segment")) { if (buffer_create(&tbuff, segments[i].mem_len, "segment")) {
buffer_delete(&new_buffer); buffer_delete(&new_buffer);
return -1; return -1;