Skip to content

Commit ad9e827

Browse files
committed
rimage: library: calculate hashes correctly
Module hash sums are per-file, when building libraries we have to walk files, not modules, and copy hashes to all modules in each file. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 2ee9611 commit ad9e827

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

tools/rimage/src/manifest.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -756,12 +756,16 @@ static int man_create_modules_in_config(struct image *image, struct sof_man_fw_d
756756

757757
static int man_hash_modules(struct image *image, struct sof_man_fw_desc *desc)
758758
{
759-
struct sof_man_module *man_module;
759+
struct sof_man_module *man_module, *man;
760+
struct manifest_module *mod_file;
760761
size_t mod_offset, mod_size;
761-
int i, ret = 0;
762+
int i, j, idx, ret = 0;
762763

763-
for (i = 0; i < image->num_modules; i++) {
764-
man_module = (void *)desc + SOF_MAN_MODULE_OFFSET(i);
764+
for (i = 0, mod_file = image->module;
765+
i < image->num_modules;
766+
i++, mod_file++) {
767+
man_module = (struct sof_man_module *)
768+
((uint8_t *)desc + SOF_MAN_MODULE_OFFSET(mod_file->file.first_module_idx));
765769

766770
if (image->adsp->exec_boot_ldr && i == 0) {
767771
fprintf(stdout, " module: no need to hash %s\n as its exec header\n",
@@ -779,6 +783,13 @@ static int man_hash_modules(struct image *image, struct sof_man_fw_desc *desc)
779783
ret = hash_sha256(image->fw_image + mod_offset, mod_size, man_module->hash, sizeof(man_module->hash));
780784
if (ret)
781785
break;
786+
787+
for (j = 1, idx = mod_file->file.first_module_idx + 1; j < mod_file->file.n_modules;
788+
j++, idx++) {
789+
man = (struct sof_man_module *)
790+
((uint8_t *)desc + SOF_MAN_MODULE_OFFSET(idx));
791+
memcpy(man->hash, man_module->hash, sizeof(man->hash));
792+
}
782793
}
783794

784795
return ret;

0 commit comments

Comments
 (0)