GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcov

gcov: Place the function information in read-only data

Moves gcov function information and pointer array to read-only data sections.

The compiler now places gcov function information and the array of pointers to this information into read-only data segments. Previously, these objects resided in writable memory, which was unnecessary as they are never modified after initialization. This change improves code safety by preventing accidental writes and potentially allows for better memory protection by the target system.

In Details

The coverage_obj_fn and coverage_obj_finish functions in coverage.cc now mark the gcov function information structures and their associated pointer arrays as read-only. This ensures that these metadata objects, which are populated during compilation and not modified at runtime, are placed in a read-only section by the target backend. This change aligns with the principle of least privilege and can enhance security and stability.

For Context
gcov
A code coverage tool used with GCC to analyze how much of your program is being executed. It works by instrumenting the code during compilation.
read-only data
A memory segment in an executable file that contains constants and other data that should not be modified during program execution. Placing data here can improve security and allow for memory sharing.
Filed Under: gcovcode coveragesecurity