Skip to content

Commit 06243f7

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 187f468 commit 06243f7

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
@@ -762,12 +762,16 @@ static int man_create_modules_in_config(struct image *image, struct sof_man_fw_d
762762

763763
static int man_hash_modules(struct image *image, struct sof_man_fw_desc *desc)
764764
{
765-
struct sof_man_module *man_module;
765+
struct sof_man_module *man_module, *man;
766+
struct manifest_module *mod_file;
766767
size_t mod_offset, mod_size;
767-
int i, ret = 0;
768+
int i, j, idx, ret = 0;
768769

769-
for (i = 0; i < image->num_modules; i++) {
770-
man_module = (void *)desc + SOF_MAN_MODULE_OFFSET(i);
770+
for (i = 0, mod_file = image->module;
771+
i < image->num_modules;
772+
i++, mod_file++) {
773+
man_module = (struct sof_man_module *)
774+
((uint8_t *)desc + SOF_MAN_MODULE_OFFSET(mod_file->file.first_module_idx));
771775

772776
if (image->adsp->exec_boot_ldr && i == 0) {
773777
fprintf(stdout, " module: no need to hash %s\n as its exec header\n",
@@ -785,6 +789,13 @@ static int man_hash_modules(struct image *image, struct sof_man_fw_desc *desc)
785789
ret = hash_sha256(image->fw_image + mod_offset, mod_size, man_module->hash, sizeof(man_module->hash));
786790
if (ret)
787791
break;
792+
793+
for (j = 1, idx = mod_file->file.first_module_idx + 1; j < mod_file->file.n_modules;
794+
j++, idx++) {
795+
man = (struct sof_man_module *)
796+
((uint8_t *)desc + SOF_MAN_MODULE_OFFSET(idx));
797+
memcpy(man->hash, man_module->hash, sizeof(man->hash));
798+
}
788799
}
789800

790801
return ret;

0 commit comments

Comments
 (0)