Skip to content

Commit

Permalink
mangle SP on ARM before storing into jmpbuf
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu user committed Nov 23, 2015
1 parent 56554a5 commit cce7364
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,11 @@ void st_thread_interrupt(_st_thread_t *thread)
}


extern unsigned long __pointer_chk_guard;
# define PTR_MANGLE(var) \
(var) = (__typeof (var)) ((unsigned long) (var) ^ __pointer_chk_guard)
# define PTR_DEMANGLE(var) PTR_MANGLE (var)

_st_thread_t *st_thread_create(void *(*start)(void *arg), void *arg,
int joinable, int stk_size)
{
Expand Down Expand Up @@ -607,7 +612,13 @@ _st_thread_t *st_thread_create(void *(*start)(void *arg), void *arg,
thread->arg = arg;

#ifndef __ia64__
#if defined(__arm__)
volatile void * l = PTR_MANGLE(stack->sp);
{ if (_setjmp ((thread)->context)) _st_thread_main();
(thread)->context[0].__jmpbuf[8] = (long) (l); };
#else
_ST_INIT_CONTEXT(thread, stack->sp, _st_thread_main);
#endif
#else
_ST_INIT_CONTEXT(thread, stack->sp, stack->bsp, _st_thread_main);
#endif
Expand Down

1 comment on commit cce7364

@winlinvip
Copy link

@winlinvip winlinvip commented on cce7364 Sep 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍
Great job, I have merged to ST for SRS ossrs/state-threads#1 (comment)

Please sign in to comment.