Merge pull request #35 from darlinghq/generate_syscalls

Add Documentation On Generating Syscalls
This commit is contained in:
CuriousTommy 2021-12-26 18:32:34 -08:00 committed by GitHub
commit 7d9ca37cb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View File

@ -29,6 +29,7 @@
- [Contributing](contributing/README.md)
- [Debugging](contributing/debugging.md)
- [Generating stubs](contributing/generating-stubs.md)
- [Generating syscalls](contributing/generating-syscalls.md)
- [High priority stuff](contributing/high-priority-stuff.md)
- [Google Summer of Code](contributing/google-summer-of-code.md)
- [Packaging](contributing/packaging.md)

View File

@ -0,0 +1,31 @@
# Generating Syscalls
While not common, there are situations where you might need to regenerate syscalls. Fortunately, Apple provides a convenient perl script called `create-syscalls.pl`. The script is located in `[XNU]/libsyscall/xcodescripts/`.
## Understanding `create-syscalls.pl`'s Arugments
When you try to run the command, without any arguments, you will get the following prompt:
```
Usage: create-syscalls.pl syscalls.master custom-directory platforms-directory platform-name out-directory
```
Unfortunately, the prompt does not give a lot of helpful information. Below is a breakdown of what the script is requesting.
* `syscalls.master` - Point to the syscalls.master file. ex: `[XNU]/bsd/kern/syscalls.master`
* `custom-directory` - Point to a directory that contains a `SYS.h`, `custom.s`, and a list of `__` files. These files can be found in a folder called custom. ex:`[XNU]/libsyscall/custom/`
* `platforms-directory`- Point to a directory that contains the `syscall.map` files. Ex:`[XNU]/libsyscall/Platforms/`
* `platform-name` - One of the platform names that are in the platform directory. ex: `MacOSX`
In addition, you will need to define the list of `ARCHS` that the tool should generate.
```
export ARCHS="arm64 i386 x86_64"
```
## Example
```
export ARCHS="arm64 i386 x86_64"
mkdir ~/Desktop/generated_syscalls
./create-syscalls.pl $XNU/bsd/kern/syscalls.master $XNU/libsyscall/custom/ $XNU/libsyscall/Platforms/ MacOSX ~/Desktop/generated_syscalls
```