aboutsummaryrefslogtreecommitdiff
path: root/gcc/coverage.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-07-14 09:40:11 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-07-21 11:39:30 +0200
commitf8884b9c51faea329196bf5914bcd2d700622c38 (patch)
tree14c9f970f6756cd58fd00bcaab04e4db9de47b00 /gcc/coverage.c
parente0335bb7d1fc7dd05e91bcdd1f65b2bcf8ec1a09 (diff)
downloadgcc-f8884b9c51faea329196bf5914bcd2d700622c38.zip
gcc-f8884b9c51faea329196bf5914bcd2d700622c38.tar.gz
gcc-f8884b9c51faea329196bf5914bcd2d700622c38.tar.bz2
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.
Diffstat (limited to 'gcc/coverage.c')
-rw-r--r--gcc/coverage.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/coverage.c b/gcc/coverage.c
index dfc8108..ac9a9fd 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -50,6 +50,7 @@ along with GCC; see the file COPYING3. If not see
#include "auto-profile.h"
#include "profile.h"
#include "diagnostic.h"
+#include "varasm.h"
#include "gcov-io.c"
@@ -1121,6 +1122,7 @@ build_gcov_info_var_registration (tree gcov_info_type)
DECL_NAME (var) = get_identifier (name_buf);
get_section (profile_info_section, SECTION_UNNAMED, NULL);
set_decl_section_name (var, profile_info_section);
+ mark_decl_referenced (var);
DECL_INITIAL (var) = build_fold_addr_expr (gcov_info_var);
varpool_node::finalize_decl (var);
}