hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/kernel/gcov/gcc_4_7.c
....@@ -33,6 +33,13 @@
3333
3434 #define GCOV_TAG_FUNCTION_LENGTH 3
3535
36
+/* Since GCC 12.1 sizes are in BYTES and not in WORDS (4B). */
37
+#if (__GNUC__ >= 12)
38
+#define GCOV_UNIT_SIZE 4
39
+#else
40
+#define GCOV_UNIT_SIZE 1
41
+#endif
42
+
3643 static struct gcov_info *gcov_info_head;
3744
3845 /**
....@@ -70,7 +77,7 @@
7077 unsigned int ident;
7178 unsigned int lineno_checksum;
7279 unsigned int cfg_checksum;
73
- struct gcov_ctr_info ctrs[0];
80
+ struct gcov_ctr_info ctrs[];
7481 };
7582
7683 /**
....@@ -78,6 +85,7 @@
7885 * @version: gcov version magic indicating the gcc version used for compilation
7986 * @next: list head for a singly-linked list
8087 * @stamp: uniquifying time stamp
88
+ * @checksum: unique object checksum
8189 * @filename: name of the associated gcov data file
8290 * @merge: merge functions (null for unused counter type)
8391 * @n_functions: number of instrumented functions
....@@ -90,6 +98,10 @@
9098 unsigned int version;
9199 struct gcov_info *next;
92100 unsigned int stamp;
101
+ /* Since GCC 12.1 a checksum field is added. */
102
+#if (__GNUC__ >= 12)
103
+ unsigned int checksum;
104
+#endif
93105 const char *filename;
94106 void (*merge[GCOV_COUNTERS])(gcov_type *, unsigned int);
95107 unsigned int n_functions;
....@@ -451,12 +463,18 @@
451463 pos += store_gcov_u32(buffer, pos, info->version);
452464 pos += store_gcov_u32(buffer, pos, info->stamp);
453465
466
+#if (__GNUC__ >= 12)
467
+ /* Use zero as checksum of the compilation unit. */
468
+ pos += store_gcov_u32(buffer, pos, 0);
469
+#endif
470
+
454471 for (fi_idx = 0; fi_idx < info->n_functions; fi_idx++) {
455472 fi_ptr = info->functions[fi_idx];
456473
457474 /* Function record. */
458475 pos += store_gcov_u32(buffer, pos, GCOV_TAG_FUNCTION);
459
- pos += store_gcov_u32(buffer, pos, GCOV_TAG_FUNCTION_LENGTH);
476
+ pos += store_gcov_u32(buffer, pos,
477
+ GCOV_TAG_FUNCTION_LENGTH * GCOV_UNIT_SIZE);
460478 pos += store_gcov_u32(buffer, pos, fi_ptr->ident);
461479 pos += store_gcov_u32(buffer, pos, fi_ptr->lineno_checksum);
462480 pos += store_gcov_u32(buffer, pos, fi_ptr->cfg_checksum);
....@@ -470,7 +488,8 @@
470488 /* Counter record. */
471489 pos += store_gcov_u32(buffer, pos,
472490 GCOV_TAG_FOR_COUNTER(ct_idx));
473
- pos += store_gcov_u32(buffer, pos, ci_ptr->num * 2);
491
+ pos += store_gcov_u32(buffer, pos,
492
+ ci_ptr->num * 2 * GCOV_UNIT_SIZE);
474493
475494 for (cv_idx = 0; cv_idx < ci_ptr->num; cv_idx++) {
476495 pos += store_gcov_u64(buffer, pos,