.. | .. |
---|
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 | /** |
---|
.. | .. |
---|
451 | 458 | pos += store_gcov_u32(buffer, pos, info->version); |
---|
452 | 459 | pos += store_gcov_u32(buffer, pos, info->stamp); |
---|
453 | 460 | |
---|
| 461 | +#if (__GNUC__ >= 12) |
---|
| 462 | + /* Use zero as checksum of the compilation unit. */ |
---|
| 463 | + pos += store_gcov_u32(buffer, pos, 0); |
---|
| 464 | +#endif |
---|
| 465 | + |
---|
454 | 466 | for (fi_idx = 0; fi_idx < info->n_functions; fi_idx++) { |
---|
455 | 467 | fi_ptr = info->functions[fi_idx]; |
---|
456 | 468 | |
---|
457 | 469 | /* Function record. */ |
---|
458 | 470 | 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); |
---|
460 | 473 | pos += store_gcov_u32(buffer, pos, fi_ptr->ident); |
---|
461 | 474 | pos += store_gcov_u32(buffer, pos, fi_ptr->lineno_checksum); |
---|
462 | 475 | pos += store_gcov_u32(buffer, pos, fi_ptr->cfg_checksum); |
---|
.. | .. |
---|
470 | 483 | /* Counter record. */ |
---|
471 | 484 | pos += store_gcov_u32(buffer, pos, |
---|
472 | 485 | 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); |
---|
474 | 488 | |
---|
475 | 489 | for (cv_idx = 0; cv_idx < ci_ptr->num; cv_idx++) { |
---|
476 | 490 | pos += store_gcov_u64(buffer, pos, |
---|