aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/gcov-io.c10
2 files changed, 13 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 118c42e..b46e05a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2014-02-03 Laurent Aflonsi <laurent.alfonsi@st.com>
+
+ PR gcov-profile/58602
+ * gcc/gcov-io.c (gcov_open): Open with truncation when mode<0
+
2014-02-03 Jan Hubicka <hubicka@ucw.cz>
PR ipa/59831
diff --git a/gcc/gcov-io.c b/gcc/gcov-io.c
index b710f59..5ef82f6 100644
--- a/gcc/gcov-io.c
+++ b/gcc/gcov-io.c
@@ -149,9 +149,15 @@ gcov_open (const char *name, int mode)
/* pass mode (ignored) for compatibility */
fd = open (name, O_RDONLY, S_IRUSR | S_IWUSR);
}
- else
+ else if (mode < 0)
+ {
+ /* Write mode - acquire a write-lock. */
+ s_flock.l_type = F_WRLCK;
+ fd = open (name, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ }
+ else /* mode == 0 */
{
- /* Write mode - acquire a write-lock. */
+ /* Read-Write mode - acquire a write-lock. */
s_flock.l_type = F_WRLCK;
fd = open (name, O_RDWR | O_CREAT, 0666);
}