Include ProPolice suport for GCC 3.4.
[dragonfly.git] / gnu / usr.bin / cc34 / cc_prep / patches / function.c.patch
1 $DragonFly: src/gnu/usr.bin/cc34/cc_prep/patches/function.c.patch,v 1.1 2004/06/19 10:30:08 joerg Exp $
2
3 --- ../gcc.orig/function.c      2004-06-18 23:08:11.000000000 +0200
4 +++ function.c  2004-06-18 23:27:25.000000000 +0200
5 @@ -63,6 +63,7 @@
6  #include "integrate.h"
7  #include "langhooks.h"
8  #include "target.h"
9 +#include "protector.h"
10  
11  #ifndef TRAMPOLINE_ALIGNMENT
12  #define TRAMPOLINE_ALIGNMENT FUNCTION_BOUNDARY
13 @@ -155,6 +156,10 @@
14  /* Array of INSN_UIDs to hold the INSN_UIDs for each sibcall epilogue
15     in this function.  */
16  static GTY(()) varray_type sibcall_epilogue;
17 +
18 +/* Current boundary mark for character arrays.  */
19 +static int temp_boundary_mark = 0;
20 +
21  \f
22  /* In order to evaluate some expressions, such as function calls returning
23     structures in memory, we need to temporarily allocate stack locations.
24 @@ -208,6 +213,8 @@
25    /* The size of the slot, including extra space for alignment.  This
26       info is for combine_temp_slots.  */
27    HOST_WIDE_INT full_size;
28 +  /* Boundary mark of a character array and the others. This info is for propolice.  */
29 +  int boundary_mark;
30  };
31  \f
32  /* This structure is used to record MEMs or pseudos used to replace VAR, any
33 @@ -638,6 +645,7 @@
34     whose lifetime is controlled by CLEANUP_POINT_EXPRs.  KEEP is 3
35     if we are to allocate something at an inner level to be treated as
36     a variable in the block (e.g., a SAVE_EXPR).
37 +   KEEP is 5 if we allocate a place to return structure.
38  
39     TYPE is the type that will be used for the stack slot.  */
40  
41 @@ -648,6 +656,8 @@
42    unsigned int align;
43    struct temp_slot *p, *best_p = 0;
44    rtx slot;
45 +  int char_array = (flag_propolice_protection
46 +                   && keep == 1 && search_string_def (type));
47  
48    /* If SIZE is -1 it means that somebody tried to allocate a temporary
49       of a variable size.  */
50 @@ -673,7 +683,8 @@
51         && ! p->in_use
52         && objects_must_conflict_p (p->type, type)
53         && (best_p == 0 || best_p->size > p->size
54 -           || (best_p->size == p->size && best_p->align > p->align)))
55 +           || (best_p->size == p->size && best_p->align > p->align))
56 +       && (! char_array || p->boundary_mark != 0))
57        {
58         if (p->align == align && p->size == size)
59           {
60 @@ -708,6 +719,7 @@
61               p->address = 0;
62               p->rtl_expr = 0;
63               p->type = best_p->type;
64 +             p->boundary_mark = best_p->boundary_mark;
65               p->next = temp_slots;
66               temp_slots = p;
67  
68 @@ -768,6 +780,7 @@
69        p->full_size = frame_offset - frame_offset_old;
70  #endif
71        p->address = 0;
72 +      p->boundary_mark = char_array ? ++temp_boundary_mark : 0;
73        p->next = temp_slots;
74        temp_slots = p;
75      }
76 @@ -932,14 +945,16 @@
77             int delete_q = 0;
78             if (! q->in_use && GET_MODE (q->slot) == BLKmode)
79               {
80 -               if (p->base_offset + p->full_size == q->base_offset)
81 +               if (p->base_offset + p->full_size == q->base_offset &&
82 +                   p->boundary_mark == q->boundary_mark)
83                   {
84                     /* Q comes after P; combine Q into P.  */
85                     p->size += q->size;
86                     p->full_size += q->full_size;
87                     delete_q = 1;
88                   }
89 -               else if (q->base_offset + q->full_size == p->base_offset)
90 +               else if (q->base_offset + q->full_size == p->base_offset &&
91 +                        p->boundary_mark == q->boundary_mark)
92                   {
93                     /* P comes after Q; combine P into Q.  */
94                     q->size += p->size;
95 @@ -1449,7 +1464,9 @@
96      }
97  
98    if (new == 0)
99 -    new = assign_stack_local_1 (decl_mode, GET_MODE_SIZE (decl_mode), 0, func);
100 +    new = function ?
101 +      assign_stack_local_1 (decl_mode, GET_MODE_SIZE (decl_mode), 0, func)
102 +      :        assign_stack_local_for_pseudo_reg (decl_mode, GET_MODE_SIZE (decl_mode), 0);
103  
104    PUT_CODE (reg, MEM);
105    PUT_MODE (reg, decl_mode);
106 @@ -3930,7 +3947,8 @@
107                  constant with that register.  */
108               temp = gen_reg_rtx (Pmode);
109               XEXP (x, 0) = new;
110 -             if (validate_change (object, &XEXP (x, 1), temp, 0))
111 +             if (validate_change (object, &XEXP (x, 1), temp, 0)
112 +                 && !flag_propolice_protection)
113                 emit_insn_before (gen_move_insn (temp, new_offset), object);
114               else
115                 {