]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
37839358 A |
6 | * The contents of this file constitute Original Code as defined in and |
7 | * are subject to the Apple Public Source License Version 1.1 (the | |
8 | * "License"). You may not use this file except in compliance with the | |
9 | * License. Please obtain a copy of the License at | |
10 | * http://www.apple.com/publicsource and read it before using this file. | |
1c79356b | 11 | * |
37839358 A |
12 | * This Original Code and all software distributed under the License are |
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
37839358 A |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
1c79356b A |
19 | * |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | #ifndef _MACHO_NLIST_H_ | |
23 | #define _MACHO_NLIST_H_ | |
24 | /* $NetBSD: nlist.h,v 1.5 1994/10/26 00:56:11 cgd Exp $ */ | |
25 | ||
26 | /*- | |
27 | * Copyright (c) 1991, 1993 | |
28 | * The Regents of the University of California. All rights reserved. | |
29 | * (c) UNIX System Laboratories, Inc. | |
30 | * All or some portions of this file are derived from material licensed | |
31 | * to the University of California by American Telephone and Telegraph | |
32 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with | |
33 | * the permission of UNIX System Laboratories, Inc. | |
34 | * | |
35 | * Redistribution and use in source and binary forms, with or without | |
36 | * modification, are permitted provided that the following conditions | |
37 | * are met: | |
38 | * 1. Redistributions of source code must retain the above copyright | |
39 | * notice, this list of conditions and the following disclaimer. | |
40 | * 2. Redistributions in binary form must reproduce the above copyright | |
41 | * notice, this list of conditions and the following disclaimer in the | |
42 | * documentation and/or other materials provided with the distribution. | |
43 | * 3. All advertising materials mentioning features or use of this software | |
44 | * must display the following acknowledgement: | |
45 | * This product includes software developed by the University of | |
46 | * California, Berkeley and its contributors. | |
47 | * 4. Neither the name of the University nor the names of its contributors | |
48 | * may be used to endorse or promote products derived from this software | |
49 | * without specific prior written permission. | |
50 | * | |
51 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
52 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
53 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
54 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
55 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
56 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
57 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
58 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
59 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
60 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
61 | * SUCH DAMAGE. | |
62 | * | |
63 | * @(#)nlist.h 8.2 (Berkeley) 1/21/94 | |
64 | */ | |
65 | ||
66 | /* | |
67 | * Format of a symbol table entry of a Mach-O file. Modified from the BSD | |
68 | * format. The modifications from the original format were changing n_other | |
69 | * (an unused field) to n_sect and the addition of the N_SECT type. These | |
70 | * modifications are required to support symbols in an arbitrary number of | |
71 | * sections not just the three sections (text, data and bss) in a BSD file. | |
72 | */ | |
73 | struct nlist { | |
74 | union { | |
75 | char *n_name; /* for use when in-core */ | |
76 | long n_strx; /* index into the string table */ | |
77 | } n_un; | |
78 | unsigned char n_type; /* type flag, see below */ | |
79 | unsigned char n_sect; /* section number or NO_SECT */ | |
80 | short n_desc; /* see <mach-o/stab.h> */ | |
81 | unsigned long n_value; /* value of this symbol (or stab offset) */ | |
82 | }; | |
83 | ||
91447636 A |
84 | /* |
85 | * This is the symbol table entry structure for 64-bit architectures. | |
86 | */ | |
87 | struct nlist_64 { | |
88 | union { | |
89 | uint32_t n_strx; /* index into the string table */ | |
90 | } n_un; | |
91 | uint8_t n_type; /* type flag, see below */ | |
92 | uint8_t n_sect; /* section number or NO_SECT */ | |
93 | uint16_t n_desc; /* see <mach-o/stab.h> */ | |
94 | uint64_t n_value; /* value of this symbol (or stab offset) */ | |
95 | }; | |
96 | ||
97 | ||
1c79356b A |
98 | /* |
99 | * Symbols with a index into the string table of zero (n_un.n_strx == 0) are | |
100 | * defined to have a null, "", name. Therefore all string indexes to non null | |
101 | * names must not have a zero string index. This is bit historical information | |
102 | * that has never been well documented. | |
103 | */ | |
104 | ||
105 | /* | |
106 | * The n_type field really contains three fields: | |
107 | * unsigned char N_STAB:3, | |
108 | * N_PEXT:1, | |
109 | * N_TYPE:3, | |
110 | * N_EXT:1; | |
111 | * which are used via the following masks. | |
112 | */ | |
113 | #define N_STAB 0xe0 /* if any of these bits set, a symbolic debugging entry */ | |
114 | #define N_PEXT 0x10 /* private external symbol bit */ | |
115 | #define N_TYPE 0x0e /* mask for the type bits */ | |
116 | #define N_EXT 0x01 /* external symbol bit, set for external symbols */ | |
117 | ||
118 | /* | |
119 | * Only symbolic debugging entries have some of the N_STAB bits set and if any | |
120 | * of these bits are set then it is a symbolic debugging entry (a stab). In | |
121 | * which case then the values of the n_type field (the entire field) are given | |
122 | * in <mach-o/stab.h> | |
123 | */ | |
124 | ||
125 | /* | |
126 | * Values for N_TYPE bits of the n_type field. | |
127 | */ | |
128 | #define N_UNDF 0x0 /* undefined, n_sect == NO_SECT */ | |
129 | #define N_ABS 0x2 /* absolute, n_sect == NO_SECT */ | |
130 | #define N_SECT 0xe /* defined in section number n_sect */ | |
131 | #define N_PBUD 0xc /* prebound undefined (defined in a dylib) */ | |
132 | #define N_INDR 0xa /* indirect */ | |
133 | ||
134 | /* | |
135 | * If the type is N_INDR then the symbol is defined to be the same as another | |
136 | * symbol. In this case the n_value field is an index into the string table | |
137 | * of the other symbol's name. When the other symbol is defined then they both | |
138 | * take on the defined type and value. | |
139 | */ | |
140 | ||
141 | /* | |
142 | * If the type is N_SECT then the n_sect field contains an ordinal of the | |
143 | * section the symbol is defined in. The sections are numbered from 1 and | |
144 | * refer to sections in order they appear in the load commands for the file | |
145 | * they are in. This means the same ordinal may very well refer to different | |
146 | * sections in different files. | |
147 | * | |
148 | * The n_value field for all symbol table entries (including N_STAB's) gets | |
149 | * updated by the link editor based on the value of it's n_sect field and where | |
150 | * the section n_sect references gets relocated. If the value of the n_sect | |
151 | * field is NO_SECT then it's n_value field is not changed by the link editor. | |
152 | */ | |
153 | #define NO_SECT 0 /* symbol is not in any section */ | |
154 | #define MAX_SECT 255 /* 1 thru 255 inclusive */ | |
155 | ||
156 | /* | |
157 | * Common symbols are represented by undefined (N_UNDF) external (N_EXT) types | |
158 | * who's values (n_value) are non-zero. In which case the value of the n_value | |
159 | * field is the size (in bytes) of the common symbol. The n_sect field is set | |
160 | * to NO_SECT. | |
161 | */ | |
162 | ||
163 | /* | |
164 | * To support the lazy binding of undefined symbols in the dynamic link-editor, | |
165 | * the undefined symbols in the symbol table (the nlist structures) are marked | |
166 | * with the indication if the undefined reference is a lazy reference or | |
167 | * non-lazy reference. If both a non-lazy reference and a lazy reference is | |
168 | * made to the same symbol the non-lazy reference takes precedence. A reference | |
169 | * is lazy only when all references to that symbol are made through a symbol | |
170 | * pointer in a lazy symbol pointer section. | |
171 | * | |
172 | * The implementation of marking nlist structures in the symbol table for | |
173 | * undefined symbols will be to use some of the bits of the n_desc field as a | |
174 | * reference type. The mask REFERENCE_TYPE will be applied to the n_desc field | |
175 | * of an nlist structure for an undefined symbol to determine the type of | |
176 | * undefined reference (lazy or non-lazy). | |
177 | * | |
178 | * The constants for the REFERENCE FLAGS are propagated to the reference table | |
179 | * in a shared library file. In that case the constant for a defined symbol, | |
180 | * REFERENCE_FLAG_DEFINED, is also used. | |
181 | */ | |
182 | /* Reference type bits of the n_desc field of undefined symbols */ | |
183 | #define REFERENCE_TYPE 0xf | |
184 | /* types of references */ | |
185 | #define REFERENCE_FLAG_UNDEFINED_NON_LAZY 0 | |
186 | #define REFERENCE_FLAG_UNDEFINED_LAZY 1 | |
187 | #define REFERENCE_FLAG_DEFINED 2 | |
188 | #define REFERENCE_FLAG_PRIVATE_DEFINED 3 | |
189 | #define REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY 4 | |
190 | #define REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY 5 | |
191 | ||
192 | /* | |
193 | * To simplify stripping of objects that use are used with the dynamic link | |
194 | * editor, the static link editor marks the symbols defined an object that are | |
195 | * referenced by a dynamicly bound object (dynamic shared libraries, bundles). | |
196 | * With this marking strip knows not to strip these symbols. | |
197 | */ | |
198 | #define REFERENCED_DYNAMICALLY 0x0010 | |
199 | ||
200 | /* | |
201 | * The non-reference type bits of the n_desc field for global symbols are | |
202 | * reserved for the dynamic link editor. All of these bits must start out | |
203 | * zero in the object file. | |
204 | */ | |
205 | #define N_DESC_DISCARDED 0x8000 /* symbol is discarded */ | |
206 | ||
207 | #endif |