2 * Copyright (c) 2015-2018 Dmitry V. Levin <ldv@altlinux.org>
5 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include <sys/sendfile.h>
19 const unsigned long pagesize = get_page_size();
23 * The si_addr field is unreliable:
24 * https://marc.info/?l=linux-s390&m=142515870124248&w=2
26 error_msg_and_skip("s390: si_addr is unreliable");
29 /* write instruction pointer length to the log */
30 assert(write(-1, NULL, 2 * sizeof(void *)) < 0);
32 /* just a noticeable line in the log */
33 assert(munmap(&main, 0) < 0);
37 perror_msg_and_fail("fork");
40 const unsigned long mask = ~(pagesize - 1);
41 unsigned long addr = (unsigned long) &main & mask;
42 unsigned long size = pagesize << 1;
46 if (dladdr(&main, &info)) {
47 const unsigned long base =
48 (unsigned long) info.dli_fbase & mask;
60 /* SIGSEGV is expected */
61 (void) munmap((void *) addr, size);
62 (void) munmap((void *) addr, size);
63 error_msg_and_skip("SIGSEGV did not happen");
67 assert(wait(&status) == pid);
68 assert(WIFSIGNALED(status));
69 assert(WTERMSIG(status) == SIGSEGV);
71 /* dump process map for debug purposes */
73 if (!open("/proc/self/maps", O_RDONLY))
74 (void) sendfile(1, 0, NULL, pagesize);