This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Fix 'ld -statistics' so that it prints a usable "data size"
- From: Simon Baldwin <simonb at google dot com>
- To: binutils at sourceware dot org
- Date: Thu, 25 Oct 2012 13:48:41 +0200
- Subject: Fix 'ld -statistics' so that it prints a usable "data size"
Fix 'ld -statistics' so that it prints a usable "data size".
Applies the essence of this gas fix to ld, since ld has the same problem:
http://sourceware.org/ml/binutils/2012-10/msg00248.html
Tested for x86_64. Comparative results shown below. OK?
Thanks.
Test results:
for i in $(seq 1 10); do
build_before/ld/as-new -statistics ... 2>&1 | grep 'data size'
done
build_before/ld/ld-new: data size 29515648
build_before/ld/ld-new: data size 29343616
build_before/ld/ld-new: data size 20610944
build_before/ld/ld-new: data size 22605696
build_before/ld/ld-new: data size 34590592
build_before/ld/ld-new: data size 4333440
build_before/ld/ld-new: data size 35454848
build_before/ld/ld-new: data size 34078592
build_before/ld/ld-new: data size 7688064
build_before/ld/ld-new: data size 9723776
for i in $(seq 1 10); do
build_after/ld/as-new -statistics ... 2>&1 | grep 'data size'
done
build_after/ld/ld-new: data size 2203648
build_after/ld/ld-new: data size 2203648
build_after/ld/ld-new: data size 2203648
build_after/ld/ld-new: data size 2203648
build_after/ld/ld-new: data size 2203648
build_after/ld/ld-new: data size 2203648
build_after/ld/ld-new: data size 2203648
build_after/ld/ld-new: data size 2203648
build_after/ld/ld-new: data size 2203648
build_after/ld/ld-new: data size 2203648
ld/ChangeLog
2012-10-25 Simon Baldwin <simonb@google.com>
* ldmain.c (main): Add start_sbrk set to sbrk(0) on entry.
On exit, compute data size as the delta between current
sbrk(0) and start_sbrk.
Index: ld/ldmain.c
===================================================================
RCS file: /cvs/src/src/ld/ldmain.c,v
retrieving revision 1.167
diff -u -p -r1.167 ldmain.c
--- ld/ldmain.c 24 Oct 2012 11:09:28 -0000 1.167
+++ ld/ldmain.c 25 Oct 2012 11:26:34 -0000
@@ -191,6 +191,9 @@ main (int argc, char **argv)
{
char *emulation;
long start_time = get_run_time ();
+#ifdef HAVE_SBRK
+ char *start_sbrk = (char *) sbrk (0);
+#endif
#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
setlocale (LC_MESSAGES, "");
@@ -505,7 +508,7 @@ main (int argc, char **argv)
program_name, run_time / 1000000, run_time % 1000000);
#ifdef HAVE_SBRK
fprintf (stderr, _("%s: data size %ld\n"), program_name,
- (long) (lim - (char *) &environ));
+ (long) (lim - start_sbrk));
#endif
fflush (stderr);
}
--
Google UK Limited | Registered Office: Belgrave House, 76 Buckingham
Palace Road, London SW1W 9TQ | Registered in England Number: 3977902