mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2024-11-18 22:07:38 +01: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:
parent
b9fe811de9
commit
26c99a3a3e
2 changed files with 3 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
/* To prevent inlining and optimizing away */
|
/* To prevent inlining and optimizing away */
|
||||||
int foo(int* f) {
|
int foo(volatile int* f) {
|
||||||
return *f;
|
return *f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,12 +46,13 @@ void handler(int num, siginfo_t* info, void* ucontext) {
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int foo(int* f);
|
int foo(volatile int* f);
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
struct sigaction a;
|
struct sigaction a;
|
||||||
memset(&a, 0, sizeof(struct sigaction));
|
memset(&a, 0, sizeof(struct sigaction));
|
||||||
a.sa_sigaction = &handler;
|
a.sa_sigaction = &handler;
|
||||||
|
a.sa_flags = SA_SIGINFO;
|
||||||
sigaction(SIGSEGV, &a, NULL);
|
sigaction(SIGSEGV, &a, NULL);
|
||||||
|
|
||||||
foo(NULL);
|
foo(NULL);
|
||||||
|
|
Loading…
Reference in a new issue