GCC currently always opens .gcda/.gcno files in write mode. This
leads to permission denied errors when opening these files if the
files are read-only. Having read-only .gcda files is useful to ensure
that one does not unintentionally modify profile data (by default, an
instrumented binary will append to .gcda files). This patch modifies
the behavior of gcov_open to only open the file in write mode if the
MODE argument is >= 0.
Bootstrapped/regtested on x86_64-linux and i686-linux. Verified that
FDO still works. Ok for trunk?
2009-09-17 Neil Vachharajani <nvachhar@gmail.com>
* gcov-io.c (gcov_open): Open files read-only when MODE < 0