]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
ld: Print 0 size in B and not in GB
authorTorbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Sun, 17 Dec 2023 21:16:08 +0000 (22:16 +0100)
committerNick Clifton <nickc@redhat.com>
Mon, 18 Dec 2023 12:32:14 +0000 (12:32 +0000)
When using --print-memory-usage, the printed size can be zero and in
that case, the unit should be B and not GB.

ld/
* ldlang.c (lang_print_memory_size) Print 0 B instead of 0 GB.
* testsuite/ld-scripts/print-memory-usage-1.l: Validate emplty region.
* testsuite/ld-scripts/print-memory-usage-1.t: Define empty region.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
ld/ldlang.c
ld/testsuite/ld-scripts/print-memory-usage-1.l
ld/testsuite/ld-scripts/print-memory-usage-1.t

index 566c2b8326ffe56e30048e5e9eb764ffe6ff1b08..105404adcfb72bc9eddd4815137f5350d9db57b1 100644 (file)
@@ -9921,7 +9921,9 @@ lang_ld_feature (char *str)
 static void
 lang_print_memory_size (uint64_t sz)
 {
-  if ((sz & 0x3fffffff) == 0)
+  if (sz == 0)
+    printf (" %10" PRIu64 " B", sz);
+  else if ((sz & 0x3fffffff) == 0)
     printf ("%10" PRIu64 " GB", sz >> 30);
   else if ((sz & 0xfffff) == 0)
     printf ("%10" PRIu64 " MB", sz >> 20);
index e666a632c964cb715a83539cb6b7a771ea2c73c9..c59722059fdf35d58bc1b18e4bf1bed54de92d55 100644 (file)
@@ -1,3 +1,4 @@
 Memory region         Used Size  Region Size  %age Used
              ROM:          32 B         1 KB      3.1[23]%
              RAM:          32 B       256 KB      0.01%
+             FOO:           0 B         1 KB      0.00%
index 97065b30c5234a53bf4a898125d833491d5037be..56484f451c505a3a7e0cefd7758bc06426fd93cf 100644 (file)
@@ -2,4 +2,5 @@ MEMORY
 {
   ROM (RX) : ORIGIN = 0x1000, LENGTH = 1K
   RAM (W)  : ORIGIN = 0x100000, LENGTH = 256K
+  FOO (RX) : ORIGIN = 0x100, LENGTH = 1K
 }