This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] Remove use of sbrk


Hi,

this patch removes the reports of data size based on sbrk.

The rational is:
* I got warnings (and thus build failure unless --disable-werror) on Darwin, as sbrk(2) is marked as deprecated. (I agree that this point is very minor).
* I seriously doubt about the accuracy of memory usage as reported by sbrk(2) as malloc doesn't allocate all its memory with sbrk. I also doubt that this is often used by developers as there are much more advanced tools to investigate performance issues.

Any comments ? Ok for trunk ?

Tristan.

binutils/
2013-12-06  Tristan Gingold  <gingold@adacore.com>

	* nm.c (show_stats): Remove variable.
	(long_options): Remove --stats option.
	(main): Remove handling of --stats.

ld/
2013-12-06  Tristan Gingold  <gingold@adacore.com>

	* ldmain.c (main): Remove display of data size.

gas/
2013-12-06  Tristan Gingold  <gingold@adacore.com>

	* as.c (start_sbrk): Remove.
	(main): Remove assignment.
	(dump_statistics): Remove display of data size.


diff --git a/binutils/nm.c b/binutils/nm.c
index 156194f..ab21a40 100644
--- a/binutils/nm.c
+++ b/binutils/nm.c
@@ -150,7 +150,6 @@ static int sort_by_size = 0;	/* Sort by size of symbol.  */
 static int undefined_only = 0;	/* Print undefined symbols only.  */
 static int dynamic = 0;		/* Print dynamic symbols.  */
 static int show_version = 0;	/* Show the version number.  */
-static int show_stats = 0;	/* Show statistics.  */
 static int show_synthetic = 0;	/* Display synthesized symbols too.  */
 static int line_numbers = 0;	/* Print line numbers for symbols.  */
 static int allow_special_symbols = 0;  /* Allow special symbols.  */
@@ -209,7 +208,6 @@ static struct option long_options[] =
   {"reverse-sort", no_argument, &reverse_sort, 1},
   {"size-sort", no_argument, 0, OPTION_SIZE_SORT},
   {"special-syms", no_argument, &allow_special_symbols, 1},
-  {"stats", no_argument, &show_stats, 1},
   {"synthetic", no_argument, &show_synthetic, 1},
   {"target", required_argument, 0, OPTION_TARGET},
   {"defined-only", no_argument, &defined_only, 1},
@@ -1692,15 +1690,6 @@ main (int argc, char **argv)
 
   END_PROGRESS (program_name);
 
-#ifdef HAVE_SBRK
-  if (show_stats)
-    {
-      char *lim = (char *) sbrk (0);
-
-      non_fatal (_("data size %ld"), (long) (lim - (char *) &environ));
-    }
-#endif
-
   exit (retval);
   return retval;
 }
diff --git a/gas/as.c b/gas/as.c
index f198043..e1afd34 100644
--- a/gas/as.c
+++ b/gas/as.c
@@ -46,12 +46,6 @@
 #define itbl_init()
 #endif
 
-#ifdef HAVE_SBRK
-#ifdef NEED_DECLARATION_SBRK
-extern void *sbrk ();
-#endif
-#endif
-
 #ifdef USING_CGEN
 /* Perform any cgen specific initialisation for gas.  */
 extern void gas_cgen_begin (void);
@@ -121,9 +115,6 @@ static struct itbl_file_list *itbl_files;
 #endif
 
 static long start_time;
-#ifdef HAVE_SBRK
-char *start_sbrk;
-#endif
 
 static int flag_macro_alternate;
 
@@ -973,17 +964,10 @@ This program has absolutely no warranty.\n"));
 static void
 dump_statistics (void)
 {
-#ifdef HAVE_SBRK
-  char *lim = (char *) sbrk (0);
-#endif
   long run_time = get_run_time () - start_time;
 
   fprintf (stderr, _("%s: total time in assembly: %ld.%06ld\n"),
 	   myname, run_time / 1000000, run_time % 1000000);
-#ifdef HAVE_SBRK
-  fprintf (stderr, _("%s: data size %ld\n"),
-	   myname, (long) (lim - start_sbrk));
-#endif
 
   subsegs_print_statistics (stderr);
   write_print_statistics (stderr);
@@ -1142,9 +1126,6 @@ main (int argc, char ** argv)
   int macro_strip_at;
 
   start_time = get_run_time ();
-#ifdef HAVE_SBRK
-  start_sbrk = (char *) sbrk (0);
-#endif
 
 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
   setlocale (LC_MESSAGES, "");
diff --git a/ld/ldmain.c b/ld/ldmain.c
index 019df71..07f14aa 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -51,12 +51,6 @@
 
 #include <string.h>
 
-#ifdef HAVE_SBRK
-#if !HAVE_DECL_SBRK
-extern void *sbrk ();
-#endif
-#endif
-
 #ifndef TARGET_SYSTEM_ROOT
 #define TARGET_SYSTEM_ROOT ""
 #endif
@@ -189,9 +183,6 @@ 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, "");
@@ -495,18 +486,11 @@ main (int argc, char **argv)
 
   if (config.stats)
     {
-#ifdef HAVE_SBRK
-      char *lim = (char *) sbrk (0);
-#endif
       long run_time = get_run_time () - start_time;
 
       fflush (stdout);
       fprintf (stderr, _("%s: total time in link: %ld.%06ld\n"),
 	       program_name, run_time / 1000000, run_time % 1000000);
-#ifdef HAVE_SBRK
-      fprintf (stderr, _("%s: data size %ld\n"), program_name,
-	       (long) (lim - start_sbrk));
-#endif
       fflush (stderr);
     }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]