Project

General

Profile

Actions

Bug #170

closed

cbfstool fails to export payloads (unknown compression error)

Added by Joel Kitching almost 6 years ago. Updated almost 6 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
userspace utilities
Target version:
-
Start date:
07/18/2018
Due date:
% Done:

0%

Estimated time:
Affected versions:
Needs backport to:
Affected hardware:
Affected OS:

Description

(from b/111576981)

Problem encountered:

$ cbfstool tianocore.cbfs extract -m x86 -n payload -f /tmp/payload -v -v
INFO: Opening image as a flat file because it doesn't contain any FMAP
DEBUG: cbfs_get_entry: found payload
Found file payload at 0x0, type simple elf, size 650878
E: Unknown compression algorithm 31!
E: Unknown decompression algorithm: 31E: Failed to decompress payload.

Expected behaviour:

$ cbfstool tianocore.cbfs extract -m x86 -n payload -f /tmp/payload -v -v
INFO: Opening image as a flat file because it doesn't contain any FMAP
DEBUG: cbfs_get_entry: found payload
Found file payload at 0x0, type payload, size 650878
INFO: Writing 5 sections.
INFO: Created 4268032 output buffer for ELF file.
INFO: Successfully dumped the file to: /tmp/payload

Why this occurs:

In cbfs-mkpayload.c, when creating PAYLOAD_SEGMENT_ENTRY segments, the only field that is written to is |load_addr|. The |compression| field is left unset, which is presumably taking on some random or deterministic value that happens to be in memory at that location.

The cbfs extract command calls into cbfs_payload_decompress, which ensures each segment has a valid compression algorithm. When it encounters a value other than 0/1/2, it throws an error and fails.

Solution:

Option A: Write CBFS_COMPRESS_NONE value to the |compression| field for PAYLOAD_SEGMENT_ENTRY (also _BSS and _PARAMS).
Option B: Ignore the |compression| field in cbfstool extract command for these payload segment types.

Actions

Also available in: Atom PDF