util/ifdtool: show overlapping region name and range details

When updating regions using a flashrom file with overlapping regions
the error message now shows overlapping region names and their ranges.

e.g:

    Regions would overlap:
           IE : 7fff000-7ffffff
      10GbE_0 : 7fff000-7ffffff

Change-Id: Ie2417e477924f0085839306a8a51d1241e20a338
Signed-off-by: Evie (Ivi) Ballou <iviballou@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/90940
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Evie (Ivi) Ballou 2026-01-27 03:18:20 +02:00 committed by Matt DeVillier
commit 26006cc217

View file

@ -2094,7 +2094,18 @@ static void new_layout(const char *filename, char *image, int size,
for (j = i + 1; j < max_regions; j++) {
if (regions_collide(&new_regions[i], &new_regions[j])) {
fprintf(stderr, "Regions would overlap.\n");
fprintf(stderr, "Regions would overlap:\n");
/* See which string is longer and make sure we pad the shorter one */
int region_name_len_i = strlen(region_name(i));
int region_name_len_j = strlen(region_name(j));
int padding = MAX(region_name_len_i, region_name_len_j);
/* Print the regions that overlap, and where each region is */
fprintf(stderr, " %*s : %x-%x\n", padding, region_name(i),
new_regions[i].base, new_regions[i].limit);
fprintf(stderr, " %*s : %x-%x\n", padding, region_name(j),
new_regions[j].base, new_regions[j].limit);
exit(EXIT_FAILURE);
}
}