Include ProPolice suport for GCC 3.4.
[dragonfly.git] / gnu / usr.bin / cc34 / cc_prep / patches / expr.c.patch
1 $DragonFly: src/gnu/usr.bin/cc34/cc_prep/patches/expr.c.patch,v 1.1 2004/06/19 10:30:08 joerg Exp $
2
3 --- ../gcc.orig/expr.c  2004-06-18 23:08:11.000000000 +0200
4 +++ expr.c      2004-06-18 23:22:24.000000000 +0200
5 @@ -48,6 +48,7 @@
6  #include "intl.h"
7  #include "tm_p.h"
8  #include "target.h"
9 +#include "protector.h"
10  
11  /* Decide whether a function's arguments should be processed
12     from first to last or from last to first.
13 @@ -1060,7 +1061,11 @@
14  
15     If ENDP is 0 return to, if ENDP is 1 return memory at the end ala
16     mempcpy, and if ENDP is 2 return memory the end minus one byte ala
17 -   stpcpy.  */
18 +   stpcpy.
19 +
20 +   When the stack protector is used at the reverse move, it starts the move
21 +   instruction from the address within the region of a variable.
22 +   So it eliminates the first address decrement instruction.  */
23  
24  rtx
25  move_by_pieces (rtx to, rtx from, unsigned HOST_WIDE_INT len,
26 @@ -1123,6 +1128,8 @@
27  
28        if (USE_LOAD_PRE_DECREMENT (mode) && data.reverse && ! data.autinc_from)
29         {
30 +         if (flag_propolice_protection)
31 +           len = len - GET_MODE_SIZE (mode);
32           data.from_addr = copy_addr_to_reg (plus_constant (from_addr, len));
33           data.autinc_from = 1;
34           data.explicit_inc_from = -1;
35 @@ -1137,6 +1144,8 @@
36         data.from_addr = copy_addr_to_reg (from_addr);
37        if (USE_STORE_PRE_DECREMENT (mode) && data.reverse && ! data.autinc_to)
38         {
39 +         if (flag_propolice_protection)
40 +           len = len - GET_MODE_SIZE (mode);
41           data.to_addr = copy_addr_to_reg (plus_constant (to_addr, len));
42           data.autinc_to = 1;
43           data.explicit_inc_to = -1;
44 @@ -1280,11 +1289,15 @@
45         from1 = adjust_address (data->from, mode, data->offset);
46  
47        if (HAVE_PRE_DECREMENT && data->explicit_inc_to < 0)
48 -       emit_insn (gen_add2_insn (data->to_addr,
49 -                                 GEN_INT (-(HOST_WIDE_INT)size)));
50 +       /* The stack protector skips the first address decrement instruction
51 +          at the reverse move.  */
52 +       if (!flag_propolice_protection || data->explicit_inc_to < -1)
53 +         emit_insn (gen_add2_insn (data->to_addr,
54 +                                   GEN_INT (-(HOST_WIDE_INT)size)));
55        if (HAVE_PRE_DECREMENT && data->explicit_inc_from < 0)
56 -       emit_insn (gen_add2_insn (data->from_addr,
57 -                                 GEN_INT (-(HOST_WIDE_INT)size)));
58 +       if (!flag_propolice_protection || data->explicit_inc_from < -1)
59 +         emit_insn (gen_add2_insn (data->from_addr,
60 +                                   GEN_INT (-(HOST_WIDE_INT)size)));
61  
62        if (data->to)
63         emit_insn ((*genfun) (to1, from1));
64 @@ -2475,7 +2488,12 @@
65  
66        if (USE_STORE_PRE_DECREMENT (mode) && data->reverse && ! data->autinc_to)
67         {
68 -         data->to_addr = copy_addr_to_reg (plus_constant (to_addr, data->len));
69 +         int len = data->len;
70 +         /* The stack protector starts the store instruction from
71 +            the address within the region of a variable.  */
72 +         if (flag_propolice_protection)
73 +           len -= GET_MODE_SIZE (mode);
74 +         data->to_addr = copy_addr_to_reg (plus_constant (to_addr, len));
75           data->autinc_to = 1;
76           data->explicit_inc_to = -1;
77         }
78 @@ -2544,8 +2562,11 @@
79         to1 = adjust_address (data->to, mode, data->offset);
80  
81        if (HAVE_PRE_DECREMENT && data->explicit_inc_to < 0)
82 -       emit_insn (gen_add2_insn (data->to_addr,
83 -                                 GEN_INT (-(HOST_WIDE_INT) size)));
84 +       /* The stack protector skips the first address decrement instruction
85 +          at the reverse store.  */
86 +       if (!flag_propolice_protection || data->explicit_inc_to < -1)
87 +         emit_insn (gen_add2_insn (data->to_addr,
88 +                                   GEN_INT (-(HOST_WIDE_INT) size)));
89  
90        cst = (*data->constfun) (data->constfundata, data->offset, mode);
91        emit_insn ((*genfun) (to1, cst));
92 @@ -5701,7 +5722,9 @@
93           && GET_CODE (XEXP (value, 0)) == PLUS
94           && GET_CODE (XEXP (XEXP (value, 0), 0)) == REG
95           && REGNO (XEXP (XEXP (value, 0), 0)) >= FIRST_VIRTUAL_REGISTER
96 -         && REGNO (XEXP (XEXP (value, 0), 0)) <= LAST_VIRTUAL_REGISTER)
97 +         && REGNO (XEXP (XEXP (value, 0), 0)) <= LAST_VIRTUAL_REGISTER
98 +         && (!flag_propolice_protection
99 +             || XEXP (XEXP (value, 0), 0) != virtual_stack_vars_rtx))
100         {
101           rtx temp = expand_simple_binop (GET_MODE (value), code,
102                                           XEXP (XEXP (value, 0), 0), op2,