Headers doesn't always occupy 1 page

This commit is contained in:
topjohnwu 2020-10-25 06:25:42 -07:00
parent 0632b146b8
commit 02ea3ca525
2 changed files with 6 additions and 3 deletions

View File

@ -294,7 +294,7 @@ void boot_img::parse_image(uint8_t *addr, format_t type) {
hdr->print();
size_t off = hdr->page_size();
size_t off = hdr->hdr_space();
hdr_addr = addr;
get_block(kernel);
get_block(ramdisk);
@ -474,9 +474,9 @@ void repack(const char* src_img, const char* out_img, bool skip_comp) {
restore_buf(fd, boot.map_addr, ACCLAIM_PRE_HEADER_SZ);
}
// Copy a page for header
// Copy header
off.header = lseek(fd, 0, SEEK_CUR);
restore_buf(fd, boot.hdr_addr, boot.hdr->page_size());
restore_buf(fd, boot.hdr_addr, boot.hdr->hdr_space());
// kernel
off.kernel = lseek(fd, 0, SEEK_CUR);

View File

@ -243,6 +243,7 @@ struct dyn_img_hdr {
}
virtual size_t hdr_size() = 0;
virtual size_t hdr_space() { return page_size(); }
const void *raw_hdr() const { return raw; }
void print();
@ -367,6 +368,8 @@ struct dyn_img_vnd_v3 : public dyn_img_hdr {
impl_val(header_size)
impl_val(dtb_size)
size_t hdr_space() override { auto sz = page_size(); return do_align(hdr_size(), sz); }
// Make API compatible
char *extra_cmdline() override { return &vnd->cmdline[BOOT_ARGS_SIZE]; }
};