1 /* Determine the virtual memory area of a given address. 2 Copyright (C) 2002-2021 Free Software Foundation, Inc. 3 Copyright (C) 2003-2006 Paolo Bonzini <bonzini@gnu.org> 4 5 This program is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 17 18 /* Written by Bruno Haible and Paolo Bonzini. */ 19 20 #ifndef _STACKVMA_H 21 #define _STACKVMA_H 22 23 #include <stdint.h> 24 25 /* Describes a virtual memory area, with some info about the gap between 26 it and the next or previous virtual memory area. */ 27 struct vma_struct 28 { 29 uintptr_t start; 30 uintptr_t end; 31 #if STACK_DIRECTION < 0 32 /* Info about the gap between this VMA and the previous one. 33 addr must be < vma->start. */ 34 int (*is_near_this) (uintptr_t addr, struct vma_struct *vma); 35 /* Private field, not provided by all sigsegv_get_vma implementations. */ 36 uintptr_t prev_end; 37 #endif 38 #if STACK_DIRECTION > 0 39 /* Info about the gap between this VMA and the next one. 40 addr must be > vma->end - 1. */ 41 int (*is_near_this) (uintptr_t addr, struct vma_struct *vma); 42 /* Private field, not provided by all sigsegv_get_vma implementations. */ 43 uintptr_t next_start; 44 #endif 45 }; 46 47 /* Determines the virtual memory area to which a given address belongs, 48 and returns 0. Returns -1 if it cannot be determined. 49 This function is used to determine the stack extent when a fault occurs. */ 50 extern int sigsegv_get_vma (uintptr_t address, struct vma_struct *vma); 51 52 /* Defined if sigsegv_get_vma actually works (i.e. does not always fail). */ 53 #if defined __linux__ || defined __ANDROID__ \ 54 || defined __FreeBSD_kernel__ || defined __FreeBSD__ || defined __DragonFly__ \ 55 || defined __NetBSD__ || defined __OpenBSD__ \ 56 || (defined __APPLE__ && defined __MACH__) \ 57 || defined _AIX || defined __sgi || defined __sun \ 58 || defined __CYGWIN__ || defined __HAIKU__ 59 # define HAVE_STACKVMA 1 60 #endif 61 62 #endif /* _STACKVMA_H */