From 6e3abe6afed380e7e9a6f430552f3ce54915eb40 Mon Sep 17 00:00:00 2001 From: Adrian Warecki Date: Fri, 10 Mar 2023 16:44:20 +0100 Subject: [PATCH] rimage: Add suport for loadable modules A new -l parameter has been added to the program's command line. It instructs the program to not treat the first module as a bootloader and not to skip the bss section for it. Signed-off-by: Adrian Warecki --- src/include/rimage/rimage.h | 3 +++ src/rimage.c | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/include/rimage/rimage.h b/src/include/rimage/rimage.h index ac0595bd8..2b9a26ef5 100644 --- a/src/include/rimage/rimage.h +++ b/src/include/rimage/rimage.h @@ -62,6 +62,9 @@ struct image { uint16_t fw_ver_build; uint32_t imr_type; + + /* Output image is a loadable module */ + bool loadable_module; }; struct memory_zone { diff --git a/src/rimage.c b/src/rimage.c index 75c4a8bff..556e05890 100644 --- a/src/rimage.c +++ b/src/rimage.c @@ -30,6 +30,7 @@ static void usage(char *name) fprintf(stdout, "\t -f firmware version = major.minor.micro\n"); fprintf(stdout, "\t -b build version\n"); fprintf(stdout, "\t -e build extended manifest\n"); + fprintf(stdout, "\t -l build loadable modules image (don't treat the first module as a bootloader)\n"); fprintf(stdout, "\t -y verify signed file\n"); fprintf(stdout, "\t -q resign binary\n"); fprintf(stdout, "\t -p set PV bit\n"); @@ -49,7 +50,7 @@ int main(int argc, char *argv[]) image.imr_type = MAN_DEFAULT_IMR_TYPE; - while ((opt = getopt(argc, argv, "ho:va:s:k:ri:f:b:ec:y:q:p")) != -1) { + while ((opt = getopt(argc, argv, "ho:va:s:k:ri:f:b:ec:y:q:p:l")) != -1) { switch (opt) { case 'o': image.out_file = optarg; @@ -97,6 +98,9 @@ int main(int argc, char *argv[]) case 'p': pv_bit = 1; break; + case 'l': + image.loadable_module = true; + break; default: /* getopt's default error message is good enough */ return 1; @@ -204,9 +208,10 @@ int main(int argc, char *argv[]) /* getopt reorders argv[] */ for (i = first_non_opt; i < argc; i++) { - /* When there is more than one module, then first one is bootloader. */ + /* When there is more than one module, then first one is bootloader. + * Does not apply to building a image of a loadable module. */ image.module[i - first_non_opt].is_bootloader = image.num_modules > 1 && - i == first_non_opt; + i == first_non_opt && !image.loadable_module; fprintf(stdout, "\nModule Reading %s\n", argv[i]); ret = elf_parse_module(&image, i - first_non_opt, argv[i]);