libc,macos: update and add missing libc headers

This commit is contained in:
Jakub Konka
2021-06-09 00:17:11 +02:00
committed by Andrew Kelley
parent 503b85a1b0
commit 51076f4e1d
44 changed files with 5345 additions and 53 deletions

View File

@@ -0,0 +1,337 @@
/*
* Copyright (c) 2004 Apple Computer, Inc. All Rights Reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* CommonDigest.h - common digest routines: MD2, MD4, MD5, SHA1.
*/
#ifndef _CC_COMMON_DIGEST_H_
#define _CC_COMMON_DIGEST_H_
#include <stdint.h>
#if defined(_MSC_VER)
#include <availability.h>
#else
#include <os/availability.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define CC_DIGEST_DEPRECATION_WARNING \
"This function is cryptographically broken and should not be used in security contexts. Clients should migrate to SHA256 (or stronger)."
/*
* For compatibility with legacy implementations, the *Init(), *Update(),
* and *Final() functions declared here *always* return a value of 1 (one).
* This corresponds to "success" in the similar openssl implementations.
* There are no errors of any kind which can be, or are, reported here,
* so you can safely ignore the return values of all of these functions
* if you are implementing new code.
*
* The one-shot functions (CC_MD2(), CC_SHA1(), etc.) perform digest
* calculation and place the result in the caller-supplied buffer
* indicated by the md parameter. They return the md parameter.
* Unlike the opensssl counterparts, these one-shot functions require
* a non-NULL md pointer. Passing in NULL for the md parameter
* results in a NULL return and no digest calculation.
*/
typedef uint32_t CC_LONG; /* 32 bit unsigned integer */
typedef uint64_t CC_LONG64; /* 64 bit unsigned integer */
/*** MD2 ***/
#define CC_MD2_DIGEST_LENGTH 16 /* digest length in bytes */
#define CC_MD2_BLOCK_BYTES 64 /* block size in bytes */
#define CC_MD2_BLOCK_LONG (CC_MD2_BLOCK_BYTES / sizeof(CC_LONG))
typedef struct CC_MD2state_st
{
int num;
unsigned char data[CC_MD2_DIGEST_LENGTH];
CC_LONG cksm[CC_MD2_BLOCK_LONG];
CC_LONG state[CC_MD2_BLOCK_LONG];
} CC_MD2_CTX;
extern int CC_MD2_Init(CC_MD2_CTX *c)
API_DEPRECATED(CC_DIGEST_DEPRECATION_WARNING, macos(10.4, 10.15), ios(2.0, 13.0));
extern int CC_MD2_Update(CC_MD2_CTX *c, const void *data, CC_LONG len)
API_DEPRECATED(CC_DIGEST_DEPRECATION_WARNING, macos(10.4, 10.15), ios(2.0, 13.0));
extern int CC_MD2_Final(unsigned char *md, CC_MD2_CTX *c)
API_DEPRECATED(CC_DIGEST_DEPRECATION_WARNING, macos(10.4, 10.15), ios(2.0, 13.0));
extern unsigned char *CC_MD2(const void *data, CC_LONG len, unsigned char *md)
API_DEPRECATED(CC_DIGEST_DEPRECATION_WARNING, macos(10.4, 10.15), ios(2.0, 13.0));
/*** MD4 ***/
#define CC_MD4_DIGEST_LENGTH 16 /* digest length in bytes */
#define CC_MD4_BLOCK_BYTES 64 /* block size in bytes */
#define CC_MD4_BLOCK_LONG (CC_MD4_BLOCK_BYTES / sizeof(CC_LONG))
typedef struct CC_MD4state_st
{
CC_LONG A,B,C,D;
CC_LONG Nl,Nh;
CC_LONG data[CC_MD4_BLOCK_LONG];
uint32_t num;
} CC_MD4_CTX;
extern int CC_MD4_Init(CC_MD4_CTX *c)
API_DEPRECATED(CC_DIGEST_DEPRECATION_WARNING, macos(10.4, 10.15), ios(2.0, 13.0));
extern int CC_MD4_Update(CC_MD4_CTX *c, const void *data, CC_LONG len)
API_DEPRECATED(CC_DIGEST_DEPRECATION_WARNING, macos(10.4, 10.15), ios(2.0, 13.0));
extern int CC_MD4_Final(unsigned char *md, CC_MD4_CTX *c)
API_DEPRECATED(CC_DIGEST_DEPRECATION_WARNING, macos(10.4, 10.15), ios(2.0, 13.0));
extern unsigned char *CC_MD4(const void *data, CC_LONG len, unsigned char *md)
API_DEPRECATED(CC_DIGEST_DEPRECATION_WARNING, macos(10.4, 10.15), ios(2.0, 13.0));
/*** MD5 ***/
#define CC_MD5_DIGEST_LENGTH 16 /* digest length in bytes */
#define CC_MD5_BLOCK_BYTES 64 /* block size in bytes */
#define CC_MD5_BLOCK_LONG (CC_MD5_BLOCK_BYTES / sizeof(CC_LONG))
typedef struct CC_MD5state_st
{
CC_LONG A,B,C,D;
CC_LONG Nl,Nh;
CC_LONG data[CC_MD5_BLOCK_LONG];
int num;
} CC_MD5_CTX;
extern int CC_MD5_Init(CC_MD5_CTX *c)
API_DEPRECATED(CC_DIGEST_DEPRECATION_WARNING, macos(10.4, 10.15), ios(2.0, 13.0));
extern int CC_MD5_Update(CC_MD5_CTX *c, const void *data, CC_LONG len)
API_DEPRECATED(CC_DIGEST_DEPRECATION_WARNING, macos(10.4, 10.15), ios(2.0, 13.0));
extern int CC_MD5_Final(unsigned char *md, CC_MD5_CTX *c)
API_DEPRECATED(CC_DIGEST_DEPRECATION_WARNING, macos(10.4, 10.15), ios(2.0, 13.0));
extern unsigned char *CC_MD5(const void *data, CC_LONG len, unsigned char *md)
API_DEPRECATED(CC_DIGEST_DEPRECATION_WARNING, macos(10.4, 10.15), ios(2.0, 13.0));
/*** SHA1 ***/
#define CC_SHA1_DIGEST_LENGTH 20 /* digest length in bytes */
#define CC_SHA1_BLOCK_BYTES 64 /* block size in bytes */
#define CC_SHA1_BLOCK_LONG (CC_SHA1_BLOCK_BYTES / sizeof(CC_LONG))
typedef struct CC_SHA1state_st
{
CC_LONG h0,h1,h2,h3,h4;
CC_LONG Nl,Nh;
CC_LONG data[CC_SHA1_BLOCK_LONG];
int num;
} CC_SHA1_CTX;
extern int CC_SHA1_Init(CC_SHA1_CTX *c);
extern int CC_SHA1_Update(CC_SHA1_CTX *c, const void *data, CC_LONG len);
extern int CC_SHA1_Final(unsigned char *md, CC_SHA1_CTX *c);
extern unsigned char *CC_SHA1(const void *data, CC_LONG len, unsigned char *md);
/*** SHA224 ***/
#define CC_SHA224_DIGEST_LENGTH 28 /* digest length in bytes */
#define CC_SHA224_BLOCK_BYTES 64 /* block size in bytes */
/* same context struct is used for SHA224 and SHA256 */
typedef struct CC_SHA256state_st
{ CC_LONG count[2];
CC_LONG hash[8];
CC_LONG wbuf[16];
} CC_SHA256_CTX;
extern int CC_SHA224_Init(CC_SHA256_CTX *c)
API_AVAILABLE(macos(10.4), ios(2.0));
extern int CC_SHA224_Update(CC_SHA256_CTX *c, const void *data, CC_LONG len)
API_AVAILABLE(macos(10.4), ios(2.0));
extern int CC_SHA224_Final(unsigned char *md, CC_SHA256_CTX *c)
API_AVAILABLE(macos(10.4), ios(2.0));
extern unsigned char *CC_SHA224(const void *data, CC_LONG len, unsigned char *md)
API_AVAILABLE(macos(10.4), ios(2.0));
/*** SHA256 ***/
#define CC_SHA256_DIGEST_LENGTH 32 /* digest length in bytes */
#define CC_SHA256_BLOCK_BYTES 64 /* block size in bytes */
extern int CC_SHA256_Init(CC_SHA256_CTX *c)
API_AVAILABLE(macos(10.4), ios(2.0));
extern int CC_SHA256_Update(CC_SHA256_CTX *c, const void *data, CC_LONG len)
API_AVAILABLE(macos(10.4), ios(2.0));
extern int CC_SHA256_Final(unsigned char *md, CC_SHA256_CTX *c)
API_AVAILABLE(macos(10.4), ios(2.0));
extern unsigned char *CC_SHA256(const void *data, CC_LONG len, unsigned char *md)
API_AVAILABLE(macos(10.4), ios(2.0));
/*** SHA384 ***/
#define CC_SHA384_DIGEST_LENGTH 48 /* digest length in bytes */
#define CC_SHA384_BLOCK_BYTES 128 /* block size in bytes */
/* same context struct is used for SHA384 and SHA512 */
typedef struct CC_SHA512state_st
{ CC_LONG64 count[2];
CC_LONG64 hash[8];
CC_LONG64 wbuf[16];
} CC_SHA512_CTX;
extern int CC_SHA384_Init(CC_SHA512_CTX *c)
API_AVAILABLE(macos(10.4), ios(2.0));
extern int CC_SHA384_Update(CC_SHA512_CTX *c, const void *data, CC_LONG len)
API_AVAILABLE(macos(10.4), ios(2.0));
extern int CC_SHA384_Final(unsigned char *md, CC_SHA512_CTX *c)
API_AVAILABLE(macos(10.4), ios(2.0));
extern unsigned char *CC_SHA384(const void *data, CC_LONG len, unsigned char *md)
API_AVAILABLE(macos(10.4), ios(2.0));
/*** SHA512 ***/
#define CC_SHA512_DIGEST_LENGTH 64 /* digest length in bytes */
#define CC_SHA512_BLOCK_BYTES 128 /* block size in bytes */
extern int CC_SHA512_Init(CC_SHA512_CTX *c)
API_AVAILABLE(macos(10.4), ios(2.0));
extern int CC_SHA512_Update(CC_SHA512_CTX *c, const void *data, CC_LONG len)
API_AVAILABLE(macos(10.4), ios(2.0));
extern int CC_SHA512_Final(unsigned char *md, CC_SHA512_CTX *c)
API_AVAILABLE(macos(10.4), ios(2.0));
extern unsigned char *CC_SHA512(const void *data, CC_LONG len, unsigned char *md)
API_AVAILABLE(macos(10.4), ios(2.0));
/*
* To use the above digest functions with existing code which uses
* the corresponding openssl functions, #define the symbol
* COMMON_DIGEST_FOR_OPENSSL in your client code (BEFORE including
* this file), and simply link against libSystem (or System.framework)
* instead of libcrypto.
*
* You can *NOT* mix and match functions operating on a given data
* type from the two implementations; i.e., if you do a CC_MD5_Init()
* on a CC_MD5_CTX object, do not assume that you can do an openssl-style
* MD5_Update() on that same context.
*/
#ifdef COMMON_DIGEST_FOR_OPENSSL
#define MD2_DIGEST_LENGTH CC_MD2_DIGEST_LENGTH
#define MD2_CTX CC_MD2_CTX
#define MD2_Init CC_MD2_Init
#define MD2_Update CC_MD2_Update
#define MD2_Final CC_MD2_Final
#define MD4_DIGEST_LENGTH CC_MD4_DIGEST_LENGTH
#define MD4_CTX CC_MD4_CTX
#define MD4_Init CC_MD4_Init
#define MD4_Update CC_MD4_Update
#define MD4_Final CC_MD4_Final
#define MD5_DIGEST_LENGTH CC_MD5_DIGEST_LENGTH
#define MD5_CTX CC_MD5_CTX
#define MD5_Init CC_MD5_Init
#define MD5_Update CC_MD5_Update
#define MD5_Final CC_MD5_Final
#define SHA_DIGEST_LENGTH CC_SHA1_DIGEST_LENGTH
#define SHA_CTX CC_SHA1_CTX
#define SHA1_Init CC_SHA1_Init
#define SHA1_Update CC_SHA1_Update
#define SHA1_Final CC_SHA1_Final
#define SHA224_DIGEST_LENGTH CC_SHA224_DIGEST_LENGTH
#define SHA256_CTX CC_SHA256_CTX
#define SHA224_Init CC_SHA224_Init
#define SHA224_Update CC_SHA224_Update
#define SHA224_Final CC_SHA224_Final
#define SHA256_DIGEST_LENGTH CC_SHA256_DIGEST_LENGTH
#define SHA256_Init CC_SHA256_Init
#define SHA256_Update CC_SHA256_Update
#define SHA256_Final CC_SHA256_Final
#define SHA384_DIGEST_LENGTH CC_SHA384_DIGEST_LENGTH
#define SHA512_CTX CC_SHA512_CTX
#define SHA384_Init CC_SHA384_Init
#define SHA384_Update CC_SHA384_Update
#define SHA384_Final CC_SHA384_Final
#define SHA512_DIGEST_LENGTH CC_SHA512_DIGEST_LENGTH
#define SHA512_Init CC_SHA512_Init
#define SHA512_Update CC_SHA512_Update
#define SHA512_Final CC_SHA512_Final
#endif /* COMMON_DIGEST_FOR_OPENSSL */
/*
* In a manner similar to that described above for openssl
* compatibility, these macros can be used to provide compatiblity
* with legacy implementations of MD5 using the interface defined
* in RFC 1321.
*/
#ifdef COMMON_DIGEST_FOR_RFC_1321
#define MD5_CTX CC_MD5_CTX
#define MD5Init CC_MD5_Init
#define MD5Update CC_MD5_Update
void MD5Final (unsigned char [16], MD5_CTX *)
API_DEPRECATED(CC_DIGEST_DEPRECATION_WARNING, macos(10.4, 10.15), ios(2.0, 13.0));
#endif /* COMMON_DIGEST_FOR_RFC_1321 */
#ifdef __cplusplus
}
#endif
#endif /* _CC_COMMON_DIGEST_H_ */

67
lib/libc/include/aarch64-macos-gnu/ar.h vendored Normal file
View File

@@ -0,0 +1,67 @@
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, Inc.
*
* This code is derived from software contributed to Berkeley by
* Hugh Smith at The University of Guelph.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)ar.h 8.2 (Berkeley) 1/21/94
*/
#ifndef _AR_H_
#define _AR_H_
/* Pre-4BSD archives had these magic numbers in them. */
#define OARMAG1 0177555
#define OARMAG2 0177545
#define ARMAG "!<arch>\n" /* ar "magic number" */
#define SARMAG 8 /* strlen(ARMAG); */
#define AR_EFMT1 "#1/" /* extended format #1 */
struct ar_hdr {
char ar_name[16]; /* name */
char ar_date[12]; /* modification time */
char ar_uid[6]; /* user id */
char ar_gid[6]; /* group id */
char ar_mode[8]; /* octal file permissions */
char ar_size[10]; /* size in bytes */
#define ARFMAG "`\n"
char ar_fmag[2]; /* consistency check */
};
#endif /* !_AR_H_ */

View File

@@ -0,0 +1,150 @@
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _MACH_O_ARCH_H_
#define _MACH_O_ARCH_H_
/*
* Copyright (c) 1997 Apple Computer, Inc.
*
* Functions that deal with information about architectures.
*
*/
#include <stdint.h>
#include <mach/machine.h>
#include <architecture/byte_order.h>
/* The NXArchInfo structs contain the architectures symbolic name
* (such as "ppc"), its CPU type and CPU subtype as defined in
* mach/machine.h, the byte order for the architecture, and a
* describing string (such as "PowerPC").
* There will both be entries for specific CPUs (such as ppc604e) as
* well as generic "family" entries (such as ppc).
*/
typedef struct {
const char *name;
cpu_type_t cputype;
cpu_subtype_t cpusubtype;
enum NXByteOrder byteorder;
const char *description;
} NXArchInfo;
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* NXGetAllArchInfos() returns a pointer to an array of all known
* NXArchInfo structures. The last NXArchInfo is marked by a NULL name.
*/
extern const NXArchInfo *NXGetAllArchInfos(void);
/* NXGetLocalArchInfo() returns the NXArchInfo for the local host, or NULL
* if none is known.
*/
extern const NXArchInfo *NXGetLocalArchInfo(void);
/* NXGetArchInfoFromName() and NXGetArchInfoFromCpuType() return the
* NXArchInfo from the architecture's name or cputype/cpusubtype
* combination. A cpusubtype of CPU_SUBTYPE_MULTIPLE can be used
* to request the most general NXArchInfo known for the given cputype.
* NULL is returned if no matching NXArchInfo can be found.
*/
extern const NXArchInfo *NXGetArchInfoFromName(const char *name);
extern const NXArchInfo *NXGetArchInfoFromCpuType(cpu_type_t cputype,
cpu_subtype_t cpusubtype);
/* The above interfaces that return pointers to NXArchInfo structs in normal
* cases returns a pointer from the array returned in NXGetAllArchInfos().
* In some cases when the cputype is CPU_TYPE_I386 or CPU_TYPE_POWERPC it will
* retun malloc(3)'ed NXArchInfo struct which contains a string in the
* description field also a malloc(3)'ed pointer. To allow programs not to
* leak memory they can call NXFreeArchInfo() on pointers returned from the
* above interfaces. Since this is a new API on older systems can use the
* code below. Going forward the above interfaces will only return pointers
* from the array returned in NXGetAllArchInfos().
*/
extern void NXFreeArchInfo(const NXArchInfo *x);
/* The code that can be used for NXFreeArchInfo() when it is not available is:
*
* static void NXFreeArchInfo(
* const NXArchInfo *x)
* {
* const NXArchInfo *p;
*
* p = NXGetAllArchInfos();
* while(p->name != NULL){
* if(x == p)
* return;
* p++;
* }
* free((char *)x->description);
* free((NXArchInfo *)x);
* }
*/
/* NXFindBestFatArch() is passed a cputype and cpusubtype and a set of
* fat_arch structs and selects the best one that matches (if any) and returns
* a pointer to that fat_arch struct (or NULL). The fat_arch structs must be
* in the host byte order and correct such that the fat_archs really points to
* enough memory for nfat_arch structs. It is possible that this routine could
* fail if new cputypes or cpusubtypes are added and an old version of this
* routine is used. But if there is an exact match between the cputype and
* cpusubtype and one of the fat_arch structs this routine will always succeed.
*/
extern struct fat_arch *NXFindBestFatArch(cpu_type_t cputype,
cpu_subtype_t cpusubtype,
struct fat_arch *fat_archs,
uint32_t nfat_archs);
/* NXFindBestFatArch_64() is passed a cputype and cpusubtype and a set of
* fat_arch_64 structs and selects the best one that matches (if any) and
* returns a pointer to that fat_arch_64 struct (or NULL). The fat_arch_64
* structs must be in the host byte order and correct such that the fat_archs64
* really points to enough memory for nfat_arch structs. It is possible that
* this routine could fail if new cputypes or cpusubtypes are added and an old
* version of this routine is used. But if there is an exact match between the
* cputype and cpusubtype and one of the fat_arch_64 structs this routine will
* always succeed.
*/
extern struct fat_arch_64 *NXFindBestFatArch_64(cpu_type_t cputype,
cpu_subtype_t cpusubtype,
struct fat_arch_64 *fat_archs64,
uint32_t nfat_archs);
/* NXCombineCpuSubtypes() returns the resulting cpusubtype when combining two
* different cpusubtypes for the specified cputype. If the two cpusubtypes
* can't be combined (the specific subtypes are mutually exclusive) -1 is
* returned indicating it is an error to combine them. This can also fail and
* return -1 if new cputypes or cpusubtypes are added and an old version of
* this routine is used. But if the cpusubtypes are the same they can always
* be combined and this routine will return the cpusubtype pass in.
*/
extern cpu_subtype_t NXCombineCpuSubtypes(cpu_type_t cputype,
cpu_subtype_t cpusubtype1,
cpu_subtype_t cpusubtype2);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _MACH_O_ARCH_H_ */

