diff --git a/src/aarch64/Ginit.c b/src/aarch64/Ginit.c index 2b08feb36..a01ee3a92 100644 --- a/src/aarch64/Ginit.c +++ b/src/aarch64/Ginit.c @@ -25,10 +25,11 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include +#include #include #include #include -#include +#include #include "unwind_i.h" @@ -84,9 +85,9 @@ get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr, return 0; } -#define PAGE_SIZE 4096 -#define PAGE_START(a) ((a) & ~(PAGE_SIZE-1)) +#define PAGE_START(addr, page_size) ((addr) & ~(page_size - 1)) +static int mem_page_size; static int mem_validate_pipe[2] = {-1, -1}; #ifdef HAVE_PIPE2 @@ -194,13 +195,14 @@ HIDDEN void tdep_init_mem_validate (void) { open_pipe (); + mem_page_size = sysconf(_SC_PAGESIZE); #ifdef HAVE_MINCORE unsigned char present = 1; - unw_word_t addr = PAGE_START((unw_word_t)&present); + unw_word_t addr = PAGE_START((unw_word_t)&present, mem_page_size); unsigned char mvec[1]; int ret; - while ((ret = mincore ((void*)addr, PAGE_SIZE, (unsigned char *)mvec)) == -1 && + while ((ret = mincore((void*)addr, mem_page_size, (unsigned char*)mvec)) == -1 && errno == EAGAIN) {} if (ret == 0) { @@ -295,12 +297,9 @@ validate_mem (unw_word_t addr) { size_t len; - if (PAGE_START(addr + sizeof (unw_word_t) - 1) == PAGE_START(addr)) - len = PAGE_SIZE; - else - len = PAGE_SIZE * 2; - addr = PAGE_START(addr); + len = mem_page_size; + addr = PAGE_START(addr, mem_page_size); if (addr == 0) return -1;