115 lines
4.2 KiB
Plaintext
115 lines
4.2 KiB
Plaintext
$OpenBSD: pp-gcc_function_c,v 1.1 2005/01/04 23:06:33 espie Exp $
|
||
--- gcc/function.c.orig Sun May 16 22:27:16 2004
|
||
+++ gcc/function.c Mon Jan 3 10:17:42 2005
|
||
@@ -59,6 +59,7 @@ Software Foundation, 59 Temple Place - S
|
||
#include "tm_p.h"
|
||
#include "integrate.h"
|
||
#include "langhooks.h"
|
||
+#include "protector.h"
|
||
|
||
#ifndef TRAMPOLINE_ALIGNMENT
|
||
#define TRAMPOLINE_ALIGNMENT FUNCTION_BOUNDARY
|
||
@@ -145,6 +146,10 @@ static GTY(()) varray_type epilogue;
|
||
/* Array of INSN_UIDs to hold the INSN_UIDs for each sibcall epilogue
|
||
in this function. */
|
||
static GTY(()) varray_type sibcall_epilogue;
|
||
+
|
||
+/* Current boundary mark for character arrays. */
|
||
+int temp_boundary_mark = 0;
|
||
+
|
||
|
||
/* In order to evaluate some expressions, such as function calls returning
|
||
structures in memory, we need to temporarily allocate stack locations.
|
||
@@ -198,6 +203,8 @@ struct temp_slot GTY(())
|
||
/* The size of the slot, including extra space for alignment. This
|
||
info is for combine_temp_slots. */
|
||
HOST_WIDE_INT full_size;
|
||
+ /* Boundary mark of a character array and the others. This info is for propolice */
|
||
+ int boundary_mark;
|
||
};
|
||
|
||
/* This structure is used to record MEMs or pseudos used to replace VAR, any
|
||
@@ -632,6 +639,7 @@ assign_stack_local (mode, size, align)
|
||
whose lifetime is controlled by CLEANUP_POINT_EXPRs. KEEP is 3
|
||
if we are to allocate something at an inner level to be treated as
|
||
a variable in the block (e.g., a SAVE_EXPR).
|
||
+ KEEP is 5 if we allocate a place to return structure.
|
||
|
||
TYPE is the type that will be used for the stack slot. */
|
||
|
||
@@ -645,6 +653,8 @@ assign_stack_temp_for_type (mode, size,
|
||
unsigned int align;
|
||
struct temp_slot *p, *best_p = 0;
|
||
rtx slot;
|
||
+ int char_array = (flag_propolice_protection
|
||
+ && keep == 1 && search_string_def (type));
|
||
|
||
/* If SIZE is -1 it means that somebody tried to allocate a temporary
|
||
of a variable size. */
|
||
@@ -670,7 +680,8 @@ assign_stack_temp_for_type (mode, size,
|
||
&& ! p->in_use
|
||
&& objects_must_conflict_p (p->type, type)
|
||
&& (best_p == 0 || best_p->size > p->size
|
||
- || (best_p->size == p->size && best_p->align > p->align)))
|
||
+ || (best_p->size == p->size && best_p->align > p->align))
|
||
+ && (! char_array || p->boundary_mark != 0))
|
||
{
|
||
if (p->align == align && p->size == size)
|
||
{
|
||
@@ -705,6 +716,7 @@ assign_stack_temp_for_type (mode, size,
|
||
p->address = 0;
|
||
p->rtl_expr = 0;
|
||
p->type = best_p->type;
|
||
+ p->boundary_mark = best_p->boundary_mark;
|
||
p->next = temp_slots;
|
||
temp_slots = p;
|
||
|
||
@@ -765,6 +777,7 @@ assign_stack_temp_for_type (mode, size,
|
||
p->full_size = frame_offset - frame_offset_old;
|
||
#endif
|
||
p->address = 0;
|
||
+ p->boundary_mark = char_array?++temp_boundary_mark:0;
|
||
p->next = temp_slots;
|
||
temp_slots = p;
|
||
}
|
||
@@ -935,14 +948,16 @@ combine_temp_slots ()
|
||
int delete_q = 0;
|
||
if (! q->in_use && GET_MODE (q->slot) == BLKmode)
|
||
{
|
||
- if (p->base_offset + p->full_size == q->base_offset)
|
||
+ if (p->base_offset + p->full_size == q->base_offset &&
|
||
+ p->boundary_mark == q->boundary_mark)
|
||
{
|
||
/* Q comes after P; combine Q into P. */
|
||
p->size += q->size;
|
||
p->full_size += q->full_size;
|
||
delete_q = 1;
|
||
}
|
||
- else if (q->base_offset + q->full_size == p->base_offset)
|
||
+ else if (q->base_offset + q->full_size == p->base_offset &&
|
||
+ p->boundary_mark == q->boundary_mark)
|
||
{
|
||
/* P comes after Q; combine P into Q. */
|
||
q->size += p->size;
|
||
@@ -1506,7 +1521,9 @@ put_reg_into_stack (function, reg, type,
|
||
}
|
||
|
||
if (new == 0)
|
||
- new = assign_stack_local_1 (decl_mode, GET_MODE_SIZE (decl_mode), 0, func);
|
||
+ new = function ?
|
||
+ assign_stack_local_1 (decl_mode, GET_MODE_SIZE (decl_mode), 0, func):
|
||
+ assign_stack_local_for_pseudo_reg (decl_mode, GET_MODE_SIZE (decl_mode), 0);
|
||
|
||
PUT_CODE (reg, MEM);
|
||
PUT_MODE (reg, decl_mode);
|
||
@@ -3986,7 +4003,8 @@ instantiate_virtual_regs_1 (loc, object,
|
||
constant with that register. */
|
||
temp = gen_reg_rtx (Pmode);
|
||
XEXP (x, 0) = new;
|
||
- if (validate_change (object, &XEXP (x, 1), temp, 0))
|
||
+ if (validate_change (object, &XEXP (x, 1), temp, 0)
|
||
+ && ! flag_propolice_protection)
|
||
emit_insn_before (gen_move_insn (temp, new_offset), object);
|
||
else
|
||
{
|