文章主要分析boot-shim.c文件的工作原理流程分析,主要包括对zbi文件的追加和剥离等内容。
起始大多数同学是不明白boot-shim存在的意义。这里有必要先给大家讲解一下zbi文件。
zbi文件
zbi,full name:zircon boot image。由zbi容器头和启动条目组成。启动条目又由zbi头和payload负载内容组成。
一个普通的zbi文件组成如下:
(提示:zbi头和负载payload是地址连续的)
zbi头结构体信息如下(可以看到该结构体是8字节对齐的,它自身大小是32字节):
// Each header must be 8-byte aligned. The length field specifies the
// actual payload length and does not include the size of padding.
typedef struct {
// ZBI_TYPE_* constant, see below.
uint32_t type;
// Size of the payload immediately following this header. This
// does not include the header itself nor any alignment padding
// after the payload.
uint32_t length;
// Type-specific extra data. Each type specifies the use of this
// field;