Merge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly
[dragonfly.git] / gnu / usr.bin / cc34 / cc_prep / patches / function.c.patch
blob6a5ee147ebf223b4ffa4c023f3df713c5c76e8f2
1 $DragonFly: src/gnu/usr.bin/cc34/cc_prep/patches/function.c.patch,v 1.5 2005/08/27 21:03:51 joerg Exp $
3 ===================================================================
4 RCS file: /home/joerg/wd/repository/dragonflybsd/src/contrib/gcc-3.4/gcc/function.c,v
5 retrieving revision 1.2
6 diff -u -r1.2 function.c
7 --- function.c 20 Dec 2004 19:23:24 -0000 1.2
8 +++ function.c 11 May 2005 16:36:11 -0000
9 @@ -63,6 +63,7 @@
10 #include "integrate.h"
11 #include "langhooks.h"
12 #include "target.h"
13 +#include "protector.h"
15 #ifndef TRAMPOLINE_ALIGNMENT
16 #define TRAMPOLINE_ALIGNMENT FUNCTION_BOUNDARY
17 @@ -155,6 +156,10 @@
18 /* Array of INSN_UIDs to hold the INSN_UIDs for each sibcall epilogue
19 in this function. */
20 static GTY(()) varray_type sibcall_epilogue;
22 +/* Current boundary mark for character arrays. */
23 +static int temp_boundary_mark = 0;
26 /* In order to evaluate some expressions, such as function calls returning
27 structures in memory, we need to temporarily allocate stack locations.
28 @@ -208,6 +213,8 @@
29 /* The size of the slot, including extra space for alignment. This
30 info is for combine_temp_slots. */
31 HOST_WIDE_INT full_size;
32 + /* Boundary mark of a character array and the others. This info is for propolice. */
33 + int boundary_mark;
36 /* This structure is used to record MEMs or pseudos used to replace VAR, any
37 @@ -641,6 +648,7 @@
38 whose lifetime is controlled by CLEANUP_POINT_EXPRs. KEEP is 3
39 if we are to allocate something at an inner level to be treated as
40 a variable in the block (e.g., a SAVE_EXPR).
41 + KEEP is 5 if we allocate a place to return structure.
43 TYPE is the type that will be used for the stack slot. */
45 @@ -651,6 +659,8 @@
46 unsigned int align;
47 struct temp_slot *p, *best_p = 0;
48 rtx slot;
49 + int char_array = (flag_propolice_protection
50 + && keep == 1 && search_string_def (type));
52 /* If SIZE is -1 it means that somebody tried to allocate a temporary
53 of a variable size. */
54 @@ -676,7 +686,8 @@
55 && ! p->in_use
56 && objects_must_conflict_p (p->type, type)
57 && (best_p == 0 || best_p->size > p->size
58 - || (best_p->size == p->size && best_p->align > p->align)))
59 + || (best_p->size == p->size && best_p->align > p->align))
60 + && (! char_array || p->boundary_mark != 0))
62 if (p->align == align && p->size == size)
64 @@ -711,6 +722,7 @@
65 p->address = 0;
66 p->rtl_expr = 0;
67 p->type = best_p->type;
68 + p->boundary_mark = best_p->boundary_mark;
69 p->next = temp_slots;
70 temp_slots = p;
72 @@ -757,6 +769,16 @@
73 way the frame grows. We include the extra space if and only if it
74 is above this slot. */
75 #ifdef FRAME_GROWS_DOWNWARD
76 + /* The stack protector can share a character buffer with another buffer
77 + in the different block only when the size of the first is bigger
78 + than the second. p->size is used for this comparison.
79 + But, in some situation, p->size is bigger than the actual size.
80 + So, we should change p->size with its aligned size. */
81 + if (flag_propolice_protection
82 + && char_array
83 + && (frame_offset_old - frame_offset >
84 + CEIL_ROUND (size, align / BITS_PER_UNIT)))
85 + frame_offset_old = frame_offset + CEIL_ROUND (size, align / BITS_PER_UNIT);
86 p->size = frame_offset_old - frame_offset;
87 #else
88 p->size = size;
89 @@ -771,6 +793,7 @@
90 p->full_size = frame_offset - frame_offset_old;
91 #endif
92 p->address = 0;
93 + p->boundary_mark = char_array ? ++temp_boundary_mark : 0;
94 p->next = temp_slots;
95 temp_slots = p;
97 @@ -935,14 +958,16 @@
98 int delete_q = 0;
99 if (! q->in_use && GET_MODE (q->slot) == BLKmode)
101 - if (p->base_offset + p->full_size == q->base_offset)
102 + if (p->base_offset + p->full_size == q->base_offset &&
103 + p->boundary_mark == q->boundary_mark)
105 /* Q comes after P; combine Q into P. */
106 p->size += q->size;
107 p->full_size += q->full_size;
108 delete_q = 1;
110 - else if (q->base_offset + q->full_size == p->base_offset)
111 + else if (q->base_offset + q->full_size == p->base_offset &&
112 + p->boundary_mark == q->boundary_mark)
114 /* P comes after Q; combine P into Q. */
115 q->size += p->size;
116 @@ -3949,7 +3974,8 @@
117 constant with that register. */
118 temp = gen_reg_rtx (Pmode);
119 XEXP (x, 0) = new;
120 - if (validate_change (object, &XEXP (x, 1), temp, 0))
121 + if (validate_change (object, &XEXP (x, 1), temp, 0)
122 + && !flag_propolice_protection)
123 emit_insn_before (gen_move_insn (temp, new_offset), object);
124 else
126 @@ -6172,7 +6198,12 @@
128 /* Recreate the block tree from the note nesting. */
129 reorder_blocks_1 (get_insns (), block, &block_stack);
130 - BLOCK_SUBBLOCKS (block) = blocks_nreverse (BLOCK_SUBBLOCKS (block));
132 + /* In propolice-protection mode, disable to change the order of SUBBLOCKS
133 + by the reason that the order is reversed from its
134 + declaration sequence. */
135 + if (! flag_propolice_protection)
136 + BLOCK_SUBBLOCKS (block) = blocks_nreverse (BLOCK_SUBBLOCKS (block));
138 /* Remove deleted blocks from the block fragment chains. */
139 reorder_fix_fragments (block);