View File

@@ -0,0 +1,68 @@
/*
* Copyright (c) 2010 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _MACHO_ARM64_RELOC_H_
#define _MACHO_ARM64_RELOC_H_
/*
* Relocation types used in the arm64 implementation.
*/
enum reloc_type_arm64
{
ARM64_RELOC_UNSIGNED, // for pointers
ARM64_RELOC_SUBTRACTOR, // must be followed by a ARM64_RELOC_UNSIGNED
ARM64_RELOC_BRANCH26, // a B/BL instruction with 26-bit displacement
ARM64_RELOC_PAGE21, // pc-rel distance to page of target
ARM64_RELOC_PAGEOFF12, // offset within page, scaled by r_length
ARM64_RELOC_GOT_LOAD_PAGE21, // pc-rel distance to page of GOT slot
ARM64_RELOC_GOT_LOAD_PAGEOFF12, // offset within page of GOT slot,
// scaled by r_length
ARM64_RELOC_POINTER_TO_GOT, // for pointers to GOT slots
ARM64_RELOC_TLVP_LOAD_PAGE21, // pc-rel distance to page of TLVP slot
ARM64_RELOC_TLVP_LOAD_PAGEOFF12, // offset within page of TLVP slot,
// scaled by r_length
ARM64_RELOC_ADDEND, // must be followed by PAGE21 or PAGEOFF12
// An arm64e authenticated pointer.
//
// Represents a pointer to a symbol (like ARM64_RELOC_UNSIGNED).
// Additionally, the resulting pointer is signed. The signature is
// specified in the target location: the addend is restricted to the lower
// 32 bits (instead of the full 64 bits for ARM64_RELOC_UNSIGNED):
//
// |63|62|61-51|50-49| 48 |47 - 32|31 - 0|
// | 1| 0| 0 | key | addr | discriminator | addend |
//
// The key is one of:
// IA: 00 IB: 01
// DA: 10 DB: 11
//
// The discriminator field is used as extra signature diversification.
//
// The addr field indicates whether the target address should be blended
// into the discriminator.
//
ARM64_RELOC_AUTHENTICATED_POINTER,
};
#endif /* #ifndef _MACHO_ARM64_RELOC_H_ */

View File

@@ -0,0 +1,532 @@
//===------------------ mach-o/compact_unwind_encoding.h ------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//
// Darwin's alternative to DWARF based unwind encodings.
//
//===----------------------------------------------------------------------===//
#ifndef __COMPACT_UNWIND_ENCODING__
#define __COMPACT_UNWIND_ENCODING__
#include <stdint.h>
//
// Compilers can emit standard DWARF FDEs in the __TEXT,__eh_frame section
// of object files. Or compilers can emit compact unwind information in
// the __LD,__compact_unwind section.
//
// When the linker creates a final linked image, it will create a
// __TEXT,__unwind_info section. This section is a small and fast way for the
// runtime to access unwind info for any given function. If the compiler
// emitted compact unwind info for the function, that compact unwind info will
// be encoded in the __TEXT,__unwind_info section. If the compiler emitted
// DWARF unwind info, the __TEXT,__unwind_info section will contain the offset
// of the FDE in the __TEXT,__eh_frame section in the final linked image.
//
// Note: Previously, the linker would transform some DWARF unwind infos into
// compact unwind info. But that is fragile and no longer done.
//
// The compact unwind endoding is a 32-bit value which encoded in an
// architecture specific way, which registers to restore from where, and how
// to unwind out of the function.
//
typedef uint32_t compact_unwind_encoding_t;
// architecture independent bits
enum {
UNWIND_IS_NOT_FUNCTION_START = 0x80000000,
UNWIND_HAS_LSDA = 0x40000000,
UNWIND_PERSONALITY_MASK = 0x30000000,
};
//
// x86
//
// 1-bit: start
// 1-bit: has lsda
// 2-bit: personality index
//
// 4-bits: 0=old, 1=ebp based, 2=stack-imm, 3=stack-ind, 4=DWARF
// ebp based:
// 15-bits (5*3-bits per reg) register permutation
// 8-bits for stack offset
// frameless:
// 8-bits stack size
// 3-bits stack adjust
// 3-bits register count
// 10-bits register permutation
//
enum {
UNWIND_X86_MODE_MASK = 0x0F000000,
UNWIND_X86_MODE_EBP_FRAME = 0x01000000,
UNWIND_X86_MODE_STACK_IMMD = 0x02000000,
UNWIND_X86_MODE_STACK_IND = 0x03000000,
UNWIND_X86_MODE_DWARF = 0x04000000,
UNWIND_X86_EBP_FRAME_REGISTERS = 0x00007FFF,
UNWIND_X86_EBP_FRAME_OFFSET = 0x00FF0000,
UNWIND_X86_FRAMELESS_STACK_SIZE = 0x00FF0000,
UNWIND_X86_FRAMELESS_STACK_ADJUST = 0x0000E000,
UNWIND_X86_FRAMELESS_STACK_REG_COUNT = 0x00001C00,
UNWIND_X86_FRAMELESS_STACK_REG_PERMUTATION = 0x000003FF,
UNWIND_X86_DWARF_SECTION_OFFSET = 0x00FFFFFF,
};
enum {
UNWIND_X86_REG_NONE = 0,
UNWIND_X86_REG_EBX = 1,
UNWIND_X86_REG_ECX = 2,
UNWIND_X86_REG_EDX = 3,
UNWIND_X86_REG_EDI = 4,
UNWIND_X86_REG_ESI = 5,
UNWIND_X86_REG_EBP = 6,
};
//
// For x86 there are four modes for the compact unwind encoding:
// UNWIND_X86_MODE_EBP_FRAME:
// EBP based frame where EBP is push on stack immediately after return address,
// then ESP is moved to EBP. Thus, to unwind ESP is restored with the current
// EPB value, then EBP is restored by popping off the stack, and the return
// is done by popping the stack once more into the pc.
// All non-volatile registers that need to be restored must have been saved
// in a small range in the stack that starts EBP-4 to EBP-1020. The offset/4
// is encoded in the UNWIND_X86_EBP_FRAME_OFFSET bits. The registers saved
// are encoded in the UNWIND_X86_EBP_FRAME_REGISTERS bits as five 3-bit entries.
// Each entry contains which register to restore.
// UNWIND_X86_MODE_STACK_IMMD:
// A "frameless" (EBP not used as frame pointer) function with a small
// constant stack size. To return, a constant (encoded in the compact
// unwind encoding) is added to the ESP. Then the return is done by
// popping the stack into the pc.
// All non-volatile registers that need to be restored must have been saved
// on the stack immediately after the return address. The stack_size/4 is
// encoded in the UNWIND_X86_FRAMELESS_STACK_SIZE (max stack size is 1024).
// The number of registers saved is encoded in UNWIND_X86_FRAMELESS_STACK_REG_COUNT.
// UNWIND_X86_FRAMELESS_STACK_REG_PERMUTATION constains which registers were
// saved and their order.
// UNWIND_X86_MODE_STACK_IND:
// A "frameless" (EBP not used as frame pointer) function large constant
// stack size. This case is like the previous, except the stack size is too
// large to encode in the compact unwind encoding. Instead it requires that
// the function contains "subl $nnnnnnnn,ESP" in its prolog. The compact
// encoding contains the offset to the nnnnnnnn value in the function in
// UNWIND_X86_FRAMELESS_STACK_SIZE.
// UNWIND_X86_MODE_DWARF:
// No compact unwind encoding is available. Instead the low 24-bits of the
// compact encoding is the offset of the DWARF FDE in the __eh_frame section.
// This mode is never used in object files. It is only generated by the
// linker in final linked images which have only DWARF unwind info for a
// function.
//
// The permutation encoding is a Lehmer code sequence encoded into a
// single variable-base number so we can encode the ordering of up to
// six registers in a 10-bit space.
//
// The following is the algorithm used to create the permutation encoding used
// with frameless stacks. It is passed the number of registers to be saved and
// an array of the register numbers saved.
//
//uint32_t permute_encode(uint32_t registerCount, const uint32_t registers[6])
//{
// uint32_t renumregs[6];
// for (int i=6-registerCount; i < 6; ++i) {
// int countless = 0;
// for (int j=6-registerCount; j < i; ++j) {
// if ( registers[j] < registers[i] )
// ++countless;
// }
// renumregs[i] = registers[i] - countless -1;
// }
// uint32_t permutationEncoding = 0;
// switch ( registerCount ) {
// case 6:
// permutationEncoding |= (120*renumregs[0] + 24*renumregs[1]
// + 6*renumregs[2] + 2*renumregs[3]
// + renumregs[4]);
// break;
// case 5:
// permutationEncoding |= (120*renumregs[1] + 24*renumregs[2]
// + 6*renumregs[3] + 2*renumregs[4]
// + renumregs[5]);
// break;
// case 4:
// permutationEncoding |= (60*renumregs[2] + 12*renumregs[3]
// + 3*renumregs[4] + renumregs[5]);
// break;
// case 3:
// permutationEncoding |= (20*renumregs[3] + 4*renumregs[4]
// + renumregs[5]);
// break;
// case 2:
// permutationEncoding |= (5*renumregs[4] + renumregs[5]);
// break;
// case 1:
// permutationEncoding |= (renumregs[5]);
// break;
// }
// return permutationEncoding;
//}
//
//
// x86_64
//
// 1-bit: start
// 1-bit: has lsda
// 2-bit: personality index
//
// 4-bits: 0=old, 1=rbp based, 2=stack-imm, 3=stack-ind, 4=DWARF
// rbp based:
// 15-bits (5*3-bits per reg) register permutation
// 8-bits for stack offset
// frameless:
// 8-bits stack size
// 3-bits stack adjust
// 3-bits register count
// 10-bits register permutation
//
enum {
UNWIND_X86_64_MODE_MASK = 0x0F000000,
UNWIND_X86_64_MODE_RBP_FRAME = 0x01000000,
UNWIND_X86_64_MODE_STACK_IMMD = 0x02000000,
UNWIND_X86_64_MODE_STACK_IND = 0x03000000,
UNWIND_X86_64_MODE_DWARF = 0x04000000,
UNWIND_X86_64_RBP_FRAME_REGISTERS = 0x00007FFF,
UNWIND_X86_64_RBP_FRAME_OFFSET = 0x00FF0000,
UNWIND_X86_64_FRAMELESS_STACK_SIZE = 0x00FF0000,
UNWIND_X86_64_FRAMELESS_STACK_ADJUST = 0x0000E000,
UNWIND_X86_64_FRAMELESS_STACK_REG_COUNT = 0x00001C00,
UNWIND_X86_64_FRAMELESS_STACK_REG_PERMUTATION = 0x000003FF,
UNWIND_X86_64_DWARF_SECTION_OFFSET = 0x00FFFFFF,
};
enum {
UNWIND_X86_64_REG_NONE = 0,
UNWIND_X86_64_REG_RBX = 1,
UNWIND_X86_64_REG_R12 = 2,
UNWIND_X86_64_REG_R13 = 3,
UNWIND_X86_64_REG_R14 = 4,
UNWIND_X86_64_REG_R15 = 5,
UNWIND_X86_64_REG_RBP = 6,
};
//
// For x86_64 there are four modes for the compact unwind encoding:
// UNWIND_X86_64_MODE_RBP_FRAME:
// RBP based frame where RBP is push on stack immediately after return address,
// then RSP is moved to RBP. Thus, to unwind RSP is restored with the current
// EPB value, then RBP is restored by popping off the stack, and the return
// is done by popping the stack once more into the pc.
// All non-volatile registers that need to be restored must have been saved
// in a small range in the stack that starts RBP-8 to RBP-2040. The offset/8
// is encoded in the UNWIND_X86_64_RBP_FRAME_OFFSET bits. The registers saved
// are encoded in the UNWIND_X86_64_RBP_FRAME_REGISTERS bits as five 3-bit entries.
// Each entry contains which register to restore.
// UNWIND_X86_64_MODE_STACK_IMMD:
// A "frameless" (RBP not used as frame pointer) function with a small
// constant stack size. To return, a constant (encoded in the compact
// unwind encoding) is added to the RSP. Then the return is done by
// popping the stack into the pc.
// All non-volatile registers that need to be restored must have been saved
// on the stack immediately after the return address. The stack_size/8 is
// encoded in the UNWIND_X86_64_FRAMELESS_STACK_SIZE (max stack size is 2048).
// The number of registers saved is encoded in UNWIND_X86_64_FRAMELESS_STACK_REG_COUNT.
// UNWIND_X86_64_FRAMELESS_STACK_REG_PERMUTATION constains which registers were
// saved and their order.
// UNWIND_X86_64_MODE_STACK_IND:
// A "frameless" (RBP not used as frame pointer) function large constant
// stack size. This case is like the previous, except the stack size is too
// large to encode in the compact unwind encoding. Instead it requires that
// the function contains "subq $nnnnnnnn,RSP" in its prolog. The compact
// encoding contains the offset to the nnnnnnnn value in the function in
// UNWIND_X86_64_FRAMELESS_STACK_SIZE.
// UNWIND_X86_64_MODE_DWARF:
// No compact unwind encoding is available. Instead the low 24-bits of the
// compact encoding is the offset of the DWARF FDE in the __eh_frame section.
// This mode is never used in object files. It is only generated by the
// linker in final linked images which have only DWARF unwind info for a
// function.
//
// ARM64
//
// 1-bit: start
// 1-bit: has lsda
// 2-bit: personality index
//
// 4-bits: 4=frame-based, 3=DWARF, 2=frameless
// frameless:
// 12-bits of stack size
// frame-based:
// 4-bits D reg pairs saved
// 5-bits X reg pairs saved
// DWARF:
// 24-bits offset of DWARF FDE in __eh_frame section
//
enum {
UNWIND_ARM64_MODE_MASK = 0x0F000000,
UNWIND_ARM64_MODE_FRAMELESS = 0x02000000,
UNWIND_ARM64_MODE_DWARF = 0x03000000,
UNWIND_ARM64_MODE_FRAME = 0x04000000,
UNWIND_ARM64_FRAME_X19_X20_PAIR = 0x00000001,
UNWIND_ARM64_FRAME_X21_X22_PAIR = 0x00000002,
UNWIND_ARM64_FRAME_X23_X24_PAIR = 0x00000004,
UNWIND_ARM64_FRAME_X25_X26_PAIR = 0x00000008,
UNWIND_ARM64_FRAME_X27_X28_PAIR = 0x00000010,
UNWIND_ARM64_FRAME_D8_D9_PAIR = 0x00000100,
UNWIND_ARM64_FRAME_D10_D11_PAIR = 0x00000200,
UNWIND_ARM64_FRAME_D12_D13_PAIR = 0x00000400,
UNWIND_ARM64_FRAME_D14_D15_PAIR = 0x00000800,
UNWIND_ARM64_FRAMELESS_STACK_SIZE_MASK = 0x00FFF000,
UNWIND_ARM64_DWARF_SECTION_OFFSET = 0x00FFFFFF,
};
// For arm64 there are three modes for the compact unwind encoding:
// UNWIND_ARM64_MODE_FRAME:
// This is a standard arm64 prolog where FP/LR are immediately pushed on the
// stack, then SP is copied to FP. If there are any non-volatile registers
// saved, then are copied into the stack frame in pairs in a contiguous
// range right below the saved FP/LR pair. Any subset of the five X pairs
// and four D pairs can be saved, but the memory layout must be in register
// number order.
// UNWIND_ARM64_MODE_FRAMELESS:
// A "frameless" leaf function, where FP/LR are not saved. The return address
// remains in LR throughout the function. If any non-volatile registers
// are saved, they must be pushed onto the stack before any stack space is
// allocated for local variables. The stack sized (including any saved
// non-volatile registers) divided by 16 is encoded in the bits
// UNWIND_ARM64_FRAMELESS_STACK_SIZE_MASK.
// UNWIND_ARM64_MODE_DWARF:
// No compact unwind encoding is available. Instead the low 24-bits of the
// compact encoding is the offset of the DWARF FDE in the __eh_frame section.
// This mode is never used in object files. It is only generated by the
// linker in final linked images which have only DWARF unwind info for a
// function.
//
#ifndef __OPEN_SOURCE__
//
// armv7k
//
// 1-bit: start
// 1-bit: has lsda
// 2-bit: personality index
//
// 4-bits: 1=frame, 2=frame+dregs, 4=dwarf
//
enum {
UNWIND_ARM_MODE_MASK = 0x0F000000,
UNWIND_ARM_MODE_FRAME = 0x01000000,
UNWIND_ARM_MODE_FRAME_D = 0x02000000,
UNWIND_ARM_MODE_DWARF = 0x04000000,
UNWIND_ARM_FRAME_STACK_ADJUST_MASK = 0x00C00000,
UNWIND_ARM_FRAME_FIRST_PUSH_R4 = 0x00000001,
UNWIND_ARM_FRAME_FIRST_PUSH_R5 = 0x00000002,
UNWIND_ARM_FRAME_FIRST_PUSH_R6 = 0x00000004,
UNWIND_ARM_FRAME_SECOND_PUSH_R8 = 0x00000008,
UNWIND_ARM_FRAME_SECOND_PUSH_R9 = 0x00000010,
UNWIND_ARM_FRAME_SECOND_PUSH_R10 = 0x00000020,
UNWIND_ARM_FRAME_SECOND_PUSH_R11 = 0x00000040,
UNWIND_ARM_FRAME_SECOND_PUSH_R12 = 0x00000080,
UNWIND_ARM_FRAME_D_REG_COUNT_MASK = 0x00000700,
UNWIND_ARM_DWARF_SECTION_OFFSET = 0x00FFFFFF,
};
// For armv7k there are three modes for the compact unwind encoding:
// UNWIND_ARM_MODE_FRAME:
// This is a standard arm prolog where lr/r7 are immediately pushed on the
// stack. As part of that first push r4, r5, or r6 can be also pushed
// and if so the FIRST_PUSH bit is set in the compact unwind. Additionally
// there can be a second push multiple which can save r8 through r12.
// If that is used, the registers saved is recorded with a SECOND_PUSH bit.
// Lastly, for var-args support, the prolog may save r1, r2, r3 to the
// stack before the frame push. If that is done the STACK_ADJUST_MASK
// records that the stack pointer must be adjust (e.g 0x00800000 means
// the stack pointer was adjusted 8 bytes down and the unwinder would
// need to add back 8 bytes to SP when unwinding through this function.
// UNWIND_ARM_MODE_FRAME_D:
// This is the same as UNWIND_ARM_MODE_FRAME, except that additionally
// some D registers were saved. The D_REG_COUNT_MASK contains which
// set if D registers were saved and where. There are currently 8 (0-7)
// possible D register save patterns supported.
// UNWIND_ARM_MODE_DWARF:
// No compact unwind encoding is available. Instead the low 24-bits of the
// compact encoding is the offset of the dwarf FDE in the __eh_frame section.
// The offset only exists in final linked images. It is zero in object files.
#endif
////////////////////////////////////////////////////////////////////////////////
//
// Relocatable Object Files: __LD,__compact_unwind
//
////////////////////////////////////////////////////////////////////////////////
//
// A compiler can generated compact unwind information for a function by adding
// a "row" to the __LD,__compact_unwind section. This section has the
// S_ATTR_DEBUG bit set, so the section will be ignored by older linkers.
// It is removed by the new linker, so never ends up in final executables.
// This section is a table, initially with one row per function (that needs
// unwind info). The table columns and some conceptual entries are:
//
// range-start pointer to start of function/range
// range-length
// compact-unwind-encoding 32-bit encoding
// personality-function or zero if no personality function
// lsda or zero if no LSDA data
//
// The length and encoding fields are 32-bits. The other are all pointer sized.
//
// In x86_64 assembly, these entry would look like:
//
// .section __LD,__compact_unwind,regular,debug
//
// #compact unwind for _foo
// .quad _foo
// .set L1,LfooEnd-_foo
// .long L1
// .long 0x01010001
// .quad 0
// .quad 0
//
// #compact unwind for _bar
// .quad _bar
// .set L2,LbarEnd-_bar
// .long L2
// .long 0x01020011
// .quad __gxx_personality
// .quad except_tab1
//
//
// Notes: There is no need for any labels in the the __compact_unwind section.
// The use of the .set directive is to force the evaluation of the
// range-length at assembly time, instead of generating relocations.
//
// To support future compiler optimizations where which non-volatile registers
// are saved changes within a function (e.g. delay saving non-volatiles until
// necessary), there can by multiple lines in the __compact_unwind table for one
// function, each with a different (non-overlapping) range and each with
// different compact unwind encodings that correspond to the non-volatiles
// saved at that range of the function.
//
// If a particular function is so wacky that there is no compact unwind way
// to encode it, then the compiler can emit traditional DWARF unwind info.
// The runtime will use which ever is available.
//
// Runtime support for compact unwind encodings are only available on 10.6
// and later. So, the compiler should not generate it when targeting pre-10.6.
////////////////////////////////////////////////////////////////////////////////
//
// Final Linked Images: __TEXT,__unwind_info
//
////////////////////////////////////////////////////////////////////////////////
//
// The __TEXT,__unwind_info section is laid out for an efficient two level lookup.
// The header of the section contains a coarse index that maps function address
// to the page (4096 byte block) containing the unwind info for that function.
//
#define UNWIND_SECTION_VERSION 1
struct unwind_info_section_header
{
uint32_t version; // UNWIND_SECTION_VERSION
uint32_t commonEncodingsArraySectionOffset;
uint32_t commonEncodingsArrayCount;
uint32_t personalityArraySectionOffset;
uint32_t personalityArrayCount;
uint32_t indexSectionOffset;
uint32_t indexCount;
// compact_unwind_encoding_t[]
// uint32_t personalities[]
// unwind_info_section_header_index_entry[]
// unwind_info_section_header_lsda_index_entry[]
};
struct unwind_info_section_header_index_entry
{
uint32_t functionOffset;
uint32_t secondLevelPagesSectionOffset; // section offset to start of regular or compress page
uint32_t lsdaIndexArraySectionOffset; // section offset to start of lsda_index array for this range
};
struct unwind_info_section_header_lsda_index_entry
{
uint32_t functionOffset;
uint32_t lsdaOffset;
};
//
// There are two kinds of second level index pages: regular and compressed.
// A compressed page can hold up to 1021 entries, but it cannot be used
// if too many different encoding types are used. The regular page holds
// 511 entries.
//
struct unwind_info_regular_second_level_entry
{
uint32_t functionOffset;
compact_unwind_encoding_t encoding;
};
#define UNWIND_SECOND_LEVEL_REGULAR 2
struct unwind_info_regular_second_level_page_header
{
uint32_t kind; // UNWIND_SECOND_LEVEL_REGULAR
uint16_t entryPageOffset;
uint16_t entryCount;
// entry array
};
#define UNWIND_SECOND_LEVEL_COMPRESSED 3
struct unwind_info_compressed_second_level_page_header
{
uint32_t kind; // UNWIND_SECOND_LEVEL_COMPRESSED
uint16_t entryPageOffset;
uint16_t entryCount;
uint16_t encodingsPageOffset;
uint16_t encodingsCount;
// 32-bit entry array
// encodings array
};
#define UNWIND_INFO_COMPRESSED_ENTRY_FUNC_OFFSET(entry) (entry & 0x00FFFFFF)
#define UNWIND_INFO_COMPRESSED_ENTRY_ENCODING_INDEX(entry) ((entry >> 24) & 0xFF)
#endif

