diff options
author | Jakub Jelinek <jakub@redhat.com> | 2005-07-02 10:52:21 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2005-07-02 10:52:21 +0200 |
commit | 77008252819720c987f11b3dade670e2b3ba09b8 (patch) | |
tree | 1cb854702400de0149fb900c82b137e5603e222b /gcc/config | |
parent | f60d648137b2d2cda1c598996b9598d559715117 (diff) | |
download | gcc-77008252819720c987f11b3dade670e2b3ba09b8.zip gcc-77008252819720c987f11b3dade670e2b3ba09b8.tar.gz gcc-77008252819720c987f11b3dade670e2b3ba09b8.tar.bz2 |
Makefile.def (target_modules): Add libssp.
* Makefile.def (target_modules): Add libssp.
* configure.in (target_libraries): Add target-libssp.
* configure: Rebuilt.
* Makefile.in: Rebuilt.
gcc/
* gcc.c (LINK_SSP_SPEC): Define.
(link_ssp_spec): New variable.
(LINK_COMMAND_SPEC): Add %(link_ssp).
(static_specs): Add link_ssp_spec.
* configure.ac (TARGET_LIBC_PROVIDES_SSP): New test.
* configure: Rebuilt.
* config.in: Rebuilt.
* config/rs6000/linux.h (TARGET_THREAD_SSP_OFFSET): Define.
* config/rs6000/linux64.h (TARGET_THREAD_SSP_OFFSET): Likewise.
* config/i386/linux.h (TARGET_THREAD_SSP_OFFSET): Likewise.
* config/i386/linux64.h (TARGET_THREAD_SSP_OFFSET): Likewise.
* config/rs6000/rs6000.md (stack_protect_set, stack_protect_test):
If TARGET_THREAD_SSP_OFFSET is defined, use -0x7010(13) resp.
-0x7008(2) instead of reading __stack_chk_guard variable.
* config/i386/i386.md (UNSPEC_SP_SET, UNSPEC_SP_TEST): Change
number.
(UNSPEC_SP_TLS_SET, UNSPEC_SP_TLS_TEST): New constants.
(stack_protect_set, stack_protect_test): Use *_tls* patterns
if TARGET_THREAD_SSP_OFFSET is defined.
(stack_tls_protect_set_si, stack_tls_protect_set_di,
stack_tls_protect_test_si, stack_tls_protect_test_di): New insns.
Revert:
2005-06-27 Richard Henderson <rth@redhat.com>
* libgcc-std.ver (GCC_4.1.0): New.
* libgcc.h (__stack_chk_guard): Declare.
(__stack_chk_fail, __stack_chk_fail_local): Declare.
* libgcc2.c (L_stack_chk, L_stack_chk_local): New.
* mklibgcc.in (lib2funcs): Add them.
From-SVN: r101531
Diffstat (limited to 'gcc/config')
-rw-r--r-- | gcc/config/i386/i386.md | 64 | ||||
-rw-r--r-- | gcc/config/i386/linux.h | 5 | ||||
-rw-r--r-- | gcc/config/i386/linux64.h | 6 | ||||
-rw-r--r-- | gcc/config/rs6000/linux.h | 5 | ||||
-rw-r--r-- | gcc/config/rs6000/linux64.h | 6 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000.md | 10 |
6 files changed, 94 insertions, 2 deletions
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 1ca5d22..c0823b6 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -81,8 +81,6 @@ (UNSPEC_FLDCW 25) (UNSPEC_REP 26) (UNSPEC_EH_RETURN 27) - (UNSPEC_SP_SET 28) - (UNSPEC_SP_TEST 29) ; For SSE/MMX support: (UNSPEC_FIX_NOTRUNC 30) @@ -140,6 +138,12 @@ (UNSPEC_FPREM_U 89) (UNSPEC_FPREM1_F 90) (UNSPEC_FPREM1_U 91) + + ; SSP patterns + (UNSPEC_SP_SET 100) + (UNSPEC_SP_TEST 101) + (UNSPEC_SP_TLS_SET 102) + (UNSPEC_SP_TLS_TEST 103) ]) (define_constants @@ -19613,10 +19617,19 @@ (match_operand 1 "memory_operand" "")] "" { +#ifdef TARGET_THREAD_SSP_OFFSET + if (TARGET_64BIT) + emit_insn (gen_stack_tls_protect_set_di (operands[0], + GEN_INT (TARGET_THREAD_SSP_OFFSET))); + else + emit_insn (gen_stack_tls_protect_set_si (operands[0], + GEN_INT (TARGET_THREAD_SSP_OFFSET))); +#else if (TARGET_64BIT) emit_insn (gen_stack_protect_set_di (operands[0], operands[1])); else emit_insn (gen_stack_protect_set_si (operands[0], operands[1])); +#endif DONE; }) @@ -19638,6 +19651,24 @@ "mov{q}\t{%1, %2|%2, %1}\;mov{q}\t{%2, %0|%0, %2}\;xor{l}\t%k2, %k2" [(set_attr "type" "multi")]) +(define_insn "stack_tls_protect_set_si" + [(set (match_operand:SI 0 "memory_operand" "=m") + (unspec:SI [(match_operand:SI 1 "const_int_operand" "i")] UNSPEC_SP_TLS_SET)) + (set (match_scratch:SI 2 "=&r") (const_int 0)) + (clobber (reg:CC FLAGS_REG))] + "" + "mov{l}\t{%%gs:%P1, %2|%2, DWORD PTR %%gs:%P1}\;mov{l}\t{%2, %0|%0, %2}\;xor{l}\t%2, %2" + [(set_attr "type" "multi")]) + +(define_insn "stack_tls_protect_set_di" + [(set (match_operand:DI 0 "memory_operand" "=m") + (unspec:DI [(match_operand:DI 1 "const_int_operand" "i")] UNSPEC_SP_TLS_SET)) + (set (match_scratch:DI 2 "=&r") (const_int 0)) + (clobber (reg:CC FLAGS_REG))] + "TARGET_64BIT" + "mov{q}\t{%%fs:%P1, %2|%2, QWORD PTR %%fs:%P1}\;mov{q}\t{%2, %0|%0, %2}\;xor{l}\t%k2, %k2" + [(set_attr "type" "multi")]) + (define_expand "stack_protect_test" [(match_operand 0 "memory_operand" "") (match_operand 1 "memory_operand" "") @@ -19649,10 +19680,19 @@ ix86_compare_op1 = operands[1]; ix86_compare_emitted = flags; +#ifdef TARGET_THREAD_SSP_OFFSET + if (TARGET_64BIT) + emit_insn (gen_stack_tls_protect_test_di (flags, operands[0], + GEN_INT (TARGET_THREAD_SSP_OFFSET))); + else + emit_insn (gen_stack_tls_protect_test_si (flags, operands[0], + GEN_INT (TARGET_THREAD_SSP_OFFSET))); +#else if (TARGET_64BIT) emit_insn (gen_stack_protect_test_di (flags, operands[0], operands[1])); else emit_insn (gen_stack_protect_test_si (flags, operands[0], operands[1])); +#endif emit_jump_insn (gen_beq (operands[2])); DONE; }) @@ -19677,6 +19717,26 @@ "mov{q}\t{%1, %3|%3, %1}\;xor{q}\t{%2, %3|%3, %2}" [(set_attr "type" "multi")]) +(define_insn "stack_tls_protect_test_si" + [(set (match_operand:CCZ 0 "flags_reg_operand" "") + (unspec:CCZ [(match_operand:SI 1 "memory_operand" "m") + (match_operand:SI 2 "const_int_operand" "i")] + UNSPEC_SP_TLS_TEST)) + (clobber (match_scratch:SI 3 "=r"))] + "" + "mov{l}\t{%1, %3|%3, %1}\;xor{l}\t{%%gs:%P2, %3|%3, DWORD PTR %%gs:%P2}" + [(set_attr "type" "multi")]) + +(define_insn "stack_tls_protect_test_di" + [(set (match_operand:CCZ 0 "flags_reg_operand" "") + (unspec:CCZ [(match_operand:DI 1 "memory_operand" "m") + (match_operand:DI 2 "const_int_operand" "i")] + UNSPEC_SP_TLS_TEST)) + (clobber (match_scratch:DI 3 "=r"))] + "TARGET_64BIT" + "mov{q}\t{%1, %3|%3, %1}\;xor{q}\t{%%fs:%P2, %3|%3, QWORD PTR %%fs:%P2}" + [(set_attr "type" "multi")]) + (include "sse.md") (include "mmx.md") (include "sync.md") diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h index 5f4c10d..082cc95 100644 --- a/gcc/config/i386/linux.h +++ b/gcc/config/i386/linux.h @@ -185,3 +185,8 @@ Boston, MA 02110-1301, USA. */ /* This macro may be overridden in i386/k*bsd-gnu.h. */ #define REG_NAME(reg) reg + +#ifdef TARGET_LIBC_PROVIDES_SSP +/* i386 glibc provides __stack_chk_guard in %gs:0x14. */ +#define TARGET_THREAD_SSP_OFFSET 0x14 +#endif diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h index 2578958..3a37f63 100644 --- a/gcc/config/i386/linux64.h +++ b/gcc/config/i386/linux64.h @@ -73,3 +73,9 @@ Boston, MA 02110-1301, USA. */ /* This macro may be overridden in i386/k*bsd-gnu.h. */ #define REG_NAME(reg) reg + +#ifdef TARGET_LIBC_PROVIDES_SSP +/* i386 glibc provides __stack_chk_guard in %gs:0x14, + x86_64 glibc provides it in %fs:0x28. */ +#define TARGET_THREAD_SSP_OFFSET (TARGET_64BIT ? 0x28 : 0x14) +#endif diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h index 949af27..79eb199 100644 --- a/gcc/config/rs6000/linux.h +++ b/gcc/config/rs6000/linux.h @@ -113,3 +113,8 @@ #define TARGET_HAS_F_SETLKW #define MD_UNWIND_SUPPORT "config/rs6000/linux-unwind.h" + +#ifdef TARGET_LIBC_PROVIDES_SSP +/* ppc32 glibc provides __stack_chk_guard in -0x7008(2). */ +#define TARGET_THREAD_SSP_OFFSET -0x7008 +#endif diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h index 68b121c..7343cbb 100644 --- a/gcc/config/rs6000/linux64.h +++ b/gcc/config/rs6000/linux64.h @@ -547,3 +547,9 @@ while (0) #endif #define MD_UNWIND_SUPPORT "config/rs6000/linux-unwind.h" + +#ifdef TARGET_LIBC_PROVIDES_SSP +/* ppc32 glibc provides __stack_chk_guard in -0x7008(2), + ppc64 glibc provides it at -0x7010(13). */ +#define TARGET_THREAD_SSP_OFFSET (TARGET_64BIT ? -0x7010 : -0x7008) +#endif diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 9211e56..3f5c1b4 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -10764,6 +10764,11 @@ (match_operand 1 "memory_operand" "")] "" { +#ifdef TARGET_THREAD_SSP_OFFSET + rtx tlsreg = gen_rtx_REG (Pmode, TARGET_64BIT ? 13 : 2); + rtx addr = gen_rtx_PLUS (Pmode, tlsreg, GEN_INT (TARGET_THREAD_SSP_OFFSET)); + operands[1] = gen_rtx_MEM (Pmode, addr); +#endif if (TARGET_64BIT) emit_insn (gen_stack_protect_setdi (operands[0], operands[1])); else @@ -10795,6 +10800,11 @@ (match_operand 2 "" "")] "" { +#ifdef TARGET_THREAD_SSP_OFFSET + rtx tlsreg = gen_rtx_REG (Pmode, TARGET_64BIT ? 13 : 2); + rtx addr = gen_rtx_PLUS (Pmode, tlsreg, GEN_INT (TARGET_THREAD_SSP_OFFSET)); + operands[1] = gen_rtx_MEM (Pmode, addr); +#endif rs6000_compare_op0 = operands[0]; rs6000_compare_op1 = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, operands[1]), UNSPEC_SP_TEST); |