Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tools/rimage/src/include/rimage/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ struct module_sections_info {
/* sections count */
unsigned int count;

/* First section */
/* sections list */
struct module_section *first_section;
struct module_section *last_section;
};

/*
Expand Down
32 changes: 19 additions & 13 deletions tools/rimage/src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,22 +218,31 @@ static void sections_info_init(struct module_sections_info *info)
* Adds section to module_sections_info structure
*
* @param info Pointer to a module_sections_info structure
* @param address section address
* @param size section size
* @param section module_section structure
*/
static void sections_info_add(struct module_sections_info *info, const uint32_t address,
const size_t size)
static void sections_info_add(struct module_sections_info *info, struct module_section *section)
{
const uint32_t end = address + size;
const uint32_t end = section->load_address + section->size;

if (address < info->start)
info->start = address;
if (section->load_address < info->start)
info->start = section->load_address;

if (end > info->end)
info->end = end;

info->size += size;
info->size += section->size;
info->count++;

/* Add section to list */
section->next_section = NULL;

if (info->last_section)
info->last_section->next_section = section;

info->last_section = section;

if (!info->first_section)
info->first_section = section;
}

/**
Expand Down Expand Up @@ -356,11 +365,8 @@ void module_parse_sections(struct module *module, const struct memory_config *me
fprintf(stdout, " ROM");
} else {
/* Add section to list */
if (info) {
sections_info_add(info, out_section->load_address, out_section->size);
out_section->next_section = info->first_section;
info->first_section = out_section;
}
if (info)
sections_info_add(info, out_section);
}

module->num_sections++;
Expand Down