1/* 2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23 24#ifndef _MACHO_LDSYMS_H_ 25#define _MACHO_LDSYMS_H_ 26 27#include <mach-o/loader.h> 28 29/* 30 * This file describes the link editor defined symbols. The semantics of a 31 * link editor symbol is that it is defined by the link editor only if it is 32 * referenced and it is an error for the user to define them (see the man page 33 * ld(1)). The standard UNIX link editor symbols: __end, __etext and __edata 34 * are not not supported by the Apple Mach-O link editor. These symbols are 35 * really not meaningful in a Mach-O object file and the link editor symbols 36 * that are supported (described here) replace them. In the case of the 37 * standard UNIX link editor symbols the program can use the symbol 38 * __mh_execute_header and walk the load commands of it's program to determine 39 * the ending (or beginning) of any section or segment in the program. Note 40 * that the compiler prepends an underbar to all external symbol names coded 41 * in a high level language. Thus in 'C' names are coded without an underbar 42 * and symbol names in the symbol table have an underbar. There are two cpp 43 * macros for each link editor defined name in this file. The macro with a 44 * leading underbar is the symbol name and the one without is the name as 45 * coded in 'C'. 46 */ 47 48/* 49 * The value of the link editor defined symbol _MH_EXECUTE_SYM is the address 50 * of the mach header in a Mach-O executable file type. It does not appear in 51 * any file type other than a MH_EXECUTE file type. The type of the symbol is 52 * absolute as the header is not part of any section. 53 */ 54#define _MH_EXECUTE_SYM "__mh_execute_header" 55#define MH_EXECUTE_SYM "_mh_execute_header" 56extern const struct 57#ifdef __LP64__ 58mach_header_64 59#else 60mach_header 61#endif 62_mh_execute_header; 63 64/* 65 * The value of the link editor defined symbol _MH_BUNDLE_SYM is the address 66 * of the mach header in a Mach-O bundle file type. It does not appear in 67 * any file type other than a MH_BUNDLE file type. The type of the symbol is 68 * an N_SECT symbol even thought the header is not part of any section. This 69 * symbol is private to the code in the bundle it is a part of. 70 */ 71#define _MH_BUNDLE_SYM "__mh_bundle_header" 72#define MH_BUNDLE_SYM "_mh_bundle_header" 73extern const struct 74#ifdef __LP64__ 75mach_header_64 76#else 77mach_header 78#endif 79_mh_bundle_header; 80 81/* 82 * The value of the link editor defined symbol _MH_DYLIB_SYM is the address 83 * of the mach header in a Mach-O dylib file type. It does not appear in 84 * any file type other than a MH_DYLIB file type. The type of the symbol is 85 * an N_SECT symbol even thought the header is not part of any section. This 86 * symbol is private to the code in the library it is a part of. 87 */ 88#define _MH_DYLIB_SYM "__mh_dylib_header" 89#define MH_DYLIB_SYM "_mh_dylib_header" 90extern const struct 91#ifdef __LP64__ 92mach_header_64 93#else 94mach_header 95#endif 96_mh_dylib_header; 97 98/* 99 * The value of the link editor defined symbol _MH_DYLINKER_SYM is the address 100 * of the mach header in a Mach-O dylinker file type. It does not appear in 101 * any file type other than a MH_DYLINKER file type. The type of the symbol is 102 * an N_SECT symbol even thought the header is not part of any section. This 103 * symbol is private to the code in the dynamic linker it is a part of. 104 */ 105#define _MH_DYLINKER_SYM "__mh_dylinker_header" 106#define MH_DYLINKER_SYM "_mh_dylinker_header" 107extern const struct 108#ifdef __LP64__ 109mach_header_64 110#else 111mach_header 112#endif 113_mh_dylinker_header; 114 115/* 116 * For the MH_PRELOAD file type the headers are not loaded as part of any 117 * segment so the link editor defines symbols defined for the beginning 118 * and ending of each segment and each section in each segment. The names for 119 * the symbols for a segment's beginning and end will have the form: 120 * __SEGNAME__begin and __SEGNAME__end where __SEGNAME is the name of the 121 * segment. The names for the symbols for a section's beginning and end will 122 * have the form: __SEGNAME__sectname__begin and __SEGNAME__sectname__end 123 * where __sectname is the name of the section and __SEGNAME is the segment it 124 * is in. 125 * 126 * The above symbols' types are those of the section they are referring to. 127 * This is true even for symbols who's values are end's of a section and 128 * that value is next address after that section and not really in that 129 * section. This results in these symbols having types referring to sections 130 * who's values are not in that section. 131 */ 132 133#endif /* _MACHO_LDSYMS_H_ */ 134