ld: Fix printed sizes in map file

Message ID 20191104081014.14963-1-ceggers@gmx.de
State New
Headers show
Series
  • ld: Fix printed sizes in map file
Related show

Commit Message

Christian Eggers Nov. 4, 2019, 8:10 a.m.
For targets with octets_per_byte>1, testsuite/ld-scripts/rgn-over*
produce wrong sizes in the generated map files:

.text           0x0000000000001000        0x6
                                          ^^^ # correct
 *(.txt)
 .txt           0x0000000000001000        0xc tmpdir/rgn-over.o
                                          ^^^ # should also be 0x6

The size in the first line is generated in ldlang.c:4436:
  minfo ("0x%V %W", section->vma, TO_ADDR (section->size));

The size in the third line is generated in ldlang.c:4656:
  minfo ("0x%V %W %pB\n", addr, size, i->owner);

Signed-off-by: Christian Eggers <ceggers@gmx.de>

---
 ld/ChangeLog | 4 ++++
 ld/ldlang.c  | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

--
2.16.4

Comments

Alan Modra Nov. 5, 2019, 9:31 a.m. | #1
On Mon, Nov 04, 2019 at 09:10:14AM +0100, Christian Eggers wrote:
> +	* ldlang.c (print_input_section): Shift printed size by opb_shift.


OK, but

> -  minfo ("0x%V %W %pB\n", addr, size, i->owner);

> +  minfo ("0x%V %W %pB\n", addr, TO_ADDR(size), i->owner);


to comply with the GNU coding standards, there should be a space
between the macro and the opening parenthesis.

>    if (size != i->rawsize && i->rawsize != 0)


Please fix the rawsize display too.

-- 
Alan Modra
Australia Development Lab, IBM
Christian Eggers Nov. 6, 2019, 5:30 a.m. | #2
> to comply with the GNU coding standards, there should be a space

> between the macro and the opening parenthesis.

changed.

>> if (size != i->rawsize && i->rawsize != 0)

> Please fix the rawsize display too.

probably done, but I don't know how to test this on my platform

regards
Christian
From dec380266d7a01a26aa76bfbfe792cd4d155c2db Mon Sep 17 00:00:00 2001
From: Christian Eggers <ceggers@gmx.de>

Date: Mon, 4 Nov 2019 08:34:54 +0100
Subject: [PATCH] ld: Fix printed sizes in map file

For targets with octets_per_byte>1, testsuite/ld-scripts/rgn-over*
produce wrong sizes in the generated map files:

.text           0x0000000000001000        0x6
                                          ^^^ # correct
 *(.txt)
 .txt           0x0000000000001000        0xc tmpdir/rgn-over.o
                                          ^^^ # should also be 0x6

The size in the first line is generated in ldlang.c:4436:
  minfo ("0x%V %W", section->vma, TO_ADDR (section->size));

The size in the third line is generated in ldlang.c:4656:
  minfo ("0x%V %W %pB\n", addr, size, i->owner);

	* ldlang.c (print_input_section): Shift printed size by opb_shift.

Signed-off-by: Christian Eggers <ceggers@gmx.de>

---
 ld/ldlang.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ld/ldlang.c b/ld/ldlang.c
index df7f659486..eedcb7f405 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -4653,7 +4653,7 @@ print_input_section (asection *i, bfd_boolean is_discarded)
 	size = 0;
     }

-  minfo ("0x%V %W %pB\n", addr, size, i->owner);
+  minfo ("0x%V %W %pB\n", addr, TO_ADDR (size), i->owner);

   if (size != i->rawsize && i->rawsize != 0)
     {
@@ -4669,7 +4669,7 @@ print_input_section (asection *i, bfd_boolean is_discarded)
 	  --len;
 	}

-      minfo (_("%W (size before relaxing)\n"), i->rawsize);
+      minfo (_("%W (size before relaxing)\n"), TO_ADDR (i->rawsize));
     }

   if (i->output_section != NULL
--
2.16.4
Alan Modra Nov. 6, 2019, 7:36 a.m. | #3
On Wed, Nov 06, 2019 at 06:30:24AM +0100, Christian Eggers wrote:
> > to comply with the GNU coding standards, there should be a space

> > between the macro and the opening parenthesis.

> changed.

> 

> >> if (size != i->rawsize && i->rawsize != 0)

> > Please fix the rawsize display too.

> probably done, but I don't know how to test this on my platform


Thanks, committed.

-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/ld/ChangeLog b/ld/ChangeLog
index 8f64296c07..73b8e6ff8d 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,7 @@ 
+2019-11-04  Christian Eggers  <ceggers@gmx.de>
+
+	* ldlang.c (print_input_section): Shift printed size by opb_shift.
+
 2019-10-22  Alan Modra  <amodra@gmail.com>

 	PR 22269
diff --git a/ld/ldlang.c b/ld/ldlang.c
index df7f659486..a5805fac40 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -4653,7 +4653,7 @@  print_input_section (asection *i, bfd_boolean is_discarded)
 	size = 0;
     }

-  minfo ("0x%V %W %pB\n", addr, size, i->owner);
+  minfo ("0x%V %W %pB\n", addr, TO_ADDR(size), i->owner);

   if (size != i->rawsize && i->rawsize != 0)
     {