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