View File

@@ -0,0 +1,83 @@
/*
* Copyright (c) 2016 Apple, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _MACH_O_FAT_H_
#define _MACH_O_FAT_H_
/*
* This header file describes the structures of the file format for "fat"
* architecture specific file (wrapper design). At the begining of the file
* there is one fat_header structure followed by a number of fat_arch
* structures. For each architecture in the file, specified by a pair of
* cputype and cpusubtype, the fat_header describes the file offset, file
* size and alignment in the file of the architecture specific member.
* The padded bytes in the file to place each member on it's specific alignment
* are defined to be read as zeros and can be left as "holes" if the file system
* can support them as long as they read as zeros.
*
* All structures defined here are always written and read to/from disk
* in big-endian order.
*/
/*
* <mach/machine.h> is needed here for the cpu_type_t and cpu_subtype_t types
* and contains the constants for the possible values of these types.
*/
#include <stdint.h>
#include <mach/machine.h>
#include <architecture/byte_order.h>
#define FAT_MAGIC 0xcafebabe
#define FAT_CIGAM 0xbebafeca /* NXSwapLong(FAT_MAGIC) */
struct fat_header {
uint32_t magic; /* FAT_MAGIC or FAT_MAGIC_64 */
uint32_t nfat_arch; /* number of structs that follow */
};
struct fat_arch {
cpu_type_t cputype; /* cpu specifier (int) */
cpu_subtype_t cpusubtype; /* machine specifier (int) */
uint32_t offset; /* file offset to this object file */
uint32_t size; /* size of this object file */
uint32_t align; /* alignment as a power of 2 */
};
/*
* The support for the 64-bit fat file format described here is a work in
* progress and not yet fully supported in all the Apple Developer Tools.
*
* When a slice is greater than 4mb or an offset to a slice is greater than 4mb
* then the 64-bit fat file format is used.
*/
#define FAT_MAGIC_64 0xcafebabf
#define FAT_CIGAM_64 0xbfbafeca /* NXSwapLong(FAT_MAGIC_64) */
struct fat_arch_64 {
cpu_type_t cputype; /* cpu specifier (int) */
cpu_subtype_t cpusubtype; /* machine specifier (int) */
uint64_t offset; /* file offset to this object file */
uint64_t size; /* size of this object file */
uint32_t align; /* alignment as a power of 2 */
uint32_t reserved; /* reserved */
};
#endif /* _MACH_O_FAT_H_ */

View File

@@ -0,0 +1,324 @@
/*
* Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _MACHO_NLIST_H_
#define _MACHO_NLIST_H_
/* $NetBSD: nlist.h,v 1.5 1994/10/26 00:56:11 cgd Exp $ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)nlist.h 8.2 (Berkeley) 1/21/94
*/
#include <stdint.h>
/*
* Format of a symbol table entry of a Mach-O file for 32-bit architectures.
* Modified from the BSD format. The modifications from the original format
* were changing n_other (an unused field) to n_sect and the addition of the
* N_SECT type. These modifications are required to support symbols in a larger
* number of sections not just the three sections (text, data and bss) in a BSD
* file.
*/
struct nlist {
union {
#ifndef __LP64__
char *n_name; /* for use when in-core */
#endif
uint32_t n_strx; /* index into the string table */
} n_un;
uint8_t n_type; /* type flag, see below */
uint8_t n_sect; /* section number or NO_SECT */
int16_t n_desc; /* see <mach-o/stab.h> */
uint32_t n_value; /* value of this symbol (or stab offset) */
};
/*
* This is the symbol table entry structure for 64-bit architectures.
*/
struct nlist_64 {
union {
uint32_t n_strx; /* index into the string table */
} n_un;
uint8_t n_type; /* type flag, see below */
uint8_t n_sect; /* section number or NO_SECT */
uint16_t n_desc; /* see <mach-o/stab.h> */
uint64_t n_value; /* value of this symbol (or stab offset) */
};
/*
* Symbols with a index into the string table of zero (n_un.n_strx == 0) are
* defined to have a null, "", name. Therefore all string indexes to non null
* names must not have a zero string index. This is bit historical information
* that has never been well documented.
*/
/*
* The n_type field really contains four fields:
* unsigned char N_STAB:3,
* N_PEXT:1,
* N_TYPE:3,
* N_EXT:1;
* which are used via the following masks.
*/
#define N_STAB 0xe0 /* if any of these bits set, a symbolic debugging entry */
#define N_PEXT 0x10 /* private external symbol bit */
#define N_TYPE 0x0e /* mask for the type bits */
#define N_EXT 0x01 /* external symbol bit, set for external symbols */
/*
* Only symbolic debugging entries have some of the N_STAB bits set and if any
* of these bits are set then it is a symbolic debugging entry (a stab). In
* which case then the values of the n_type field (the entire field) are given
* in <mach-o/stab.h>
*/
/*
* Values for N_TYPE bits of the n_type field.
*/
#define N_UNDF 0x0 /* undefined, n_sect == NO_SECT */
#define N_ABS 0x2 /* absolute, n_sect == NO_SECT */
#define N_SECT 0xe /* defined in section number n_sect */
#define N_PBUD 0xc /* prebound undefined (defined in a dylib) */
#define N_INDR 0xa /* indirect */
/*
* If the type is N_INDR then the symbol is defined to be the same as another
* symbol. In this case the n_value field is an index into the string table
* of the other symbol's name. When the other symbol is defined then they both
* take on the defined type and value.
*/
/*
* If the type is N_SECT then the n_sect field contains an ordinal of the
* section the symbol is defined in. The sections are numbered from 1 and
* refer to sections in order they appear in the load commands for the file
* they are in. This means the same ordinal may very well refer to different
* sections in different files.
*
* The n_value field for all symbol table entries (including N_STAB's) gets
* updated by the link editor based on the value of it's n_sect field and where
* the section n_sect references gets relocated. If the value of the n_sect
* field is NO_SECT then it's n_value field is not changed by the link editor.
*/
#define NO_SECT 0 /* symbol is not in any section */
#define MAX_SECT 255 /* 1 thru 255 inclusive */
/*
* Common symbols are represented by undefined (N_UNDF) external (N_EXT) types
* who's values (n_value) are non-zero. In which case the value of the n_value
* field is the size (in bytes) of the common symbol. The n_sect field is set
* to NO_SECT. The alignment of a common symbol may be set as a power of 2
* between 2^1 and 2^15 as part of the n_desc field using the macros below. If
* the alignment is not set (a value of zero) then natural alignment based on
* the size is used.
*/
#define GET_COMM_ALIGN(n_desc) (((n_desc) >> 8) & 0x0f)
#define SET_COMM_ALIGN(n_desc,align) \
(n_desc) = (((n_desc) & 0xf0ff) | (((align) & 0x0f) << 8))
/*
* To support the lazy binding of undefined symbols in the dynamic link-editor,
* the undefined symbols in the symbol table (the nlist structures) are marked
* with the indication if the undefined reference is a lazy reference or
* non-lazy reference. If both a non-lazy reference and a lazy reference is
* made to the same symbol the non-lazy reference takes precedence. A reference
* is lazy only when all references to that symbol are made through a symbol
* pointer in a lazy symbol pointer section.
*
* The implementation of marking nlist structures in the symbol table for
* undefined symbols will be to use some of the bits of the n_desc field as a
* reference type. The mask REFERENCE_TYPE will be applied to the n_desc field
* of an nlist structure for an undefined symbol to determine the type of
* undefined reference (lazy or non-lazy).
*
* The constants for the REFERENCE FLAGS are propagated to the reference table
* in a shared library file. In that case the constant for a defined symbol,
* REFERENCE_FLAG_DEFINED, is also used.
*/
/* Reference type bits of the n_desc field of undefined symbols */
#define REFERENCE_TYPE 0x7
/* types of references */
#define REFERENCE_FLAG_UNDEFINED_NON_LAZY 0
#define REFERENCE_FLAG_UNDEFINED_LAZY 1
#define REFERENCE_FLAG_DEFINED 2
#define REFERENCE_FLAG_PRIVATE_DEFINED 3
#define REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY 4
#define REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY 5
/*
* To simplify stripping of objects that use are used with the dynamic link
* editor, the static link editor marks the symbols defined an object that are
* referenced by a dynamicly bound object (dynamic shared libraries, bundles).
* With this marking strip knows not to strip these symbols.
*/
#define REFERENCED_DYNAMICALLY 0x0010
/*
* For images created by the static link editor with the -twolevel_namespace
* option in effect the flags field of the mach header is marked with
* MH_TWOLEVEL. And the binding of the undefined references of the image are
* determined by the static link editor. Which library an undefined symbol is
* bound to is recorded by the static linker in the high 8 bits of the n_desc
* field using the SET_LIBRARY_ORDINAL macro below. The ordinal recorded
* references the libraries listed in the Mach-O's LC_LOAD_DYLIB,
* LC_LOAD_WEAK_DYLIB, LC_REEXPORT_DYLIB, LC_LOAD_UPWARD_DYLIB, and
* LC_LAZY_LOAD_DYLIB, etc. load commands in the order they appear in the
* headers. The library ordinals start from 1.
* For a dynamic library that is built as a two-level namespace image the
* undefined references from module defined in another use the same nlist struct
* an in that case SELF_LIBRARY_ORDINAL is used as the library ordinal. For
* defined symbols in all images they also must have the library ordinal set to
* SELF_LIBRARY_ORDINAL. The EXECUTABLE_ORDINAL refers to the executable
* image for references from plugins that refer to the executable that loads
* them.
*
* The DYNAMIC_LOOKUP_ORDINAL is for undefined symbols in a two-level namespace
* image that are looked up by the dynamic linker with flat namespace semantics.
* This ordinal was added as a feature in Mac OS X 10.3 by reducing the
* value of MAX_LIBRARY_ORDINAL by one. So it is legal for existing binaries
* or binaries built with older tools to have 0xfe (254) dynamic libraries. In
* this case the ordinal value 0xfe (254) must be treated as a library ordinal
* for compatibility.
*/
#define GET_LIBRARY_ORDINAL(n_desc) (((n_desc) >> 8) & 0xff)
#define SET_LIBRARY_ORDINAL(n_desc,ordinal) \
(n_desc) = (((n_desc) & 0x00ff) | (((ordinal) & 0xff) << 8))
#define SELF_LIBRARY_ORDINAL 0x0
#define MAX_LIBRARY_ORDINAL 0xfd
#define DYNAMIC_LOOKUP_ORDINAL 0xfe
#define EXECUTABLE_ORDINAL 0xff
/*
* The bit 0x0020 of the n_desc field is used for two non-overlapping purposes
* and has two different symbolic names, N_NO_DEAD_STRIP and N_DESC_DISCARDED.
*/
/*
* The N_NO_DEAD_STRIP bit of the n_desc field only ever appears in a
* relocatable .o file (MH_OBJECT filetype). And is used to indicate to the
* static link editor it is never to dead strip the symbol.
*/
#define N_NO_DEAD_STRIP 0x0020 /* symbol is not to be dead stripped */
/*
* The N_DESC_DISCARDED bit of the n_desc field never appears in linked image.
* But is used in very rare cases by the dynamic link editor to mark an in
* memory symbol as discared and longer used for linking.
*/
#define N_DESC_DISCARDED 0x0020 /* symbol is discarded */
/*
* The N_WEAK_REF bit of the n_desc field indicates to the dynamic linker that
* the undefined symbol is allowed to be missing and is to have the address of
* zero when missing.
*/
#define N_WEAK_REF 0x0040 /* symbol is weak referenced */
/*
* The N_WEAK_DEF bit of the n_desc field indicates to the static and dynamic
* linkers that the symbol definition is weak, allowing a non-weak symbol to
* also be used which causes the weak definition to be discared. Currently this
* is only supported for symbols in coalesed sections.
*/
#define N_WEAK_DEF 0x0080 /* coalesed symbol is a weak definition */
/*
* The N_REF_TO_WEAK bit of the n_desc field indicates to the dynamic linker
* that the undefined symbol should be resolved using flat namespace searching.
*/
#define N_REF_TO_WEAK 0x0080 /* reference to a weak symbol */
/*
* The N_ARM_THUMB_DEF bit of the n_desc field indicates that the symbol is
* a defintion of a Thumb function.
*/
#define N_ARM_THUMB_DEF 0x0008 /* symbol is a Thumb function (ARM) */
/*
* The N_SYMBOL_RESOLVER bit of the n_desc field indicates that the
* that the function is actually a resolver function and should
* be called to get the address of the real function to use.
* This bit is only available in .o files (MH_OBJECT filetype)
*/
#define N_SYMBOL_RESOLVER 0x0100
/*
* The N_ALT_ENTRY bit of the n_desc field indicates that the
* symbol is pinned to the previous content.
*/
#define N_ALT_ENTRY 0x0200
/*
* The N_COLD_FUNC bit of the n_desc field indicates that the symbol is used
* infrequently and the linker should order it towards the end of the section.
*/
#define N_COLD_FUNC 0x0400
#ifndef __STRICT_BSD__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*
* The function nlist(3) from the C library.
*/
extern int nlist (const char *filename, struct nlist *list);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __STRICT_BSD__ */
#endif /* _MACHO_LIST_H_ */

