@@ -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