1 : /*
2 : * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 : * Use of this source code is governed by a BSD-style license that can be
4 : * found in the LICENSE file.
5 : */
6 :
7 : #include <errno.h>
8 : #include <sys/mman.h>
9 :
10 : #include "native_client/src/shared/platform/nacl_log.h"
11 : #include "native_client/src/trusted/service_runtime/arch/sel_ldr_arch.h"
12 : #include "native_client/src/trusted/service_runtime/sel_addrspace.h"
13 : #include "native_client/src/trusted/service_runtime/sel_ldr.h"
14 :
15 :
16 12 : void NaClAddrSpaceFree(struct NaClApp *nap) {
17 12 : char *base = (char *) nap->mem_start - NACL_ADDRSPACE_LOWER_GUARD_SIZE;
18 12 : uintptr_t addrsp_size = (uintptr_t) 1U << nap->addr_bits;
19 12 : size_t full_size = (NACL_ADDRSPACE_LOWER_GUARD_SIZE + addrsp_size +
20 : NACL_ADDRSPACE_UPPER_GUARD_SIZE);
21 12 : if (munmap(base, full_size) != 0) {
22 0 : NaClLog(LOG_FATAL, "NaClAddrSpaceFree: munmap() failed, errno %d\n",
23 0 : errno);
24 0 : }
25 12 : }
|