From 22703df0df76accb65607f28070a9771b5bb42de Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Mon, 2 Dec 2002 09:00:27 +0000 Subject: Import propolice (http://www.trl.ibm.com/projects/security/ssp), a stack attack protection scheme, into gcc. This protection is enabled by default. It can be turned off by using the -fno-stack-protector flag. Code by Hiroaki Etoh (etoh at jp dot ibm dot com); work on openbsd-specific integration by fgsch@, deraadt@ and myself; tests by fgsch@, naddy@ and myself; beer drinking by myself. Please note that system upgrades with this new code will require a new libc and ld.so to be build and installed before the propolice-enabled compiler can be installed. --- gnu/egcs/gcc/gcse.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'gnu/egcs/gcc/gcse.c') diff --git a/gnu/egcs/gcc/gcse.c b/gnu/egcs/gcc/gcse.c index d7fde36ecd8..3dab465ee4b 100644 --- a/gnu/egcs/gcc/gcse.c +++ b/gnu/egcs/gcc/gcse.c @@ -1394,6 +1394,7 @@ hash_expr_1 (x, mode, do_not_record_p) return 0; } hash += (unsigned) MEM; + hash += MEM_ALIAS_SET (x); x = XEXP (x, 0); goto repeat; @@ -1526,6 +1527,14 @@ expr_equiv_p (x, y) case REG: return REGNO (x) == REGNO (y); + case MEM: + /* Can't merge two expressions in different alias sets, since we can + decide that the expression is transparent in a block when it isn't, + due to it being set with the different alias set. */ + if (MEM_ALIAS_SET (x) != MEM_ALIAS_SET (y)) + return 0; + break; + /* For commutative operations, check both orders. */ case PLUS: case MULT: @@ -3709,7 +3718,7 @@ cprop_insn (insn, alter_jumps) /* Find an assignment that sets reg_used and is available at the start of the block. */ set = find_avail_set (regno, insn); - if (! set) + if (! set || set->expr->volatil) continue; pat = set->expr; @@ -4189,9 +4198,26 @@ insert_insn_end_bb (expr, bb, pre) } } - new_insn = emit_insn_before (pat, insn); - if (BLOCK_HEAD (bb) == insn) - BLOCK_HEAD (bb) = new_insn; + /* If we found all the parameter loads, then we want to insert + before the first parameter load. + + If we did not find all the parameter loads, then we might have + stopped on the head of the block, which could be a CODE_LABEL. + If we inserted before the CODE_LABEL, then we would be putting + the insn in the wrong basic block. In that case, put the insn + after the CODE_LABEL. + + ?!? Do we need to account for NOTE_INSN_BASIC_BLOCK here? */ + if (GET_CODE (insn) != CODE_LABEL) + { + new_insn = emit_insn_before (pat, insn); + if (BLOCK_HEAD (bb) == insn) + BLOCK_HEAD (bb) = new_insn; + } + else + { + new_insn = emit_insn_after (pat, insn); + } } else { -- cgit v1.2.3