1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-06-28 12:11:45 +02:00

Fix init-local-signal test (#50)

* Add `SA_SIGINFO` flag

  This is needed to guarantee the availability of the `ucontext` argument

* Mark the `NULL` pointer load as `volatile`

  Further prevent any compiler optimization on the load.
This commit is contained in:
Yichao Yu 2017-10-31 11:41:51 -04:00 committed by Dave Watson
parent b9fe811de9
commit 26c99a3a3e
2 changed files with 3 additions and 2 deletions

View file

@ -1,6 +1,6 @@
#include <stdio.h>
/* To prevent inlining and optimizing away */
int foo(int* f) {
int foo(volatile int* f) {
return *f;
}

View file

@ -46,12 +46,13 @@ void handler(int num, siginfo_t* info, void* ucontext) {
exit(-1);
}
int foo(int* f);
int foo(volatile int* f);
int main(){
struct sigaction a;
memset(&a, 0, sizeof(struct sigaction));
a.sa_sigaction = &handler;
a.sa_flags = SA_SIGINFO;
sigaction(SIGSEGV, &a, NULL);
foo(NULL);