View File

@@ -0,0 +1,90 @@
/*
* Copyright (c) 2016 Apple, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/* ranlib.h 4.1 83/05/03 */
#ifndef _MACH_O_RANLIB_H_
#define _MACH_O_RANLIB_H_
#include <stdint.h>
#include <sys/types.h> /* off_t */
/*
* There are two known orders of table of contents for archives. The first is
* the order ranlib(1) originally produced and still produces without any
* options. This table of contents has the archive member name "__.SYMDEF"
* This order has the ranlib structures in the order the objects appear in the
* archive and the symbol names of those objects in the order of symbol table.
* The second know order is sorted by symbol name and is produced with the -s
* option to ranlib(1). This table of contents has the archive member name
* "__.SYMDEF SORTED" and many programs (notably the 1.0 version of ld(1) can't
* tell the difference between names because of the imbedded blank in the name
* and works with either table of contents). This second order is used by the
* post 1.0 link editor to produce faster linking. The original 1.0 version of
* ranlib(1) gets confused when it is run on a archive with the second type of
* table of contents because it and ar(1) which it uses use different ways to
* determined the member name (ar(1) treats all blanks in the name as
* significant and ranlib(1) only checks for the first one).
*/
#define SYMDEF "__.SYMDEF"
#define SYMDEF_SORTED "__.SYMDEF SORTED"
/*
* Structure of the __.SYMDEF table of contents for an archive.
* __.SYMDEF begins with a uint32_t giving the size in bytes of the ranlib
* structures which immediately follow, and then continues with a string
* table consisting of a uint32_t giving the number of bytes of strings which
* follow and then the strings themselves. The ran_strx fields index the
* string table whose first byte is numbered 0.
*/
struct ranlib {
union {
uint32_t ran_strx; /* string table index of */
#ifndef __LP64__
char *ran_name; /* symbol defined by */
#endif
} ran_un;
uint32_t ran_off; /* library member at this offset */
};
#define SYMDEF_64 "__.SYMDEF_64"
#define SYMDEF_64_SORTED "__.SYMDEF_64 SORTED"
/*
* The support for the 64-bit table of contents described here is a work in
* progress and not yet fully supported in all the Apple Developer Tools.
*
* When an archive offset to a library member is more than 32-bits then this is
* the structure of the __.SYMDEF_64 table of contents for an archive.
* __.SYMDEF_64 begins with a uint64_t giving the size in bytes of the ranlib
* structures which immediately follow, and then continues with a string
* table consisting of a uint64_t giving the number of bytes of strings which
* follow and then the strings themselves. The ran_strx fields index the
* string table whose first byte is numbered 0.
*/
struct ranlib_64 {
union {
uint64_t ran_strx; /* string table index of */
} ran_un;
uint64_t ran_off; /* library member at this offset */
};
#endif /* _MACH_O_RANLIB_H_ */

View File

@@ -0,0 +1,203 @@
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/* $NetBSD: exec.h,v 1.6 1994/10/27 04:16:05 cgd Exp $ */
/*
* Copyright (c) 1993 Christopher G. Demetriou
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _MACHO_RELOC_H_
#define _MACHO_RELOC_H_
#include <stdint.h>
/*
* Format of a relocation entry of a Mach-O file. Modified from the 4.3BSD
* format. The modifications from the original format were changing the value
* of the r_symbolnum field for "local" (r_extern == 0) relocation entries.
* This modification is required to support symbols in an arbitrary number of
* sections not just the three sections (text, data and bss) in a 4.3BSD file.
* Also the last 4 bits have had the r_type tag added to them.
*/
struct relocation_info {
int32_t r_address; /* offset in the section to what is being
relocated */
uint32_t r_symbolnum:24, /* symbol index if r_extern == 1 or section
ordinal if r_extern == 0 */
r_pcrel:1, /* was relocated pc relative already */
r_length:2, /* 0=byte, 1=word, 2=long, 3=quad */
r_extern:1, /* does not include value of sym referenced */
r_type:4; /* if not 0, machine specific relocation type */
};
#define R_ABS 0 /* absolute relocation type for Mach-O files */
/*
* The r_address is not really the address as it's name indicates but an offset.
* In 4.3BSD a.out objects this offset is from the start of the "segment" for
* which relocation entry is for (text or data). For Mach-O object files it is
* also an offset but from the start of the "section" for which the relocation
* entry is for. See comments in <mach-o/loader.h> about the r_address feild
* in images for used with the dynamic linker.
*
* In 4.3BSD a.out objects if r_extern is zero then r_symbolnum is an ordinal
* for the segment the symbol being relocated is in. These ordinals are the
* symbol types N_TEXT, N_DATA, N_BSS or N_ABS. In Mach-O object files these
* ordinals refer to the sections in the object file in the order their section
* structures appear in the headers of the object file they are in. The first
* section has the ordinal 1, the second 2, and so on. This means that the
* same ordinal in two different object files could refer to two different
* sections. And further could have still different ordinals when combined
* by the link-editor. The value R_ABS is used for relocation entries for
* absolute symbols which need no further relocation.
*/
/*
* For RISC machines some of the references are split across two instructions
* and the instruction does not contain the complete value of the reference.
* In these cases a second, or paired relocation entry, follows each of these
* relocation entries, using a PAIR r_type, which contains the other part of the
* reference not contained in the instruction. This other part is stored in the
* pair's r_address field. The exact number of bits of the other part of the
* reference store in the r_address field is dependent on the particular
* relocation type for the particular architecture.
*/
/*
* To make scattered loading by the link editor work correctly "local"
* relocation entries can't be used when the item to be relocated is the value
* of a symbol plus an offset (where the resulting expresion is outside the
* block the link editor is moving, a blocks are divided at symbol addresses).
* In this case. where the item is a symbol value plus offset, the link editor
* needs to know more than just the section the symbol was defined. What is
* needed is the actual value of the symbol without the offset so it can do the
* relocation correctly based on where the value of the symbol got relocated to
* not the value of the expression (with the offset added to the symbol value).
* So for the NeXT 2.0 release no "local" relocation entries are ever used when
* there is a non-zero offset added to a symbol. The "external" and "local"
* relocation entries remain unchanged.
*
* The implemention is quite messy given the compatibility with the existing
* relocation entry format. The ASSUMPTION is that a section will never be
* bigger than 2**24 - 1 (0x00ffffff or 16,777,215) bytes. This assumption
* allows the r_address (which is really an offset) to fit in 24 bits and high
* bit of the r_address field in the relocation_info structure to indicate
* it is really a scattered_relocation_info structure. Since these are only
* used in places where "local" relocation entries are used and not where
* "external" relocation entries are used the r_extern field has been removed.
*
* For scattered loading to work on a RISC machine where some of the references
* are split across two instructions the link editor needs to be assured that
* each reference has a unique 32 bit reference (that more than one reference is
* NOT sharing the same high 16 bits for example) so it move each referenced
* item independent of each other. Some compilers guarantees this but the
* compilers don't so scattered loading can be done on those that do guarantee
* this.
*/
#if defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__)
/*
* The reason for the ifdef's of __BIG_ENDIAN__ and __LITTLE_ENDIAN__ are that
* when stattered relocation entries were added the mistake of using a mask
* against a structure that is made up of bit fields was used. To make this
* design work this structure must be laid out in memory the same way so the
* mask can be applied can check the same bit each time (r_scattered).
*/
#endif /* defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__) */
#define R_SCATTERED 0x80000000 /* mask to be applied to the r_address field
of a relocation_info structure to tell that
is is really a scattered_relocation_info
stucture */
struct scattered_relocation_info {
#ifdef __BIG_ENDIAN__
uint32_t r_scattered:1, /* 1=scattered, 0=non-scattered (see above) */
r_pcrel:1, /* was relocated pc relative already */
r_length:2, /* 0=byte, 1=word, 2=long, 3=quad */
r_type:4, /* if not 0, machine specific relocation type */
r_address:24; /* offset in the section to what is being
relocated */
int32_t r_value; /* the value the item to be relocated is
refering to (without any offset added) */
#endif /* __BIG_ENDIAN__ */
#ifdef __LITTLE_ENDIAN__
uint32_t
r_address:24, /* offset in the section to what is being
relocated */
r_type:4, /* if not 0, machine specific relocation type */
r_length:2, /* 0=byte, 1=word, 2=long, 3=quad */
r_pcrel:1, /* was relocated pc relative already */
r_scattered:1; /* 1=scattered, 0=non-scattered (see above) */
int32_t r_value; /* the value the item to be relocated is
refering to (without any offset added) */
#endif /* __LITTLE_ENDIAN__ */
};
/*
* Relocation types used in a generic implementation. Relocation entries for
* normal things use the generic relocation as discribed above and their r_type
* is GENERIC_RELOC_VANILLA (a value of zero).
*
* Another type of generic relocation, GENERIC_RELOC_SECTDIFF, is to support
* the difference of two symbols defined in different sections. That is the
* expression "symbol1 - symbol2 + constant" is a relocatable expression when
* both symbols are defined in some section. For this type of relocation the
* both relocations entries are scattered relocation entries. The value of
* symbol1 is stored in the first relocation entry's r_value field and the
* value of symbol2 is stored in the pair's r_value field.
*
* A special case for a prebound lazy pointer is needed to beable to set the
* value of the lazy pointer back to its non-prebound state. This is done
* using the GENERIC_RELOC_PB_LA_PTR r_type. This is a scattered relocation
* entry where the r_value feild is the value of the lazy pointer not prebound.
*/
enum reloc_type_generic
{
GENERIC_RELOC_VANILLA, /* generic relocation as discribed above */
GENERIC_RELOC_PAIR, /* Only follows a GENERIC_RELOC_SECTDIFF */
GENERIC_RELOC_SECTDIFF,
GENERIC_RELOC_PB_LA_PTR, /* prebound lazy pointer */
GENERIC_RELOC_LOCAL_SECTDIFF,
GENERIC_RELOC_TLV /* thread local variables */
};
#endif /* _MACHO_RELOC_H_ */

View File

@@ -0,0 +1,126 @@
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _MACHO_STAB_H_
#define _MACHO_STAB_H_
/* $NetBSD: stab.h,v 1.4 1994/10/26 00:56:25 cgd Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)stab.h 5.2 (Berkeley) 4/4/91
*/
/*
* This file gives definitions supplementing <nlist.h> for permanent symbol
* table entries of Mach-O files. Modified from the BSD definitions. The
* modifications from the original definitions were changing what the values of
* what was the n_other field (an unused field) which is now the n_sect field.
* These modifications are required to support symbols in an arbitrary number of
* sections not just the three sections (text, data and bss) in a BSD file.
* The values of the defined constants have NOT been changed.
*
* These must have one of the N_STAB bits on. The n_value fields are subject
* to relocation according to the value of their n_sect field. So for types
* that refer to things in sections the n_sect field must be filled in with the
* proper section ordinal. For types that are not to have their n_value field
* relocatated the n_sect field must be NO_SECT.
*/
/*
* Symbolic debugger symbols. The comments give the conventional use for
*
* .stabs "n_name", n_type, n_sect, n_desc, n_value
*
* where n_type is the defined constant and not listed in the comment. Other
* fields not listed are zero. n_sect is the section ordinal the entry is
* refering to.
*/
#define N_GSYM 0x20 /* global symbol: name,,NO_SECT,type,0 */
#define N_FNAME 0x22 /* procedure name (f77 kludge): name,,NO_SECT,0,0 */
#define N_FUN 0x24 /* procedure: name,,n_sect,linenumber,address */
#define N_STSYM 0x26 /* static symbol: name,,n_sect,type,address */
#define N_LCSYM 0x28 /* .lcomm symbol: name,,n_sect,type,address */
#define N_BNSYM 0x2e /* begin nsect sym: 0,,n_sect,0,address */
#define N_AST 0x32 /* AST file path: name,,NO_SECT,0,0 */
#define N_OPT 0x3c /* emitted with gcc2_compiled and in gcc source */
#define N_RSYM 0x40 /* register sym: name,,NO_SECT,type,register */
#define N_SLINE 0x44 /* src line: 0,,n_sect,linenumber,address */
#define N_ENSYM 0x4e /* end nsect sym: 0,,n_sect,0,address */
#define N_SSYM 0x60 /* structure elt: name,,NO_SECT,type,struct_offset */
#define N_SO 0x64 /* source file name: name,,n_sect,0,address */
#define N_OSO 0x66 /* object file name: name,,(see below),0,st_mtime */
/* historically N_OSO set n_sect to 0. The N_OSO
* n_sect may instead hold the low byte of the
* cpusubtype value from the Mach-O header. */
#define N_LSYM 0x80 /* local sym: name,,NO_SECT,type,offset */
#define N_BINCL 0x82 /* include file beginning: name,,NO_SECT,0,sum */
#define N_SOL 0x84 /* #included file name: name,,n_sect,0,address */
#define N_PARAMS 0x86 /* compiler parameters: name,,NO_SECT,0,0 */
#define N_VERSION 0x88 /* compiler version: name,,NO_SECT,0,0 */
#define N_OLEVEL 0x8A /* compiler -O level: name,,NO_SECT,0,0 */
#define N_PSYM 0xa0 /* parameter: name,,NO_SECT,type,offset */
#define N_EINCL 0xa2 /* include file end: name,,NO_SECT,0,0 */
#define N_ENTRY 0xa4 /* alternate entry: name,,n_sect,linenumber,address */
#define N_LBRAC 0xc0 /* left bracket: 0,,NO_SECT,nesting level,address */
#define N_EXCL 0xc2 /* deleted include file: name,,NO_SECT,0,sum */
#define N_RBRAC 0xe0 /* right bracket: 0,,NO_SECT,nesting level,address */
#define N_BCOMM 0xe2 /* begin common: name,,NO_SECT,0,0 */
#define N_ECOMM 0xe4 /* end common: name,,n_sect,0,0 */
#define N_ECOML 0xe8 /* end common (local name): 0,,n_sect,0,address */
#define N_LENG 0xfe /* second stab entry with length information */
/*
* for the berkeley pascal compiler, pc(1):
*/
#define N_PC 0x30 /* global pascal symbol: name,,NO_SECT,subtype,line */
#endif /* _MACHO_STAB_H_ */

View File

