From 1769380a11463b907263ef5443de5d14559f2095 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Thu, 5 Dec 2019 16:37:25 +1030 Subject: [PATCH] PR25244, --print-memory-usage, division by zero if MEMORY length is zero PR 25244 * ldlang.c (lang_print_memory_usage): Don't print percent used when length is zero. --- ld/ChangeLog | 6 ++++++ ld/ldlang.c | 9 +++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index adca95ffc0b..15b2d805334 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,9 @@ +2019-12-05 Alan Modra + + PR 25244 + * ldlang.c (lang_print_memory_usage): Don't print percent used + when length is zero. + 2019-11-27 Andrew Burgess * testsuite/ld-elf/eh5.d: Accept version 3 DWARF CIE. diff --git a/ld/ldlang.c b/ld/ldlang.c index 191d8f1c61d..bb3cd912157 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -9273,14 +9273,15 @@ lang_print_memory_usage (void) for (r = lang_memory_region_list; r->next != NULL; r = r->next) { bfd_vma used_length = r->current - r->origin; - double percent; printf ("%16s: ",r->name_list.name); lang_print_memory_size (used_length); lang_print_memory_size ((bfd_vma) r->length); - percent = used_length * 100.0 / r->length; - - printf (" %6.2f%%\n", percent); + if (r->length != 0) + { + double percent = used_length * 100.0 / r->length; + printf (" %6.2f%%\n", percent); + } } } -- 2.30.2