6 #include <sys/ucontext.h>
7 #include <asm/unistd.h>
9 #define VAL1 0x11223344
10 #define VAL2 0x44332211
12 static void handler1(int sig
, siginfo_t
*si
, ucontext_t
*uc
)
14 /* Since the handler will be called as kill leaves the kernel,
15 this is replacing the kill syscall's return value. */
16 if (uc
->uc_mcontext
.gregs
[REG_EAX
] != 0)
17 printf("FAILED: handler2 expected eax == 0, not %d\n", uc
->uc_mcontext
.gregs
[REG_EAX
]);
18 uc
->uc_mcontext
.gregs
[REG_EAX
] = VAL1
;
24 : : : "edx", "esi", "edi");
27 static void handler2(int sig
, struct sigcontext sc
)
29 /* Since the handler will be called as kill leaves the kernel,
30 this is replacing the kill syscall's return value. */
32 printf("FAILED: handler2 expected eax == 0, not %p\n", (void*)sc
.eax
);
40 : : : "edx", "esi", "edi");
49 sa
.sa_handler
= (void*)handler1
;
50 sa
.sa_flags
= SA_SIGINFO
;
51 sigfillset(&sa
.sa_mask
);
53 sigaction(SIGUSR1
, &sa
, NULL
);
55 sa
.sa_handler
= (void*)handler2
;
57 sigfillset(&sa
.sa_mask
);
59 sigaction(SIGUSR2
, &sa
, NULL
);
62 //"movl $0x11111111, %%ebp\n"
63 "movl $0x22222222, %%edx\n"
64 "movl $0x33333333, %%esi\n"
65 "movl $0x44444444, %%edi\n"
67 : "=a" (ret
), "=d" (v2
), "=S" (v3
), "=D" (v4
)
68 : "0" (__NR_kill
), "b" (getpid()), "c" (SIGUSR1
));
69 printf("v2=%x v3=%x v4=%x\n", v2
, v3
, v4
);
72 printf("PASS %x\n", ret
);
74 printf("FAIL ret=%x not %x\n", ret
, VAL1
);
77 //"movl $0x11111111, %%ebp\n"
78 "movl $0x22222222, %%edx\n"
79 "movl $0x33333333, %%esi\n"
80 "movl $0x44444444, %%edi\n"
82 : "=a" (ret
), "=d" (v2
), "=S" (v3
), "=D" (v4
)
83 : "0" (__NR_kill
), "b" (getpid()), "c" (SIGUSR2
));
84 printf("v2=%x v3=%x v4=%x\n", v2
, v3
, v4
);
87 printf("PASS %x\n", ret
);
89 printf("FAIL ret=%x not %x\n", ret
, VAL2
);