Skip to main content
Renesas Singapore - Knowledgebase

Using detection of stack smashing at the same time as multi-tasking (CC-RL)

Last Updated:05/10/2017


I am using the CC-RL compiler for RL78 devices and the RI78V4 real-time OS for the RL78. Can I use detection of stack smashing by the professional edition along with multi-tasking?


Whether you can or can’t use the function depends on the situation.
The compiler generates code for the following operations in functions to be checked for stack smashing.

  1. Reserving two consecutive locations immediately before the local variable area of the stack that is related to the function at the entrance to the function then storing the value specified by num in the two bytes at the locations.
  2. Checking that the value specified by num has not been overwritten on exit from the function.
  3. Calling the __stack_chk_fail function if it has been overwritten, since this indicates smashing of the stack during execution.  

You can use the detection of stack smashing when multi-tasking causes switching to and return from a task, since the situation is the same as that described in 1 and 2.

However, detection cannot be used for an interrupt handler or task of the real-time OS, since stack smashing cannot be detected for a function which is specified with any of the following directives.

#pragma inline, inline keyword,#pragma inline_asm,
#pragma no_stack_protector,#pragma rtos_interrupt,
#pragma rtos_task

Suitable Products
e² studio
CS+ (formerly CubeSuite+)
C Compiler Package for RL78 Family
  • Was this article helpful?