| 1 | /* |
| 2 | * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. |
| 3 | * |
| 4 | * @APPLE_LICENSE_HEADER_START@ |
| 5 | * |
| 6 | * This file contains Original Code and/or Modifications of Original Code |
| 7 | * as defined in and that are subject to the Apple Public Source License |
| 8 | * Version 2.0 (the 'License'). You may not use this file except in |
| 9 | * compliance with the License. Please obtain a copy of the License at |
| 10 | * http://www.opensource.apple.com/apsl/ and read it before using this |
| 11 | * file. |
| 12 | * |
| 13 | * The Original Code and all software distributed under the License are |
| 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER |
| 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
| 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
| 18 | * Please see the License for the specific language governing rights and |
| 19 | * limitations under the License. |
| 20 | * |
| 21 | * @APPLE_LICENSE_HEADER_END@ |
| 22 | */ |
| 23 | #ifndef _MACH_O_GETSECT_H_ |
| 24 | #define _MACH_O_GETSECT_H_ |
| 25 | |
| 26 | #include <stdint.h> |
| 27 | #include <mach-o/loader.h> |
| 28 | #include <Availability.h> |
| 29 | #include <TargetConditionals.h> |
| 30 | |
| 31 | #ifndef __CCTOOLS_DEPRECATED |
| 32 | #define __CCTOOLS_DEPRECATED __API_DEPRECATED("No longer supported", macos(10.0, 13.0), ios(1.0, 16.0), watchos(1.0, 8.0), tvos(1.0, 16.0)) |
| 33 | #define __CCTOOLS_DEPRECATED_MSG(_msg) __API_DEPRECATED_WITH_REPLACEMENT(_msg, macos(10.0, 13.0), ios(1.0, 16.0), watchos(1.0, 8.0), tvos(1.0, 16.0)) |
| 34 | #endif |
| 35 | |
| 36 | |
| 37 | #ifdef __cplusplus |
| 38 | extern "C" { |
| 39 | #endif /* __cplusplus */ |
| 40 | |
| 41 | /* |
| 42 | * Runtime interfaces for Mach-O programs. For both 32-bit and 64-bit programs, |
| 43 | * where the sizes returned will be 32-bit or 64-bit based on the size of |
| 44 | * 'unsigned long'. |
| 45 | */ |
| 46 | extern char *getsectdata( |
| 47 | const char *segname, |
| 48 | const char *sectname, |
| 49 | unsigned long *size) __CCTOOLS_DEPRECATED_MSG("use getsectiondata()"); |
| 50 | |
| 51 | extern char *getsectdatafromFramework( |
| 52 | const char *FrameworkName, |
| 53 | const char *segname, |
| 54 | const char *sectname, |
| 55 | unsigned long *size) __CCTOOLS_DEPRECATED; |
| 56 | |
| 57 | extern unsigned long get_end(void) __CCTOOLS_DEPRECATED; |
| 58 | extern unsigned long get_etext(void) __CCTOOLS_DEPRECATED; |
| 59 | extern unsigned long get_edata(void) __CCTOOLS_DEPRECATED; |
| 60 | |
| 61 | #ifndef __LP64__ |
| 62 | /* |
| 63 | * Runtime interfaces for 32-bit Mach-O programs. |
| 64 | */ |
| 65 | extern const struct section *getsectbyname( |
| 66 | const char *segname, |
| 67 | const char *sectname) __CCTOOLS_DEPRECATED_MSG("use getsectiondata(&__dso_handle,)"); |
| 68 | |
| 69 | extern uint8_t *getsectiondata( |
| 70 | const struct mach_header *mhp, |
| 71 | const char *segname, |
| 72 | const char *sectname, |
| 73 | unsigned long *size); |
| 74 | |
| 75 | extern const struct segment_command *getsegbyname( |
| 76 | const char *segname) __CCTOOLS_DEPRECATED; |
| 77 | |
| 78 | extern uint8_t *getsegmentdata( |
| 79 | const struct mach_header *mhp, |
| 80 | const char *segname, |
| 81 | unsigned long *size); |
| 82 | |
| 83 | #else /* defined(__LP64__) */ |
| 84 | /* |
| 85 | * Runtime interfaces for 64-bit Mach-O programs. |
| 86 | */ |
| 87 | extern const struct section_64 *getsectbyname( |
| 88 | const char *segname, |
| 89 | const char *sectname); |
| 90 | |
| 91 | extern uint8_t *getsectiondata( |
| 92 | const struct mach_header_64 *mhp, |
| 93 | const char *segname, |
| 94 | const char *sectname, |
| 95 | unsigned long *size); |
| 96 | |
| 97 | extern const struct segment_command_64 *getsegbyname( |
| 98 | const char *segname) __CCTOOLS_DEPRECATED; |
| 99 | |
| 100 | extern uint8_t *getsegmentdata( |
| 101 | const struct mach_header_64 *mhp, |
| 102 | const char *segname, |
| 103 | unsigned long *size); |
| 104 | |
| 105 | #endif /* defined(__LP64__) */ |
| 106 | |
| 107 | /* |
| 108 | * Interfaces for tools working with 32-bit Mach-O files. |
| 109 | */ |
| 110 | extern char *getsectdatafromheader( |
| 111 | const struct mach_header *mhp, |
| 112 | const char *segname, |
| 113 | const char *sectname, |
| 114 | uint32_t *size) __CCTOOLS_DEPRECATED_MSG("use getsectiondata()"); |
| 115 | |
| 116 | extern const struct section *getsectbynamefromheader( |
| 117 | const struct mach_header *mhp, |
| 118 | const char *segname, |
| 119 | const char *sectname) __CCTOOLS_DEPRECATED_MSG("use getsectiondata()"); |
| 120 | |
| 121 | extern const struct section *getsectbynamefromheaderwithswap( |
| 122 | struct mach_header *mhp, |
| 123 | const char *segname, |
| 124 | const char *sectname, |
| 125 | int fSwap) __CCTOOLS_DEPRECATED_MSG("use getsectiondata()"); |
| 126 | |
| 127 | /* |
| 128 | * Interfaces for tools working with 64-bit Mach-O files. |
| 129 | */ |
| 130 | extern char *getsectdatafromheader_64( |
| 131 | const struct mach_header_64 *mhp, |
| 132 | const char *segname, |
| 133 | const char *sectname, |
| 134 | uint64_t *size) __CCTOOLS_DEPRECATED_MSG("use getsectiondata()"); |
| 135 | |
| 136 | extern const struct section_64 *getsectbynamefromheader_64( |
| 137 | const struct mach_header_64 *mhp, |
| 138 | const char *segname, |
| 139 | const char *sectname) __CCTOOLS_DEPRECATED_MSG("use getsectiondata()"); |
| 140 | |
| 141 | extern const struct section *getsectbynamefromheaderwithswap_64( |
| 142 | struct mach_header_64 *mhp, |
| 143 | const char *segname, |
| 144 | const char *sectname, |
| 145 | int fSwap) __CCTOOLS_DEPRECATED_MSG("use getsectiondata()"); |
| 146 | |
| 147 | #ifdef __cplusplus |
| 148 | } |
| 149 | #endif /* __cplusplus */ |
| 150 | |
| 151 | #endif /* _MACH_O_GETSECT_H_ */ |