This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: libssp, fix AVR bootstrap failure for gcc


The code in 

/libssp/ssp.c

implicitly assumes that the define symbols O_RDONLY and O_WRONLY exist. For 
the AVR target those are not defined in the header files included by ssp.c. 
Also the code does not work as expected for embedded targets that do not have 
"files" with the usual meaning.

All of this causes a bootstrap failure for the AVR target.

The patch adds #ifdefs as guards that first check for existing definitions of 
O_RDONLY and O_WRONLY before actually using them.

After applying this change, bootstrap again succeeds.

Bjoern.


2005-12-30  Bjoern Haase  <bjoern.m.haase@web.de>

        * ssp.c: add "#ifdef" protections for symbols O_RDONLY and O_WRONLY


Index: ssp.c
===================================================================
--- ssp.c	(revision 109170)
+++ ssp.c	(working copy)
@@ -67,6 +67,8 @@
   if (__stack_chk_guard != 0)
     return;
 
+#ifdef O_RDONLY
+
   fd = open ("/dev/urandom", O_RDONLY);
   if (fd != -1)
     {
@@ -77,6 +79,8 @@
         return;
     }
 
+#endif
+
   /* If a random generator can't be used, the protector switches the guard
      to the "terminator canary".  */
   p = (unsigned char *) &__stack_chk_guard;
@@ -97,6 +101,8 @@
 
   /* Print error message directly to the tty.  This avoids Bad Things
      happening if stderr is redirected.  */
+
+#ifdef O_WRONLY
   fd = open (_PATH_TTY, O_WRONLY);
   if (fd != -1)
     {
@@ -124,6 +130,7 @@
         }
       close (fd);
     }
+#endif
 
 #ifdef HAVE_SYSLOG_H
   /* Only send the error to syslog if there was no tty available.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]