Skip to content

Commit 280b11c

Browse files
committed
arm64e build docs
1 parent 59da0eb commit 280b11c

5 files changed

Lines changed: 66 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
cmake_minimum_required(VERSION "3.1")
15+
cmake_minimum_required(VERSION "3.5")
1616
set (CMAKE_CXX_STANDARD 17)
1717

1818
# Determine whether TinyInst should be build for arm64 or x86
@@ -168,3 +168,14 @@ add_executable(litecov
168168
)
169169

170170
target_link_libraries(litecov tinyinst)
171+
172+
if(APPLE)
173+
set_target_properties(litecov PROPERTIES
174+
XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "${CMAKE_CURRENT_SOURCE_DIR}/tinyinst.entitlements"
175+
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-"
176+
)
177+
set_target_properties(sslhook PROPERTIES
178+
XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "${CMAKE_CURRENT_SOURCE_DIR}/tinyinst.entitlements"
179+
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-"
180+
)
181+
endif()

arm64e.entitlements

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.cs.debugger</key>
6+
<true/>
7+
<key>com.apple.private.thread-set-state</key>
8+
<true/>
9+
</dict>
10+
</plist>

macOS/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ aligns to 16k to ensure that not only parts of a module is instrumented. This
2828
behavior is controlled by the `-page_extend_modules` flag which is set to
2929
`true` by default on M1. In some cases it might be possible to turn off this flag resulting in better performance.
3030

31+
## Running against arm64e binaries
32+
33+
See [here](https://github.com/googleprojectzero/TinyInst/blob/master/macOS/README.md)
34+
3135
## TinyInst and Guard Malloc
3236

3337
On macOS, [Guard Malloc](https://developer.apple.com/library/archive/documentation/Performance/Conceptual/ManagingMemory/Articles/MallocDebug.html) is a special version of the malloc library that makes it easier to catch certain types of memory safety issues. To enable Guard Malloc for a target process running under TinyInst, use the following flag:

macOS/arm64e.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Running against arm64e binaries
2+
3+
Note: There is a high probability you don't need this. By default, all binaries you compile yourself on Apple silicom macs will be arm64 (and *not* arm64e) binaries. E.g. a fuzzing harness you wrote yourself will be an arm64 binary even if it loads libraries made and signed by Apple. Only binaries that ship with the system and are signed by Apple will be arm64e binaries. You can always check which architecture a binary is compiled for by running the `file` command against it.
4+
5+
In order to successfully run TinyInst or Jackalope against arm64e binaries, you need to do the following:
6+
7+
1. Disable System Integrity Protection (SIP) by following instructions [here](https://developer.apple.com/documentation/security/disabling-and-enabling-system-integrity-protection).
8+
9+
2. Enable arm64e ABI and disable Apple Mobile File Integrity (AMFI) by running the following command
10+
```
11+
sudo nvram boot-args="-arm64e_preview_abi amfi_get_out_of_my_way=1"
12+
```
13+
and restarting the system.
14+
15+
3. Build arm64e version of TinyInst / Jackalope by running the following commands from the source directory. This is the same build process as usual but with `-DCMAKE_OSX_ARCHITECTURES=arm64e` argument added.
16+
17+
```
18+
mkdir buildarm64e
19+
cd arm64e
20+
cmake -G Xcode -DCMAKE_OSX_ARCHITECTURES=arm64e ..
21+
cmake --build . --config Release
22+
```
23+
24+
4. You might also need to add additional entitlements to your TinyInst / Jackalope binaries by running
25+
```
26+
codesign -f -s - --entitlements path/to/TinyInst/arm64e.entitlements path/to/litecov/or/fuzzer
27+
```
28+
29+
You should be able to run successfully against an arm64e binary now, e.g.
30+
```
31+
/path/to/litecov -instrument_module ls -- /bin/ls .
32+
```

tinyinst.entitlements

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.cs.debugger</key>
6+
<true/>
7+
</dict>
8+
</plist>

0 commit comments

Comments
 (0)