Merge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly
[dragonfly.git] / gnu / usr.bin / cc34 / cc_prep / patches / toplev.c.patch
1 $DragonFly: src/gnu/usr.bin/cc34/cc_prep/patches/toplev.c.patch,v 1.4 2005/08/27 21:03:51 joerg Exp $
2
3 ===================================================================
4 RCS file: /home/joerg/wd/repository/dragonflybsd/src/contrib/gcc-3.4/gcc/toplev.c,v
5 retrieving revision 1.2
6 diff -u -r1.3 toplev.c
7 --- toplev.c    24 May 2005 06:29:31 -0000      1.3
8 +++ toplev.c    27 Aug 2005 16:40:53 -0000
9 @@ -79,6 +79,7 @@
10  #include "coverage.h"
11  #include "value-prof.h"
12  #include "alloc-pool.h"
13 +#include "protector.h"
14  
15  #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
16  #include "dwarf2out.h"
17 @@ -979,6 +980,15 @@
18     minimum function alignment.  Zero means no alignment is forced.  */
19  int force_align_functions_log;
20  
21 +#if defined(STACK_PROTECTOR) && defined(STACK_GROWS_DOWNWARD)
22 +/* Nonzero means use propolice as a stack protection method */
23 +int flag_propolice_protection = 1;
24 +int flag_stack_protection = 0;
25 +#else
26 +int flag_propolice_protection = 0;
27 +int flag_stack_protection = 0;
28 +#endif
29 +
30  typedef struct
31  {
32    const char *const string;
33 @@ -1154,7 +1164,9 @@
34    {"mem-report", &mem_report, 1 },
35    { "trapv", &flag_trapv, 1 },
36    { "wrapv", &flag_wrapv, 1 },
37 -  { "new-ra", &flag_new_regalloc, 1 }
38 +  { "new-ra", &flag_new_regalloc, 1 },
39 +  {"stack-protector", &flag_propolice_protection, 1 },
40 +  {"stack-protector-all", &flag_stack_protection, 1 }
41  };
42  
43  /* Here is a table, controlled by the tm.h file, listing each -m switch
44 @@ -3163,6 +3175,11 @@
45    remove_unnecessary_notes ();
46    reorder_blocks ();
47  
48 +  /* In propolice-protection mode, we will change the variables in the
49 +     stack to be able to detect buffer overflows.  */
50 +  if (flag_propolice_protection)
51 +    prepare_stack_protection (DECL_INLINE (decl));
52 +
53    ggc_collect ();
54  
55    /* Initialize some variables used by the optimizers.  */
56 @@ -4485,6 +4502,12 @@
57      /* The presence of IEEE signaling NaNs, implies all math can trap.  */
58      if (flag_signaling_nans)
59        flag_trapping_math = 1;
60 +
61 +  /* This combination makes optimized frame addressings and causes
62 +    a internal compilation error at prepare_stack_protection.
63 +    so don't allow it.  */
64 +  if (flag_stack_protection && !flag_propolice_protection)
65 +    flag_propolice_protection = TRUE;
66  }
67  
68  /* Initialize the compiler back end.  */