]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcov: fix TOPN streaming from shared libraries
authorSergei Trofimovich <siarheit@google.com>
Sun, 6 Sep 2020 11:13:54 +0000 (12:13 +0100)
committerSergei Trofimovich <siarheit@google.com>
Fri, 2 Oct 2020 12:29:29 +0000 (13:29 +0100)
Before the change gcc did not stream correctly TOPN counters
if counters belonged to a non-local shared object.

As a result zero-section optimization generated TOPN sections
in a form not recognizable by '__gcov_merge_topn'.

The problem happens because in a case of multiple shared objects
'__gcov_merge_topn' function is present in address space multiple
times (once per each object).

The fix is to never rely on function address and predicate on TOPN
counter types.

libgcc/ChangeLog:

PR gcov-profile/96913
* libgcov-driver.c (write_one_data): Avoid function pointer
comparison in TOP streaming decision.

(cherry picked from commit 4ecf368f4b4223fb2df4f3887429dfbb48852e38)

libgcc/libgcov-driver.c

index fb320738e1e8652adae8330f5985ecbe077f3672..37438883d379b2b80ab642d0ee585f98b5b43b72 100644 (file)
@@ -242,7 +242,7 @@ prune_counters (struct gcov_info *gi)
          if (gi->merge[j] == NULL)
            continue;
 
-         if (gi->merge[j] == __gcov_merge_topn)
+         if (j == GCOV_COUNTER_V_TOPN || j == GCOV_COUNTER_V_INDIR)
            {
              gcc_assert (!(ci->num % GCOV_TOPN_VALUES_COUNTERS));
              for (unsigned k = 0; k < (ci->num / GCOV_TOPN_VALUES_COUNTERS);