.. | .. |
---|
33 | 33 | |
---|
34 | 34 | #define GCOV_TAG_FUNCTION_LENGTH 3 |
---|
35 | 35 | |
---|
| 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 | + |
---|
36 | 43 | static struct gcov_info *gcov_info_head; |
---|
37 | 44 | |
---|
38 | 45 | /** |
---|
.. | .. |
---|
70 | 77 | unsigned int ident; |
---|
71 | 78 | unsigned int lineno_checksum; |
---|
72 | 79 | unsigned int cfg_checksum; |
---|
73 | | - struct gcov_ctr_info ctrs[0]; |
---|
| 80 | + struct gcov_ctr_info ctrs[]; |
---|
74 | 81 | }; |
---|
75 | 82 | |
---|
76 | 83 | /** |
---|
.. | .. |
---|
78 | 85 | * @version: gcov version magic indicating the gcc version used for compilation |
---|
79 | 86 | * @next: list head for a singly-linked list |
---|
80 | 87 | * @stamp: uniquifying time stamp |
---|
| 88 | + * @checksum: unique object checksum |
---|
81 | 89 | * @filename: name of the associated gcov data file |
---|
82 | 90 | * @merge: merge functions (null for unused counter type) |
---|
83 | 91 | * @n_functions: number of instrumented functions |
---|
.. | .. |
---|
90 | 98 | unsigned int version; |
---|
91 | 99 | struct gcov_info *next; |
---|
92 | 100 | unsigned int stamp; |
---|
| 101 | + /* Since GCC 12.1 a checksum field is added. */ |
---|
| 102 | +#if (__GNUC__ >= 12) |
---|
| 103 | + unsigned int checksum; |
---|
| 104 | +#endif |
---|
93 | 105 | const char *filename; |
---|
94 | 106 | void (*merge[GCOV_COUNTERS])(gcov_type *, unsigned int); |
---|
95 | 107 | unsigned int n_functions; |
---|
.. | .. |
---|
451 | 463 | pos += store_gcov_u32(buffer, pos, info->version); |
---|
452 | 464 | pos += store_gcov_u32(buffer, pos, info->stamp); |
---|
453 | 465 | |
---|
| 466 | +#if (__GNUC__ >= 12) |
---|
| 467 | + /* Use zero as checksum of the compilation unit. */ |
---|
| 468 | + pos += store_gcov_u32(buffer, pos, 0); |
---|
| 469 | +#endif |
---|
| 470 | + |
---|
454 | 471 | for (fi_idx = 0; fi_idx < info->n_functions; fi_idx++) { |
---|
455 | 472 | fi_ptr = info->functions[fi_idx]; |
---|
456 | 473 | |
---|
457 | 474 | /* Function record. */ |
---|
458 | 475 | 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); |
---|
460 | 478 | pos += store_gcov_u32(buffer, pos, fi_ptr->ident); |
---|
461 | 479 | pos += store_gcov_u32(buffer, pos, fi_ptr->lineno_checksum); |
---|
462 | 480 | pos += store_gcov_u32(buffer, pos, fi_ptr->cfg_checksum); |
---|
.. | .. |
---|
470 | 488 | /* Counter record. */ |
---|
471 | 489 | pos += store_gcov_u32(buffer, pos, |
---|
472 | 490 | 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); |
---|
474 | 493 | |
---|
475 | 494 | for (cv_idx = 0; cv_idx < ci_ptr->num; cv_idx++) { |
---|
476 | 495 | pos += store_gcov_u64(buffer, pos, |
---|