@@ -0,0 +1,185 @@
/*
* Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* Relocations for x86_64 are a bit different than for other architectures in
* Mach-O: Scattered relocations are not used. Almost all relocations produced
* by the compiler are external relocations. An external relocation has the
* r_extern bit set to 1 and the r_symbolnum field contains the symbol table
* index of the target label.
*
* When the assembler is generating relocations, if the target label is a local
* label (begins with 'L'), then the previous non-local label in the same
* section is used as the target of the external relocation. An addend is used
* with the distance from that non-local label to the target label. Only when
* there is no previous non-local label in the section is an internal
* relocation used.
*
* The addend (i.e. the 4 in _foo+4) is encoded in the instruction (Mach-O does
* not have RELA relocations). For PC-relative relocations, the addend is
* stored directly in the instruction. This is different from other Mach-O
* architectures, which encode the addend minus the current section offset.
*
* The relocation types are:
*
* X86_64_RELOC_UNSIGNED // for absolute addresses
* X86_64_RELOC_SIGNED // for signed 32-bit displacement
* X86_64_RELOC_BRANCH // a CALL/JMP instruction with 32-bit displacement
* X86_64_RELOC_GOT_LOAD // a MOVQ load of a GOT entry
* X86_64_RELOC_GOT // other GOT references
* X86_64_RELOC_SUBTRACTOR // must be followed by a X86_64_RELOC_UNSIGNED
*
* The following are sample assembly instructions, followed by the relocation
* and section content they generate in an object file:
*
* call _foo
* r_type=X86_64_RELOC_BRANCH, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* E8 00 00 00 00
*
* call _foo+4
* r_type=X86_64_RELOC_BRANCH, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* E8 04 00 00 00
*
* movq _foo@GOTPCREL(%rip), %rax
* r_type=X86_64_RELOC_GOT_LOAD, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* 48 8B 05 00 00 00 00
*
* pushq _foo@GOTPCREL(%rip)
* r_type=X86_64_RELOC_GOT, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* FF 35 00 00 00 00
*
* movl _foo(%rip), %eax
* r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* 8B 05 00 00 00 00
*
* movl _foo+4(%rip), %eax
* r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* 8B 05 04 00 00 00
*
* movb $0x12, _foo(%rip)
* r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* C6 05 FF FF FF FF 12
*
* movl $0x12345678, _foo(%rip)
* r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* C7 05 FC FF FF FF 78 56 34 12
*
* .quad _foo
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo
* 00 00 00 00 00 00 00 00
*
* .quad _foo+4
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo
* 04 00 00 00 00 00 00 00
*
* .quad _foo - _bar
* r_type=X86_64_RELOC_SUBTRACTOR, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_bar
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo
* 00 00 00 00 00 00 00 00
*
* .quad _foo - _bar + 4
* r_type=X86_64_RELOC_SUBTRACTOR, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_bar
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo
* 04 00 00 00 00 00 00 00
*
* .long _foo - _bar
* r_type=X86_64_RELOC_SUBTRACTOR, r_length=2, r_extern=1, r_pcrel=0, r_symbolnum=_bar
* r_type=X86_64_RELOC_UNSIGNED, r_length=2, r_extern=1, r_pcrel=0, r_symbolnum=_foo
* 00 00 00 00
*
* lea L1(%rip), %rax
* r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_prev
* 48 8d 05 12 00 00 00
* // assumes _prev is the first non-local label 0x12 bytes before L1
*
* lea L0(%rip), %rax
* r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=0, r_pcrel=1, r_symbolnum=3
* 48 8d 05 56 00 00 00
* // assumes L0 is in third section and there is no previous non-local label.
* // The rip-relative-offset of 0x00000056 is L0-address_of_next_instruction.
* // address_of_next_instruction is the address of the relocation + 4.
*
* add $6,L0(%rip)
* r_type=X86_64_RELOC_SIGNED_1, r_length=2, r_extern=0, r_pcrel=1, r_symbolnum=3
* 83 05 18 00 00 00 06
* // assumes L0 is in third section and there is no previous non-local label.
* // The rip-relative-offset of 0x00000018 is L0-address_of_next_instruction.
* // address_of_next_instruction is the address of the relocation + 4 + 1.
* // The +1 comes from SIGNED_1. This is used because the relocation is not
* // at the end of the instruction.
*
* .quad L1
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_prev
* 12 00 00 00 00 00 00 00
* // assumes _prev is the first non-local label 0x12 bytes before L1
*
* .quad L0
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=0, r_pcrel=0, r_symbolnum=3
* 56 00 00 00 00 00 00 00
* // assumes L0 is in third section, has an address of 0x00000056 in .o
* // file, and there is no previous non-local label
*
* .quad _foo - .
* r_type=X86_64_RELOC_SUBTRACTOR, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_prev
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo
* EE FF FF FF FF FF FF FF
* // assumes _prev is the first non-local label 0x12 bytes before this
* // .quad
*
* .quad _foo - L1
* r_type=X86_64_RELOC_SUBTRACTOR, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_prev
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo
* EE FF FF FF FF FF FF FF
* // assumes _prev is the first non-local label 0x12 bytes before L1
*
* .quad L1 - _prev
* // No relocations. This is an assembly time constant.
* 12 00 00 00 00 00 00 00
* // assumes _prev is the first non-local label 0x12 bytes before L1
*
*
*
* In final linked images, there are only two valid relocation kinds:
*
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_pcrel=0, r_extern=1, r_symbolnum=sym_index
* This tells dyld to add the address of a symbol to a pointer sized (8-byte)
* piece of data (i.e on disk the 8-byte piece of data contains the addend). The
* r_symbolnum contains the index into the symbol table of the target symbol.
*
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_pcrel=0, r_extern=0, r_symbolnum=0
* This tells dyld to adjust the pointer sized (8-byte) piece of data by the amount
* the containing image was loaded from its base address (e.g. slide).
*
*/
enum reloc_type_x86_64
{
X86_64_RELOC_UNSIGNED, // for absolute addresses
X86_64_RELOC_SIGNED, // for signed 32-bit displacement
X86_64_RELOC_BRANCH, // a CALL/JMP instruction with 32-bit displacement
X86_64_RELOC_GOT_LOAD, // a MOVQ load of a GOT entry
X86_64_RELOC_GOT, // other GOT references
X86_64_RELOC_SUBTRACTOR, // must be followed by a X86_64_RELOC_UNSIGNED
X86_64_RELOC_SIGNED_1, // for signed 32-bit displacement with a -1 addend
X86_64_RELOC_SIGNED_2, // for signed 32-bit displacement with a -2 addend
X86_64_RELOC_SIGNED_4, // for signed 32-bit displacement with a -4 addend
X86_64_RELOC_TLV, // for thread local variables
};

View File

@@ -327,6 +327,14 @@
/* Denied by security policy
*/
#define KERN_MISSING_KC 54
/* The KC on which the function is operating is missing
*/
#define KERN_INVALID_KC 55
/* The KC on which the function is operating is invalid
*/
#define KERN_RETURN_MAX 0x100
/* Maximum return value allowable
*/

View File

