This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch RFC] SH: -fstack-protector support

Kaz Kojima wrote:

2005-07-20  Kaz Kojima  <>

* config/sh/ (UNSPEC_SP_SET, UNSPEC_SP_TEST): New constants.
(stack_protect_set, stack_protect_test): New expanders.
(stack_protect_set_si, stack_protect_set_si_media,
stack_protect_set_di_media, stack_protect_test_si,
stack_protect_test_si_media, stack_protect_test_di_media):
New insns.

The stack_protect_test pattern agrees with the use in function.c:stack_protect_epilogue,
but it does not agree with the documentation in md.texi. Either stack_protect_epilogue
and the stack_protect_test definitions, or the stack_protect_test documentation are wrong.

The SHmedia test patterns can be improved by useing a sub or xor operation instead
of the compare and zeroing, and inverting the branch. If the comparison suceeds, nothing
is leaked. If it fails, not the value, but only the difference is leaked, so that's OK with the
letter of the description; it is also OK with the spirit of the description because the
miscompare already indicates a stack smash, so control is tranferred to the stack_protect_fail
code, and the difference won't leak to an attacker.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]