mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-06 19:07:25 +08:00
linux.h (TARGET_THREAD_SSP_OFFSET): Define.
2005-08-12 Andreas Krebbel <krebbel1@de.ibm.com> Jakub Jelinek <jakub@redhat.com> * config/s390/linux.h (TARGET_THREAD_SSP_OFFSET): Define. * config/s390/s390-protos.h (s390_get_thread_pointer): Prototype added. * config/s390/s390.c (print_operand): New output modifier 'G' added. (get_thread_pointer): Renamed to s390_get_thread_pointer. * config/s390/s390.md (stack_protect_set, stack_protect_test): If TARGET_THREAD_SSP_OFFSET is defined, change operands[1] to (MEM:P (PLUS:P (tp, TARGET_THREAD_SSP_OFFSET))). (UNSPEC_SP_SET, UNSPEC_SP_TEST): New constants. ("stack_protect_set", "stack_protect_test"): New expanders. ("stack_protect_setsi", "stack_protect_setdi", "stack_protect_testsi", "stack_protect_testdi"): New insn definitions. Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r103034
This commit is contained in:
parent
4700982dd7
commit
7b8acc3494
@ -1,3 +1,18 @@
|
||||
2005-08-12 Andreas Krebbel <krebbel1@de.ibm.com>
|
||||
Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* config/s390/linux.h (TARGET_THREAD_SSP_OFFSET): Define.
|
||||
* config/s390/s390-protos.h (s390_get_thread_pointer): Prototype added.
|
||||
* config/s390/s390.c (print_operand): New output modifier 'G' added.
|
||||
(get_thread_pointer): Renamed to s390_get_thread_pointer.
|
||||
* config/s390/s390.md (stack_protect_set, stack_protect_test): If
|
||||
TARGET_THREAD_SSP_OFFSET is defined, change operands[1] to
|
||||
(MEM:P (PLUS:P (tp, TARGET_THREAD_SSP_OFFSET))).
|
||||
(UNSPEC_SP_SET, UNSPEC_SP_TEST): New constants.
|
||||
("stack_protect_set", "stack_protect_test"): New expanders.
|
||||
("stack_protect_setsi", "stack_protect_setdi", "stack_protect_testsi",
|
||||
"stack_protect_testdi"): New insn definitions.
|
||||
|
||||
2005-08-12 Andreas Krebbel <krebbel1@de.ibm.com>
|
||||
|
||||
* config/s390/s390.md ("*movdf_31"): Changed constraint from P to K.
|
||||
|
@ -94,4 +94,10 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
|
||||
#define MD_UNWIND_SUPPORT "config/s390/linux-unwind.h"
|
||||
|
||||
#ifdef TARGET_LIBC_PROVIDES_SSP
|
||||
/* s390 glibc provides __stack_chk_guard in 0x14(tp),
|
||||
s390x glibc provides it at 0x28(tp). */
|
||||
#define TARGET_THREAD_SSP_OFFSET (TARGET_64BIT ? 0x28 : 0x14)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -91,6 +91,7 @@ extern void s390_initialize_trampoline (rtx, rtx, rtx);
|
||||
extern rtx s390_gen_rtx_const_DI (int, int);
|
||||
extern int s390_agen_dep_p (rtx, rtx);
|
||||
extern rtx s390_load_got (void);
|
||||
extern rtx s390_get_thread_pointer (void);
|
||||
extern void s390_emit_tpf_eh_return (rtx);
|
||||
extern bool s390_legitimate_address_without_index_p (rtx);
|
||||
extern int s390_branch_condition_mask (rtx);
|
||||
|
@ -2832,8 +2832,8 @@ legitimize_pic_address (rtx orig, rtx reg)
|
||||
|
||||
/* Load the thread pointer into a register. */
|
||||
|
||||
static rtx
|
||||
get_thread_pointer (void)
|
||||
rtx
|
||||
s390_get_thread_pointer (void)
|
||||
{
|
||||
rtx tp = gen_reg_rtx (Pmode);
|
||||
|
||||
@ -2893,7 +2893,7 @@ legitimize_tls_address (rtx addr, rtx reg)
|
||||
temp = gen_reg_rtx (Pmode);
|
||||
emit_libcall_block (insn, temp, r2, new);
|
||||
|
||||
new = gen_rtx_PLUS (Pmode, get_thread_pointer (), temp);
|
||||
new = gen_rtx_PLUS (Pmode, s390_get_thread_pointer (), temp);
|
||||
if (reg != 0)
|
||||
{
|
||||
s390_load_address (reg, new);
|
||||
@ -2916,7 +2916,7 @@ legitimize_tls_address (rtx addr, rtx reg)
|
||||
temp = gen_reg_rtx (Pmode);
|
||||
emit_libcall_block (insn, temp, r2, new);
|
||||
|
||||
new = gen_rtx_PLUS (Pmode, get_thread_pointer (), temp);
|
||||
new = gen_rtx_PLUS (Pmode, s390_get_thread_pointer (), temp);
|
||||
base = gen_reg_rtx (Pmode);
|
||||
s390_load_address (base, new);
|
||||
|
||||
@ -3003,7 +3003,7 @@ legitimize_tls_address (rtx addr, rtx reg)
|
||||
emit_insn (gen_rtx_SET (Pmode, temp, new));
|
||||
}
|
||||
|
||||
new = gen_rtx_PLUS (Pmode, get_thread_pointer (), temp);
|
||||
new = gen_rtx_PLUS (Pmode, s390_get_thread_pointer (), temp);
|
||||
if (reg != 0)
|
||||
{
|
||||
s390_load_address (reg, new);
|
||||
@ -3018,7 +3018,7 @@ legitimize_tls_address (rtx addr, rtx reg)
|
||||
temp = gen_reg_rtx (Pmode);
|
||||
emit_move_insn (temp, new);
|
||||
|
||||
new = gen_rtx_PLUS (Pmode, get_thread_pointer (), temp);
|
||||
new = gen_rtx_PLUS (Pmode, s390_get_thread_pointer (), temp);
|
||||
if (reg != 0)
|
||||
{
|
||||
s390_load_address (reg, new);
|
||||
@ -3931,6 +3931,7 @@ print_operand_address (FILE *file, rtx addr)
|
||||
'C': print opcode suffix for branch condition.
|
||||
'D': print opcode suffix for inverse branch condition.
|
||||
'J': print tls_load/tls_gdcall/tls_ldcall suffix
|
||||
'G': print the size of the operand in bytes.
|
||||
'O': print only the displacement of a memory reference.
|
||||
'R': print only the base register of a memory reference.
|
||||
'S': print S-type memory reference (base+displacement).
|
||||
@ -3977,6 +3978,10 @@ print_operand (FILE *file, rtx x, int code)
|
||||
gcc_unreachable ();
|
||||
return;
|
||||
|
||||
case 'G':
|
||||
fprintf (file, "%u", GET_MODE_SIZE (GET_MODE (x)));
|
||||
return;
|
||||
|
||||
case 'O':
|
||||
{
|
||||
struct s390_address ad;
|
||||
|
@ -122,7 +122,11 @@
|
||||
(UNSPEC_TLS_LOAD 512)
|
||||
|
||||
; String Functions
|
||||
(UNSPEC_SRST 600)
|
||||
(UNSPEC_SRST 600)
|
||||
|
||||
; Stack Smashing Protector
|
||||
(UNSPEC_SP_SET 700)
|
||||
(UNSPEC_SP_TEST 701)
|
||||
])
|
||||
|
||||
;;
|
||||
@ -7145,3 +7149,65 @@
|
||||
DONE;
|
||||
})
|
||||
|
||||
;
|
||||
; Stack Protector Patterns
|
||||
;
|
||||
|
||||
(define_expand "stack_protect_set"
|
||||
[(set (match_operand 0 "memory_operand" "")
|
||||
(match_operand 1 "memory_operand" ""))]
|
||||
""
|
||||
{
|
||||
#ifdef TARGET_THREAD_SSP_OFFSET
|
||||
operands[1]
|
||||
= gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
|
||||
GEN_INT (TARGET_THREAD_SSP_OFFSET)));
|
||||
#endif
|
||||
if (TARGET_64BIT)
|
||||
emit_insn (gen_stack_protect_setdi (operands[0], operands[1]));
|
||||
else
|
||||
emit_insn (gen_stack_protect_setsi (operands[0], operands[1]));
|
||||
|
||||
DONE;
|
||||
})
|
||||
|
||||
(define_insn "stack_protect_set<mode>"
|
||||
[(set (match_operand:DSI 0 "memory_operand" "=Q")
|
||||
(unspec:DSI [(match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_SET))]
|
||||
""
|
||||
"mvc\t%O0(%G0,%R0),%S1"
|
||||
[(set_attr "op_type" "SS")])
|
||||
|
||||
(define_expand "stack_protect_test"
|
||||
[(set (reg:CC CC_REGNUM)
|
||||
(compare (match_operand 0 "memory_operand" "")
|
||||
(match_operand 1 "memory_operand" "")))
|
||||
(match_operand 2 "" "")]
|
||||
""
|
||||
{
|
||||
#ifdef TARGET_THREAD_SSP_OFFSET
|
||||
operands[1]
|
||||
= gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
|
||||
GEN_INT (TARGET_THREAD_SSP_OFFSET)));
|
||||
#endif
|
||||
s390_compare_op0 = operands[0];
|
||||
s390_compare_op1 = operands[1];
|
||||
s390_compare_emitted = gen_rtx_REG (CCZmode, CC_REGNUM);
|
||||
|
||||
if (TARGET_64BIT)
|
||||
emit_insn (gen_stack_protect_testdi (operands[0], operands[1]));
|
||||
else
|
||||
emit_insn (gen_stack_protect_testsi (operands[0], operands[1]));
|
||||
|
||||
emit_jump_insn (gen_beq (operands[2]));
|
||||
|
||||
DONE;
|
||||
})
|
||||
|
||||
(define_insn "stack_protect_test<mode>"
|
||||
[(set (reg:CCZ CC_REGNUM)
|
||||
(unspec:CCZ [(match_operand:DSI 0 "memory_operand" "Q")
|
||||
(match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_TEST))]
|
||||
""
|
||||
"clc\t%O0(%G0,%R0),%S1"
|
||||
[(set_attr "op_type" "SS")])
|
||||
|
Loading…
Reference in New Issue
Block a user