@@ -102,6 +102,11 @@ extern kern_return_t _kernelrpc_mach_vm_deallocate_trap(
mach_vm_size_t size
);
extern kern_return_t task_dyld_process_info_notify_get(
mach_port_name_array_t names_addr,
natural_t *names_count_addr
);
extern kern_return_t _kernelrpc_mach_vm_protect_trap(
mach_port_name_t target,
mach_vm_address_t address,

View File

@@ -146,6 +146,7 @@ typedef mach_port_t arcade_register_t;
typedef mach_port_t ipc_eventlink_t;
typedef mach_port_t eventlink_port_pair_t[2];
typedef mach_port_t suid_cred_t;
typedef mach_port_t task_id_token_t;
/*
@@ -168,6 +169,8 @@ typedef mach_port_t io_master_t;
typedef mach_port_t UNDServerRef;
typedef mach_port_t mach_eventlink_t;
typedef ipc_info_port_t exception_handler_info_t;
/*
* Mig doesn't translate the components of an array.
* For example, Mig won't use the thread_t translations
@@ -246,25 +249,26 @@ typedef uint32_t suid_cred_uid_t;
#define MACH_EVENTLINK_NULL ((mach_eventlink_t) 0)
#define IPC_EVENTLINK_NULL ((ipc_eventlink_t) 0)
#define SUID_CRED_NULL ((suid_cred_t) 0)
#define TASK_ID_TOKEN_NULL ((task_id_token_t) 0)
/* capability strictly _DECREASING_.
* not ordered the other way around because we want TASK_FLAVOR_CONTROL
* to be closest to the itk_lock. see task.h.
*/
typedef unsigned int mach_task_flavor_t;
#define TASK_FLAVOR_CONTROL 0 /* a task_t */
#define TASK_FLAVOR_CONTROL 0 /* a task_t */
#define TASK_FLAVOR_READ 1 /* a task_read_t */
#define TASK_FLAVOR_INSPECT 2 /* a task_inspect_t */
#define TASK_FLAVOR_NAME 3 /* a task_name_t */
/* capability strictly _DECREASING_ */
typedef unsigned int mach_thread_flavor_t;
#define THREAD_FLAVOR_CONTROL 0 /* a thread_t */
#define THREAD_FLAVOR_CONTROL 0 /* a thread_t */
#define THREAD_FLAVOR_READ 1 /* a thread_read_t */
#define THREAD_FLAVOR_INSPECT 2 /* a thread_inspect_t */
/* DEPRECATED */
typedef natural_t ledger_item_t;
typedef natural_t ledger_item_t;
#define LEDGER_ITEM_INFINITY ((ledger_item_t) (~0))
typedef int64_t ledger_amount_t;

View File

@@ -376,9 +376,7 @@ typedef integer_t cpu_threadtype_t;
#define CPUFAMILY_INTEL_SKYLAKE 0x37fc219f
#define CPUFAMILY_INTEL_KABYLAKE 0x0f817246
#define CPUFAMILY_INTEL_ICELAKE 0x38435547
#if !defined(RC_HIDE_XNU_COMETLAKE)
#define CPUFAMILY_INTEL_COMETLAKE 0x1cf8a03e
#endif /* not RC_HIDE_XNU_COMETLAKE */
#define CPUFAMILY_ARM_9 0xe73283ae
#define CPUFAMILY_ARM_11 0x8ff620d8
#define CPUFAMILY_ARM_XSCALE 0x53b005f5

View File

@@ -211,7 +211,6 @@ typedef mach_port_type_t *mach_port_type_array_t;
#define MACH_PORT_TYPE_LABELH MACH_PORT_TYPE(MACH_PORT_RIGHT_LABELH) /* obsolete */
/* Convenient combinations. */
#define MACH_PORT_TYPE_SEND_RECEIVE \
@@ -388,9 +387,16 @@ enum mach_port_guard_exception_codes {
kGUARD_EXC_SEND_INVALID_RIGHT = 1u << 18,
kGUARD_EXC_RCV_INVALID_NAME = 1u << 19,
kGUARD_EXC_RCV_GUARDED_DESC = 1u << 20, /* should never be fatal; for development only */
kGUARD_EXC_MOD_REFS_NON_FATAL = 1u << 21,
kGUARD_EXC_IMMOVABLE_NON_FATAL = 1u << 22,
};
#define MAX_FATAL_kGUARD_EXC_CODE (1u << 6)
#define MAX_FATAL_kGUARD_EXC_CODE (1u << 7)
/*
* Mach port guard flags.
*/
#define MPG_FLAGS_NONE (0x00ull)
/*
* These flags are used as bits in the subcode of kGUARD_EXC_STRICT_REPLY exceptions.
@@ -402,6 +408,16 @@ enum mach_port_guard_exception_codes {
#define MPG_FLAGS_STRICT_REPLY_MISMATCHED_PERSONA (0x10ull << 56)
#define MPG_FLAGS_STRICT_REPLY_MASK (0xffull << 56)
/*
* These flags are used as bits in the subcode of kGUARD_EXC_MOD_REFS exceptions.
*/
#define MPG_FLAGS_MOD_REFS_PINNED_DEALLOC (0x01ull << 56)
/*
* These flags are used as bits in the subcode of kGUARD_EXC_IMMOVABLE exceptions.
*/
#define MPG_FLAGS_IMMOVABLE_PINNED (0x01ull << 56)
/*
* Flags for mach_port_guard_with_flags. These flags extend
* the attributes associated with a guarded port.

View File

@@ -49,7 +49,7 @@ typedef function_table_entry *function_table_t;
#endif /* AUTOTEST */
#ifndef task_MSG_COUNT
#define task_MSG_COUNT 55
#define task_MSG_COUNT 61
#endif /* task_MSG_COUNT */
#include <mach/std_types.h>
@@ -175,7 +175,7 @@ __WATCHOS_PROHIBITED
__TVOS_PROHIBITED
kern_return_t task_suspend
(
task_t target_task
task_read_t target_task
);
/* Routine task_resume */
@@ -188,7 +188,7 @@ __WATCHOS_PROHIBITED
__TVOS_PROHIBITED
kern_return_t task_resume
(
task_t target_task
task_read_t target_task
);
/* Routine task_get_special_port */
@@ -305,7 +305,7 @@ kern_return_t task_swap_exception_ports
thread_state_flavor_t new_flavor,
exception_mask_array_t masks,
mach_msg_type_number_t *masksCnt,
exception_handler_array_t old_handlerss,
exception_handler_array_t old_handlers,
exception_behavior_array_t old_behaviors,
exception_flavor_array_t old_flavors
);
@@ -606,7 +606,7 @@ __WATCHOS_PROHIBITED
__TVOS_PROHIBITED
kern_return_t task_suspend2
(
task_t target_task,
task_read_t target_task,
task_suspension_token_t *suspend_token
);
@@ -687,7 +687,7 @@ extern
#endif /* mig_external */
kern_return_t task_generate_corpse
(
task_t task,
task_read_t task,
mach_port_t *corpse_task_port
);
@@ -848,6 +848,72 @@ kern_return_t task_create_suid_cred
suid_cred_t *delegation
);
/* Routine task_dyld_process_info_notify_register */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t task_dyld_process_info_notify_register
(
task_read_t target_task,
mach_port_t notify
);
/* Routine task_create_identity_token */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t task_create_identity_token
(
task_t task,
task_id_token_t *token
);
/* Routine task_identity_token_get_task_port */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t task_identity_token_get_task_port
(
task_id_token_t token,
task_flavor_t flavor,
mach_port_t *task_port
);
/* Routine task_dyld_process_info_notify_deregister */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t task_dyld_process_info_notify_deregister
(
task_read_t target_task,
mach_port_name_t notify
);
/* Routine task_get_exception_ports_info */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t task_get_exception_ports_info
(
mach_port_t port,
exception_mask_t exception_mask,
exception_mask_array_t masks,
mach_msg_type_number_t *masksCnt,
exception_handler_info_array_t old_handlers_info,
exception_behavior_array_t old_behaviors,
exception_flavor_array_t old_flavors
);
__END_DECLS
/********************** Caution **************************/
@@ -1586,6 +1652,66 @@ __END_DECLS
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
/* start of the kernel processed data */
mach_msg_body_t msgh_body;
mach_msg_port_descriptor_t notify;
/* end of the kernel processed data */
} __Request__task_dyld_process_info_notify_register_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
} __Request__task_create_identity_token_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
task_flavor_t flavor;
} __Request__task_identity_token_get_task_port_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
mach_port_name_t notify;
} __Request__task_dyld_process_info_notify_deregister_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
exception_mask_t exception_mask;
} __Request__task_get_exception_ports_info_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Request__task_subsystem__defined */
/* union of all requests */
@@ -1648,6 +1774,11 @@ union __RequestUnion__task_subsystem {
__Request__task_get_exc_guard_behavior_t Request_task_get_exc_guard_behavior;
__Request__task_set_exc_guard_behavior_t Request_task_set_exc_guard_behavior;
__Request__task_create_suid_cred_t Request_task_create_suid_cred;
__Request__task_dyld_process_info_notify_register_t Request_task_dyld_process_info_notify_register;
__Request__task_create_identity_token_t Request_task_create_identity_token;
__Request__task_identity_token_get_task_port_t Request_task_identity_token_get_task_port;
__Request__task_dyld_process_info_notify_deregister_t Request_task_dyld_process_info_notify_deregister;
__Request__task_get_exception_ports_info_t Request_task_get_exception_ports_info;
};
#endif /* !__RequestUnion__task_subsystem__defined */
/* typedefs for all replies */
@@ -1867,7 +1998,7 @@ union __RequestUnion__task_subsystem {
mach_msg_header_t Head;
/* start of the kernel processed data */
mach_msg_body_t msgh_body;
mach_msg_port_descriptor_t old_handlerss[32];
mach_msg_port_descriptor_t old_handlers[32];
/* end of the kernel processed data */
NDR_record_t NDR;
mach_msg_type_number_t masksCnt;
@@ -2392,6 +2523,75 @@ union __RequestUnion__task_subsystem {
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
} __Reply__task_dyld_process_info_notify_register_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
/* start of the kernel processed data */
mach_msg_body_t msgh_body;
mach_msg_port_descriptor_t token;
/* end of the kernel processed data */
} __Reply__task_create_identity_token_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
/* start of the kernel processed data */
mach_msg_body_t msgh_body;
mach_msg_port_descriptor_t task_port;
/* end of the kernel processed data */
} __Reply__task_identity_token_get_task_port_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
} __Reply__task_dyld_process_info_notify_deregister_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
mach_msg_type_number_t masksCnt;
exception_mask_t masks[32];
exception_handler_info_t old_handlers_info[32];
exception_behavior_t old_behaviors[32];
thread_state_flavor_t old_flavors[32];
} __Reply__task_get_exception_ports_info_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Reply__task_subsystem__defined */
/* union of all replies */
@@ -2454,6 +2654,11 @@ union __ReplyUnion__task_subsystem {
__Reply__task_get_exc_guard_behavior_t Reply_task_get_exc_guard_behavior;
__Reply__task_set_exc_guard_behavior_t Reply_task_set_exc_guard_behavior;
__Reply__task_create_suid_cred_t Reply_task_create_suid_cred;
__Reply__task_dyld_process_info_notify_register_t Reply_task_dyld_process_info_notify_register;
__Reply__task_create_identity_token_t Reply_task_create_identity_token;
__Reply__task_identity_token_get_task_port_t Reply_task_identity_token_get_task_port;
__Reply__task_dyld_process_info_notify_deregister_t Reply_task_dyld_process_info_notify_deregister;
__Reply__task_get_exception_ports_info_t Reply_task_get_exception_ports_info;
};
#endif /* !__RequestUnion__task_subsystem__defined */
@@ -2513,7 +2718,12 @@ union __ReplyUnion__task_subsystem {
{ "task_inspect", 3451 },\
{ "task_get_exc_guard_behavior", 3452 },\
{ "task_set_exc_guard_behavior", 3453 },\
{ "task_create_suid_cred", 3454 }
{ "task_create_suid_cred", 3454 },\
{ "task_dyld_process_info_notify_register", 3456 },\
{ "task_create_identity_token", 3457 },\
{ "task_identity_token_get_task_port", 3458 },\
{ "task_dyld_process_info_notify_deregister", 3459 },\
{ "task_get_exception_ports_info", 3460 }
#endif
#ifdef __AfterMigUserHeader

View File

@@ -81,7 +81,9 @@ typedef int task_special_port_t;
#define TASK_READ_PORT 6 /* The read port for task. */
/*
* Evolving and likely to change.
*/
#define TASK_SEATBELT_PORT 7 /* Seatbelt compiler/DEM port for task. */

View File

@@ -49,7 +49,7 @@ typedef function_table_entry *function_table_t;
#endif /* AUTOTEST */
#ifndef thread_act_MSG_COUNT
#define thread_act_MSG_COUNT 29
#define thread_act_MSG_COUNT 31
#endif /* thread_act_MSG_COUNT */
#include <mach/std_types.h>
@@ -149,7 +149,7 @@ extern
__WATCHOS_PROHIBITED
kern_return_t thread_suspend
(
thread_act_t target_act
thread_read_t target_act
);
/* Routine thread_resume */
@@ -161,7 +161,7 @@ extern
__WATCHOS_PROHIBITED
kern_return_t thread_resume
(
thread_act_t target_act
thread_read_t target_act
);
/* Routine thread_abort */
@@ -484,6 +484,23 @@ kern_return_t thread_convert_thread_state
mach_msg_type_number_t *out_stateCnt
);
/* Routine thread_get_exception_ports_info */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t thread_get_exception_ports_info
(
mach_port_t port,
exception_mask_t exception_mask,
exception_mask_array_t masks,
mach_msg_type_number_t *masksCnt,
exception_handler_info_array_t old_handlers_info,
exception_behavior_array_t old_behaviors,
exception_flavor_array_t old_flavors
);
__END_DECLS
/********************** Caution **************************/
@@ -884,6 +901,18 @@ __END_DECLS
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
exception_mask_t exception_mask;
} __Request__thread_get_exception_ports_info_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Request__thread_act_subsystem__defined */
/* union of all requests */
@@ -920,6 +949,7 @@ union __RequestUnion__thread_act_subsystem {
__Request__thread_set_mach_voucher_t Request_thread_set_mach_voucher;
__Request__thread_swap_mach_voucher_t Request_thread_swap_mach_voucher;
__Request__thread_convert_thread_state_t Request_thread_convert_thread_state;
__Request__thread_get_exception_ports_info_t Request_thread_get_exception_ports_info;
};
#endif /* !__RequestUnion__thread_act_subsystem__defined */
/* typedefs for all replies */
@@ -1307,6 +1337,23 @@ union __RequestUnion__thread_act_subsystem {
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
mach_msg_type_number_t masksCnt;
exception_mask_t masks[32];
exception_handler_info_t old_handlers_info[32];
exception_behavior_t old_behaviors[32];
thread_state_flavor_t old_flavors[32];
} __Reply__thread_get_exception_ports_info_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Reply__thread_act_subsystem__defined */
/* union of all replies */
@@ -1343,6 +1390,7 @@ union __ReplyUnion__thread_act_subsystem {
__Reply__thread_set_mach_voucher_t Reply_thread_set_mach_voucher;
__Reply__thread_swap_mach_voucher_t Reply_thread_swap_mach_voucher;
__Reply__thread_convert_thread_state_t Reply_thread_convert_thread_state;
__Reply__thread_get_exception_ports_info_t Reply_thread_get_exception_ports_info;
};
#endif /* !__RequestUnion__thread_act_subsystem__defined */
@@ -1376,7 +1424,8 @@ union __ReplyUnion__thread_act_subsystem {
{ "thread_get_mach_voucher", 3625 },\
{ "thread_set_mach_voucher", 3626 },\
{ "thread_swap_mach_voucher", 3627 },\
{ "thread_convert_thread_state", 3628 }
{ "thread_convert_thread_state", 3628 },\
{ "thread_get_exception_ports_info", 3630 }
#endif
#ifdef __AfterMigUserHeader

View File

@@ -73,6 +73,7 @@
#define THREAD_READ_PORT 3 /* The read port for thread. */
#define THREAD_MAX_SPECIAL_PORT THREAD_READ_PORT
/*
* Definitions for ease of use
*/

View File

@@ -272,6 +272,7 @@ typedef struct vm_purgeable_info *vm_purgeable_info_t;
#define VM_FLAGS_NO_CACHE 0x0010
#define VM_FLAGS_RESILIENT_CODESIGN 0x0020
#define VM_FLAGS_RESILIENT_MEDIA 0x0040
#define VM_FLAGS_PERMANENT 0x0080
#define VM_FLAGS_OVERWRITE 0x4000 /* delete any existing mappings first */
/*
* VM_FLAGS_SUPERPAGE_MASK
@@ -295,6 +296,7 @@ typedef struct vm_purgeable_info *vm_purgeable_info_t;
VM_FLAGS_4GB_CHUNK | \
VM_FLAGS_RANDOM_ADDR | \
VM_FLAGS_NO_CACHE | \
VM_FLAGS_PERMANENT | \
VM_FLAGS_OVERWRITE | \
VM_FLAGS_SUPERPAGE_MASK | \
VM_FLAGS_ALIAS_MASK)

View File

@@ -127,7 +127,8 @@ struct rt_metrics {
#define RTF_PROXY 0x8000000 /* proxying, no interface scope */
#define RTF_ROUTER 0x10000000 /* host is a router */
#define RTF_DEAD 0x20000000 /* Route entry is being freed */
/* 0x40000000 and up unassigned */
#define RTF_GLOBAL 0x40000000 /* route to destination of the global internet */
/* 0x80000000 unassigned */
#define RTPRF_OURS RTF_PROTO3 /* set on routes we manage */
#define RTF_BITS \
@@ -135,7 +136,7 @@ struct rt_metrics {
"\10DELCLONE\11CLONING\12XRESOLVE\13LLINFO\14STATIC\15BLACKHOLE" \
"\16NOIFREF\17PROTO2\20PROTO1\21PRCLONING\22WASCLONED\23PROTO3" \
"\25PINNED\26LOCAL\27BROADCAST\30MULTICAST\31IFSCOPE\32CONDEMNED" \
"\33IFREF\34PROXY\35ROUTER"
"\33IFREF\34PROXY\35ROUTER\37GLOBAL"
#define IS_DIRECT_HOSTROUTE(rt) \
(((rt)->rt_flags & (RTF_HOST | RTF_GATEWAY)) == RTF_HOST)

View File

@@ -283,4 +283,22 @@
# endif
#endif
/* OBJC_COLD: very rarely called, e.g. on error path */
#if !defined(OBJC_COLD)
# if __OBJC__ && __has_attribute(cold)
# define OBJC_COLD __attribute__((cold))
# else
# define OBJC_COLD
# endif
#endif
/* OBJC_NORETURN: does not return normally, but may throw */
#if !defined(OBJC_NORETURN)
# if __OBJC__ && __has_attribute(noreturn)
# define OBJC_NORETURN __attribute__((noreturn))
# else
# define OBJC_NORETURN
# endif
#endif
#endif

View File

@@ -557,11 +557,11 @@ __API_AVAILABLE(macos(10.4), ios(2.0))
void pthread_yield_np(void);
__API_AVAILABLE(macos(11.0))
__API_UNAVAILABLE(ios, tvos, watchos)
__API_UNAVAILABLE(ios, tvos, watchos, driverkit)
void pthread_jit_write_protect_np(int enabled);
__API_AVAILABLE(macos(11.0))
__API_UNAVAILABLE(ios, tvos, watchos)
__API_UNAVAILABLE(ios, tvos, watchos, driverkit)
int pthread_jit_write_protect_supported_np(void);
/*!

View File

@@ -15,7 +15,7 @@
*
* <pre>
* @textblock
* simd_float4 vector = *(packed_simd_float4 *)&array[i];
* simd_float4 vector = *(simd_packed_float4 *)&array[i];
* // do something with vector ...
* @/textblock
* </pre>

View File

@@ -335,6 +335,12 @@
#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_3(x)
#endif
#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 140500
#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_5(x) x
#else
#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_5(x)
#endif
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1000
#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_0(x) x
#else
@@ -543,4 +549,10 @@
#define __DARWIN_ALIAS_STARTING_MAC___MAC_11_1(x) x
#else
#define __DARWIN_ALIAS_STARTING_MAC___MAC_11_1(x)
#endif
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 110300
#define __DARWIN_ALIAS_STARTING_MAC___MAC_11_3(x) x
#else
#define __DARWIN_ALIAS_STARTING_MAC___MAC_11_3(x)
#endif

View File

@@ -80,6 +80,8 @@
#include <mach/boolean.h>
#include <Availability.h>
struct session;
struct pgrp;

View File

@@ -0,0 +1,40 @@
/*
* Copyright (c) 1999, 2000-2005 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef __SYS_RANDOM_H__
#define __SYS_RANDOM_H__
#include <sys/appleapiopts.h>
#include <sys/cdefs.h>
__BEGIN_DECLS
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0)
int getentropy(void* buffer, size_t size);
__END_DECLS
#endif /* __SYS_RANDOM_H__ */

View File

@@ -457,6 +457,8 @@ struct proc_rlimit_control_wakeupmon {
#define IOPOL_TYPE_VFS_STATFS_NO_DATA_VOLUME 4
#define IOPOL_TYPE_VFS_TRIGGER_RESOLVE 5
#define IOPOL_TYPE_VFS_IGNORE_CONTENT_PROTECTION 6
#define IOPOL_TYPE_VFS_IGNORE_PERMISSIONS 7
#define IOPOL_TYPE_VFS_SKIP_MTIME_UPDATE 8
/* scope */
#define IOPOL_SCOPE_PROCESS 0
@@ -492,6 +494,12 @@ struct proc_rlimit_control_wakeupmon {
#define IOPOL_VFS_CONTENT_PROTECTION_DEFAULT 0
#define IOPOL_VFS_CONTENT_PROTECTION_IGNORE 1
#define IOPOL_VFS_IGNORE_PERMISSIONS_OFF 0
#define IOPOL_VFS_IGNORE_PERMISSIONS_ON 1
#define IOPOL_VFS_SKIP_MTIME_UPDATE_OFF 0
#define IOPOL_VFS_SKIP_MTIME_UPDATE_ON 1
#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */

View File

@@ -81,10 +81,10 @@
#include <sys/appleapiopts.h>
#include <sys/time.h>
#include <sys/ucred.h>
#include <sys/proc.h>
#include <sys/vm.h>
/*
* Definitions for sysctl call. The sysctl call uses a hierarchical name
* for objects that can be examined or modified. The name is expressed as
@@ -135,25 +135,26 @@ struct ctlname {
int ctl_type; /* type of name */
};
#define CTLTYPE 0xf /* Mask for the type */
#define CTLTYPE_NODE 1 /* name is a node */
#define CTLTYPE_INT 2 /* name describes an integer */
#define CTLTYPE_STRING 3 /* name describes a string */
#define CTLTYPE_QUAD 4 /* name describes a 64-bit number */
#define CTLTYPE_OPAQUE 5 /* name describes a structure */
#define CTLTYPE_STRUCT CTLTYPE_OPAQUE /* name describes a structure */
#define CTLTYPE 0xf /* Mask for the type */
#define CTLTYPE_NODE 1 /* name is a node */
#define CTLTYPE_INT 2 /* name describes an integer */
#define CTLTYPE_STRING 3 /* name describes a string */
#define CTLTYPE_QUAD 4 /* name describes a 64-bit number */
#define CTLTYPE_OPAQUE 5 /* name describes a structure */
#define CTLTYPE_STRUCT CTLTYPE_OPAQUE /* name describes a structure */
#define CTLFLAG_RD 0x80000000 /* Allow reads of variable */
#define CTLFLAG_WR 0x40000000 /* Allow writes to the variable */
#define CTLFLAG_RW (CTLFLAG_RD|CTLFLAG_WR)
#define CTLFLAG_NOLOCK 0x20000000 /* XXX Don't Lock */
#define CTLFLAG_ANYBODY 0x10000000 /* All users can set this var */
#define CTLFLAG_SECURE 0x08000000 /* Permit set only if securelevel<=0 */
#define CTLFLAG_MASKED 0x04000000 /* deprecated variable, do not display */
#define CTLFLAG_NOAUTO 0x02000000 /* do not auto-register */
#define CTLFLAG_KERN 0x01000000 /* valid inside the kernel */
#define CTLFLAG_LOCKED 0x00800000 /* node will handle locking itself */
#define CTLFLAG_OID2 0x00400000 /* struct sysctl_oid has version info */
#define CTLFLAG_RD 0x80000000 /* Allow reads of variable */
#define CTLFLAG_WR 0x40000000 /* Allow writes to the variable */
#define CTLFLAG_RW (CTLFLAG_RD|CTLFLAG_WR)
#define CTLFLAG_NOLOCK 0x20000000 /* XXX Don't Lock */
#define CTLFLAG_ANYBODY 0x10000000 /* All users can set this var */
#define CTLFLAG_SECURE 0x08000000 /* Permit set only if securelevel<=0 */
#define CTLFLAG_MASKED 0x04000000 /* deprecated variable, do not display */
#define CTLFLAG_NOAUTO 0x02000000 /* do not auto-register */
#define CTLFLAG_KERN 0x01000000 /* valid inside the kernel */
#define CTLFLAG_LOCKED 0x00800000 /* node will handle locking itself */
#define CTLFLAG_OID2 0x00400000 /* struct sysctl_oid has version info */
#define CTLFLAG_EXPERIMENT 0x00100000 /* Allows writing w/ the trial experiment entitlement. */
/*
* USE THIS instead of a hardwired number from the categories below
@@ -168,8 +169,8 @@ struct ctlname {
* in I/O-Kit. In this case, you have to call sysctl_register_oid()
* manually - just like in a KEXT.
*/
#define OID_AUTO (-1)
#define OID_AUTO_START 100 /* conventional */
#define OID_AUTO (-1)
#define OID_AUTO_START 100 /* conventional */
#define SYSCTL_DEF_ENABLED

View File

@@ -181,6 +181,7 @@
#include <mach/port.h>
#include <mach/thread_status.h>
#include <mach/machine/vm_types.h>
#include <mach_debug/ipc_info.h>
/*
* Exported types
*/
@@ -196,6 +197,7 @@ typedef exception_mask_t *exception_mask_array_t;
typedef exception_behavior_t *exception_behavior_array_t;
typedef thread_state_flavor_t *exception_flavor_array_t;
typedef mach_port_t *exception_port_array_t;
typedef ipc_info_port_t *exception_port_info_array_t;
typedef mach_exception_data_type_t mach_exception_code_t;
typedef mach_exception_data_type_t mach_exception_subcode_t;

View File

@@ -108,9 +108,10 @@
#define HOST_SYSPOLICYD_PORT (22 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_FILECOORDINATIOND_PORT (23 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_FAIRPLAYD_PORT (24 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_IOCOMPRESSIONSTATS_PORT (25 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_MAX_SPECIAL_PORT HOST_FAIRPLAYD_PORT
/* MAX = last since rdar://35861175 */
#define HOST_MAX_SPECIAL_PORT HOST_IOCOMPRESSIONSTATS_PORT
/* MAX = last since rdar://59872249 */
/* obsolete name */
#define HOST_CHUD_PORT HOST_LAUNCHCTL_PORT
@@ -274,6 +275,13 @@
#define host_set_fairplayd_port(host, port) \
(host_set_special_port((host), HOST_FAIRPLAYD_PORT, (port)))
#define host_get_iocompressionstats_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_IOCOMPRESSIONSTATS_PORT, (port)))
#define host_set_iocompressionstats_port(host, port) \
(host_set_special_port((host), HOST_IOCOMPRESSIONSTATS_PORT, (port)))
/* HOST_RESOURCE_NOTIFY_PORT doesn't #defines these conveniences.
* All lookups go through send_resource_violation()
*/

View File

@@ -64,6 +64,10 @@
#include <sys/cdefs.h>
#ifndef KERNEL
#include <Availability.h>
#endif
/*
* Kernel-related ports; how a task/thread controls itself
*/
@@ -71,6 +75,8 @@
__BEGIN_DECLS
extern mach_port_t mach_host_self(void);
extern mach_port_t mach_thread_self(void);
__API_AVAILABLE(macos(11.3), ios(14.5), tvos(14.5), watchos(7.3))
extern boolean_t mach_task_is_self(task_name_t task);
extern kern_return_t host_page_size(host_t, vm_size_t *);
extern mach_port_t mach_task_self_;

View File

@@ -79,6 +79,7 @@
#include <sys/cdefs.h>
#define VM_64_BIT_DATA_OBJECTS
typedef unsigned long long memory_object_offset_t;
@@ -95,6 +96,11 @@ typedef unsigned long long vm_object_id_t;
typedef mach_port_t memory_object_t;
/*
* vestigial, maintained for source compatibility,
* no MIG interface will accept or return non NULL
* objects for those.
*/
typedef mach_port_t memory_object_control_t;

View File

@@ -49,7 +49,7 @@ typedef function_table_entry *function_table_t;
#endif /* AUTOTEST */
#ifndef vm_map_MSG_COUNT
#define vm_map_MSG_COUNT 32
#define vm_map_MSG_COUNT 33
#endif /* vm_map_MSG_COUNT */
#include <mach/std_types.h>
@@ -493,6 +493,27 @@ kern_return_t vm_map_exec_lockdown
vm_map_t target_task
);
/* Routine vm_remap_new */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t vm_remap_new
(
vm_map_t target_task,
vm_address_t *target_address,
vm_size_t size,
vm_address_t mask,
int flags,
vm_map_read_t src_task,
vm_address_t src_address,
boolean_t copy,
vm_prot_t *cur_protection,
vm_prot_t *max_protection,
vm_inherit_t inheritance
);
__END_DECLS
/********************** Caution **************************/
@@ -924,6 +945,30 @@ __END_DECLS
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
/* start of the kernel processed data */
mach_msg_body_t msgh_body;
mach_msg_port_descriptor_t src_task;
/* end of the kernel processed data */
NDR_record_t NDR;
vm_address_t target_address;
vm_size_t size;
vm_address_t mask;
int flags;
vm_address_t src_address;
boolean_t copy;
vm_prot_t cur_protection;
vm_prot_t max_protection;
vm_inherit_t inheritance;
} __Request__vm_remap_new_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Request__vm_map_subsystem__defined */
/* union of all requests */
@@ -959,6 +1004,7 @@ union __RequestUnion__vm_map_subsystem {
__Request__vm_map_64_t Request_vm_map_64;
__Request__vm_purgable_control_t Request_vm_purgable_control;
__Request__vm_map_exec_lockdown_t Request_vm_map_exec_lockdown;
__Request__vm_remap_new_t Request_vm_remap_new;
};
#endif /* !__RequestUnion__vm_map_subsystem__defined */
/* typedefs for all replies */
@@ -1363,6 +1409,21 @@ union __RequestUnion__vm_map_subsystem {
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
vm_address_t target_address;
vm_prot_t cur_protection;
vm_prot_t max_protection;
} __Reply__vm_remap_new_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Reply__vm_map_subsystem__defined */
/* union of all replies */
@@ -1398,6 +1459,7 @@ union __ReplyUnion__vm_map_subsystem {
__Reply__vm_map_64_t Reply_vm_map_64;
__Reply__vm_purgable_control_t Reply_vm_purgable_control;
__Reply__vm_map_exec_lockdown_t Reply_vm_map_exec_lockdown;
__Reply__vm_remap_new_t Reply_vm_remap_new;
};
#endif /* !__RequestUnion__vm_map_subsystem__defined */
@@ -1430,7 +1492,8 @@ union __ReplyUnion__vm_map_subsystem {
{ "mach_make_memory_entry_64", 3825 },\
{ "vm_map_64", 3826 },\
{ "vm_purgable_control", 3830 },\
{ "vm_map_exec_lockdown", 3831 }
{ "vm_map_exec_lockdown", 3831 },\
{ "vm_remap_new", 3832 }
#endif
#ifdef __AfterMigUserHeader

View File

@@ -113,4 +113,11 @@ typedef struct ipc_info_tree_name {
typedef ipc_info_tree_name_t *ipc_info_tree_name_array_t;
typedef struct ipc_info_port {
natural_t iip_port_object; /* port object identifier */
natural_t iip_receiver_object; /* receiver task identifier (if any) */
} ipc_info_port_t;
typedef ipc_info_port_t *exception_handler_info_array_t;
#endif /* _MACH_DEBUG_IPC_INFO_H_ */

View File

@@ -190,9 +190,9 @@ int clock_settime(clockid_t __clock_id, const struct timespec *__tp);
#endif /* __DARWIN_C_LEVEL */
#endif /* _DARWIN_FEATURE_CLOCK_GETTIME */
#if (__DARWIN_C_LEVEL >= __DARWIN_C_FULL) && \
((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
(defined(__cplusplus) && __cplusplus >= 201703L))
#if (__DARWIN_C_LEVEL >= __DARWIN_C_FULL) || \
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
(defined(__cplusplus) && __cplusplus >= 201703L)
/* ISO/IEC 9899:201x 7.27.2.5 The timespec_get function */
#define TIME_UTC 1 /* time elapsed since epoch */
__API_AVAILABLE(macosx(10.15), ios(13.0), tvos(13.0), watchos(6.0))

View File

@@ -0,0 +1,204 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
#ifndef _MACH_EXCEPTION_TYPES_H_
#define _MACH_EXCEPTION_TYPES_H_
#include <mach/machine/exception.h>
/*
* Machine-independent exception definitions.
*/
#define EXC_BAD_ACCESS 1 /* Could not access memory */
/* Code contains kern_return_t describing error. */
/* Subcode contains bad memory address. */
#define EXC_BAD_INSTRUCTION 2 /* Instruction failed */
/* Illegal or undefined instruction or operand */
#define EXC_ARITHMETIC 3 /* Arithmetic exception */
/* Exact nature of exception is in code field */
#define EXC_EMULATION 4 /* Emulation instruction */
/* Emulation support instruction encountered */
/* Details in code and subcode fields */
#define EXC_SOFTWARE 5 /* Software generated exception */
/* Exact exception is in code field. */
/* Codes 0 - 0xFFFF reserved to hardware */
/* Codes 0x10000 - 0x1FFFF reserved for OS emulation (Unix) */
#define EXC_BREAKPOINT 6 /* Trace, breakpoint, etc. */
/* Details in code field. */
#define EXC_SYSCALL 7 /* System calls. */
#define EXC_MACH_SYSCALL 8 /* Mach system calls. */
#define EXC_RPC_ALERT 9 /* RPC alert */
#define EXC_CRASH 10 /* Abnormal process exit */
#define EXC_RESOURCE 11 /* Hit resource consumption limit */
/* Exact resource is in code field. */
#define EXC_GUARD 12 /* Violated guarded resource protections */
#define EXC_CORPSE_NOTIFY 13 /* Abnormal process exited to corpse state */
#define EXC_CORPSE_VARIANT_BIT 0x100 /* bit set for EXC_*_CORPSE variants of EXC_* */
/*
* Machine-independent exception behaviors
*/
# define EXCEPTION_DEFAULT 1
/* Send a catch_exception_raise message including the identity.
*/
# define EXCEPTION_STATE 2
/* Send a catch_exception_raise_state message including the
* thread state.
*/
# define EXCEPTION_STATE_IDENTITY 3
/* Send a catch_exception_raise_state_identity message including
* the thread identity and state.
*/
#define MACH_EXCEPTION_ERRORS 0x40000000
/* include additional exception specific errors, not used yet. */
#define MACH_EXCEPTION_CODES 0x80000000
/* Send 64-bit code and subcode in the exception header */
#define MACH_EXCEPTION_MASK (MACH_EXCEPTION_CODES | MACH_EXCEPTION_ERRORS)
/*
* Masks for exception definitions, above
* bit zero is unused, therefore 1 word = 31 exception types
*/
#define EXC_MASK_BAD_ACCESS (1 << EXC_BAD_ACCESS)
#define EXC_MASK_BAD_INSTRUCTION (1 << EXC_BAD_INSTRUCTION)
#define EXC_MASK_ARITHMETIC (1 << EXC_ARITHMETIC)
#define EXC_MASK_EMULATION (1 << EXC_EMULATION)
#define EXC_MASK_SOFTWARE (1 << EXC_SOFTWARE)
#define EXC_MASK_BREAKPOINT (1 << EXC_BREAKPOINT)
#define EXC_MASK_SYSCALL (1 << EXC_SYSCALL)
#define EXC_MASK_MACH_SYSCALL (1 << EXC_MACH_SYSCALL)
#define EXC_MASK_RPC_ALERT (1 << EXC_RPC_ALERT)
#define EXC_MASK_CRASH (1 << EXC_CRASH)
#define EXC_MASK_RESOURCE (1 << EXC_RESOURCE)
#define EXC_MASK_GUARD (1 << EXC_GUARD)
#define EXC_MASK_CORPSE_NOTIFY (1 << EXC_CORPSE_NOTIFY)
#define EXC_MASK_ALL (EXC_MASK_BAD_ACCESS | \
EXC_MASK_BAD_INSTRUCTION | \
EXC_MASK_ARITHMETIC | \
EXC_MASK_EMULATION | \
EXC_MASK_SOFTWARE | \
EXC_MASK_BREAKPOINT | \
EXC_MASK_SYSCALL | \
EXC_MASK_MACH_SYSCALL | \
EXC_MASK_RPC_ALERT | \
EXC_MASK_RESOURCE | \
EXC_MASK_GUARD | \
EXC_MASK_MACHINE)
#define FIRST_EXCEPTION 1 /* ZERO is illegal */
/*
* Machine independent codes for EXC_SOFTWARE
* Codes 0x10000 - 0x1FFFF reserved for OS emulation (Unix)
* 0x10000 - 0x10002 in use for unix signals
* 0x20000 - 0x2FFFF reserved for MACF
*/
#define EXC_SOFT_SIGNAL 0x10003 /* Unix signal exceptions */
#define EXC_MACF_MIN 0x20000 /* MACF exceptions */
#define EXC_MACF_MAX 0x2FFFF
#ifndef ASSEMBLER
#include <mach/port.h>
#include <mach/thread_status.h>
#include <mach/machine/vm_types.h>
/*
* Exported types
*/
typedef int exception_type_t;
typedef integer_t exception_data_type_t;
typedef int64_t mach_exception_data_type_t;
typedef int exception_behavior_t;
typedef exception_data_type_t *exception_data_t;
typedef mach_exception_data_type_t *mach_exception_data_t;
typedef unsigned int exception_mask_t;
typedef exception_mask_t *exception_mask_array_t;
typedef exception_behavior_t *exception_behavior_array_t;
typedef thread_state_flavor_t *exception_flavor_array_t;
typedef mach_port_t *exception_port_array_t;
typedef mach_exception_data_type_t mach_exception_code_t;
typedef mach_exception_data_type_t mach_exception_subcode_t;
#endif /* ASSEMBLER */
#endif /* _MACH_EXCEPTION_TYPES_H_ */

View File

@@ -0,0 +1,281 @@
/*
* Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* File: mach/host_special_ports.h
*
* Defines codes for access to host-wide special ports.
*/
#ifndef _MACH_HOST_SPECIAL_PORTS_H_
#define _MACH_HOST_SPECIAL_PORTS_H_
/*
* Cannot be set or gotten from user space
*/
#define HOST_SECURITY_PORT 0
#define HOST_MIN_SPECIAL_PORT HOST_SECURITY_PORT
/*
* Always provided by kernel (cannot be set from user-space).
*/
#define HOST_PORT 1
#define HOST_PRIV_PORT 2
#define HOST_IO_MASTER_PORT 3
#define HOST_MAX_SPECIAL_KERNEL_PORT 7 /* room to grow */
#define HOST_LAST_SPECIAL_KERNEL_PORT HOST_IO_MASTER_PORT
/*
* Not provided by kernel
*/
#define HOST_DYNAMIC_PAGER_PORT (1 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_AUDIT_CONTROL_PORT (2 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_USER_NOTIFICATION_PORT (3 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_AUTOMOUNTD_PORT (4 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_LOCKD_PORT (5 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_KTRACE_BACKGROUND_PORT (6 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_SEATBELT_PORT (7 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_KEXTD_PORT (8 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_LAUNCHCTL_PORT (9 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_UNFREED_PORT (10 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_AMFID_PORT (11 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_GSSD_PORT (12 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_TELEMETRY_PORT (13 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_ATM_NOTIFICATION_PORT (14 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_COALITION_PORT (15 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_SYSDIAGNOSE_PORT (16 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_XPC_EXCEPTION_PORT (17 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_CONTAINERD_PORT (18 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_NODE_PORT (19 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_RESOURCE_NOTIFY_PORT (20 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_CLOSURED_PORT (21 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_SYSPOLICYD_PORT (22 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_FILECOORDINATIOND_PORT (23 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_FAIRPLAYD_PORT (24 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_MAX_SPECIAL_PORT HOST_FAIRPLAYD_PORT
/* MAX = last since rdar://35861175 */
/* obsolete name */
#define HOST_CHUD_PORT HOST_LAUNCHCTL_PORT
/*
* Special node identifier to always represent the local node.
*/
#define HOST_LOCAL_NODE -1
/*
* Definitions for ease of use.
*
* In the get call, the host parameter can be any host, but will generally
* be the local node host port. In the set call, the host must the per-node
* host port for the node being affected.
*/
#define host_get_host_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_PORT, (port)))
#define host_set_host_port(host, port) (KERN_INVALID_ARGUMENT)
#define host_get_host_priv_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_PRIV_PORT, (port)))
#define host_set_host_priv_port(host, port) (KERN_INVALID_ARGUMENT)
#define host_get_io_master_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_IO_MASTER_PORT, (port)))
#define host_set_io_master_port(host, port) (KERN_INVALID_ARGUMENT)
/*
* User-settable special ports.
*/
#define host_get_dynamic_pager_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_DYNAMIC_PAGER_PORT, (port)))
#define host_set_dynamic_pager_port(host, port) \
(host_set_special_port((host), HOST_DYNAMIC_PAGER_PORT, (port)))
#define host_get_audit_control_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_AUDIT_CONTROL_PORT, (port)))
#define host_set_audit_control_port(host, port) \
(host_set_special_port((host), HOST_AUDIT_CONTROL_PORT, (port)))
#define host_get_user_notification_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_USER_NOTIFICATION_PORT, (port)))
#define host_set_user_notification_port(host, port) \
(host_set_special_port((host), HOST_USER_NOTIFICATION_PORT, (port)))
#define host_get_automountd_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_AUTOMOUNTD_PORT, (port)))
#define host_set_automountd_port(host, port) \
(host_set_special_port((host), HOST_AUTOMOUNTD_PORT, (port)))
#define host_get_lockd_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_LOCKD_PORT, (port)))
#define host_set_lockd_port(host, port) \
(host_set_special_port((host), HOST_LOCKD_PORT, (port)))
#define host_get_ktrace_background_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_KTRACE_BACKGROUND_PORT, (port)))
#define host_set_ktrace_background_port(host, port) \
(host_set_special_port((host), HOST_KTRACE_BACKGROUND_PORT, (port)))
#define host_get_kextd_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_KEXTD_PORT, (port)))
#define host_set_kextd_port(host, port) \
(host_set_special_port((host), HOST_KEXTD_PORT, (port)))
#define host_get_launchctl_port(host, port) \
(host_get_special_port((host), HOST_LOCAL_NODE, HOST_LAUNCHCTL_PORT, \
(port)))
#define host_set_launchctl_port(host, port) \
(host_set_special_port((host), HOST_LAUNCHCTL_PORT, (port)))
#define host_get_chud_port(host, port) host_get_launchctl_port(host, port)
#define host_set_chud_port(host, port) host_set_launchctl_port(host, port)
#define host_get_unfreed_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_UNFREED_PORT, (port)))
#define host_set_unfreed_port(host, port) \
(host_set_special_port((host), HOST_UNFREED_PORT, (port)))
#define host_get_amfid_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_AMFID_PORT, (port)))
#define host_set_amfid_port(host, port) \
(host_set_special_port((host), HOST_AMFID_PORT, (port)))
#define host_get_gssd_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_GSSD_PORT, (port)))
#define host_set_gssd_port(host, port) \
(host_set_special_port((host), HOST_GSSD_PORT, (port)))
#define host_get_telemetry_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_TELEMETRY_PORT, (port)))
#define host_set_telemetry_port(host, port) \
(host_set_special_port((host), HOST_TELEMETRY_PORT, (port)))
#define host_get_atm_notification_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_ATM_NOTIFICATION_PORT, (port)))
#define host_set_atm_notification_port(host, port) \
(host_set_special_port((host), HOST_ATM_NOTIFICATION_PORT, (port)))
#define host_get_coalition_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_COALITION_PORT, (port)))
#define host_set_coalition_port(host, port) \
(host_set_special_port((host), HOST_COALITION_PORT, (port)))
#define host_get_sysdiagnose_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_SYSDIAGNOSE_PORT, (port)))
#define host_set_sysdiagnose_port(host, port) \
(host_set_special_port((host), HOST_SYSDIAGNOSE_PORT, (port)))
#define host_get_container_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_CONTAINERD_PORT, (port)))
#define host_set_container_port(host, port) \
(host_set_special_port((host), HOST_CONTAINERD_PORT, (port)))
#define host_get_node_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_NODE_PORT, (port)))
#define host_set_node_port(host, port) \
(host_set_special_port((host), HOST_NODE_PORT, (port)))
#define host_get_closured_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_CLOSURED_PORT, (port)))
#define host_set_closured_port(host, port) \
(host_set_special_port((host), HOST_CLOSURED_PORT, (port)))
#define host_get_syspolicyd_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_SYSPOLICYD_PORT, (port)))
#define host_set_syspolicyd_port(host, port) \
(host_set_special_port((host), HOST_SYSPOLICYD_PORT, (port)))
#define host_get_filecoordinationd_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_FILECOORDINATIOND_PORT, (port)))
#define host_set_filecoordinationd_port(host, port) \
(host_set_special_port((host), HOST_FILECOORDINATIOND_PORT, (port)))
#define host_get_fairplayd_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_FAIRPLAYD_PORT, (port)))
#define host_set_fairplayd_port(host, port) \
(host_set_special_port((host), HOST_FAIRPLAYD_PORT, (port)))
/* HOST_RESOURCE_NOTIFY_PORT doesn't #defines these conveniences.
* All lookups go through send_resource_violation()
*/
#endif /* _MACH_HOST_SPECIAL_PORTS_H_ */

View File

@@ -0,0 +1,110 @@
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988,1987,1986 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
* Items provided by the Mach environment initialization.
*/
#ifndef _MACH_INIT_
#define _MACH_INIT_ 1
#include <mach/mach_types.h>
#include <mach/vm_page_size.h>
#include <stdarg.h>
#include <sys/cdefs.h>
/*
* Kernel-related ports; how a task/thread controls itself
*/
__BEGIN_DECLS
extern mach_port_t mach_host_self(void);
extern mach_port_t mach_thread_self(void);
extern kern_return_t host_page_size(host_t, vm_size_t *);
extern mach_port_t mach_task_self_;
#define mach_task_self() mach_task_self_
#define current_task() mach_task_self()
__END_DECLS
#include <mach/mach_traps.h>
__BEGIN_DECLS
/*
* Other important ports in the Mach user environment
*/
extern mach_port_t bootstrap_port;
/*
* Where these ports occur in the "mach_ports_register"
* collection... only servers or the runtime library need know.
*/
#define NAME_SERVER_SLOT 0
#define ENVIRONMENT_SLOT 1
#define SERVICE_SLOT 2
#define MACH_PORTS_SLOTS_USED 3
/*
* fprintf_stderr uses vprintf_stderr_func to produce
* error messages, this can be overridden by a user
* application to point to a user-specified output function
*/
extern int (*vprintf_stderr_func)(const char *format, va_list ap);
__END_DECLS
#endif /* _MACH_INIT_ */

View File

@@ -0,0 +1,299 @@
/*
* Copyright (c) 2000-2016 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* File: memory_object.h
* Author: Michael Wayne Young
*
* External memory management interface definition.
*/
#ifndef _MACH_MEMORY_OBJECT_TYPES_H_
#define _MACH_MEMORY_OBJECT_TYPES_H_
/*
* User-visible types used in the external memory
* management interface:
*/
#include <mach/port.h>
#include <mach/message.h>
#include <mach/vm_prot.h>
#include <mach/vm_sync.h>
#include <mach/vm_types.h>
#include <mach/machine/vm_types.h>
#include <sys/cdefs.h>
#define VM_64_BIT_DATA_OBJECTS
typedef unsigned long long memory_object_offset_t;
typedef unsigned long long memory_object_size_t;
typedef natural_t memory_object_cluster_size_t;
typedef natural_t * memory_object_fault_info_t;
typedef unsigned long long vm_object_id_t;
/*
* Temporary until real EMMI version gets re-implemented
*/
typedef mach_port_t memory_object_t;
typedef mach_port_t memory_object_control_t;
typedef memory_object_t *memory_object_array_t;
/* A memory object ... */
/* Used by the kernel to retrieve */
/* or store data */
typedef mach_port_t memory_object_name_t;
/* Used to describe the memory ... */
/* object in vm_regions() calls */
typedef mach_port_t memory_object_default_t;
/* Registered with the host ... */
/* for creating new internal objects */
#define MEMORY_OBJECT_NULL ((memory_object_t) 0)
#define MEMORY_OBJECT_CONTROL_NULL ((memory_object_control_t) 0)
#define MEMORY_OBJECT_NAME_NULL ((memory_object_name_t) 0)
#define MEMORY_OBJECT_DEFAULT_NULL ((memory_object_default_t) 0)
typedef int memory_object_copy_strategy_t;
/* How memory manager handles copy: */
#define MEMORY_OBJECT_COPY_NONE 0
/* ... No special support */
#define MEMORY_OBJECT_COPY_CALL 1
/* ... Make call on memory manager */
#define MEMORY_OBJECT_COPY_DELAY 2
/* ... Memory manager doesn't
* change data externally.
*/
#define MEMORY_OBJECT_COPY_TEMPORARY 3
/* ... Memory manager doesn't
* change data externally, and
* doesn't need to see changes.
*/
#define MEMORY_OBJECT_COPY_SYMMETRIC 4
/* ... Memory manager doesn't
* change data externally,
* doesn't need to see changes,
* and object will not be
* multiply mapped.
*
* XXX
* Not yet safe for non-kernel use.
*/
#define MEMORY_OBJECT_COPY_INVALID 5
/* ... An invalid copy strategy,
* for external objects which
* have not been initialized.
* Allows copy_strategy to be
* examined without also
* examining pager_ready and
* internal.
*/
typedef int memory_object_return_t;
/* Which pages to return to manager
* this time (lock_request) */
#define MEMORY_OBJECT_RETURN_NONE 0
/* ... don't return any. */
#define MEMORY_OBJECT_RETURN_DIRTY 1
/* ... only dirty pages. */
#define MEMORY_OBJECT_RETURN_ALL 2
/* ... dirty and precious pages. */
#define MEMORY_OBJECT_RETURN_ANYTHING 3
/* ... any resident page. */
/*
* Data lock request flags
*/
#define MEMORY_OBJECT_DATA_FLUSH 0x1
#define MEMORY_OBJECT_DATA_NO_CHANGE 0x2
#define MEMORY_OBJECT_DATA_PURGE 0x4
#define MEMORY_OBJECT_COPY_SYNC 0x8
#define MEMORY_OBJECT_DATA_SYNC 0x10
#define MEMORY_OBJECT_IO_SYNC 0x20
#define MEMORY_OBJECT_DATA_FLUSH_ALL 0x40
/*
* Types for the memory object flavor interfaces
*/
#define MEMORY_OBJECT_INFO_MAX (1024)
typedef int *memory_object_info_t;
typedef int memory_object_flavor_t;
typedef int memory_object_info_data_t[MEMORY_OBJECT_INFO_MAX];
#define MEMORY_OBJECT_PERFORMANCE_INFO 11
#define MEMORY_OBJECT_ATTRIBUTE_INFO 14
#define MEMORY_OBJECT_BEHAVIOR_INFO 15
struct memory_object_perf_info {
memory_object_cluster_size_t cluster_size;
boolean_t may_cache;
};
struct memory_object_attr_info {
memory_object_copy_strategy_t copy_strategy;
memory_object_cluster_size_t cluster_size;
boolean_t may_cache_object;
boolean_t temporary;
};
struct memory_object_behave_info {
memory_object_copy_strategy_t copy_strategy;
boolean_t temporary;
boolean_t invalidate;
boolean_t silent_overwrite;
boolean_t advisory_pageout;
};
typedef struct memory_object_behave_info *memory_object_behave_info_t;
typedef struct memory_object_behave_info memory_object_behave_info_data_t;
typedef struct memory_object_perf_info *memory_object_perf_info_t;
typedef struct memory_object_perf_info memory_object_perf_info_data_t;
typedef struct memory_object_attr_info *memory_object_attr_info_t;
typedef struct memory_object_attr_info memory_object_attr_info_data_t;
#define MEMORY_OBJECT_BEHAVE_INFO_COUNT ((mach_msg_type_number_t) \
(sizeof(memory_object_behave_info_data_t)/sizeof(int)))
#define MEMORY_OBJECT_PERF_INFO_COUNT ((mach_msg_type_number_t) \
(sizeof(memory_object_perf_info_data_t)/sizeof(int)))
#define MEMORY_OBJECT_ATTR_INFO_COUNT ((mach_msg_type_number_t) \
(sizeof(memory_object_attr_info_data_t)/sizeof(int)))
#define invalid_memory_object_flavor(f) \
(f != MEMORY_OBJECT_ATTRIBUTE_INFO && \
f != MEMORY_OBJECT_PERFORMANCE_INFO && \
f != OLD_MEMORY_OBJECT_BEHAVIOR_INFO && \
f != MEMORY_OBJECT_BEHAVIOR_INFO && \
f != OLD_MEMORY_OBJECT_ATTRIBUTE_INFO)
/*
* Used to support options on memory_object_release_name call
*/
#define MEMORY_OBJECT_TERMINATE_IDLE 0x1
#define MEMORY_OBJECT_RESPECT_CACHE 0x2
#define MEMORY_OBJECT_RELEASE_NO_OP 0x4
/* named entry processor mapping options */
/* enumerated */
#define MAP_MEM_NOOP 0
#define MAP_MEM_COPYBACK 1
#define MAP_MEM_IO 2
#define MAP_MEM_WTHRU 3
#define MAP_MEM_WCOMB 4 /* Write combining mode */
/* aka store gather */
#define MAP_MEM_INNERWBACK 5
#define MAP_MEM_POSTED 6
#define MAP_MEM_RT 7
#define MAP_MEM_POSTED_REORDERED 8
#define MAP_MEM_POSTED_COMBINED_REORDERED 9
#define GET_MAP_MEM(flags) \
((((unsigned int)(flags)) >> 24) & 0xFF)
#define SET_MAP_MEM(caching, flags) \
((flags) = ((((unsigned int)(caching)) << 24) \
& 0xFF000000) | ((flags) & 0xFFFFFF));
/* leave room for vm_prot bits (0xFF ?) */
#define MAP_MEM_LEDGER_TAGGED 0x002000 /* object owned by a specific task and ledger */
#define MAP_MEM_PURGABLE_KERNEL_ONLY 0x004000 /* volatility controlled by kernel */
#define MAP_MEM_GRAB_SECLUDED 0x008000 /* can grab secluded pages */
#define MAP_MEM_ONLY 0x010000 /* change processor caching */
#define MAP_MEM_NAMED_CREATE 0x020000 /* create extant object */
#define MAP_MEM_PURGABLE 0x040000 /* create a purgable VM object */
#define MAP_MEM_NAMED_REUSE 0x080000 /* reuse provided entry if identical */
#define MAP_MEM_USE_DATA_ADDR 0x100000 /* preserve address of data, rather than base of page */
#define MAP_MEM_VM_COPY 0x200000 /* make a copy of a VM range */
#define MAP_MEM_VM_SHARE 0x400000 /* extract a VM range for remap */
#define MAP_MEM_4K_DATA_ADDR 0x800000 /* preserve 4K aligned address of data */
#define MAP_MEM_FLAGS_MASK 0x00FFFF00
#define MAP_MEM_FLAGS_USER ( \
MAP_MEM_PURGABLE_KERNEL_ONLY | \
MAP_MEM_GRAB_SECLUDED | \
MAP_MEM_ONLY | \
MAP_MEM_NAMED_CREATE | \
MAP_MEM_PURGABLE | \
MAP_MEM_NAMED_REUSE | \
MAP_MEM_USE_DATA_ADDR | \
MAP_MEM_VM_COPY | \
MAP_MEM_VM_SHARE | \
MAP_MEM_LEDGER_TAGGED | \
MAP_MEM_4K_DATA_ADDR)
#define MAP_MEM_FLAGS_ALL ( \
MAP_MEM_FLAGS_USER)
#endif /* _MACH_MEMORY_OBJECT_TYPES_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,116 @@
/*
* Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* File: mach_debug/ipc_info.h
* Author: Rich Draves
* Date: March, 1990
*
* Definitions for the IPC debugging interface.
*/
#ifndef _MACH_DEBUG_IPC_INFO_H_
#define _MACH_DEBUG_IPC_INFO_H_
#include <mach/boolean.h>
#include <mach/port.h>
#include <mach/machine/vm_types.h>
/*
* Remember to update the mig type definitions
* in mach_debug_types.defs when adding/removing fields.
*/
typedef struct ipc_info_space {
natural_t iis_genno_mask; /* generation number mask */
natural_t iis_table_size; /* size of table */
natural_t iis_table_next; /* next possible size of table */
natural_t iis_tree_size; /* size of tree (UNUSED) */
natural_t iis_tree_small; /* # of small entries in tree (UNUSED) */
natural_t iis_tree_hash; /* # of hashed entries in tree (UNUSED) */
} ipc_info_space_t;
typedef struct ipc_info_space_basic {
natural_t iisb_genno_mask; /* generation number mask */
natural_t iisb_table_size; /* size of table */
natural_t iisb_table_next; /* next possible size of table */
natural_t iisb_table_inuse; /* number of entries in use */
natural_t iisb_reserved[2]; /* future expansion */
} ipc_info_space_basic_t;
typedef struct ipc_info_name {
mach_port_name_t iin_name; /* port name, including gen number */
/*boolean_t*/ integer_t iin_collision; /* collision at this entry? */
mach_port_type_t iin_type; /* straight port type */
mach_port_urefs_t iin_urefs; /* user-references */
natural_t iin_object; /* object pointer/identifier */
natural_t iin_next; /* marequest/next in free list */
natural_t iin_hash; /* hash index */
} ipc_info_name_t;
typedef ipc_info_name_t *ipc_info_name_array_t;
/* UNUSED */
typedef struct ipc_info_tree_name {
ipc_info_name_t iitn_name;
mach_port_name_t iitn_lchild; /* name of left child */
mach_port_name_t iitn_rchild; /* name of right child */
} ipc_info_tree_name_t;
typedef ipc_info_tree_name_t *ipc_info_tree_name_array_t;
#endif /* _MACH_DEBUG_IPC_INFO_H_ */

