Skip to content

Commit df3af2b

Browse files
committed
rimage: module: Fix section order in output image
Fixed the order in which sections are placed in the output firmware image for platforms using a simple manifest. Fixes: #8336 Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
1 parent a951579 commit df3af2b

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

tools/rimage/src/include/rimage/module.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ struct module_sections_info {
6363
/* sections count */
6464
unsigned int count;
6565

66-
/* First section */
66+
/* sections list */
6767
struct module_section *first_section;
68+
struct module_section *last_section;
6869
};
6970

7071
/*

tools/rimage/src/module.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -218,22 +218,31 @@ static void sections_info_init(struct module_sections_info *info)
218218
* Adds section to module_sections_info structure
219219
*
220220
* @param info Pointer to a module_sections_info structure
221-
* @param address section address
222-
* @param size section size
221+
* @param section module_section structure
223222
*/
224-
static void sections_info_add(struct module_sections_info *info, const uint32_t address,
225-
const size_t size)
223+
static void sections_info_add(struct module_sections_info *info, struct module_section *section)
226224
{
227-
const uint32_t end = address + size;
225+
const uint32_t end = section->load_address + section->size;
228226

229-
if (address < info->start)
230-
info->start = address;
227+
if (section->load_address < info->start)
228+
info->start = section->load_address;
231229

232230
if (end > info->end)
233231
info->end = end;
234232

235-
info->size += size;
233+
info->size += section->size;
236234
info->count++;
235+
236+
/* Add section to list */
237+
section->next_section = NULL;
238+
239+
if (info->last_section)
240+
info->last_section->next_section = section;
241+
242+
info->last_section = section;
243+
244+
if (!info->first_section)
245+
info->first_section = section;
237246
}
238247

239248
/**
@@ -356,11 +365,8 @@ void module_parse_sections(struct module *module, const struct memory_config *me
356365
fprintf(stdout, " ROM");
357366
} else {
358367
/* Add section to list */
359-
if (info) {
360-
sections_info_add(info, out_section->load_address, out_section->size);
361-
out_section->next_section = info->first_section;
362-
info->first_section = out_section;
363-
}
368+
if (info)
369+
sections_info_add(info, out_section);
364370
}
365371

366372
module->num_sections++;

0 commit comments

Comments
 (0)