forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
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 /**
....@@ -451,12 +458,18 @@
451458 pos += store_gcov_u32(buffer, pos, info->version);
452459 pos += store_gcov_u32(buffer, pos, info->stamp);
453460
461
+#if (__GNUC__ >= 12)
462
+ /* Use zero as checksum of the compilation unit. */
463
+ pos += store_gcov_u32(buffer, pos, 0);
464
+#endif
465
+
454466 for (fi_idx = 0; fi_idx < info->n_functions; fi_idx++) {
455467 fi_ptr = info->functions[fi_idx];
456468
457469 /* Function record. */
458470 pos += store_gcov_u32(buffer, pos, GCOV_TAG_FUNCTION);
459
- pos += store_gcov_u32(buffer, pos, GCOV_TAG_FUNCTION_LENGTH);
471
+ pos += store_gcov_u32(buffer, pos,
472
+ GCOV_TAG_FUNCTION_LENGTH * GCOV_UNIT_SIZE);
460473 pos += store_gcov_u32(buffer, pos, fi_ptr->ident);
461474 pos += store_gcov_u32(buffer, pos, fi_ptr->lineno_checksum);
462475 pos += store_gcov_u32(buffer, pos, fi_ptr->cfg_checksum);
....@@ -470,7 +483,8 @@
470483 /* Counter record. */
471484 pos += store_gcov_u32(buffer, pos,
472485 GCOV_TAG_FOR_COUNTER(ct_idx));
473
- pos += store_gcov_u32(buffer, pos, ci_ptr->num * 2);
486
+ pos += store_gcov_u32(buffer, pos,
487
+ ci_ptr->num * 2 * GCOV_UNIT_SIZE);
474488
475489 for (cv_idx = 0; cv_idx < ci_ptr->num; cv_idx++) {
476490 pos += store_gcov_u64(buffer, pos,