1 /* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*-* 
   3  * Copyright (c) 2009 Apple Inc. All rights reserved. 
   5  * @APPLE_LICENSE_HEADER_START@ 
   7  * This file contains Original Code and/or Modifications of Original Code 
   8  * as defined in and that are subject to the Apple Public Source License 
   9  * Version 2.0 (the 'License'). You may not use this file except in 
  10  * compliance with the License. Please obtain a copy of the License at 
  11  * http://www.opensource.apple.com/apsl/ and read it before using this 
  14  * The Original Code and all software distributed under the License are 
  15  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
  16  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
  17  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 
  18  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
  19  * Please see the License for the specific language governing rights and 
  20  * limitations under the License. 
  22  * @APPLE_LICENSE_HEADER_END@ 
  25 #ifndef __INPUT_FILES_H__ 
  26 #define __INPUT_FILES_H__ 
  29 #include <sys/types.h> 
  32 #include <sys/sysctl.h> 
  37 #include <mach/mach_time.h> 
  38 #include <mach/vm_statistics.h> 
  39 #include <mach/mach_init.h> 
  40 #include <mach/mach_host.h> 
  42 #include <mach-o/dyld.h> 
  52 class InputFiles 
: public ld::dylib::File::DylibHandler
 
  55                                                                 InputFiles(Options
& opts
, const char** archName
); 
  57         // implementation from ld::dylib::File::DylibHandler 
  58         virtual ld::dylib::File
*        findDylib(const char* installPath
, const char* fromPath
); 
  60         // iterates all atoms in initial files 
  61         bool                                            forEachInitialAtom(ld::File::AtomHandler
&) const; 
  62         // searches libraries for name 
  63         bool                                            searchLibraries(const char* name
, bool searchDylibs
, bool searchArchives
, ld::File::AtomHandler
&) const; 
  64         // see if any linked dylibs export a weak def of symbol 
  65         bool                                            searchWeakDefInDylib(const char* name
) const; 
  66         // copy dylibs to link with in command line order 
  67         void                                            dylibs(ld::Internal
& state
); 
  69         bool                                            inferredArch() const { return _inferredArch
; } 
  71         uint32_t                                        nextInputOrdinal() const  { return _nextInputOrdinal
++; } 
  73         // for -print_statistics 
  74         uint64_t                                        _totalObjectSize
; 
  75         uint64_t                                        _totalArchiveSize
; 
  76         uint32_t                                        _totalObjectLoaded
; 
  77         uint32_t                                        _totalArchivesLoaded
; 
  78         uint32_t                                        _totalDylibsLoaded
; 
  82         void                                            inferArchitecture(Options
& opts
, const char** archName
); 
  83         const char*                                     fileArch(const uint8_t* p
, unsigned len
); 
  84         ld::File
*                                       makeFile(const Options::FileInfo
& info
); 
  85         ld::File
*                                       addDylib(ld::dylib::File
* f
,        const Options::FileInfo
& info
, uint64_t mappedLen
); 
  86         ld::File
*                                       addObject(ld::relocatable::File
* f
, const Options::FileInfo
& info
, uint64_t mappedLen
); 
  87         ld::File
*                                       addArchive(ld::File
* f
,             const Options::FileInfo
& info
, uint64_t mappedLen
); 
  88         void                                            logTraceInfo (const char* format
, ...) const; 
  89         void                                            logDylib(ld::File
*, bool indirect
); 
  90         void                                            logArchive(ld::File
*) const; 
  91         void                                            createIndirectDylibs(); 
  92         void                                            checkDylibClientRestrictions(ld::dylib::File
*); 
  93         void                                            createOpaqueFileSections(); 
  97                 bool operator()(const char* left
, const char* right
) const { return (strcmp(left
, right
) == 0); } 
  99         typedef __gnu_cxx::hash_map
<const char*, ld::dylib::File
*, __gnu_cxx::hash
<const char*>, CStringEquals
> InstallNameToDylib
; 
 101         const Options
&                          _options
; 
 102         std::vector
<ld::File
*>          _inputFiles
; 
 103         mutable std::set
<class ld::File
*>       _archiveFilesLogged
; 
 104         InstallNameToDylib                      _installPathToDylibs
; 
 105         std::set
<ld::dylib::File
*>      _allDylibs
; 
 106         ld::dylib::File
*                        _bundleLoader
; 
 107         mutable uint32_t                        _nextInputOrdinal
; 
 108         bool                                            _allDirectDylibsLoaded
; 
 115 #endif // __INPUT_FILES_H__