]>
git.saurik.com Git - apple/dyld.git/blob - dyld3/RootsChecker.h
2 * Copyright (c) 2020 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
26 #ifndef __DYLD_ROOTS_CHECKER_H__
27 #define __DYLD_ROOTS_CHECKER_H__
29 #include <TargetConditionals.h>
31 #if TARGET_OS_OSX && (BUILDING_DYLD || BUILDING_CLOSURE_UTIL) && !TARGET_OS_SIMULATOR
32 #define DYLD_SIMULATOR_ROOTS_SUPPORT 1
34 #define DYLD_SIMULATOR_ROOTS_SUPPORT 0
37 class DyldSharedCache
;
46 #define VIS_HIDDEN __attribute__((visibility("hidden")))
48 class VIS_HIDDEN RootsChecker
51 RootsChecker() = default;
53 // Does a on-disk binary represent a root.
54 // If the cache expects dylibs on disk, then so long as the dylib matches
55 // the mod time and inode in the cache, it is not a root.
56 // For the macOS simulator support dylibs, which are on disk, whether they
57 // are roots depends on the state we are tracking in the comm page.
58 // For all other dylibs and all other platforms, on-disk dylibs are always roots
59 bool onDiskFileIsRoot(const char* path
, const DyldSharedCache
* cache
, const closure::Image
* image
,
60 const closure::FileSystem
* fileSystem
,
61 uint64_t inode
, uint64_t modtime
) const;
63 #if DYLD_SIMULATOR_ROOTS_SUPPORT
64 static bool uuidMatchesSharedCache(const char* path
, const closure::FileSystem
* fileSystem
,
65 const DyldSharedCache
* cache
);
67 void setLibsystemKernelIsRoot(bool v
) {
68 libsystemKernelIsRoot
= v
;
70 void setLibsystemPlatformIsRoot(bool v
) {
71 libsystemPlatformIsRoot
= v
;
73 void setLibsystemPThreadIsRoot(bool v
) {
74 libsystemPThreadIsRoot
= v
;
76 void setFileSystemCanBeModified(bool v
) {
77 fileSystemCanBeModified
= v
;
82 // By default, assume nothing is a root, but that the file system is writable.
83 // This should be conservatively correct.
84 #if DYLD_SIMULATOR_ROOTS_SUPPORT
85 bool libsystemKernelIsRoot
= false;
86 bool libsystemPlatformIsRoot
= false;
87 bool libsystemPThreadIsRoot
= false;
88 bool fileSystemCanBeModified
= true;
94 #endif // __DYLD_ROOTS_CHECKER_H__