Files
clang-p2996/lldb/test/Shell/Unwind/Inputs/unaligned-pc-sigbus.c
Pavel Labath d12c48cad5 [lldb/aarch64] Allow unaligned PC addresses below a trap handler (#92093)
The stack validation heuristic is counter-productive in this case, as
the unaligned address is most likely the thing that caused the signal in
the first place.
2024-05-15 10:02:24 +02:00

22 lines
390 B
C

#include <signal.h>
#include <stdint.h>
#include <unistd.h>
void sigbus_handler(int signo) { _exit(47); }
int target_function() { return 47; }
int main() {
signal(SIGBUS, sigbus_handler);
// Generate a SIGBUS by deliverately calling through an unaligned function
// pointer.
union {
int (*t)();
uintptr_t p;
} u;
u.t = target_function;
u.p |= 1;
return u.t();
}