gcov: Fix use of profile info section
commitf8884b9c51faea329196bf5914bcd2d700622c38
authorSebastian Huber <sebastian.huber@embedded-brains.de>
Wed, 14 Jul 2021 07:40:11 +0000 (14 09:40 +0200)
committerSebastian Huber <sebastian.huber@embedded-brains.de>
Wed, 21 Jul 2021 09:39:30 +0000 (21 11:39 +0200)
tree14c9f970f6756cd58fd00bcaab04e4db9de47b00
parente0335bb7d1fc7dd05e91bcdd1f65b2bcf8ec1a09
gcov: Fix use of profile info section

If the -fprofile-info-section is used, then the gcov information is registered
in a linker set.  This is done by build_gcov_info_var_registration().  The
compiler generated object placed in the section was not marked as referenced,
so once optimization was enabled, this object was optimized away.  Mark it as
referenced.

gcc/
* coverage.c (build_gcov_info_var_registration): Mark the object placed
in the linker set as referenced so that it does not get optimized away.
gcc/coverage.c