1/* 2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23#if defined(__MWERKS__) && !defined(__private_extern__) 24#define __private_extern__ __declspec(private_extern) 25#endif 26 27/* 28 * Global types, variables and routines declared in the file pass1.c. 29 * 30 * The following include file need to be included before this file: 31 * #include "ld.h" 32 */ 33 34#ifndef RLD 35/* TRUE if -search_paths_first was specified */ 36__private_extern__ enum bool search_paths_first; 37 38/* the user specified directories to search for -lx filenames, and the number 39 of them */ 40__private_extern__ char **search_dirs; 41__private_extern__ unsigned long nsearch_dirs; 42 43/* 44 * The user specified directories to search via the environment variable 45 * LD_LIBRARY_PATH. 46 */ 47__private_extern__ char **ld_library_paths; 48__private_extern__ unsigned long nld_library_paths; 49 50/* the standard directories to search for -lx filenames */ 51__private_extern__ char *standard_dirs[]; 52 53/* 54 * The user specified directories to search for "-framework Foo" names, and the 55 * number of them. These are specified with -F options. 56 */ 57__private_extern__ char **framework_dirs; 58__private_extern__ unsigned long nframework_dirs; 59 60/* the standard framework directories to search for "-framework Foo" names */ 61__private_extern__ char *standard_framework_dirs[]; 62 63/* the pointer to the head of the base object file's segments */ 64__private_extern__ struct merged_segment *base_obj_segments; 65 66/* 67 * These are pointers to strings and symbols used to search of the table of 68 * contents of a library. These have to be can not be local so that routines 69 * can set them and that ranlib_bsearch() and dylib_bsearch() can use them. 70 */ 71__private_extern__ char *bsearch_strings; 72#ifndef RLD 73__private_extern__ struct nlist *bsearch_symbols; 74#endif /* !defined(RLD) */ 75 76/* 77 * The lists of libraries to be search with dynamic library search semantics. 78 */ 79enum library_type { 80 DYLIB, 81 SORTED_ARCHIVE, 82 UNSORTED_ARCHIVE, 83 BUNDLE_LOADER 84}; 85struct dynamic_library { 86 enum library_type type; 87 88 /* following used for dynamic libraries */ 89 char *dylib_name; 90 struct dylib_command *dl; 91 char *umbrella_name; 92 char *library_name; 93 enum bool indirect_twolevel_ref_flagged; 94 enum bool some_non_weak_refs; 95 enum bool some_symbols_referenced; 96 enum bool force_weak_dylib; 97 struct object_file *definition_obj; 98 char *dylib_file; /* argument to -dylib_file "install_name:file_name" */ 99 struct dylib_table_of_contents *tocs; 100 struct nlist *symbols; 101 char *strings; 102 struct dylib_module *mods; 103 struct prebound_dylib_command *pbdylib; 104 char *linked_modules; 105 /* following are used when -twolevel_namespace is in effect */ 106 unsigned long ndependent_images; 107 struct dynamic_library **dependent_images; 108 enum bool sub_images_setup; 109 unsigned long nsub_images; 110 struct dynamic_library **sub_images; 111 enum bool twolevel_searched; 112 113 /* following used for archive libraries */ 114 char *file_name; 115 char *file_addr; 116 unsigned long file_size; 117 unsigned long nranlibs; 118 struct ranlib *ranlibs; 119 char *ranlib_strings; 120 enum bool ld_trace_archive_printed; 121 122 struct dynamic_library *next; 123}; 124 125/* 126 * The list of dynamic libraries to search. The list of specified libraries 127 * can contain archive libraries when archive libraries appear after dynamic 128 * libraries on the link line. 129 */ 130__private_extern__ struct dynamic_library *dynamic_libs; 131 132__private_extern__ unsigned int indirect_library_ratio; 133 134#endif /* !defined(RLD) */ 135 136__private_extern__ void pass1( 137 char *filename, 138 enum bool lname, 139 enum bool base_name, 140 enum bool framework_name, 141 enum bool bundle_loader, 142 enum bool force_weak); 143__private_extern__ void merge( 144 enum bool dylib_only, 145 enum bool bundle_loader, 146 enum bool force_weak); 147__private_extern__ void check_fat( 148 char *file_name, 149 unsigned long file_size, 150 struct fat_header *fat_header, 151 struct fat_arch *fat_archs, 152 char *ar_name, 153 unsigned long ar_name_size); 154 155#ifndef RLD 156__private_extern__ void search_dynamic_libs( 157 void); 158__private_extern__ void prebinding_check_for_dylib_override_symbols( 159 void); 160__private_extern__ void twolevel_namespace_check_for_unused_dylib_symbols( 161 void); 162__private_extern__ struct dynamic_library *add_dynamic_lib( 163 enum library_type type, 164 struct dylib_command *dl, 165 struct object_file *definition_obj); 166__private_extern__ int dylib_bsearch( 167 const char *symbol_name, 168 const struct dylib_table_of_contents *toc); 169#endif /* !defined(RLD) */ 170 171#ifdef RLD 172__private_extern__ void merge_base_program( 173 char *basefile_name, 174 struct mach_header *basefile_addr, 175 struct segment_command *seg_linkedit, 176 struct nlist *symtab, 177 unsigned long nsyms, 178 char *strtab, 179 unsigned long strsize); 180#endif /* RLD */ 181