backport: libgcov.c: Add references to gcov_reset and gcov_dump from L_gcov section.

Backport r188134 from google/main:

        2012-06-01   Teresa Johnson  <tejohnson@google.com>

        * libgcov.c: Add references to gcov_reset and gcov_dump
        from L_gcov section.

From-SVN: r199103
This commit is contained in:
Teresa Johnson 2013-05-20 13:33:56 +00:00
parent 928804629e
commit e442847d9f

View File

@ -94,6 +94,21 @@ extern int gcov_dump_complete ATTRIBUTE_HIDDEN;
#ifdef L_gcov
#include "gcov-io.c"
/* Create a strong reference to these symbols so that they are
unconditionally pulled into the instrumented binary, even when
the only reference is a weak reference. This is necessary because
we are using weak references to handle older compilers that
pre-date these new functions. A subtlety of the linker is that
it will only resolve weak references defined within archive libraries
when there is a string reference to something else defined within
the same object file. Since these two functions are defined within
their own object files (using L_gcov_reset and L_gcov_dump), they
would not get resolved. Since there are symbols within the main L_gcov
section that are strongly referenced during -fprofile-generate builds,
these symbols will always need to be resolved. */
void (*__gcov_dummy_ref1)() = &__gcov_reset;
void (*__gcov_dummy_ref2)() = &__gcov_dump;
/* Utility function for outputing errors. */
static int
gcov_error (const char *fmt, ...)