https://sourceware.org/bugzilla/show_bug.cgi?id=32764

--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> ---
This change:

diff --git a/gprof/gprof.c b/gprof/gprof.c
index 9392575f747..d1cbf25fa28 100644
--- a/gprof/gprof.c
+++ b/gprof/gprof.c
@@ -527,17 +527,6 @@ This program is free software.  This program has
absolutely no warranty.\n"));
   if (ignore_direct_calls)
     core_get_text_space (core_bfd);

-  /* Create symbols from core image.  */
-  if (external_symbol_table)
-    core_create_syms_from (external_symbol_table);
-  else if (line_granularity)
-    core_create_line_syms ();
-  else
-    core_create_function_syms ();
-
-  /* Translate sym specs into syms.  */
-  sym_id_parse ();
-
   if (file_format == FF_PROF)
     {
       fprintf (stderr,
@@ -557,6 +546,18 @@ This program is free software.  This program has
absolutely no warranty.\n"));
       while (optind++ < argc);
     }

+  /* Create symbols from core image.  */
+  if (external_symbol_table)
+    core_create_syms_from (external_symbol_table);
+  else if (line_granularity)
+    core_create_line_syms ();
+  else
+    core_create_function_syms ();
+
+  /* Translate sym specs into syms.  */
+  sym_id_parse ();
+
+
   /* If user did not specify output style, try to guess something
      reasonable.  */
   if (output_style == 0)

caused the regression.  Before this change, entries in symtab.base were updated
by

#0  cg_tally (from_pc=<optimized out>, self_pc=<optimized out>, count=1000)
    at /export/gnu/import/git/gitlab/x86-binutils/gprof/call_graph.c:67
#1  0x000000000040261c in cg_read_rec (ifp=ifp@entry=0x553d10, 
    filename=filename@entry=0x7fffffffde8a
"/export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/gmon/tst-gmon.data.187731")
    at /export/gnu/import/git/gitlab/x86-binutils/gprof/call_graph.c:99
#2  0x0000000000407bed in gmon_out_read (
    filename=0x7fffffffde8a
"/export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/gmon/tst-gmon.data.187731")
    at /export/gnu/import/git/gitlab/x86-binutils/gprof/gmon_io.c:338
#3  0x0000000000409375 in main (argc=3, argv=0x7fffffffda48)
    at /export/gnu/import/git/gitlab/x86-binutils/gprof/gprof.c:553
(gdb) 

To properly populate symtab.base, symbols were loaded first.  When symbols
are loaded after histograms, we must rearrange the code to call cg_tally with
symbols loaded.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to