Skip to content

Commit 4c361b6

Browse files
committed
rimage: manifest: Improved handling of empty RODATA segment
If the RODATA segment does not contain any data, its type is marked as empty. Cleared the readonly flag because this segment also contains .data sections. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
1 parent fa41033 commit 4c361b6

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

tools/rimage/src/manifest.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,20 +240,21 @@ static int man_get_module_manifest(struct image *image, struct manifest_module *
240240
segment->flags.r.load = 1;
241241
segment->flags.r.readonly = 1;
242242
segment->flags.r.code = 1;
243+
segment->flags.r.type = SOF_MAN_SEGMENT_TEXT;
243244

244245
/* data segment */
245246
segment = &man_module->segment[SOF_MAN_SEGMENT_RODATA];
246247
segment->flags.r.contents = 1;
247248
segment->flags.r.alloc = 1;
248249
segment->flags.r.load = 1;
249-
segment->flags.r.readonly = 1;
250+
segment->flags.r.readonly = 0; /* rodata segment contains also writtable data */
250251
segment->flags.r.data = 1;
251-
segment->flags.r.type = 1;
252+
segment->flags.r.type = SOF_MAN_SEGMENT_RODATA;
252253

253254
/* bss segment */
254255
segment = &man_module->segment[SOF_MAN_SEGMENT_BSS];
255256
segment->flags.r.alloc = 1;
256-
segment->flags.r.type = 2;
257+
segment->flags.r.type = SOF_MAN_SEGMENT_BSS;
257258

258259
fprintf(stdout, " Entry point 0x%8.8x\n", man_module->entry_point);
259260

@@ -368,14 +369,26 @@ static int man_module_create(struct image *image, struct manifest_module *module
368369

369370

370371
/* data section */
371-
man_module->segment[SOF_MAN_SEGMENT_RODATA].v_base_addr = module->file.data.start;
372-
man_module->segment[SOF_MAN_SEGMENT_RODATA].file_offset = module->foffset +
373-
module->text_fixup_size;
374372

375373
/* file_size is already aligned to MAN_PAGE_SIZE */
376374
pages = module->file.data.file_size / MAN_PAGE_SIZE;
377375

378376
man_module->segment[SOF_MAN_SEGMENT_RODATA].flags.r.length = pages;
377+
if (pages) {
378+
man_module->segment[SOF_MAN_SEGMENT_RODATA].v_base_addr = module->file.data.start;
379+
man_module->segment[SOF_MAN_SEGMENT_RODATA].file_offset = module->foffset +
380+
module->text_fixup_size;
381+
/* Copy data sections content */
382+
err = man_copy_elf_sections(image, module, &man_module->segment[SOF_MAN_SEGMENT_RODATA],
383+
module->file.data.first_section);
384+
if (err)
385+
return err;
386+
} else {
387+
man_module->segment[SOF_MAN_SEGMENT_RODATA].v_base_addr = 0;
388+
man_module->segment[SOF_MAN_SEGMENT_RODATA].file_offset = 0;
389+
man_module->segment[SOF_MAN_SEGMENT_RODATA].flags.ul = 0;
390+
man_module->segment[SOF_MAN_SEGMENT_RODATA].flags.r.type = SOF_MAN_SEGMENT_EMPTY;
391+
}
379392

380393
/* Copy data sections content */
381394
err = man_copy_elf_sections(image, module, &man_module->segment[SOF_MAN_SEGMENT_RODATA],

0 commit comments

Comments
 (0)