https://gcc.gnu.org/g:47f8297d0e1e97d12ff9f67bc10f6b14fb0a5005
commit r17-6615-g47f8297d0e1e97d12ff9f67bc10f6b14fb0a5005 Author: Sebastian Huber <[email protected]> Date: Fri Nov 20 02:13:37 2026 +0100 gcov: Place the function information in read-only data The compiler placed the gcov function information and the array of pointers to it in writable data. The program never writes to these objects. Mark both objects read-only. The target then places them in its read-only data section, or in a section which the dynamic linker makes read-only after the relocation. Assisted-by: Claude Opus 5.5 gcc/ChangeLog: * coverage.cc (coverage_obj_fn): Mark the function information read-only. (coverage_obj_finish): Mark the array of pointers to the function information read-only. Signed-off-by: Sebastian Huber <[email protected]> Diff: --- gcc/coverage.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/coverage.cc b/gcc/coverage.cc index cbe58033c2dd..31d57205dd28 100644 --- a/gcc/coverage.cc +++ b/gcc/coverage.cc @@ -1214,6 +1214,8 @@ coverage_obj_fn (vec<constructor_elt, va_gc> *ctor, tree fn, tree init = build_fn_info (data, gcov_fn_info_type, gcov_info_var); tree var = build_var (fn, gcov_fn_info_type, -1); + /* The library reads the function information only. */ + TREE_READONLY (var) = 1; DECL_INITIAL (var) = init; varpool_node::finalize_decl (var); @@ -1238,6 +1240,7 @@ coverage_obj_finish (vec<constructor_elt, va_gc> *ctor, char name_buf[32]; TREE_STATIC (fn_info_ary) = 1; + TREE_READONLY (fn_info_ary) = 1; ASM_GENERATE_INTERNAL_LABEL (name_buf, "LPBX", 1); DECL_NAME (fn_info_ary) = get_identifier (name_buf); DECL_INITIAL (fn_info_ary) = build_constructor (fn_info_ary_type, ctor);
