├── .gitignore
├── APPLE_LICENSE
├── README.md
├── ar
├── append.c
├── ar.1
├── ar.5
├── ar.c
├── archive.c
├── archive.h
├── contents.c
├── delete.c
├── extern.h
├── extract.c
├── misc.c
├── move.c
├── pathnames.h
├── print.c
└── replace.c
├── cctools.xcodeproj
├── project.pbxproj
└── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ └── IDEWorkspaceChecks.plist
├── efitools
├── makerelocs.c
├── mtoc.c
└── mtor.c
├── gprof
├── arcs.c
├── calls.c
├── dfn.c
├── getnfile.c
├── gprof.c
├── gprof.callg
├── gprof.flat
├── gprof.h
├── hertz.c
├── lookup.c
├── m68k.h
├── printgprof.c
├── printlist.c
├── scatter.c
└── vax.h
├── include
├── architecture
│ ├── i386
│ │ ├── fpu.h
│ │ └── frame.h
│ ├── m88k
│ │ ├── fp_regs.h
│ │ └── reg_help.h
│ ├── nrw
│ │ ├── macro_help.h
│ │ └── reg_help.h
│ └── sparc
│ │ └── reg.h
├── coff
│ ├── aouthdr.h
│ ├── base_relocs.h
│ ├── bytesex.h
│ ├── debug_directory.h
│ ├── filehdr.h
│ ├── ms_dos_stub.h
│ ├── scnhdr.h
│ └── syment.h
├── elf
│ └── dwarf2.h
├── gnu
│ ├── a.out.h
│ ├── exec.h
│ └── symseg.h
├── i386
│ └── eflags.h
├── llvm-c
│ └── Disassembler.h
├── mach-o
│ ├── arch.h
│ ├── arm
│ │ └── reloc.h
│ ├── arm64
│ │ └── reloc.h
│ ├── dyld.h
│ ├── dyld_debug.h
│ ├── dyld_gdb.h
│ ├── dyld_priv.h
│ ├── fat.h
│ ├── getsect.h
│ ├── gmon.h
│ ├── i386
│ │ └── swap.h
│ ├── kld.h
│ ├── ldsyms.h
│ ├── loader.h
│ ├── nlist.h
│ ├── ranlib.h
│ ├── redo_prebinding.h
│ ├── reloc.h
│ ├── rld.h
│ ├── rld_state.h
│ ├── sarld.h
│ ├── stab.h
│ ├── swap.h
│ └── x86_64
│ │ └── reloc.h
├── mach
│ ├── arm
│ │ ├── _structs.h
│ │ ├── thread_state.h
│ │ └── thread_status.h
│ ├── hppa
│ │ └── thread_status.h
│ ├── i386
│ │ ├── _structs.h
│ │ ├── fp_reg.h
│ │ ├── thread_state.h
│ │ └── thread_status.h
│ ├── i860
│ │ └── thread_status.h
│ ├── m68k
│ │ └── thread_status.h
│ ├── m88k
│ │ └── thread_status.h
│ ├── machine-cctools.h
│ ├── ppc
│ │ ├── _structs.h
│ │ └── thread_status.h
│ ├── slot_name.h
│ └── sparc
│ │ └── thread_status.h
├── modules
│ ├── MachO.exclavecore.modulemap
│ ├── MachO.exclavekit.modulemap
│ ├── MachO_Private.exclavekit.modulemap
│ ├── mach-o.exclavekit.modulemap
│ └── mach-o.exclavekit.private.modulemap
├── opcode
│ └── arm.h
├── standalone
│ ├── getsect.h
│ └── libsa.h
├── stuff
│ ├── SymLoc.h
│ ├── align.h
│ ├── allocate.h
│ ├── arch.h
│ ├── args.h
│ ├── best_arch.h
│ ├── bool.h
│ ├── breakout.h
│ ├── bytesex.h
│ ├── code_directory.h
│ ├── crc32.h
│ ├── depinfo.h
│ ├── diagnostics.h
│ ├── dylib_roots.h
│ ├── dylib_table.h
│ ├── errors.h
│ ├── execute.h
│ ├── guess_short_name.h
│ ├── hash_string.h
│ ├── hppa.h
│ ├── llvm.h
│ ├── lto.h
│ ├── macosx_deployment_target.h
│ ├── ofile.h
│ ├── openstep_mach.h
│ ├── print.h
│ ├── reloc.h
│ ├── rnd.h
│ ├── seg_addr_table.h
│ ├── symbol.h
│ ├── symbol_list.h
│ ├── unix_standard_mode.h
│ ├── version_number.h
│ ├── vm_flush_cache.h
│ ├── write64.h
│ └── xcode.h
├── sys
│ └── gmon.h
└── xar
│ └── xar.h
├── ld
├── 4byte_literals.c
├── 4byte_literals.h
├── 8byte_literals.c
├── 8byte_literals.h
├── arm_reloc.c
├── arm_reloc.h
├── coalesced_sections.c
├── coalesced_sections.h
├── cstring_literals.c
├── cstring_literals.h
├── debugcompunit.c
├── debugcompunit.h
├── debugline.c
├── debugline.h
├── dwarf2.h
├── dylibs.c
├── dylibs.h
├── fvmlibs.c
├── fvmlibs.h
├── generic_reloc.c
├── generic_reloc.h
├── hash_string.h
├── hppa_reloc.c
├── hppa_reloc.h
├── i860_reloc.c
├── i860_reloc.h
├── indirect_sections.c
├── indirect_sections.h
├── layout.c
├── layout.h
├── ld.c
├── ld.h
├── librld.ofileList
├── literal_pointers.c
├── literal_pointers.h
├── live_refs.h
├── m88k_reloc.c
├── m88k_reloc.h
├── mod_sections.c
├── mod_sections.h
├── objects.c
├── objects.h
├── pass1.c
├── pass1.h
├── pass2.c
├── pass2.h
├── ppc_reloc.c
├── ppc_reloc.h
├── rld.c
├── sections.c
├── sections.h
├── sets.c
├── sets.h
├── sparc_reloc.c
├── sparc_reloc.h
├── specs.c
├── specs.h
├── symbols.c
├── symbols.h
├── uuid.c
└── uuid.h
├── libmacho
├── arch.c
├── dylib.ofileList
├── get_end.c
├── getsecbyname.c
├── getsegbyname.c
├── i386_swap.c
├── shlib.ofileList
├── slot_name.c
└── swap.c
├── libstuff
├── SymLoc.c
├── align.c
├── allocate.c
├── apple_version.c
├── arch.c
├── arch_usage.c
├── args.c
├── best_arch.c
├── breakout.c
├── bytesex.c
├── checkout.c
├── code_directory.c
├── coff_bytesex.c
├── crc32.c
├── depinfo.c
├── diagnostics.c
├── dylib_roots.c
├── dylib_table.c
├── errors.c
├── execute.c
├── fatal_arch.c
├── fatals.c
├── get_arch_from_host.c
├── get_toc_byte_sex.c
├── guess_short_name.c
├── hash_string.c
├── hppa.c
├── llvm.c
├── lto.c
├── macosx_deployment_target.c
├── ofile.c
├── ofile_error.c
├── ofile_get_word.c
├── print.c
├── reloc.c
├── rnd.c
├── seg_addr_table.c
├── set_arch_flag_name.c
├── swap_headers.c
├── symbol_list.c
├── unix_standard_mode.c
├── version_number.c
├── vm_flush_cache.c
├── write64.c
├── writeout.c
└── xcode.c
├── libstuff_test
├── align_test.c
├── allocate_test.c
├── arch_test.c
├── args_test.c
├── depinfo_test.c
├── get_arch_from_host_test.c
├── guess_short_name_test.c
├── libstuff_test.c
├── null_test.c
├── reset_load_command_pointers_test.c
├── rnd_test.c
├── test.c
├── test.h
├── test_main.h
├── test_util.c
├── test_util.h
└── version_number_test.c
├── man
├── Mach-O.5
├── NSModule.3
├── NSObjectFileImage.3
├── NSObjectFileImage_priv.3
├── a.out.5
├── arch.3
├── as.1
├── bitcode_strip.1
├── check_dylib.1
├── checksyms.1
├── cmpdylib.1
├── codesign_allocate.1
├── ctf_insert.1
├── depinfo.1
├── diagtest.1
├── dyld.1
├── dyld.3
├── dyld_debug.3
├── end.3
├── get_end.3
├── getsectbyname.3
├── getsectbynamefromheader.3
├── getsectdata.3
├── getsectdatafromheader.3
├── getsegbyname.3
├── gprof.1
├── indr.1
├── install_name_tool.1
├── kld.3
├── ld_classic.1
├── libtool.1
├── lipo.1
├── llvm-otool.1
├── mtoc.1
├── mtor.1
├── nm-classic.1
├── nm.1
├── nmedit.1
├── otool-classic.1
├── otool.1
├── pagestuff.1
├── ranlib.1
├── ranlib.5
├── redo_prebinding.1
├── redo_prebinding.3
├── rld.3
├── seg_addr_table.1
├── segedit.1
├── size-classic.1
├── size.1
├── stab.5
├── strings.1
├── strip.1
└── vtool.1
├── misc
├── Info.plist
├── as
├── bitcode_strip.c
├── check_dylib.c
├── checksyms.c
├── cmpdylib.c
├── codesign_allocate-Info.plist
├── codesign_allocate.c
├── ctf_insert.c
├── depinfo.c
├── diagtest.c
├── indr.c
├── inout.c
├── install_name_tool.c
├── libtool.c
├── lipo.c
├── nm.c
├── pagestuff.c
├── redo_prebinding.c
├── seg_addr_table.c
├── seg_hack.c
├── segedit.c
├── size.c
├── strings.c
├── strip.c
└── vtool.c
├── otool
├── arm64_disasm.c
├── arm64_disasm.h
├── arm_disasm.c
├── arm_disasm.h
├── coff_print.c
├── cxa_demangle.h
├── dyld_bind_info.c
├── dyld_bind_info.h
├── fixup-chains.h
├── i386_disasm.c
├── i386_disasm.h
├── main.c
├── ofile_print.c
├── ofile_print.h
├── otool.h
├── print_bitcode.c
├── print_objc.c
├── print_objc2_32bit.c
├── print_objc2_64bit.c
├── print_objc2_util.c
└── print_objc2_util.h
├── tests
├── Makefile
├── README.md
├── bin
│ ├── check.pl
│ ├── exit-non-zero-pass.pl
│ ├── fail-if-exit-non-zero.pl
│ ├── fail-if-exit-zero.pl
│ ├── fail-if-no-stdin.pl
│ ├── fail-if-stdin.pl
│ ├── fail-iff-exit-zero.pl
│ ├── new-makefile-test.pl
│ ├── note-tool.pl
│ ├── pass-iff-exit-non-zero.pl
│ ├── pass-iff-exit-zero.pl
│ ├── pass-iff-no-stdin.pl
│ ├── pass-iff-stdin.pl
│ ├── rewrite-macho.pl
│ ├── run-tests.pl
│ └── verify-align.pl
├── data
│ └── echo.fat
├── include
│ ├── MachO.pm
│ ├── MachO
│ │ ├── ArchiveObject.pm
│ │ ├── Base.pm
│ │ ├── CPU.pm
│ │ ├── FatHeader.pm
│ │ ├── FatObject.pm
│ │ ├── LEB128.pm
│ │ ├── LoadCommands.pm
│ │ ├── MachHeader.pm
│ │ ├── MachObject.pm
│ │ ├── StringTable.pm
│ │ ├── SymbolTable.pm
│ │ └── Trie.pm
│ └── common.makefile
├── run-tests
├── src
│ ├── bar.c
│ ├── foo.c
│ ├── hello.c
│ ├── hello_textexec.c
│ ├── objc_hi.m
│ ├── preload.c
│ ├── preload_bss.c
│ ├── times.c
│ └── verstool.c
└── test-cases
│ ├── 1a_harness_test
│ └── Makefile
│ ├── 1b_check_test
│ └── Makefile
│ ├── as-gas
│ └── Makefile
│ ├── as-llvm
│ └── Makefile
│ ├── as-symbol
│ ├── Makefile
│ └── x.s
│ ├── bitcode_strip-bigendian
│ └── Makefile
│ ├── bitcode_strip-chained-binds
│ └── Makefile
│ ├── bitcode_strip-codesign
│ └── Makefile
│ ├── bitcode_strip-resign
│ └── Makefile
│ ├── bitcode_strip_arm64_32
│ ├── Makefile
│ └── empty.c
│ ├── bitcode_strip_large
│ └── Makefile
│ ├── cc_log_diagnostics
│ └── Makefile
│ ├── codesign
│ └── Makefile
│ ├── codesign_allocate-bigendian
│ └── Makefile
│ ├── codesign_allocate-chained-binds
│ └── Makefile
│ ├── codesign_allocate_arm64_32
│ └── Makefile
│ ├── codesign_allocate_debug
│ └── Makefile
│ ├── codesign_allocate_large
│ └── Makefile
│ ├── codesign_allocate_requirement
│ └── Makefile
│ ├── ctf_insert-no-text
│ ├── Makefile
│ ├── in.exe
│ └── in.txt
│ ├── ctf_insert-split_seg-chained
│ ├── Makefile
│ └── preload.c
│ ├── ctf_insert-split_seg
│ ├── Makefile
│ └── preload.c
│ ├── ctf_insert
│ └── Makefile
│ ├── install_name_tool-change
│ ├── Makefile
│ └── client.c
│ ├── install_name_tool-id
│ └── Makefile
│ ├── libstuff-unit-tests
│ └── Makefile
│ ├── libtool-atfile
│ ├── Makefile
│ ├── deterministic.txt
│ ├── libfoo.c
│ ├── loop.txt
│ ├── object.txt
│ └── static.txt
│ ├── libtool-atomic
│ ├── Makefile
│ └── libfoo.c
│ ├── libtool-cpusubtype-flags
│ └── Makefile
│ ├── libtool-deterministic
│ ├── Makefile
│ └── libfoo.c
│ ├── libtool-filelist-commapath
│ ├── Makefile
│ ├── filelist, dir
│ │ └── filelist
│ └── libfoo.c
│ ├── libtool-ldtrace-file
│ └── Makefile
│ ├── libtool-ldtrace-json-file
│ └── Makefile
│ ├── libtool-ldtrace-json-stderr
│ └── Makefile
│ ├── libtool-ldtrace-stderr
│ └── Makefile
│ ├── libtool-static-times
│ └── Makefile
│ ├── libtool-static
│ ├── Makefile
│ └── libfoo.c
│ ├── lipo-arch_blank
│ └── Makefile
│ ├── lipo-archs
│ └── Makefile
│ ├── lipo-bigendian
│ └── Makefile
│ ├── lipo-cpusubtype-order
│ ├── Makefile
│ └── foo.c
│ ├── lipo-hidden
│ ├── Makefile
│ └── empty.c
│ ├── lipo-info
│ └── Makefile
│ ├── lipo-large
│ └── Makefile
│ ├── lipo-thin-times
│ └── Makefile
│ ├── llvm-otool
│ └── Makefile
│ ├── mtor-bad-file
│ └── Makefile
│ ├── mtor-preload-bss
│ └── Makefile
│ ├── mtor-preload-packdata
│ └── Makefile
│ ├── mtor-preload
│ └── Makefile
│ ├── mtor-usage
│ └── Makefile
│ ├── nm-classic-lto-weak-ref
│ ├── Makefile
│ └── weak-ref.cpp
│ ├── nm-classic-m-cold-func
│ ├── Makefile
│ └── symtool.c
│ ├── nm-classic-m
│ ├── Makefile
│ ├── atsPathVersSuffix.c
│ ├── atsVersSuffix.c
│ ├── foo.c
│ ├── fooPath.c
│ ├── fooPathSuffix.c
│ ├── fooPathVers.c
│ ├── fooSuffix.c
│ ├── fooVers.c
│ ├── foo_bar.c
│ ├── foo_barSuffix.c
│ ├── main.c
│ ├── qt.c
│ ├── qtPath.c
│ ├── x.c
│ ├── xPathSuffix.c
│ └── xSuffix.c
│ ├── nmedit-D
│ └── Makefile
│ ├── nmedit-reloc-bypass
│ ├── Makefile
│ ├── ex.a
│ ├── ex.c
│ └── ex.exp
│ ├── nmedit-usage
│ └── Makefile
│ ├── otool-classic-L
│ ├── Makefile
│ └── mangle.pl
│ ├── otool-classic-S
│ └── Makefile
│ ├── otool-classic-addr-slide
│ └── Makefile
│ ├── otool-classic-bind_info-chained-weak
│ ├── Makefile
│ ├── weak-large-addends.cpp
│ ├── weak-no-addends.cpp
│ └── weak-small-addends.cpp
│ ├── otool-classic-bind_info-chained
│ └── Makefile
│ ├── otool-classic-bind_info
│ └── Makefile
│ ├── otool-classic-cpusubtype-flags
│ └── Makefile
│ ├── otool-classic-f
│ └── Makefile
│ ├── otool-classic-o-rel32
│ ├── Makefile
│ ├── hi-abs-32.dylib
│ ├── hi-abs-64.dylib
│ ├── hi-dir-32.dylib
│ ├── hi-dir-64.dylib
│ ├── hi-rel-32.dylib
│ ├── hi-rel-64.dylib
│ ├── hi.h
│ ├── hi.m
│ └── main.m
│ ├── otool-classic-o-selrefs
│ ├── Dylib.h
│ ├── Dylib.m
│ ├── Makefile
│ ├── Protocol.h
│ └── Tool.m
│ ├── otool-classic-o
│ ├── Dylib.h
│ ├── Dylib.m
│ ├── Makefile
│ ├── Protocol.h
│ └── Tool.m
│ ├── otool-classic-pointer-formats
│ ├── Makefile
│ ├── firmware.c
│ ├── tool.c
│ ├── tool_ARM64E
│ ├── tool_NONE
│ ├── tool_PTR_32
│ ├── tool_PTR_32_FIRMWARE
│ ├── tool_PTR_64
│ ├── tool_PTR_ARM64E_USERLAND24
│ └── tool_THREADED
│ ├── otool-classic-ptrauth-flag
│ └── Makefile
│ ├── otool-classic-t
│ ├── Makefile
│ └── hello.s
│ ├── otool-classic-x
│ └── Makefile
│ ├── pagestuff-chained-binds
│ └── Makefile
│ ├── pagestuff-usage
│ ├── Makefile
│ ├── testfile
│ └── verstool.c
│ ├── ranlib-8byte-aligned
│ └── Makefile
│ ├── ranlib-atomic
│ ├── Makefile
│ └── libfoo.c
│ ├── ranlib-t
│ └── Makefile
│ ├── segedit-extract
│ ├── Makefile
│ ├── MementoMori1.txt
│ └── main.c
│ ├── segedit-replace-bigendian
│ ├── Makefile
│ ├── MementoMori1.txt
│ ├── MementoMori2.txt
│ ├── dirty_data.txt
│ └── main.c
│ ├── segedit-replace-chained-binds
│ ├── Makefile
│ ├── MementoMori1.txt
│ ├── MementoMori2.txt
│ ├── dirty_data.txt
│ └── main.c
│ ├── segedit-replace
│ ├── Makefile
│ ├── MementoMori1.txt
│ ├── MementoMori2.txt
│ ├── dirty_data.txt
│ └── main.c
│ ├── size-usage
│ └── Makefile
│ ├── strings-stdin
│ └── Makefile
│ ├── strip-D
│ └── Makefile
│ ├── strip-R
│ ├── Makefile
│ └── list.txt
│ ├── strip-S-dice
│ ├── Makefile
│ └── dice.o
│ ├── strip-S-nosyms
│ ├── Makefile
│ └── nosyms.o
│ ├── strip-T
│ ├── Makefile
│ └── hello.swift
│ ├── strip-archive-times
│ └── Makefile
│ ├── strip-chained-binds
│ ├── Makefile
│ └── symbols.c
│ ├── strip-dylib-exports-trie
│ ├── Makefile
│ └── foo.c
│ ├── strip-indirectsym_pad
│ ├── Makefile
│ ├── dylib.c
│ └── dylib.sym
│ ├── strip-prestripped
│ └── Makefile
│ ├── strip-resign
│ └── Makefile
│ ├── strip-uniq
│ ├── Makefile
│ ├── bar.c
│ ├── foo.c
│ └── main.c
│ ├── strip-zero-ar-date
│ └── Makefile
│ ├── verify-build-version
│ ├── Makefile
│ └── foo.c
│ ├── verify-iosmac-backdeploy
│ ├── Makefile
│ └── foo.c
│ ├── verify-iosmac
│ ├── Makefile
│ └── foo.c
│ ├── vtool-remove
│ └── Makefile
│ ├── vtool-set
│ └── Makefile
│ ├── vtool-show
│ └── Makefile
│ └── vtool-usage
│ └── Makefile
├── update.sh
└── xcode
├── as_license.sh
├── cctools.xcconfig
├── codesign_allocate.xcconfig
├── copy_if.sh
├── copy_macho_headers_standalone.sh
├── create_symlink.sh
├── libstuff.xcconfig
├── macho_dynamic.xcconfig
├── macho_dynamic_driverkit.xcconfig
├── macho_headers.sh
├── macho_headers.xcconfig
├── macho_static.xcconfig
├── otool.xcconfig
├── private_efi.xcconfig
├── private_test.xcconfig
├── private_tool.xcconfig
├── public_tool.xcconfig
└── strip.xcconfig
/.gitignore:
--------------------------------------------------------------------------------
1 | # Don't track content of these folders
2 | **/xcuserdata
3 |
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # cctools
2 |
3 | This repo is a mirror of cctools source dumps from opensource.apple.com.
4 | This is useful for diffing changes between Xcode versions and building
5 | various tools for debugging issues.
6 |
7 | ## Building
8 |
9 | If you would like to build any of these tools yourself, which can be
10 | useful for debugging various issues, you can use these branches:
11 |
12 | - [buildable-16.0](https://github.com/keith/cctools/tree/buildable-16.0)
13 | - [buildable-15.3](https://github.com/keith/cctools/tree/buildable-15.3)
14 | - [buildable-15.0](https://github.com/keith/cctools/tree/buildable-15.0)
15 | - [buildable-13.2.1](https://github.com/keith/cctools/tree/buildable-13.2.1)
16 | - [buildable-12.0](https://github.com/keith/cctools/tree/buildable-12.0)
17 |
18 |
19 | ## Updating this repo
20 |
21 | ```sh
22 | ./update.sh URL_OF_TAR_GZ
23 | ```
24 |
--------------------------------------------------------------------------------
/cctools.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/cctools.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/gprof/gprof.flat:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | flat profile:
5 |
6 | % the percentage of the total running time of the
7 | time program used by this function.
8 |
9 | cumulative a running sum of the number of seconds accounted
10 | seconds for by this function and those listed above it.
11 |
12 | self the number of seconds accounted for by this
13 | seconds function alone. This is the major sort for this
14 | listing.
15 |
16 | calls the number of times this function was invoked, if
17 | this function is profiled, else blank.
18 |
19 | self the average number of milliseconds spent in this
20 | ms/call function per call, if this function is profiled,
21 | else blank.
22 |
23 | total the average number of milliseconds spent in this
24 | ms/call function and its descendents per call, if this
25 | function is profiled, else blank.
26 |
27 | name the name of the function. This is the minor sort
28 | for this listing. The index shows the location of
29 | the function in the gprof listing. If the index is
30 | in parenthesis it shows where it would appear in
31 | the gprof listing if it were to be printed.
32 |
33 |
--------------------------------------------------------------------------------
/include/coff/bytesex.h:
--------------------------------------------------------------------------------
1 | #ifndef _COFF_BYTESEX_H
2 | #define _COFF_BYTESEX_H
3 |
4 | #include "stuff/bytesex.h"
5 | #include "coff/base_relocs.h"
6 | #include "coff/ms_dos_stub.h"
7 | #include "coff/filehdr.h"
8 | #include "coff/aouthdr.h"
9 | #include "coff/scnhdr.h"
10 | #include "coff/syment.h"
11 | #include "coff/debug_directory.h"
12 |
13 | __private_extern__ void swap_base_relocation_block_header(
14 | struct base_relocation_block_header *h,
15 | enum byte_sex target_byte_sex);
16 |
17 | __private_extern__ void swap_base_relocation_entry(
18 | struct base_relocation_entry *b,
19 | uint32_t n,
20 | enum byte_sex target_byte_sex);
21 |
22 | __private_extern__ void swap_ms_dos_stub(
23 | struct ms_dos_stub *m,
24 | enum byte_sex target_byte_sex);
25 |
26 | __private_extern__ void swap_filehdr(
27 | struct filehdr *f,
28 | enum byte_sex target_byte_sex);
29 |
30 | __private_extern__ void swap_aouthdr(
31 | struct aouthdr *a,
32 | enum byte_sex target_byte_sex);
33 |
34 | __private_extern__ void swap_aouthdr_64(
35 | struct aouthdr_64 *a,
36 | enum byte_sex target_byte_sex);
37 |
38 | __private_extern__ void swap_scnhdr(
39 | struct scnhdr *s,
40 | uint32_t n,
41 | enum byte_sex target_byte_sex);
42 |
43 | __private_extern__ void swap_syment(
44 | struct syment *s,
45 | uint32_t n,
46 | enum byte_sex target_byte_sex);
47 |
48 | __private_extern__ void swap_debug_directory_entry(
49 | struct debug_directory_entry *d,
50 | enum byte_sex target_byte_sex);
51 |
52 | __private_extern__ void swap_mtoc_debug_info(
53 | struct mtoc_debug_info *m,
54 | enum byte_sex target_byte_sex);
55 |
56 | #endif /* _COFF_BYTESEX_H */
57 |
--------------------------------------------------------------------------------
/include/mach/arm/thread_state.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
3 | */
4 | /*
5 | * @OSF_COPYRIGHT@
6 | */
7 |
8 | #ifndef _MACH_ARM_THREAD_STATE_H_
9 | #define _MACH_ARM_THREAD_STATE_H_
10 |
11 | #define ARM_THREAD_STATE_MAX (272)
12 |
13 | #if defined (__arm__)
14 | #define THREAD_STATE_MAX ARM_THREAD_STATE_MAX
15 | #endif
16 |
17 | #if defined(__arm64__) && !defined(THREAD_STATE_MAX)
18 | #define THREAD_STATE_MAX ARM_THREAD_STATE_MAX
19 | #endif
20 |
21 | #endif /* _MACH_ARM_THREAD_STATE_H_ */
22 |
--------------------------------------------------------------------------------
/include/mach/i386/thread_state.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
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. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 | /*
29 | * @OSF_COPYRIGHT@
30 | */
31 |
32 | #ifndef _MACH_I386_THREAD_STATE_H_
33 | #define _MACH_I386_THREAD_STATE_H_
34 |
35 | /* Size of maximum exported thread state in words */
36 | #define I386_THREAD_STATE_MAX (614) /* Size of biggest state possible */
37 |
38 | #if defined (__i386__) || defined(__x86_64__)
39 | #define THREAD_STATE_MAX I386_THREAD_STATE_MAX
40 | #endif
41 |
42 | #endif /* _MACH_I386_THREAD_STATE_H_ */
43 |
--------------------------------------------------------------------------------
/include/mach/slot_name.h:
--------------------------------------------------------------------------------
1 | #include
2 | extern void slot_name(cpu_type_t,
3 | cpu_subtype_t,
4 | char **,
5 | char **);
6 |
--------------------------------------------------------------------------------
/include/modules/MachO.exclavecore.modulemap:
--------------------------------------------------------------------------------
1 | module MachO [system] {
2 | umbrella "mach-o"
3 | module * { export * }
4 | }
5 |
--------------------------------------------------------------------------------
/include/modules/MachO.exclavekit.modulemap:
--------------------------------------------------------------------------------
1 | module MachO [system] {
2 | umbrella "mach-o"
3 | module * { export * }
4 | }
5 |
--------------------------------------------------------------------------------
/include/modules/MachO_Private.exclavekit.modulemap:
--------------------------------------------------------------------------------
1 | module MachO_Private [system] {
2 | umbrella "mach-o"
3 |
4 | module dyld {
5 | header "mach-o/dyld_priv.h"
6 | export *
7 | }
8 |
9 | explicit module * { export * }
10 | }
11 |
--------------------------------------------------------------------------------
/include/modules/mach-o.exclavekit.modulemap:
--------------------------------------------------------------------------------
1 | extern module MachO "../MachO.modulemap"
2 |
3 | module MachO_Placeholder_OldFile [system] {
4 | }
5 |
--------------------------------------------------------------------------------
/include/modules/mach-o.exclavekit.private.modulemap:
--------------------------------------------------------------------------------
1 | extern module MachO_Private "../MachO_Private.modulemap"
2 |
3 | module MachO_Private_Placeholder_OldFile [system] {
4 | }
5 |
--------------------------------------------------------------------------------
/include/stuff/SymLoc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | #include "bool.h"
24 |
25 | extern const char * symLocForDylib(
26 | const char *installName,
27 | const char *releaseName,
28 | enum bool *found_project,
29 | enum bool disablewarnings,
30 | enum bool no_error_if_missing);
31 |
32 | extern const char * dstLocForDylib(
33 | const char *installName,
34 | const char *releaseName,
35 | enum bool *found_project,
36 | enum bool disablewarnings,
37 | enum bool no_error_if_missing);
38 |
39 | const char * LocForDylib(
40 | const char *installName,
41 | const char *releaseName,
42 | const char *dirname,
43 | enum bool *found_project,
44 | enum bool disablewarnings,
45 | enum bool no_error_if_missing);
46 |
--------------------------------------------------------------------------------
/include/stuff/allocate.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | #if defined(__MWERKS__) && !defined(__private_extern__)
24 | #define __private_extern__ __declspec(private_extern)
25 | #endif
26 |
27 | /* defined in allocate.c */
28 |
29 | __private_extern__ void *allocate(
30 | size_t size);
31 |
32 | __private_extern__ void *reallocate(
33 | void *,
34 | size_t size);
35 |
36 | __private_extern__ char *savestr(
37 | const char *s);
38 |
39 | __private_extern__ char *makestr(
40 | const char *args, ...);
41 |
--------------------------------------------------------------------------------
/include/stuff/crc32.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | __private_extern__ uint32_t crc32(
24 | const void *buf,
25 | uint32_t len);
26 |
--------------------------------------------------------------------------------
/include/stuff/dylib_roots.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | extern char * get_symfile_for_dylib(
24 | char *install_name,
25 | char *release_name,
26 | enum bool *found_project,
27 | enum bool disablewarnings,
28 | enum bool no_error_if_missing);
29 |
30 | extern char * get_dstfile_for_dylib(
31 | char *install_name,
32 | char *release_name,
33 | enum bool *found_project,
34 | enum bool disablewarnings,
35 | enum bool no_error_if_missing);
36 |
37 | extern char * find_dylib_in_root(
38 | char *install_name,
39 | const char *root);
40 |
--------------------------------------------------------------------------------
/include/stuff/dylib_table.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | /*
24 | * The table of known dynamic library names and addresses they are linked at.
25 | * This is loaded from a -dylib_table option or from the default file:
26 | * ~rc/Data/DylibTable .
27 | */
28 | struct dylib_table {
29 | uint32_t seg1addr;
30 | char *name;
31 | };
32 |
33 | extern struct dylib_table * parse_dylib_table(
34 | char *file_name,
35 | char *flag,
36 | char *argument);
37 |
38 | extern struct dylib_table * parse_default_dylib_table(
39 | char **file_name);
40 |
41 | extern struct dylib_table *search_dylib_table(
42 | struct dylib_table *dylib_table,
43 | char *name);
44 |
45 | extern char * guess_dylib_install_name(
46 | char *name);
47 |
--------------------------------------------------------------------------------
/include/stuff/execute.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | #if defined(__MWERKS__) && !defined(__private_extern__)
24 | #define __private_extern__ __declspec(private_extern)
25 | #endif
26 |
27 | /*
28 | * execute() does an execvp using the argv passed to it. If the parameter
29 | * verbose is non-zero the command is printed to stderr. A non-zero return
30 | * value indicates success zero indicates failure.
31 | */
32 | __private_extern__ int execute(
33 | char **argv,
34 | int verbose);
35 |
36 | __private_extern__ void add_execute_list(
37 | char *str);
38 |
39 | __private_extern__ void add_execute_list_with_prefix(
40 | char *str);
41 |
42 | __private_extern__ char * cmd_with_prefix(
43 | char *str);
44 |
45 | __private_extern__ void reset_execute_list(
46 | void);
47 |
48 | __private_extern__ int execute_list(
49 | int verbose);
50 |
--------------------------------------------------------------------------------
/include/stuff/guess_short_name.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | #include "stuff/bool.h"
24 |
25 | __private_extern__ char * guess_short_name(
26 | char *name,
27 | enum bool *is_framework,
28 | char **return_suffix);
29 |
--------------------------------------------------------------------------------
/include/stuff/hash_string.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | #if defined(__MWERKS__) && !defined(__private_extern__)
24 | #define __private_extern__ __declspec(private_extern)
25 | #endif
26 |
27 | __private_extern__ int32_t hash_string(
28 | char *key);
29 |
--------------------------------------------------------------------------------
/include/stuff/llvm.h:
--------------------------------------------------------------------------------
1 | #ifndef _STUFF_LLVM_H_
2 | #define _STUFF_LLVM_H_
3 |
4 | #include "llvm-c/Disassembler.h"
5 |
6 | void* llvm_load(void);
7 |
8 | __private_extern__ LLVMDisasmContextRef llvm_create_disasm(
9 | const char *TripleName,
10 | const char *CPU,
11 | void *DisInfo,
12 | int TagType,
13 | LLVMOpInfoCallback GetOpInfo,
14 | LLVMSymbolLookupCallback SymbolLookUp);
15 |
16 | __private_extern__ void llvm_disasm_dispose(
17 | LLVMDisasmContextRef DC);
18 |
19 | __private_extern__ size_t llvm_disasm_instruction(
20 | LLVMDisasmContextRef DC,
21 | uint8_t *Bytes,
22 | uint64_t BytesSize,
23 | uint64_t Pc,
24 | char *OutString,
25 | size_t OutStringSize);
26 |
27 | __private_extern__ int llvm_disasm_set_options(
28 | LLVMDisasmContextRef DC,
29 | uint64_t Options);
30 |
31 | __private_extern__ const char *llvm_disasm_version_string(
32 | void);
33 |
34 | __private_extern__ int llvm_disasm_new_getopinfo_abi(
35 | void);
36 |
37 | #endif /* _STUFF_LLVM_H_ */
38 |
--------------------------------------------------------------------------------
/include/stuff/lto.h:
--------------------------------------------------------------------------------
1 | #ifndef _STUFF_LTO_H_
2 | #define _STUFF_LTO_H_
3 |
4 | #include "stuff/arch.h"
5 |
6 | #ifdef LTO_SUPPORT
7 |
8 | __private_extern__ int is_llvm_bitcode_from_memory(
9 | char *addr,
10 | uint32_t size,
11 | struct arch_flag *arch_flag,
12 | void **mod); /* maybe NULL */
13 |
14 | __private_extern__ uint32_t lto_get_nsyms(
15 | void *mod);
16 |
17 | __private_extern__ int lto_toc_symbol(
18 | void *mod,
19 | uint32_t symbol_index,
20 | int commons_in_toc);
21 |
22 | __private_extern__ void lto_get_nlist_64(
23 | struct nlist_64 *nl,
24 | void *mod,
25 | uint32_t symbol_index);
26 |
27 | __private_extern__ const char * lto_symbol_name(
28 | void *mod,
29 | uint32_t symbol_index);
30 |
31 | __private_extern__ void lto_free(
32 | void *mod);
33 |
34 | #endif /* LTO_SUPPORT */
35 |
36 | #endif /* _STUFF_LTO_H_ */
37 |
--------------------------------------------------------------------------------
/include/stuff/macosx_deployment_target.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | #include
24 |
25 | struct macosx_deployment_target {
26 | uint32_t major; /* major version */
27 | uint32_t minor; /* minor version (if any or zero) */
28 | char *name; /* name for printing */
29 | };
30 |
31 | __private_extern__ void get_macosx_deployment_target(
32 | struct macosx_deployment_target *value);
33 |
34 | __private_extern__ void put_macosx_deployment_target(
35 | char *target);
36 |
--------------------------------------------------------------------------------
/include/stuff/print.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | #if defined(__MWERKS__) && !defined(__private_extern__)
24 | #define __private_extern__ __declspec(private_extern)
25 | #endif
26 |
27 | #import
28 |
29 | __private_extern__ void print(
30 | const char *format, ...)
31 | #ifdef __GNUC__
32 | __attribute__ ((format (printf, 1, 2)))
33 | #endif
34 | ;
35 | __private_extern__ void vprint(
36 | const char *format, va_list ap)
37 | __attribute__((format(printf, 1, 0)));
38 |
--------------------------------------------------------------------------------
/include/stuff/reloc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | #if defined(__MWERKS__) && !defined(__private_extern__)
24 | #define __private_extern__ __declspec(private_extern)
25 | #endif
26 |
27 | #import
28 | #import "stuff/bool.h"
29 |
30 | __private_extern__ uint32_t reloc_pair_r_type(
31 | cpu_type_t cputype);
32 | __private_extern__ enum bool reloc_has_pair(
33 | cpu_type_t cputype,
34 | uint32_t r_type);
35 | __private_extern__ enum bool reloc_is_sectdiff(
36 | cpu_type_t cputype,
37 | uint32_t r_type);
38 |
--------------------------------------------------------------------------------
/include/stuff/symbol.h:
--------------------------------------------------------------------------------
1 | #ifndef _STUFF_SYMBOL_H_
2 | #define _STUFF_SYMBOL_H_
3 |
4 | #include
5 |
6 | struct symbol {
7 | char *name;
8 | char *indr_name;
9 | uint64_t n_value;
10 | int is_thumb;
11 | };
12 |
13 | #endif /* _STUFF_SYMBOL_H_ */
14 |
--------------------------------------------------------------------------------
/include/stuff/symbol_list.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | #include
24 | #include
25 |
26 | /*
27 | * Data structures to perform selective stripping of symbol table entries.
28 | */
29 | struct symbol_list {
30 | char *name; /* name of the global symbol */
31 | void *sym; /* pointer to the nlist structure for this symbol */
32 | enum bool seen; /* set if the symbol is seen in the input file */
33 | };
34 |
35 | __private_extern__ void setup_symbol_list(
36 | char *file,
37 | struct symbol_list **list,
38 | uint32_t *size);
39 |
40 | __private_extern__ int symbol_list_bsearch(
41 | const char *name,
42 | const struct symbol_list *sym);
43 |
--------------------------------------------------------------------------------
/include/stuff/unix_standard_mode.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | #include "stuff/bool.h"
24 |
25 | __private_extern__ enum bool get_unix_standard_mode(
26 | void);
27 |
--------------------------------------------------------------------------------
/include/stuff/version_number.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | __private_extern__ enum bool get_version_number(
24 | const char *flag,
25 | const char *argument,
26 | uint32_t *value);
27 |
--------------------------------------------------------------------------------
/include/stuff/vm_flush_cache.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | #if defined(__MWERKS__) && !defined(__private_extern__)
24 | #define __private_extern__ __declspec(private_extern)
25 | #endif
26 |
27 | #import
28 | __private_extern__ kern_return_t vm_flush_cache(
29 | mach_port_t target_task,
30 | vm_address_t address,
31 | vm_size_t size);
32 |
--------------------------------------------------------------------------------
/include/stuff/write64.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 |
24 | #include
25 |
26 | /*
27 | * This is a drop-in write(2) replacement that does the right thing when trying
28 | * to write out 31-bits or more of data. While the write(2) system call has
29 | * 64-bit wide arguments, it only honors 31 bits for historical reasons.
30 | * This restriction does not appear to be unique to Darwin.
31 | */
32 | ssize_t write64(int fildes, const void *buf, size_t nbyte);
33 |
--------------------------------------------------------------------------------
/include/stuff/xcode.h:
--------------------------------------------------------------------------------
1 | //
2 | // xcode.h
3 | // cctools
4 | //
5 | // Created by Michael Trent on 4/24/20.
6 | //
7 |
8 | const char* xcode_developer_path(void);
9 |
--------------------------------------------------------------------------------
/ld/arm_reloc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | #if defined(__MWERKS__) && !defined(__private_extern__)
24 | #define __private_extern__ __declspec(private_extern)
25 | #endif
26 |
27 | /*
28 | * Global types, variables and routines declared in the file arm_reloc.c.
29 | *
30 | * The following include file need to be included before this file:
31 | * #include
32 | * #include "section.h"
33 | */
34 | __private_extern__ void arm_reloc(
35 | char *contents,
36 | struct relocation_info *relocs,
37 | struct section_map *section_map,
38 | struct live_refs *refs,
39 | unsigned long reloc_index);
40 |
--------------------------------------------------------------------------------
/ld/coalesced_sections.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | #if defined(__MWERKS__) && !defined(__private_extern__)
24 | #define __private_extern__ __declspec(private_extern)
25 | #endif
26 |
27 | __private_extern__ void coalesced_section_merge(
28 | void *data,
29 | struct merged_section *ms,
30 | struct section *s,
31 | struct section_map *section_map,
32 | enum bool redo_live);
33 |
34 | __private_extern__ void coalesced_section_order(
35 | void *data,
36 | struct merged_section *ms);
37 |
38 | __private_extern__ void coalesced_section_reset_live(
39 | void *data,
40 | struct merged_section *ms);
41 |
--------------------------------------------------------------------------------
/ld/hash_string.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | /*
24 | * hash_string() compute a hash code for the specified null terminated string.
25 | * The caller can then mod it with the size of the hash table.
26 | */
27 | static
28 | inline
29 | unsigned long
30 | hash_string(
31 | char *key,
32 | unsigned long *len)
33 | {
34 | char *cp;
35 | long k;
36 |
37 | cp = key;
38 | k = 0;
39 | while(*cp)
40 | k = (((k << 1) + (k >> 14)) ^ (*cp++)) & 0x3fff;
41 | if(len != NULL)
42 | *len = cp - key;
43 | return(k);
44 | }
45 |
--------------------------------------------------------------------------------
/ld/hppa_reloc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | #if defined(__MWERKS__) && !defined(__private_extern__)
24 | #define __private_extern__ __declspec(private_extern)
25 | #endif
26 |
27 | /*
28 | * Global types, variables and routines declared in the file hppa_reloc.c.
29 | *
30 | * The following include file need to be included before this file:
31 | * #include
32 | * #include "section.h"
33 | */
34 | __private_extern__ void hppa_reloc(
35 | char *contents,
36 | struct relocation_info *relocs,
37 | struct section_map *map);
38 |
--------------------------------------------------------------------------------
/ld/i860_reloc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | #if defined(__MWERKS__) && !defined(__private_extern__)
24 | #define __private_extern__ __declspec(private_extern)
25 | #endif
26 |
27 | /*
28 | * Global types, variables and routines declared in the file i860_reloc.c.
29 | *
30 | * The following include file need to be included before this file:
31 | * #include
32 | * #include "section.h"
33 | */
34 | __private_extern__ void i860_reloc(
35 | char *contents,
36 | struct relocation_info *relocs,
37 | struct section_map *map);
38 |
--------------------------------------------------------------------------------
/ld/librld.ofileList:
--------------------------------------------------------------------------------
1 | librld.o
2 |
--------------------------------------------------------------------------------
/ld/m88k_reloc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | #if defined(__MWERKS__) && !defined(__private_extern__)
24 | #define __private_extern__ __declspec(private_extern)
25 | #endif
26 |
27 | /*
28 | * Global types, variables and routines declared in the file m88k_reloc.c.
29 | *
30 | * The following include file need to be included before this file:
31 | * #include
32 | * #include "section.h"
33 | */
34 | __private_extern__ void m88k_reloc(
35 | char *contents,
36 | struct relocation_info *relocs,
37 | struct section_map *map);
38 |
--------------------------------------------------------------------------------
/ld/ppc_reloc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | #if defined(__MWERKS__) && !defined(__private_extern__)
24 | #define __private_extern__ __declspec(private_extern)
25 | #endif
26 |
27 | /*
28 | * Global types, variables and routines declared in the file ppc_reloc.c.
29 | *
30 | * The following include file need to be included before this file:
31 | * #include
32 | * #include "section.h"
33 | */
34 | __private_extern__ void ppc_reloc(
35 | char *contents,
36 | struct relocation_info *relocs,
37 | struct section_map *section_map,
38 | struct live_refs *refs,
39 | unsigned long reloc_index);
40 |
--------------------------------------------------------------------------------
/ld/sparc_reloc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | #if defined(__MWERKS__) && !defined(__private_extern__)
24 | #define __private_extern__ __declspec(private_extern)
25 | #endif
26 |
27 | /*
28 | * Global types, variables and routines declared in the file sparc_reloc.c.
29 | *
30 | * The following include file need to be included before this file:
31 | * #include
32 | * #include "section.h"
33 | */
34 | __private_extern__ void sparc_reloc(
35 | char *contents,
36 | struct relocation_info *relocs,
37 | struct section_map *map);
38 |
39 |
--------------------------------------------------------------------------------
/ld/uuid.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | #if defined(__MWERKS__) && !defined(__private_extern__)
24 | #define __private_extern__ __declspec(private_extern)
25 | #endif
26 |
27 | #include
28 | #include
29 | #if !(defined(KLD) && defined(__STATIC__))
30 | #include
31 | #else
32 | #include
33 | #endif /* !(defined(KLD) && defined(__STATIC__)) */
34 |
35 | /*
36 | * uuid() is called to set the uuid[] bytes for the uuid load command.
37 | */
38 | __private_extern__
39 | void
40 | uuid(
41 | uint8_t *uuid)
42 | {
43 | #if defined(KLD) && defined(__STATIC__)
44 | memset(uuid, '\0', sizeof(struct uuid_command));
45 | #else
46 | uuid_generate_random((void *)uuid);
47 | #endif
48 | }
49 |
--------------------------------------------------------------------------------
/ld/uuid.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 |
24 | /*
25 | * uuid() is called to set the uuid[] bytes for the uuid load command.
26 | */
27 | __private_extern__ void uuid(
28 | uint8_t *uuid);
29 |
--------------------------------------------------------------------------------
/libmacho/dylib.ofileList:
--------------------------------------------------------------------------------
1 | arch.o
2 | getsecbyname.o
3 | getsegbyname.o
4 | get_end.o
5 | swap.o
6 | i386_swap.o
7 | m68k_swap.o
8 | sparc_swap.o
9 | ppc_swap.o
10 |
--------------------------------------------------------------------------------
/libmacho/shlib.ofileList:
--------------------------------------------------------------------------------
1 | arch.o
2 | getmachhead.o
3 | getsecbyname.o
4 | getsegbyname.o
5 | get_end.o
6 | swap.o
7 |
--------------------------------------------------------------------------------
/libstuff/apple_version.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2020 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | /*
24 | * apple_version.c
25 | * cctools libstuff
26 | *
27 | * Created by Michael Trent on 12/20/18.
28 | */
29 |
30 | #ifndef CURRENT_PROJECT_VERSION
31 | #define CURRENT_PROJECT_VERSION "cctools-localbuild"
32 | #endif /* CURRENT_PROJECT_VERSION */
33 |
34 | const char apple_version[] = "" CURRENT_PROJECT_VERSION;
35 |
--------------------------------------------------------------------------------
/libstuff/arch_usage.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | #ifndef RLD
24 | #include /* first to get rid of pre-comp warning */
25 | #include
26 | #include "stuff/arch.h"
27 | #include "stuff/errors.h"
28 |
29 | /*
30 | * arch_usage() is called when an unknown architecture flag is encountered.
31 | * It prints the currently know architecture flags on stderr.
32 | */
33 | __private_extern__
34 | void
35 | arch_usage(void)
36 | {
37 | unsigned long i;
38 | const struct arch_flag *arch_flags;
39 |
40 | arch_flags = get_arch_flags();
41 | fprintf(stderr, "%s: known architecture flags are:", progname);
42 | for(i = 0; arch_flags[i].name != NULL; i++){
43 | fprintf(stderr, " %s", arch_flags[i].name);
44 | }
45 | fprintf(stderr, "\n");
46 | }
47 | #endif /* !defined(RLD) */
48 |
--------------------------------------------------------------------------------
/libstuff/hash_string.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | #include
24 | #include "stuff/hash_string.h"
25 | /*
26 | * A hash function used for converting a string into a single number. It is
27 | * then usually mod'ed with the hash table size to get an index into the hash
28 | * table.
29 | */
30 | __private_extern__
31 | int32_t
32 | hash_string(
33 | char *key)
34 | {
35 | char *cp;
36 | int32_t k;
37 |
38 | cp = key;
39 | k = 0;
40 | while(*cp)
41 | k = (((k << 1) + (k >> 14)) ^ (*cp++)) & 0x3fff;
42 | return(k);
43 | }
44 |
--------------------------------------------------------------------------------
/libstuff/print.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
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
11 | * file.
12 | *
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.
20 | *
21 | * @APPLE_LICENSE_HEADER_END@
22 | */
23 | #ifndef RLD
24 | #include
25 | #include
26 | #include "stuff/print.h"
27 |
28 | /*
29 | * All printing of all messages for ofile functions goes through this function.
30 | * It is broken out here so it can be overridden for some uses.
31 | */
32 | __private_extern__
33 | void
34 | vprint(
35 | const char *format,
36 | va_list ap)
37 | {
38 | vfprintf(stderr, format, ap);
39 | }
40 |
41 | /*
42 | * The print function that just calls the above vprint() function.
43 | */
44 | __private_extern__
45 | void
46 | print(
47 | const char *format,
48 | ...)
49 | {
50 | va_list ap;
51 |
52 | va_start(ap, format);
53 | vprint(format, ap);
54 | va_end(ap);
55 | }
56 | #endif /* !defined(RLD) */
57 |
--------------------------------------------------------------------------------
/libstuff/xcode.c:
--------------------------------------------------------------------------------
1 | //
2 | // xcode.c
3 | // stuff
4 | //
5 | // Created by Michael Trent on 4/24/20.
6 | //
7 |
8 | #include "stuff/write64.h"
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 |
16 | const char* xcode_developer_path(void)
17 | {
18 | static const char* xc_dev_path;
19 |
20 | if (!xc_dev_path) {
21 | void* handle = dlopen("/usr/lib/libxcselect.dylib", RTLD_NOW);
22 | if (handle) {
23 | bool (*xc_get_path)(char *buffer, int buffer_size,
24 | bool *was_environment, bool *was_cltools,
25 | bool *was_default);
26 | xc_get_path = dlsym(handle, "xcselect_get_developer_dir_path");
27 | if (xc_get_path) {
28 | char path[MAXPATHLEN];
29 | bool ignore;
30 | if (xc_get_path(path, MAXPATHLEN, &ignore, &ignore, &ignore)) {
31 | xc_dev_path = (const char*)strdup(path);
32 | }
33 | }
34 | }
35 | }
36 |
37 | return xc_dev_path;
38 | }
39 |
--------------------------------------------------------------------------------
/libstuff_test/get_arch_from_host_test.c:
--------------------------------------------------------------------------------
1 | //
2 | // get_arch_from_host_test.c
3 | // libstuff_test
4 | //
5 | // Created by Michael Trent on 1/21/19.
6 | //
7 |
8 | #include "test_main.h"
9 |
10 | #include "stuff/arch.h"
11 |
12 | static void test_get_arch_from_host(void)
13 | {
14 | struct arch_flag family;
15 | struct arch_flag specific;
16 |
17 | // it's difficult to test the active host without knowing what it is.
18 | int res = get_arch_from_host(&family, &specific);
19 | check_nonzero("get_arch_from_host result", res);
20 | check_nonzero("family cputype", family.cputype);
21 | check_nonzero("specific cputype", specific.cputype);
22 | }
23 |
24 | static int test_main(void)
25 | {
26 | int err = 0;
27 |
28 | if (!err) err = test_add("test get_arch_from_host", test_get_arch_from_host);
29 |
30 | return err;
31 | }
32 |
--------------------------------------------------------------------------------
/libstuff_test/libstuff_test.c:
--------------------------------------------------------------------------------
1 | //
2 | // main.cpp
3 | // libstuff_test
4 | //
5 | // Created by Michael Trent on 1/19/19.
6 | //
7 |
8 | #include "test.h"
9 |
10 | #include "stuff/errors.h"
11 |
12 | /* used by error routines as the name of this program */
13 | char *progname = NULL;
14 |
15 | int main(int argc, const char * argv[])
16 | {
17 | progname = (char*)argv[0];
18 |
19 | // run the tests
20 | return test_run();
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/libstuff_test/null_test.c:
--------------------------------------------------------------------------------
1 | //
2 | // null_test.cpp
3 | // libstuff_test
4 | //
5 | // Created by Michael Trent on 1/19/19.
6 | //
7 |
8 | #include "test_main.h"
9 |
10 | static void test_null(void)
11 | {
12 | ;
13 | }
14 |
15 | int test_main(void)
16 | {
17 | return test_add("test harness initialization", test_null);
18 | }
19 |
--------------------------------------------------------------------------------
/libstuff_test/test_main.h:
--------------------------------------------------------------------------------
1 | //
2 | // test_main.h
3 | // cctools
4 | //
5 | // Created by Michael Trent on 5/25/19.
6 | //
7 | // When creating a new test, include this header, call the TEST_INTIALIZE
8 | // macro, then define a function test_main() like so:
9 | //
10 | // static int test_main(void)
11 | // {
12 | // int err = 0;
13 | // if (!err) err = test_add("some test", test_some_test);
14 | // return err;
15 | // }
16 | //
17 | // individal tests take and return void, and call check_* or test_* functions
18 | // to report failure status.
19 |
20 | #ifndef test_case_h
21 | #define test_case_h
22 |
23 | #ifdef __cplusplus
24 | extern "C" {
25 | #endif
26 |
27 | #include "test.h"
28 |
29 | #define TEST_INITIALIZE \
30 | static int test_main(void);\
31 | __attribute__((constructor)) static void init(void)\
32 | {\
33 | test_register_initializer(0, test_main);\
34 | }\
35 |
36 | TEST_INITIALIZE
37 |
38 | #ifdef __cplusplus
39 | }
40 | #endif
41 |
42 | #endif /* test_case_h */
43 |
--------------------------------------------------------------------------------
/libstuff_test/test_util.c:
--------------------------------------------------------------------------------
1 | //
2 | // test_util.c
3 | // libstuff_test
4 | //
5 | // Created by Michael Trent on 5/31/19.
6 | //
7 |
8 | #include "test_util.h"
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 |
16 | int test_write_tmp_data(const void* data, size_t size, char** name_p)
17 | {
18 | if (!data || !name_p) {
19 | errno = EINVAL;
20 | return -1;
21 | }
22 |
23 | char* name = strdup("/tmp/libstuff_test.XXXXXX");
24 | int fd = mkstemp(name);
25 | if (-1 == fd) {
26 | fprintf(stderr, "error: cannot make temporary file: %s\n",
27 | strerror(errno));
28 | free(name);
29 | return -1;
30 | }
31 |
32 | const unsigned char* uchars = (const unsigned char*)data;
33 | while (size) {
34 | const size_t limit = 0x7FFFFFFF;
35 | size_t towrite = size < limit ? size : limit;
36 | ssize_t wrote = write(fd, uchars, towrite);
37 | if (-1 == wrote) {
38 | fprintf(stderr, "error: cannot write to file %s: %s\n", name,
39 | strerror(errno));
40 | free(name);
41 | return -1;
42 | }
43 | else if (0 == wrote) {
44 | break;
45 | }
46 | else {
47 | size -= wrote;
48 | uchars += wrote;
49 | }
50 | }
51 |
52 | *name_p = name;
53 | return 0;
54 | }
55 |
--------------------------------------------------------------------------------
/libstuff_test/test_util.h:
--------------------------------------------------------------------------------
1 | //
2 | // test_util.h
3 | // libstuff_test
4 | //
5 | // Created by Michael Trent on 5/31/19.
6 | //
7 |
8 | #ifndef test_util_h
9 | #define test_util_h
10 |
11 | #include
12 |
13 | // test_write_tmp_data
14 | // write data of size to a file in /tmp. The path to the file will be returned
15 | // in *name, which will need to be deallocated via free(). Returns 0 on success
16 | // or -1 on error.
17 | int test_write_tmp_data(const void* data, size_t size, char** name);
18 |
19 | #endif /* test_util_h */
20 |
--------------------------------------------------------------------------------
/man/NSObjectFileImage_priv.3:
--------------------------------------------------------------------------------
1 | .TH NSObjectFileImage 3 "July 9, 2003" "Apple Computer, Inc."
2 | .SH NAME
3 | NSObjectFileImage_priv \- programmatic interface for working with Mach-O files
4 | .SH SYNOPSIS
5 | .nf
6 | .PP
7 | #include
8 | .sp .5
9 | extern enum DYLD_BOOL
10 | NSFindSectionAndOffsetInObjectFileImage(
11 | NSObjectFileImage objectFileImage,
12 | unsigned long imageOffset,
13 | const char** segmentName, /* can be NULL */
14 | const char** sectionName, /* can be NULL */
15 | unsigned long* sectionOffset) /* can be NULL */
16 | .sp .5
17 | extern enum DYLD_BOOL
18 | NSHasModInitObjectFileImage(
19 | NSObjectFileImage objectFileImage);
20 | .fi
21 | .SH DESCRIPTION
22 | .PP
23 | These routines are the programmatic interface for working with Mach-O files.
24 | They bring the Mach-O file into memory and the API allows the file to
25 | be inspected or loaded into the program. On creation of an object file image
26 | it is checked to insure it is a valid format and it is compatible with the host
27 | machine's cpu architecture.
28 | .PP
29 | .PP
30 | .I NSFindSectionAndOffsetInObjectFileImage
31 | is supplied an imageOffset into an ObjectFileImage and returns
32 | via parameters the segment/section name and offset into that section of
33 | that imageOffset. It returns FALSE if the imageOffset is not
34 | in any section, otherwise TRUE. You can used the resulting sectionOffset to
35 | index into the data returned by NSGetSectionDataInObjectFileImage.
36 | .PP
37 | .I NSHasModInitObjectFileImage
38 | returns TRUE if the NSObjectFileImage has any module initialization routines
39 | and FALSE otherwise.
40 |
41 | .SH ALSO SEE
42 | NSObjectFileImage(3), NSModule(3), dyld(3)
43 |
--------------------------------------------------------------------------------
/man/a.out.5:
--------------------------------------------------------------------------------
1 | .so man5/Mach-O.5
2 |
--------------------------------------------------------------------------------
/man/as.1:
--------------------------------------------------------------------------------
1 | .TH AS 1 "August 23, 2023" "Apple Inc."
2 | .SH NAME
3 | as \- assembler
4 | .SH SYNOPSIS
5 | .B as
6 | [
7 | .I "option \&..."
8 | ] [
9 | .I "file \&..."
10 | ]
11 | .SH DESCRIPTION
12 | The
13 | .I as
14 | command is deprecated. It is now calls clang to use clang's "intergated assembler".
15 | .PP
16 | Clang will automatically run its assembler on files with a .s extension.
17 | So you can replace: "as -arch arm64 foo.s -o foo.o" with "clang -arch arm64 foo.s -o foo.o"
18 | .SH "SEE ALSO"
19 | cc(1), ld(1), nm(1), otool(1), arch(3), Mach-O(5)
20 |
--------------------------------------------------------------------------------
/man/bitcode_strip.1:
--------------------------------------------------------------------------------
1 | .TH BITCODE_STRIP 1 "June 23, 2020" "Apple, Inc."
2 | .SH NAME
3 | bitcode_strip \- remove or leave the bitcode segment in a Mach-O file
4 | .SH SYNOPSIS
5 | .B bitcode_strip
6 | .I input
7 | [
8 | .B \-r
9 | |
10 | .B \-m
11 | |
12 | .B \-l
13 | ] [
14 | .B \-v
15 | ] [
16 | .B \-keep_cs
17 | ]
18 | .BI \-o " output"
19 | .SH DESCRIPTION
20 | .I bitcode_strip
21 | strips Mach-O files and Universal files containing LLVM bitcode, either by
22 | removing the bitcode or by removing the native executable code. If the Mach-O
23 | file or architecture in an Universal file does not have a bitcode segment it
24 | is left essentially unchanged. By default
25 | .B bitcode_strip
26 | will remove the code signature load commands from the output file as the
27 | code signature is no longer valid.
28 | .SH OPTIONS
29 | .TP
30 | .B \-r
31 | Remove the __LLVM bitcode segment entirely.
32 | .TP
33 | .B \-m
34 | Remove the bitcode from the __LLVM segment, leaving behind a marker.
35 | .TP
36 | .B \-l
37 | Remove all of the native executable code, leaving the LLVM bitcode behind. In
38 | this case,
39 | .B bitcode_strip
40 | will take care to preserve the (__TEXT,__info_plist) section while removing the
41 | rest of the __TEXT segment.
42 | .TP
43 | .B \-v
44 | Print the arguments passed to other tools run by
45 | .B bitcode_strip
46 | when processing bitcode files.
47 | .TP
48 | .B \-keep_cs
49 | Preserve the codesign load commands in the output binary, even though the code
50 | signature is no longer valid. This can be useful when using
51 | .BR codesign (1)
52 | .B \-preserve-metadata
53 | to resign the binary.
54 | .TP
55 | .BI \-o " output"
56 | specifies the output file as
57 | .I output.
58 | .TP
59 | .BI input
60 | specifies the input Mach-O or Universal file to operate on.
61 | .SH "SEE ALSO"
62 | .BR codesign (1),
63 | .BR otool (1).
64 |
--------------------------------------------------------------------------------
/man/check_dylib.1:
--------------------------------------------------------------------------------
1 | .TH CHECK_DYLIB l "September 10, 2001" "Apple Computer, Inc."
2 | .SH NAME
3 | check_dylib \- perform checks on a dynamic library file
4 | .SH SYNOPSIS
5 | .B check_dylib
6 | filename \-install_name
7 | .I install_name
8 | \-seg_addr_table
9 | .I seg_addr_table
10 | \-seg_addr_table_filename
11 | .I path_name
12 | .sp .5
13 | .SH DESCRIPTION
14 | .I Check_dylib
15 | is a tool used by Apple's Build and Integration team to perform checks on a
16 | Mach-O dynamic library as part of the build process. The checks are performed
17 | and
18 | .IR check_dylib (l)
19 | returns the status of the checks as exit values.
20 | .PP
21 | The checks are performed in the following order:
22 | .PP
23 | If the install name of the dynamic library does not start with @executable_path
24 | check the install name of the dynamic library file against the specified
25 | .B \-install_name
26 | argument and if it does not match it exit with a value of 2.
27 | .PP
28 | Check the segment address table specified by
29 | .B \-seg_addr_table
30 | for an entry with the
31 | .I path_name
32 | argument of the
33 | .B \-seg_addr_table_filename
34 | and if one is not found in the table exit with a value of 3.
35 | .PP
36 | Check the dynamic library file's address against the address in the matching
37 | entry in the segment address table specified by
38 | .B \-seg_addr_table
39 | and
40 | .B \-seg_addr_table_filename
41 | and if it does not match exit with a value of 4.
42 | .PP
43 | Check the address of the dynamic library and if it is zero exit with a value
44 | of 5.
45 | .PP
46 | If there is any other errors
47 | .IR check_dylib (l)
48 | exits with a value of 1. If no checks fail then
49 | .IR check_dylib (l)
50 | exits with a value of 0.
51 | .SH "SEE ALSO"
52 | seg_addr_table(l), doug(0)
53 |
--------------------------------------------------------------------------------
/man/codesign_allocate.1:
--------------------------------------------------------------------------------
1 | .TH CODESIGN_ALLOCATE 1 "April 17, 2017" "Apple, Inc."
2 | .SH NAME
3 | codesign_allocate \- add code signing data to a Mach-O file
4 | .SH SYNOPSIS
5 | .B codesign_allocate
6 | \-i oldfile [ \-a arch size ]... [ \-A cputype cpusubtype size ]... \-o newfile
7 | .SH DESCRIPTION
8 | .I codesign_allocate
9 | sets up a Mach-O file used by the dynamic linker so space for code signing data
10 | of the specified size for the specified architecture is embedded in the Mach-O
11 | file. The program must be passed one \-a argument or one \-A argument for each
12 | architecture in a universal file, or exactly one \-a or \-A for a thin file.
13 | .TP
14 | .BI \-i " oldfile"
15 | specifies the input file as
16 | .I oldfile.
17 | .TP
18 | .BI \-o " newfile"
19 | specifies the output file as
20 | .I newfile.
21 | .TP
22 | .BI \-a " arch size"
23 | specifies for the architecture
24 | .I arch
25 | that the size of the code signing data is to be
26 | .I size.
27 | The value of
28 | .I size
29 | must be a multiple of 16.
30 | .TP
31 | .BI \-A " cputype cpusubtype size"
32 | specifies for the architecture as a pair of decimal integers for the cputype and
33 | cpusubtype that the size of the code signing data is to be
34 | .I size.
35 | The value of
36 | .I size
37 | must be a multiple of 16.
38 | .TP
39 | .BI \-r
40 | remove the code signature data and the LC_CODE_SIGNATURE load command. This
41 | is the same as specifiying the
42 | .B -a
43 | or
44 | .B -A
45 | option with a
46 | .I size
47 | of zero.
48 | .TP
49 | .BI \-p
50 | page align the code signature data by padding string table and changing its
51 | size. This is not the default as
52 | .IR codesign (1)
53 | currently can't use this option.
54 |
--------------------------------------------------------------------------------
/man/ctf_insert.1:
--------------------------------------------------------------------------------
1 | .TH CTF_INSERT 1 "June 23, 2020" "Apple, Inc."
2 | .SH NAME
3 | ctf_insert \- insert Compact C Type Format data into a mach_kernel file
4 | .SH SYNOPSIS
5 | .B ctf_insert
6 | input [ \-arch arch file ]... \-o output
7 | .SH DESCRIPTION
8 | .I ctf_insert
9 | inserts CTF (Compact C Type Format) data into a mach_kernel binary, storing the
10 | data in a newly created (__CTF,__ctf) section. This section must not be
11 | present in the input file.
12 | .IR ctf_insert (1)
13 | must be passed one
14 | .B \-arch
15 | argument for each architecture in a universal file, or
16 | exactly one
17 | .B \-arch
18 | for a thin file.
19 | .TP
20 | .BI input
21 | specifies the input mach_kernel.
22 | .TP
23 | .BI \-o " output"
24 | specifies the output file.
25 | .TP
26 | .BI \-arch " arch file"
27 | specifies a file of CTF data to be used for the specified
28 | .I arch
29 | in a Mach-O or universal file. The file's content will be stored in a newly
30 | created (__CTF,__ctf) section.
31 | .SH "SEE ALSO"
32 | .BR otool (1),
33 | .BR segedit (1).
34 |
--------------------------------------------------------------------------------
/man/end.3:
--------------------------------------------------------------------------------
1 | .so man3/get_end.3
2 |
--------------------------------------------------------------------------------
/man/getsectbynamefromheader.3:
--------------------------------------------------------------------------------
1 | .so man3/getsectbyname.3
2 |
--------------------------------------------------------------------------------
/man/getsectdata.3:
--------------------------------------------------------------------------------
1 | .so man3/getsectbyname.3
2 |
--------------------------------------------------------------------------------
/man/getsectdatafromheader.3:
--------------------------------------------------------------------------------
1 | .so man3/getsectbyname.3
2 |
--------------------------------------------------------------------------------
/man/getsegbyname.3:
--------------------------------------------------------------------------------
1 | .TH GETSEGBYNAME 3 "October 3, 2008" "Apple, Inc."
2 | .SH NAME
3 | getsegbyname \- get the segment command for the named segment
4 | .SH SYNOPSIS
5 | .nf
6 | \fB#include \fR
7 | .PP
8 | const struct segment_command *\fBgetsegbyname\fR(const char *\fIsegname\fR);
9 | .fi
10 | .SH DESCRIPTION
11 | This routine returns the segment_command structure for the named segment if it
12 | exists in the Mach-O (Mach object) executable
13 | .IR getsegbyname (3)
14 | is linked into. Otherwise
15 | .IR getsegbyname (3)
16 | returns
17 | .SM NULL.
18 | It uses the link editor defined symbol _mh_execute_header and
19 | just looks through the load commands. Since these are mapped into the
20 | .SM \_\|\_TEXT
21 | segment they are read-only and thus
22 | .I const
23 | by default.
24 | If this is to be used in executables linked with
25 | .B \-pie
26 | then the value return by the call to
27 | .IR _dyld_get_image_vmaddr_slide (0)
28 | will need to be added to the
29 | .B vmaddr
30 | field of the segment_command struct.
31 | .SH "SEE ALSO"
32 | end(3), getsectbyname(3)
33 |
--------------------------------------------------------------------------------
/man/mtoc.1:
--------------------------------------------------------------------------------
1 | .TH MTOC 1 "July 21, 2017" "Apple, Inc."
2 | .SH NAME
3 | mtoc \- convert a Mach-O file to a PECOFF file
4 | .SH SYNOPSIS
5 | .B mtoc
6 | [ \-subsystem type ] [ \-section_alignment value ] [ \-align value ] [ \-version major.minor ] [ \-d filename ] input output
7 | .SH DESCRIPTION
8 | .I mtoc
9 | converts the
10 | .I input
11 | EFI file built as a Mach-O file into an
12 | .I output
13 | PEFOFF file.
14 | .TP
15 | .BI \-subsystem " type"
16 | specifies the EFI subsystem
17 | .I type
18 | which can be
19 | .IR application ,
20 | .I boot
21 | or
22 | .I runtime.
23 | The default is
24 | .IR application .
25 | .TP
26 | .BI "\-section_alignment" " value"
27 | Specifies the PECOFF section alignment.
28 | .I value
29 | is a hexadecimal number that must be an integral power of 2.
30 | The default is the Mac OS X target pagesize (1000 hex). This value should
31 | match the value used for
32 | .B "\-segalign"
33 | when linking the Mach-O file.
34 | .TP
35 | .BI "\-align" " value"
36 | Specifies the PECOFF file and section alignment.
37 | .I value
38 | is a hexadecimal number that must be an integral power of 2.
39 | The default is 400 hex. This value should match the value used for
40 | .B "\-segalign"
41 | when linking the Mach-O file.
42 | .TP
43 | .BI "\-version" " major.minor"
44 | Specifies the PECOFF
45 | .I major
46 | and
47 | .I minor
48 | versions for the MajorImageVersion and MinorImageVersion fields.
49 | .TP
50 | .BI "\-d " filename"
51 | Specifies the filename to be used to create a debug directory entry with.
52 |
--------------------------------------------------------------------------------
/man/nm-classic.1:
--------------------------------------------------------------------------------
1 | .so man1/nm.1
2 |
--------------------------------------------------------------------------------
/man/otool.1:
--------------------------------------------------------------------------------
1 | .so man1/otool-classic.1
2 |
--------------------------------------------------------------------------------
/man/pagestuff.1:
--------------------------------------------------------------------------------
1 | .TH PAGESTUFF 1 "June 23, 2020" "Apple, Inc."
2 | .SH NAME
3 | pagestuff \- Mach-O file page analysis tool
4 | .SH SYNOPSIS
5 | pagestuff file [-arch arch_flag] [[-a] [-p] | [pagenumber...]]
6 | .SH DESCRIPTION
7 | .B pagestuff
8 | shows how a structure of a Mach-O or universal file corresponds
9 | to logical pages on the current system. Structural information includes
10 | the location and extent of file headers, sections and segments, symbol tables,
11 | code signatures, etc. When displaying a universal file, all architectures will
12 | be shown unless otherwise specified by the
13 | .B \-arch
14 | flag.
15 | .PP
16 | The options to
17 | .BR pagestuff (1)
18 | are:
19 | .TP
20 | .BI \-arch " arch_type"
21 | Specifies the architecture,
22 | .I arch_type,
23 | of the file for
24 | .B pagestuff
25 | to operate on when the file is a universal file. (See
26 | .BR arch (3)
27 | for the currently known
28 | .IR arch_type s.)
29 | When this option is used the logical page numbers start from the beginning of
30 | the architecture file within the universal file.
31 | .TP
32 | .BI \-pagesize " pagesize"
33 | Specifies the page size to use when computing logical page boundaries. By
34 | default
35 | .I pagestuff
36 | will use the page size of the current system.
37 | .TP
38 | .B \-a
39 | Display all pages in the file.
40 | .TP
41 | .B \-p
42 | Print a list of the sections of the specified file, offsets and lengths.
43 | When displaying a universal file, all archs will be displayed unless
44 | Print a list of the sections of the specified Mach-O file, with offsets and
45 | lengths. Note that the
46 | .BR size (1)
47 | tool displays a much more concise listing given the `-l -m -x' arguments.
48 | .SH "SEE ALSO"
49 | .BR size (1) ,
50 | .BR arch (3) ,
51 | .BR Mach-O (5) .
52 |
--------------------------------------------------------------------------------
/man/ranlib.1:
--------------------------------------------------------------------------------
1 | .so man1/libtool.1
2 |
--------------------------------------------------------------------------------
/man/size-classic.1:
--------------------------------------------------------------------------------
1 | .so man1/size.1
2 |
--------------------------------------------------------------------------------
/man/size.1:
--------------------------------------------------------------------------------
1 | .TH SIZE 1 "July 28, 2005" "Apple Computer, Inc."
2 | .SH NAME
3 | size \- print the size of the sections in an object file
4 | .SH SYNOPSIS
5 | .B size
6 | [ option ... ] [ object ... ]
7 | .SH DESCRIPTION
8 | .I Size
9 | (without the
10 | .B \-m
11 | option) prints the (decimal) number of bytes required by the \_\^\_TEXT,
12 | \_\^\_DATA and \_\^\_OBJC segments. All other segments are totaled and
13 | that size is listed in the `others' column. The final two columns is
14 | the sum in decimal and hexadecimal.
15 | If no file is specified,
16 | .B a.out
17 | is used.
18 | .PP
19 | The options to
20 | .IR size (1)
21 | are:
22 | .TP
23 | .B \-
24 | Treat the remaining arguments as name of object files not options to
25 | .IR size (1).
26 | .TP
27 | .B \-m
28 | Print the sizes of the Mach-O segments and sections as well as the total sizes
29 | of the sections in each segment and the total size of the segments in the file.
30 | .TP
31 | .B \-l
32 | When used with the
33 | .B \-m
34 | option, also print the addresses and offsets of the sections and segments.
35 | .TP
36 | .B \-x
37 | When used with the
38 | .B \-m
39 | option,
40 | print the values in hexadecimal (with leading 0x's) rather than decimal.
41 | .TP
42 | .BI \-arch " arch_type"
43 | Specifies the architecture,
44 | .I arch_type,
45 | of the file for
46 | .IR size (1)
47 | to operate on when the file is a universal file. (See
48 | .IR arch (3)
49 | for the currently know
50 | .IR arch_type s.)
51 | The
52 | .I arch_type
53 | can be "all" to operate on all architectures in the file.
54 | The default is to display only the host architecture, if the file contains it;
55 | otherwise, all architectures in the file are shown.
56 | .SH "SEE ALSO"
57 | otool(1)
58 | .SH BUGS
59 | The size of common symbols can't be reflected in any of the numbers for
60 | relocatable object files.
61 |
--------------------------------------------------------------------------------
/misc/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleIdentifier
8 | com.apple.tool.codesign_allocate.standard
9 | CFBundleInfoDictionaryVersion
10 | 6.0
11 | CFBundleName
12 | codesign_allocate
13 | CFBundleVersion
14 | 0.3
15 | Application-Group
16 | com.apple.tool.codesign_allocate
17 |
18 |
19 |
--------------------------------------------------------------------------------
/misc/as:
--------------------------------------------------------------------------------
1 | #!/bin/zsh
2 |
3 | DIR="$(dirname "$(realpath "$0")")"
4 |
5 | # remove -q and -Q args (which clang does not support)
6 | for arg do
7 | shift
8 | [ "$arg" = "-q" ] && continue
9 | [ "$arg" = "-Q" ] && continue
10 | set -- "$@" "$arg"
11 | done
12 |
13 | # use clang driver to run clang's integrated assembler
14 | $DIR/clang -x assembler -c "$@"
15 |
16 |
17 |
--------------------------------------------------------------------------------
/misc/codesign_allocate-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleIdentifier
8 | com.apple.tool.codesign_allocate.standard
9 | CFBundleInfoDictionaryVersion
10 | 6.0
11 | CFBundleName
12 | codesign_allocate
13 | CFBundleVersion
14 | 0.3
15 | Application-Group
16 | com.apple.tool.codesign_allocate
17 |
18 |
19 |
--------------------------------------------------------------------------------
/misc/depinfo.c:
--------------------------------------------------------------------------------
1 | //
2 | // main.c
3 | // depinfo
4 | //
5 | // Created by Michael Trent on 9/10/19.
6 | //
7 |
8 | #include "stuff/depinfo.h"
9 | #include "stuff/errors.h"
10 |
11 | #include
12 | #include
13 |
14 | char* progname;
15 |
16 | void usage(const char * __restrict format, ...)
17 | __attribute__((format(printf, 1, 2)));
18 |
19 | int main(int argc, const char * argv[])
20 | {
21 | progname = (char*)*argv++;
22 | argc--;
23 |
24 | if (argc == 0)
25 | usage(NULL);
26 |
27 | int showPaths = argc > 1;
28 | while (argc > 0)
29 | {
30 | if (showPaths)
31 | printf("%s:\n", *argv);
32 | depinfo_read(*argv, DI_READ_LOG | DI_READ_NORETVAL);
33 | if (errors)
34 | return 1;
35 | argv++;
36 | argc--;
37 | }
38 | return 0;
39 | }
40 |
41 | void usage(const char * __restrict format, ...)
42 | {
43 | const char* basename = strrchr(progname, '/');
44 | if (basename)
45 | basename++;
46 | else
47 | basename = progname;
48 |
49 | va_list args;
50 | va_start(args, format);
51 |
52 | if (format) {
53 | fprintf(stderr, "error: ");
54 | vfprintf(stderr, format, args);;
55 | fprintf(stderr, "\n");
56 | }
57 |
58 | va_end(args);
59 |
60 | fprintf(stderr, "usage: %s ...\n", basename);
61 |
62 | exit(EXIT_FAILURE);
63 | }
64 |
--------------------------------------------------------------------------------
/otool/arm64_disasm.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | #import
4 | #import
5 | #include "stuff/symbol.h"
6 | #include "llvm-c/Disassembler.h"
7 |
8 | extern uint32_t arm64_disassemble(
9 | char *sect,
10 | uint32_t left,
11 | uint64_t addr,
12 | uint64_t sect_addr,
13 | enum byte_sex object_byte_sex,
14 | struct relocation_info *relocs,
15 | uint32_t nrelocs,
16 | struct relocation_info *ext_relocs,
17 | uint32_t next_relocs,
18 | struct relocation_info *loc_relocs,
19 | uint32_t nloc_relocs,
20 | struct dyld_bind_info *dbi,
21 | uint64_t ndbi,
22 | enum chain_format_t chain_format,
23 | struct nlist *symbols,
24 | struct nlist_64 *symbols64,
25 | uint32_t nsymbols,
26 | struct symbol *sorted_symbols,
27 | uint32_t nsorted_symbols,
28 | char *strings,
29 | uint32_t strings_size,
30 | uint32_t *indirect_symbols,
31 | uint32_t nindirect_symbols,
32 | cpu_type_t cputype,
33 | struct load_command *load_commands,
34 | uint32_t ncmds,
35 | uint32_t sizeofcmds,
36 | char *object_addr,
37 | uint64_t object_size,
38 | enum bool verbose,
39 | LLVMDisasmContextRef dc);
40 |
41 | extern LLVMDisasmContextRef create_arm64_llvm_disassembler(
42 | cpu_subtype_t cpusubtype);
43 | extern void delete_arm64_llvm_disassembler(LLVMDisasmContextRef dc);
44 |
--------------------------------------------------------------------------------
/otool/cxa_demangle.h:
--------------------------------------------------------------------------------
1 | extern
2 | char *
3 | __cxa_demangle(
4 | const char* mangled_name,
5 | char *output_buffer,
6 | size_t *length,
7 | int *status);
8 |
--------------------------------------------------------------------------------
/tests/Makefile:
--------------------------------------------------------------------------------
1 | INSTALL_FILES = Makefile bin include run-tests test-cases
2 | EXECUTABLES_FILES = run-tests bin/exit-non-zero-pass.pl \
3 | bin/fail-if-exit-non-zero.pl bin/fail-if-exit-zero.pl \
4 | bin/fail-if-no-stdin.pl bin/fail-if-stdin.pl \
5 | bin/fail-iff-exit-zero.pl bin/pass-iff-exit-non-zero.pl \
6 | bin/pass-iff-exit-zero.pl bin/pass-iff-no-stdin.pl \
7 | bin/pass-iff-stdin.pl bin/verify-align.pl
8 |
9 | MKDIRS = /bin/mkdir -p
10 | SRCROOT = .
11 |
12 | installsrc:
13 | $(MKDIRS) $(SRCROOT)
14 | chmod 755 $(SRCROOT)
15 | gnutar cf - $(INSTALL_FILES) | (cd $(SRCROOT); gnutar xf -)
16 | chmod -R u+rwX,go+rX $(SRCROOT)/*
17 | cd $(SRCROOT); chmod a+x $(EXECUTABLES_FILES)
18 | #cd $(SRCROOT); chmod a-w `find . -type f -print`
19 | find $(SRCROOT) -type f -exec chmod a-w '{}' \;
20 |
--------------------------------------------------------------------------------
/tests/bin/exit-non-zero-pass.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl -w
2 |
3 | #
4 | # Usage:
5 | #
6 | # ${PASS_UNLESS} "test name" command
7 | #
8 |
9 | use strict;
10 |
11 | my $string = shift @ARGV;
12 | my $ret = system(@ARGV);
13 | my $exit_value = $ret >> 8;
14 | my $signal_num = $ret & 127;
15 | my $dumped_core = $ret & 128;
16 | my $crashed = $signal_num + $dumped_core;
17 |
18 | if(0 == $exit_value || 0 != $crashed)
19 | {
20 | printf("FAIL $string\n");
21 | }
22 | else
23 | {
24 | printf("PASS $string\n");
25 | }
26 |
27 | exit 0;
28 |
--------------------------------------------------------------------------------
/tests/bin/fail-if-exit-non-zero.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl -w
2 |
3 | use strict;
4 |
5 | my $test_name = "";
6 | if ( exists $ENV{UNIT_TEST_NAME} ) {
7 | $test_name = $ENV{UNIT_TEST_NAME};
8 | }
9 |
10 | if(system(@ARGV) != 0)
11 | {
12 | printf("FAIL $test_name\n");
13 | exit 1;
14 | }
15 |
16 | exit 0;
17 |
--------------------------------------------------------------------------------
/tests/bin/fail-if-exit-zero.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl -w
2 |
3 | use strict;
4 |
5 | my $test_name = "";
6 | if ( exists $ENV{UNIT_TEST_NAME} ) {
7 | $test_name = $ENV{UNIT_TEST_NAME};
8 | }
9 |
10 | my $ret = system(@ARGV);
11 | my $exit_value = $ret >> 8;
12 | my $signal_num = $ret & 127;
13 | my $dumped_core = $ret & 128;
14 | my $crashed = $signal_num + $dumped_core;
15 |
16 | if(0 == $exit_value || 0 != $crashed)
17 | {
18 | printf("FAIL $test_name\n");
19 | exit 1;
20 | }
21 |
22 | exit 0;
23 |
--------------------------------------------------------------------------------
/tests/bin/fail-if-no-stdin.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl -w
2 |
3 | #
4 | # Usage:
5 | #
6 | # command | ${FAIL_IF_EMPTY}
7 | #
8 |
9 | use strict;
10 |
11 | my $test_name = "";
12 | if ( exists $ENV{UNIT_TEST_NAME} ) {
13 | $test_name = $ENV{UNIT_TEST_NAME};
14 | }
15 |
16 | if( eof STDIN )
17 | {
18 | printf("FAIL $test_name\n");
19 | exit 1;
20 | }
21 |
22 | exit 0;
23 |
--------------------------------------------------------------------------------
/tests/bin/fail-if-stdin.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl -w
2 |
3 | #
4 | # Usage:
5 | #
6 | # command | ${FAIL_IF_STDIN}
7 | #
8 |
9 | use strict;
10 |
11 | my $test_name = "";
12 | if ( exists $ENV{UNIT_TEST_NAME} ) {
13 | $test_name = $ENV{UNIT_TEST_NAME};
14 | }
15 |
16 | if( eof STDIN )
17 | {
18 | exit 0;
19 | }
20 |
21 | printf("FAIL $test_name\n");
22 | exit 1;
23 |
--------------------------------------------------------------------------------
/tests/bin/fail-iff-exit-zero.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl -w
2 |
3 | #
4 | # Usage:
5 | #
6 | # ${FALL_IFF} command
7 | #
8 |
9 | use strict;
10 |
11 | my $test_name = "";
12 | if ( exists $ENV{UNIT_TEST_NAME} ) {
13 | $test_name = $ENV{UNIT_TEST_NAME};
14 | }
15 |
16 | my $ret = system(@ARGV);
17 | my $exit_value = $ret >> 8;
18 | my $signal_num = $ret & 127;
19 | my $dumped_core = $ret & 128;
20 | my $crashed = $signal_num + $dumped_core;
21 |
22 | if(0 == $exit_value || 0 != $crashed)
23 | {
24 | printf("FAIL $test_name\n");
25 | exit 1;
26 | }
27 |
28 | printf("PASS $test_name\n");
29 | exit 0;
30 |
--------------------------------------------------------------------------------
/tests/bin/pass-iff-exit-non-zero.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl -w
2 |
3 | #
4 | # Usage:
5 | #
6 | # ${PASS_IFF} command
7 | #
8 |
9 | use strict;
10 |
11 | my $test_name = "";
12 | if ( exists $ENV{UNIT_TEST_NAME} ) {
13 | $test_name = $ENV{UNIT_TEST_NAME};
14 | }
15 |
16 | my $ret = system(@ARGV);
17 | my $exit_value = $ret >> 8;
18 | my $signal_num = $ret & 127;
19 | my $dumped_core = $ret & 128;
20 | my $crashed = $signal_num + $dumped_core;
21 |
22 | if(0 == $exit_value || 0 != $crashed)
23 | {
24 | printf("FAIL $test_name\n");
25 | exit 1;
26 | }
27 |
28 | printf("PASS $test_name\n");
29 | exit 0;
30 |
--------------------------------------------------------------------------------
/tests/bin/pass-iff-exit-zero.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl -w
2 |
3 | #
4 | # Usage:
5 | #
6 | # ${PASS_IFF} command
7 | #
8 |
9 | use strict;
10 |
11 | my $test_name = "";
12 | if ( exists $ENV{UNIT_TEST_NAME} ) {
13 | $test_name = $ENV{UNIT_TEST_NAME};
14 | }
15 |
16 | if(0 != system(@ARGV))
17 | {
18 | printf("FAIL $test_name\n");
19 | exit 1;
20 | }
21 |
22 | printf("PASS $test_name\n");
23 | exit 0;
24 |
--------------------------------------------------------------------------------
/tests/bin/pass-iff-no-stdin.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl -w
2 |
3 | #
4 | # Usage:
5 | #
6 | # command | ${PASS_IFF_EMPTY}
7 | #
8 |
9 | use strict;
10 |
11 | my $test_name = "";
12 | if ( exists $ENV{UNIT_TEST_NAME} ) {
13 | $test_name = $ENV{UNIT_TEST_NAME};
14 | }
15 |
16 | if( eof STDIN )
17 | {
18 | printf("PASS $test_name\n");
19 | exit 0;
20 | }
21 |
22 | printf("FAIL $test_name\n");
23 | exit 1;
24 |
--------------------------------------------------------------------------------
/tests/bin/pass-iff-stdin.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl -w
2 |
3 | #
4 | # Usage:
5 | #
6 | # command | ${PASS_IFF_STDIN}
7 | #
8 |
9 | use strict;
10 |
11 | my $test_name = "";
12 | if ( exists $ENV{UNIT_TEST_NAME} ) {
13 | $test_name = $ENV{UNIT_TEST_NAME};
14 | }
15 |
16 | if( eof STDIN )
17 | {
18 | printf("FAIL $test_name\n");
19 | exit 1
20 | }
21 |
22 | printf("PASS $test_name\n");
23 | exit 0;
24 |
25 |
--------------------------------------------------------------------------------
/tests/data/echo.fat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keith/cctools/675c0644a2c90af04a075b048a438af35dfd7b4f/tests/data/echo.fat
--------------------------------------------------------------------------------
/tests/src/bar.c:
--------------------------------------------------------------------------------
1 | int bar(void)
2 | {
3 | return 0;
4 | }
5 |
--------------------------------------------------------------------------------
/tests/src/foo.c:
--------------------------------------------------------------------------------
1 | #if !defined(FOO)
2 | #define FOO foo
3 | #endif
4 |
5 | int FOO(void)
6 | {
7 | return 0;
8 | }
9 |
--------------------------------------------------------------------------------
/tests/src/hello.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main(void)
4 | {
5 | printf("hello, world!\n");
6 | return 0;
7 | }
8 |
--------------------------------------------------------------------------------
/tests/src/hello_textexec.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | __attribute__ ((section ("__TEXT_EXEC,__text,regular,pure_instructions")))
4 | static void hello(void)
5 | {
6 | printf("hello, world!\n");
7 | }
8 |
9 | int main(void)
10 | {
11 | hello();
12 | return 0;
13 | }
14 |
--------------------------------------------------------------------------------
/tests/src/objc_hi.m:
--------------------------------------------------------------------------------
1 | #import
2 | #include
3 |
4 | @interface Hi : NSObject
5 | {
6 | int payload;
7 | }
8 | - (void)greetings;
9 | - (void)unused;
10 | @end
11 |
12 | @implementation Hi
13 | - (void)greetings
14 | {
15 | printf("hello, Objective-C!\n");
16 | }
17 | - (void)unused
18 | {
19 | }
20 | @end
21 |
22 | int main(void)
23 | {
24 | @autoreleasepool {
25 | Hi* hi = [[Hi alloc] init];
26 | [hi greetings];
27 | }
28 | return 0;
29 | }
30 |
--------------------------------------------------------------------------------
/tests/src/preload.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | //#if defined(__LP64__)
4 | //const uint64_t data_addr = 0;
5 | //const uint32_t data_size = 0;
6 | //#else
7 | const uint32_t data_addr = 0;
8 | const uint32_t data_size = 0;
9 | //#endif
10 |
11 | char hello[32] = "hello\n";
12 |
13 | int main(void)
14 | {
15 | static char zero[32];
16 | int i;
17 | for (i = 0; hello[i]; ++i);
18 | return i;
19 | }
20 |
--------------------------------------------------------------------------------
/tests/src/preload_bss.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | const uint32_t data_addr = 0;
4 | const uint32_t data_size = 0;
5 |
6 | int main(void)
7 | {
8 | static char zero[32];
9 | int i;
10 | for (i = 0; zero[i]; ++i);
11 | return i;
12 | }
13 |
--------------------------------------------------------------------------------
/tests/src/times.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | int main(int argc, const char* argv[])
6 | {
7 | for(int i = 1; i < argc; ++i) {
8 | const char* path = argv[i];
9 | struct stat sb;
10 |
11 | printf("%s\n", path);
12 | if (0 == stat(path, &sb)) {
13 | printf(" atime: %ld\t%ld\n", sb.st_atimespec.tv_sec,
14 | sb.st_atimespec.tv_nsec);
15 | printf(" mtime: %ld\t%ld\n", sb.st_mtimespec.tv_sec,
16 | sb.st_mtimespec.tv_nsec);
17 | printf(" ctime: %ld\t%ld\n", sb.st_ctimespec.tv_sec,
18 | sb.st_ctimespec.tv_nsec);
19 | printf(" btime: %ld\t%ld\n", sb.st_birthtimespec.tv_sec,
20 | sb.st_birthtimespec.tv_nsec);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/tests/test-cases/1a_harness_test/Makefile:
--------------------------------------------------------------------------------
1 | # PLATFORM: MACOS
2 |
3 | TESTROOT = ../..
4 | include ${TESTROOT}/include/common.makefile
5 |
6 | all:
7 | ${PASS_IFF} true
8 |
9 | clean:
10 |
--------------------------------------------------------------------------------
/tests/test-cases/1b_check_test/Makefile:
--------------------------------------------------------------------------------
1 | # PLATFORM: MACOS
2 |
3 | TESTROOT = ../..
4 | include ${TESTROOT}/include/common.makefile
5 |
6 | all:
7 | $(PASS_IFF) ${TESTROOT}/bin/check.pl -tv
8 |
9 | clean:
10 |
--------------------------------------------------------------------------------
/tests/test-cases/as-llvm/Makefile:
--------------------------------------------------------------------------------
1 | # PLATFORM: MACOS
2 | #
3 | # smoke test for as, just to exercise some code.
4 | #
5 | # This test uses the llvm assemblers for code generation.
6 |
7 | PLATFORM = MACOS
8 | TESTROOT = ../..
9 | include ${TESTROOT}/include/common.makefile
10 |
11 | .PHONY: all clean
12 |
13 | all:
14 | # make sure as can find clang
15 | ${AS} /dev/null 2>&1 > as.txt | echo
16 | if grep -q "not installed" as.txt;\
17 | then\
18 | echo XFAIL;\
19 | false;\
20 | fi
21 |
22 | # convert a non-trivial test binary into assembly
23 | ${CC} -arch ${ARCH} ${TESTROOT}/src/verstool.c -S -o verstool.s -O2
24 |
25 | # build the binary
26 | ${FAIL_IF_ERROR} ${AS} -arch ${ARCH} -q -o verstool.o verstool.s 2>&1
27 | ${FAIL_IF_ERROR} ${CC} -o verstool verstool.o -lsystem 2>&1
28 |
29 | # run the binary, if applicable
30 | if [ "$(ARCH)" == "x64_64" ]; \
31 | then \
32 | ./verstool 2>&1 | ${CHECK}; \
33 | fi
34 | # CHECK: usage: verstool list
35 | # CHECK: write [(vm|bv) ] ...