208
lib/libc/include/x86_64-macos-gnu/time.h vendored Normal file
View File

@@ -0,0 +1,208 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)time.h 8.3 (Berkeley) 1/21/94
*/
#ifndef _TIME_H_
#define _TIME_H_
#include <_types.h>
#include <sys/cdefs.h>
#include <Availability.h>
#include <sys/_types/_clock_t.h>
#include <sys/_types/_null.h>
#include <sys/_types/_size_t.h>
#include <sys/_types/_time_t.h>
#include <sys/_types/_timespec.h>
struct tm {
int tm_sec; /* seconds after the minute [0-60] */
int tm_min; /* minutes after the hour [0-59] */
int tm_hour; /* hours since midnight [0-23] */
int tm_mday; /* day of the month [1-31] */
int tm_mon; /* months since January [0-11] */
int tm_year; /* years since 1900 */
int tm_wday; /* days since Sunday [0-6] */
int tm_yday; /* days since January 1 [0-365] */
int tm_isdst; /* Daylight Savings Time flag */
long tm_gmtoff; /* offset from UTC in seconds */
char *tm_zone; /* timezone abbreviation */
};
#if __DARWIN_UNIX03
#define CLOCKS_PER_SEC 1000000 /* [XSI] */
#else /* !__DARWIN_UNIX03 */
#include <machine/_limits.h> /* Include file containing CLK_TCK. */
#define CLOCKS_PER_SEC (__DARWIN_CLK_TCK)
#endif /* __DARWIN_UNIX03 */
#ifndef _ANSI_SOURCE
extern char *tzname[];
#endif
extern int getdate_err;
#if __DARWIN_UNIX03
extern long timezone __DARWIN_ALIAS(timezone);
#endif /* __DARWIN_UNIX03 */
extern int daylight;
__BEGIN_DECLS
char *asctime(const struct tm *);
clock_t clock(void) __DARWIN_ALIAS(clock);
char *ctime(const time_t *);
double difftime(time_t, time_t);
struct tm *getdate(const char *);
struct tm *gmtime(const time_t *);
struct tm *localtime(const time_t *);
time_t mktime(struct tm *) __DARWIN_ALIAS(mktime);
size_t strftime(char * __restrict, size_t, const char * __restrict, const struct tm * __restrict) __DARWIN_ALIAS(strftime);
char *strptime(const char * __restrict, const char * __restrict, struct tm * __restrict) __DARWIN_ALIAS(strptime);
time_t time(time_t *);
#ifndef _ANSI_SOURCE
void tzset(void);
#endif /* not ANSI */
/* [TSF] Thread safe functions */
char *asctime_r(const struct tm * __restrict, char * __restrict);
char *ctime_r(const time_t *, char *);
struct tm *gmtime_r(const time_t * __restrict, struct tm * __restrict);
struct tm *localtime_r(const time_t * __restrict, struct tm * __restrict);
#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
time_t posix2time(time_t);
#if !__DARWIN_UNIX03
char *timezone(int, int);
#endif /* !__DARWIN_UNIX03 */
void tzsetwall(void);
time_t time2posix(time_t);
time_t timelocal(struct tm * const);
time_t timegm(struct tm * const);
#endif /* neither ANSI nor POSIX */
#if !defined(_ANSI_SOURCE)
int nanosleep(const struct timespec *__rqtp, struct timespec *__rmtp) __DARWIN_ALIAS_C(nanosleep);
#endif
#if !defined(_DARWIN_FEATURE_CLOCK_GETTIME) || _DARWIN_FEATURE_CLOCK_GETTIME != 0
#if __DARWIN_C_LEVEL >= 199309L
#if __has_feature(enumerator_attributes)
#define __CLOCK_AVAILABILITY __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0)
#else
#define __CLOCK_AVAILABILITY
#endif
typedef enum {
_CLOCK_REALTIME __CLOCK_AVAILABILITY = 0,
#define CLOCK_REALTIME _CLOCK_REALTIME
_CLOCK_MONOTONIC __CLOCK_AVAILABILITY = 6,
#define CLOCK_MONOTONIC _CLOCK_MONOTONIC
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
_CLOCK_MONOTONIC_RAW __CLOCK_AVAILABILITY = 4,
#define CLOCK_MONOTONIC_RAW _CLOCK_MONOTONIC_RAW
_CLOCK_MONOTONIC_RAW_APPROX __CLOCK_AVAILABILITY = 5,
#define CLOCK_MONOTONIC_RAW_APPROX _CLOCK_MONOTONIC_RAW_APPROX
_CLOCK_UPTIME_RAW __CLOCK_AVAILABILITY = 8,
#define CLOCK_UPTIME_RAW _CLOCK_UPTIME_RAW
_CLOCK_UPTIME_RAW_APPROX __CLOCK_AVAILABILITY = 9,
#define CLOCK_UPTIME_RAW_APPROX _CLOCK_UPTIME_RAW_APPROX
#endif
_CLOCK_PROCESS_CPUTIME_ID __CLOCK_AVAILABILITY = 12,
#define CLOCK_PROCESS_CPUTIME_ID _CLOCK_PROCESS_CPUTIME_ID
_CLOCK_THREAD_CPUTIME_ID __CLOCK_AVAILABILITY = 16
#define CLOCK_THREAD_CPUTIME_ID _CLOCK_THREAD_CPUTIME_ID
} clockid_t;
__CLOCK_AVAILABILITY
int clock_getres(clockid_t __clock_id, struct timespec *__res);
__CLOCK_AVAILABILITY
int clock_gettime(clockid_t __clock_id, struct timespec *__tp);
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
__CLOCK_AVAILABILITY
__uint64_t clock_gettime_nsec_np(clockid_t __clock_id);
#endif
__OSX_AVAILABLE(10.12) __IOS_PROHIBITED
__TVOS_PROHIBITED __WATCHOS_PROHIBITED
int clock_settime(clockid_t __clock_id, const struct timespec *__tp);
#undef __CLOCK_AVAILABILITY
#endif /* __DARWIN_C_LEVEL */
#endif /* _DARWIN_FEATURE_CLOCK_GETTIME */
#if (__DARWIN_C_LEVEL >= __DARWIN_C_FULL) && \
((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
(defined(__cplusplus) && __cplusplus >= 201703L))
/* ISO/IEC 9899:201x 7.27.2.5 The timespec_get function */
#define TIME_UTC 1 /* time elapsed since epoch */
__API_AVAILABLE(macosx(10.15), ios(13.0), tvos(13.0), watchos(6.0))
int timespec_get(struct timespec *ts, int base);
#endif
__END_DECLS
#ifdef _USE_EXTENDED_LOCALES_
#include <xlocale/_time.h>
#endif /* _USE_EXTENDED_LOCALES_ */
#endif /* !_TIME_H_ */