aboutsummaryrefslogtreecommitdiff
path: root/ld/ldlang.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-12-05 16:37:25 +1030
committerAlan Modra <amodra@gmail.com>2019-12-05 17:35:13 +1030
commit1769380a11463b907263ef5443de5d14559f2095 (patch)
treec204179b9a8b58fe806249d62bcad87ef363b5dd /ld/ldlang.c
parent378fd436405b3051df34ac995b2e03fe1f3d1907 (diff)
downloadgdb-1769380a11463b907263ef5443de5d14559f2095.zip
gdb-1769380a11463b907263ef5443de5d14559f2095.tar.gz
gdb-1769380a11463b907263ef5443de5d14559f2095.tar.bz2
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.
Diffstat (limited to 'ld/ldlang.c')
-rw-r--r--ld/ldlang.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 191d8f1..bb3cd91 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);
+ }
}
}