* [PATCH] ld: Print 0 size in B and not in GB
@ 2023-12-17 21:16 Torbjörn SVENSSON
2023-12-18 12:33 ` Nick Clifton
0 siblings, 1 reply; 2+ messages in thread
From: Torbjörn SVENSSON @ 2023-12-17 21:16 UTC (permalink / raw)
To: binutils; +Cc: Torbjörn SVENSSON
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 | 4 +++-
ld/testsuite/ld-scripts/print-memory-usage-1.l | 1 +
ld/testsuite/ld-scripts/print-memory-usage-1.t | 1 +
3 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 566c2b8326f..105404adcfb 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -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);
diff --git a/ld/testsuite/ld-scripts/print-memory-usage-1.l b/ld/testsuite/ld-scripts/print-memory-usage-1.l
index e666a632c96..c59722059fd 100644
--- a/ld/testsuite/ld-scripts/print-memory-usage-1.l
+++ b/ld/testsuite/ld-scripts/print-memory-usage-1.l
@@ -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%
diff --git a/ld/testsuite/ld-scripts/print-memory-usage-1.t b/ld/testsuite/ld-scripts/print-memory-usage-1.t
index 97065b30c52..56484f451c5 100644
--- a/ld/testsuite/ld-scripts/print-memory-usage-1.t
+++ b/ld/testsuite/ld-scripts/print-memory-usage-1.t
@@ -2,4 +2,5 @@ MEMORY
{
ROM (RX) : ORIGIN = 0x1000, LENGTH = 1K
RAM (W) : ORIGIN = 0x100000, LENGTH = 256K
+ FOO (RX) : ORIGIN = 0x100, LENGTH = 1K
}
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] ld: Print 0 size in B and not in GB
2023-12-17 21:16 [PATCH] ld: Print 0 size in B and not in GB Torbjörn SVENSSON
@ 2023-12-18 12:33 ` Nick Clifton
0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2023-12-18 12:33 UTC (permalink / raw)
To: Torbjörn SVENSSON, binutils
Hi Torbjörn,
> 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.
Patch approved and applied.
Cheers
Nick
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-12-18 12:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-17 21:16 [PATCH] ld: Print 0 size in B and not in GB Torbjörn SVENSSON
2023-12-18 12:33 ` Nick Clifton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).