1 $DragonFly: src/gnu/usr.bin/cc34/cc_prep/patches/expr.c.patch,v 1.3 2004/12/21 13:10:48 joerg Exp $
3 ===================================================================
4 RCS file: /home/joerg/wd/repository/dragonflybsd/src/contrib/gcc-3.4/gcc/expr.c,v
5 retrieving revision 1.1
7 --- expr.c 20 Jun 2004 02:14:49 -0000 1.1
8 +++ expr.c 20 Dec 2004 20:48:10 -0000
13 +#include "protector.h"
15 /* Decide whether a function's arguments should be processed
16 from first to last or from last to first.
17 @@ -1060,7 +1061,11 @@
19 If ENDP is 0 return to, if ENDP is 1 return memory at the end ala
20 mempcpy, and if ENDP is 2 return memory the end minus one byte ala
24 + When the stack protector is used at the reverse move, it starts the move
25 + instruction from the address within the region of a variable.
26 + So it eliminates the first address decrement instruction. */
29 move_by_pieces (rtx to, rtx from, unsigned HOST_WIDE_INT len,
32 if (USE_LOAD_PRE_DECREMENT (mode) && data.reverse && ! data.autinc_from)
34 + if (flag_propolice_protection)
35 + len = len - GET_MODE_SIZE (mode);
36 data.from_addr = copy_addr_to_reg (plus_constant (from_addr, len));
38 data.explicit_inc_from = -1;
40 data.from_addr = copy_addr_to_reg (from_addr);
41 if (USE_STORE_PRE_DECREMENT (mode) && data.reverse && ! data.autinc_to)
43 + if (flag_propolice_protection)
44 + len = len - GET_MODE_SIZE (mode);
45 data.to_addr = copy_addr_to_reg (plus_constant (to_addr, len));
47 data.explicit_inc_to = -1;
48 @@ -1280,11 +1289,15 @@
49 from1 = adjust_address (data->from, mode, data->offset);
51 if (HAVE_PRE_DECREMENT && data->explicit_inc_to < 0)
52 - emit_insn (gen_add2_insn (data->to_addr,
53 - GEN_INT (-(HOST_WIDE_INT)size)));
54 + /* The stack protector skips the first address decrement instruction
55 + at the reverse move. */
56 + if (!flag_propolice_protection || data->explicit_inc_to < -1)
57 + emit_insn (gen_add2_insn (data->to_addr,
58 + GEN_INT (-(HOST_WIDE_INT)size)));
59 if (HAVE_PRE_DECREMENT && data->explicit_inc_from < 0)
60 - emit_insn (gen_add2_insn (data->from_addr,
61 - GEN_INT (-(HOST_WIDE_INT)size)));
62 + if (!flag_propolice_protection || data->explicit_inc_from < -1)
63 + emit_insn (gen_add2_insn (data->from_addr,
64 + GEN_INT (-(HOST_WIDE_INT)size)));
67 emit_insn ((*genfun) (to1, from1));
68 @@ -2475,7 +2488,12 @@
70 if (USE_STORE_PRE_DECREMENT (mode) && data->reverse && ! data->autinc_to)
72 - data->to_addr = copy_addr_to_reg (plus_constant (to_addr, data->len));
73 + int len = data->len;
74 + /* The stack protector starts the store instruction from
75 + the address within the region of a variable. */
76 + if (flag_propolice_protection)
77 + len -= GET_MODE_SIZE (mode);
78 + data->to_addr = copy_addr_to_reg (plus_constant (to_addr, len));
80 data->explicit_inc_to = -1;
82 @@ -2544,8 +2562,11 @@
83 to1 = adjust_address (data->to, mode, data->offset);
85 if (HAVE_PRE_DECREMENT && data->explicit_inc_to < 0)
86 - emit_insn (gen_add2_insn (data->to_addr,
87 - GEN_INT (-(HOST_WIDE_INT) size)));
88 + /* The stack protector skips the first address decrement instruction
89 + at the reverse store. */
90 + if (!flag_propolice_protection || data->explicit_inc_to < -1)
91 + emit_insn (gen_add2_insn (data->to_addr,
92 + GEN_INT (-(HOST_WIDE_INT) size)));
94 cst = (*data->constfun) (data->constfundata, data->offset, mode);
95 emit_insn ((*genfun) (to1, cst));
97 && GET_CODE (XEXP (value, 0)) == PLUS
98 && GET_CODE (XEXP (XEXP (value, 0), 0)) == REG
99 && REGNO (XEXP (XEXP (value, 0), 0)) >= FIRST_VIRTUAL_REGISTER
100 - && REGNO (XEXP (XEXP (value, 0), 0)) <= LAST_VIRTUAL_REGISTER)
101 + && REGNO (XEXP (XEXP (value, 0), 0)) <= LAST_VIRTUAL_REGISTER
102 + && (!flag_propolice_protection
103 + || XEXP (XEXP (value, 0), 0) != virtual_stack_vars_rtx))
105 rtx temp = expand_simple_binop (GET_MODE (value), code,
106 XEXP (XEXP (value, 0), 0), op2,