]> git.saurik.com Git - apple/ld64.git/blob - src/ld/Options.h
ld64-242.2.tar.gz
[apple/ld64.git] / src / ld / Options.h
1 /* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*-
2 *
3 * Copyright (c) 2005-2010 Apple Inc. All rights reserved.
4 *
5 * @APPLE_LICENSE_HEADER_START@
6 *
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
12 * file.
13 *
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.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24
25 #ifndef __OPTIONS__
26 #define __OPTIONS__
27
28
29 #include <stdint.h>
30 #include <mach/machine.h>
31
32 #include <vector>
33 #include <unordered_set>
34 #include <unordered_map>
35
36 #include "ld.hpp"
37 #include "Snapshot.h"
38
39 extern void throwf (const char* format, ...) __attribute__ ((noreturn,format(printf, 1, 2)));
40 extern void warning(const char* format, ...) __attribute__((format(printf, 1, 2)));
41
42 class Snapshot;
43
44 class LibraryOptions
45 {
46 public:
47 LibraryOptions() : fWeakImport(false), fReExport(false), fBundleLoader(false),
48 fLazyLoad(false), fUpward(false), fIndirectDylib(false),
49 fForceLoad(false) {}
50 // for dynamic libraries
51 bool fWeakImport;
52 bool fReExport;
53 bool fBundleLoader;
54 bool fLazyLoad;
55 bool fUpward;
56 bool fIndirectDylib;
57 // for static libraries
58 bool fForceLoad;
59 };
60
61
62
63 //
64 // The public interface to the Options class is the abstract representation of what work the linker
65 // should do.
66 //
67 // This abstraction layer will make it easier to support a future where the linker is a shared library
68 // invoked directly from Xcode. The target settings in Xcode would be used to directly construct an Options
69 // object (without building a command line which is then parsed).
70 //
71 //
72 class Options
73 {
74 public:
75 Options(int argc, const char* argv[]);
76 ~Options();
77
78 enum OutputKind { kDynamicExecutable, kStaticExecutable, kDynamicLibrary, kDynamicBundle, kObjectFile, kDyld, kPreload, kKextBundle };
79 enum NameSpace { kTwoLevelNameSpace, kFlatNameSpace, kForceFlatNameSpace };
80 // Standard treatment for many options.
81 enum Treatment { kError, kWarning, kSuppress, kNULL, kInvalid };
82 enum UndefinedTreatment { kUndefinedError, kUndefinedWarning, kUndefinedSuppress, kUndefinedDynamicLookup };
83 enum WeakReferenceMismatchTreatment { kWeakReferenceMismatchError, kWeakReferenceMismatchWeak,
84 kWeakReferenceMismatchNonWeak };
85 enum CommonsMode { kCommonsIgnoreDylibs, kCommonsOverriddenByDylibs, kCommonsConflictsDylibsError };
86 enum UUIDMode { kUUIDNone, kUUIDRandom, kUUIDContent };
87 enum LocalSymbolHandling { kLocalSymbolsAll, kLocalSymbolsNone, kLocalSymbolsSelectiveInclude, kLocalSymbolsSelectiveExclude };
88 enum DebugInfoStripping { kDebugInfoNone, kDebugInfoMinimal, kDebugInfoFull };
89
90 class FileInfo {
91 public:
92 const char* path;
93 uint64_t fileLen;
94 time_t modTime;
95 LibraryOptions options;
96 ld::File::Ordinal ordinal;
97 bool fromFileList;
98
99 // These are used by the threaded input file parsing engine.
100 mutable int inputFileSlot; // The input file "slot" assigned to this particular file
101 bool readyToParse;
102
103 // The use pattern for FileInfo is to create one on the stack in a leaf function and return
104 // it to the calling frame by copy. Therefore the copy constructor steals the path string from
105 // the source, which dies with the stack frame.
106 FileInfo(FileInfo const &other) : path(other.path), fileLen(other.fileLen), modTime(other.modTime), options(other.options), ordinal(other.ordinal), fromFileList(other.fromFileList), inputFileSlot(-1) { ((FileInfo&)other).path = NULL; };
107
108 // Create an empty FileInfo. The path can be set implicitly by checkFileExists().
109 FileInfo() : path(NULL), fileLen(0), modTime(0), options(), fromFileList(false) {};
110
111 // Create a FileInfo for a specific path, but does not stat the file.
112 FileInfo(const char *_path) : path(strdup(_path)), fileLen(0), modTime(0), options(), fromFileList(false) {};
113
114 ~FileInfo() { if (path) ::free((void*)path); }
115
116 // Stat the file and update fileLen and modTime.
117 // If the object already has a path the p must be NULL.
118 // If the object does not have a path then p can be any candidate path, and if the file exists the object permanently remembers the path.
119 // Returns true if the file exists, false if not.
120 bool checkFileExists(const Options& options, const char *p=NULL);
121
122 // Returns true if a previous call to checkFileExists() succeeded.
123 // Returns false if the file does not exist of checkFileExists() has never been called.
124 bool missing() const { return modTime==0; }
125 };
126
127 struct ExtraSection {
128 const char* segmentName;
129 const char* sectionName;
130 const char* path;
131 const uint8_t* data;
132 uint64_t dataLen;
133 typedef ExtraSection* iterator;
134 typedef const ExtraSection* const_iterator;
135 };
136
137 struct SectionAlignment {
138 const char* segmentName;
139 const char* sectionName;
140 uint8_t alignment;
141 };
142
143 struct SectionOrderList {
144 const char* segmentName;
145 std::vector<const char*> sectionOrder;
146 };
147
148 struct OrderedSymbol {
149 const char* symbolName;
150 const char* objectFileName;
151 };
152 typedef const OrderedSymbol* OrderedSymbolsIterator;
153
154 struct SegmentStart {
155 const char* name;
156 uint64_t address;
157 };
158
159 struct SegmentSize {
160 const char* name;
161 uint64_t size;
162 };
163
164 struct SegmentProtect {
165 const char* name;
166 uint32_t max;
167 uint32_t init;
168 };
169
170 struct DylibOverride {
171 const char* installName;
172 const char* useInstead;
173 };
174
175 struct AliasPair {
176 const char* realName;
177 const char* alias;
178 };
179
180 struct SectionRename {
181 const char* fromSegment;
182 const char* fromSection;
183 const char* toSegment;
184 const char* toSection;
185 };
186
187 struct SegmentRename {
188 const char* fromSegment;
189 const char* toSegment;
190 };
191
192 enum { depLinkerVersion=0x00, depObjectFile=0x10, depDirectDylib=0x10, depIndirectDylib=0x10,
193 depUpwardDirectDylib=0x10, depUpwardIndirectDylib=0x10, depArchive=0x10,
194 depFileList=0x10, depSection=0x10, depBundleLoader=0x10, depMisc=0x10, depNotFound=0x11,
195 depOutputFile = 0x40 };
196
197 void dumpDependency(uint8_t, const char* path) const;
198
199 typedef const char* const* UndefinesIterator;
200
201 // const ObjectFile::ReaderOptions& readerOptions();
202 const char* outputFilePath() const { return fOutputFile; }
203 const std::vector<FileInfo>& getInputFiles() const { return fInputFiles; }
204
205 cpu_type_t architecture() const { return fArchitecture; }
206 bool preferSubArchitecture() const { return fHasPreferredSubType; }
207 cpu_subtype_t subArchitecture() const { return fSubArchitecture; }
208 bool allowSubArchitectureMismatches() const { return fAllowCpuSubtypeMismatches; }
209 bool forceCpuSubtypeAll() const { return fForceSubtypeAll; }
210 const char* architectureName() const { return fArchitectureName; }
211 void setArchitecture(cpu_type_t, cpu_subtype_t subtype);
212 bool archSupportsThumb2() const { return fArchSupportsThumb2; }
213 OutputKind outputKind() const { return fOutputKind; }
214 bool prebind() const { return fPrebind; }
215 bool bindAtLoad() const { return fBindAtLoad; }
216 NameSpace nameSpace() const { return fNameSpace; }
217 const char* installPath() const; // only for kDynamicLibrary
218 uint64_t currentVersion() const { return fDylibCurrentVersion; } // only for kDynamicLibrary
219 uint32_t currentVersion32() const; // only for kDynamicLibrary
220 uint32_t compatibilityVersion() const { return fDylibCompatVersion; } // only for kDynamicLibrary
221 const char* entryName() const { return fEntryName; } // only for kDynamicExecutable or kStaticExecutable
222 const char* executablePath();
223 uint64_t baseAddress() const { return fBaseAddress; }
224 uint64_t maxAddress() const { return fMaxAddress; }
225 bool keepPrivateExterns() const { return fKeepPrivateExterns; } // only for kObjectFile
226 bool needsModuleTable() const { return fNeedsModuleTable; } // only for kDynamicLibrary
227 bool interposable(const char* name) const;
228 bool hasExportRestrictList() const { return (fExportMode != kExportDefault); } // -exported_symbol or -unexported_symbol
229 bool hasExportMaskList() const { return (fExportMode == kExportSome); } // just -exported_symbol
230 bool hasWildCardExportRestrictList() const;
231 bool hasReExportList() const { return ! fReExportSymbols.empty(); }
232 bool wasRemovedExport(const char* sym) const { return ( fRemovedExports.find(sym) != fRemovedExports.end() ); }
233 bool allGlobalsAreDeadStripRoots() const;
234 bool shouldExport(const char*) const;
235 bool shouldReExport(const char*) const;
236 bool ignoreOtherArchInputFiles() const { return fIgnoreOtherArchFiles; }
237 bool traceDylibs() const { return fTraceDylibs; }
238 bool traceArchives() const { return fTraceArchives; }
239 bool deadCodeStrip() const { return fDeadStrip; }
240 UndefinedTreatment undefinedTreatment() const { return fUndefinedTreatment; }
241 ld::MacVersionMin macosxVersionMin() const { return fMacVersionMin; }
242 ld::IOSVersionMin iOSVersionMin() const { return fIOSVersionMin; }
243 bool minOS(ld::MacVersionMin mac, ld::IOSVersionMin iPhoneOS);
244 bool messagesPrefixedWithArchitecture();
245 Treatment picTreatment();
246 WeakReferenceMismatchTreatment weakReferenceMismatchTreatment() const { return fWeakReferenceMismatchTreatment; }
247 const char* umbrellaName() const { return fUmbrellaName; }
248 const std::vector<const char*>& allowableClients() const { return fAllowableClients; }
249 const char* clientName() const { return fClientName; }
250 const char* initFunctionName() const { return fInitFunctionName; } // only for kDynamicLibrary
251 const char* dotOutputFile();
252 uint64_t pageZeroSize() const { return fZeroPageSize; }
253 bool hasCustomStack() const { return (fStackSize != 0); }
254 uint64_t customStackSize() const { return fStackSize; }
255 uint64_t customStackAddr() const { return fStackAddr; }
256 bool hasExecutableStack() const { return fExecutableStack; }
257 bool hasNonExecutableHeap() const { return fNonExecutableHeap; }
258 UndefinesIterator initialUndefinesBegin() const { return &fInitialUndefines[0]; }
259 UndefinesIterator initialUndefinesEnd() const { return &fInitialUndefines[fInitialUndefines.size()]; }
260 const std::vector<const char*>& initialUndefines() const { return fInitialUndefines; }
261 bool printWhyLive(const char* name) const;
262 uint32_t minimumHeaderPad() const { return fMinimumHeaderPad; }
263 bool maxMminimumHeaderPad() const { return fMaxMinimumHeaderPad; }
264 ExtraSection::const_iterator extraSectionsBegin() const { return &fExtraSections[0]; }
265 ExtraSection::const_iterator extraSectionsEnd() const { return &fExtraSections[fExtraSections.size()]; }
266 CommonsMode commonsMode() const { return fCommonsMode; }
267 bool warnCommons() const { return fWarnCommons; }
268 bool keepRelocations();
269 FileInfo findFile(const char* path) const;
270 UUIDMode UUIDMode() const { return fUUIDMode; }
271 bool warnStabs();
272 bool pauseAtEnd() { return fPause; }
273 bool printStatistics() const { return fStatistics; }
274 bool printArchPrefix() const { return fMessagesPrefixedWithArchitecture; }
275 void gotoClassicLinker(int argc, const char* argv[]);
276 bool sharedRegionEligible() const { return fSharedRegionEligible; }
277 bool printOrderFileStatistics() const { return fPrintOrderFileStatistics; }
278 const char* dTraceScriptName() { return fDtraceScriptName; }
279 bool dTrace() { return (fDtraceScriptName != NULL); }
280 unsigned long orderedSymbolsCount() const { return fOrderedSymbols.size(); }
281 OrderedSymbolsIterator orderedSymbolsBegin() const { return &fOrderedSymbols[0]; }
282 OrderedSymbolsIterator orderedSymbolsEnd() const { return &fOrderedSymbols[fOrderedSymbols.size()]; }
283 bool splitSeg() const { return fSplitSegs; }
284 uint64_t baseWritableAddress() { return fBaseWritableAddress; }
285 uint64_t segmentAlignment() const { return fSegmentAlignment; }
286 uint64_t segPageSize(const char* segName) const;
287 uint64_t customSegmentAddress(const char* segName) const;
288 bool hasCustomSegmentAddress(const char* segName) const;
289 bool hasCustomSectionAlignment(const char* segName, const char* sectName) const;
290 uint8_t customSectionAlignment(const char* segName, const char* sectName) const;
291 uint32_t initialSegProtection(const char*) const;
292 uint32_t maxSegProtection(const char*) const;
293 bool saveTempFiles() const { return fSaveTempFiles; }
294 const std::vector<const char*>& rpaths() const { return fRPaths; }
295 bool readOnlyx86Stubs() { return fReadOnlyx86Stubs; }
296 const std::vector<DylibOverride>& dylibOverrides() const { return fDylibOverrides; }
297 const char* generatedMapPath() const { return fMapPath; }
298 bool positionIndependentExecutable() const { return fPositionIndependentExecutable; }
299 Options::FileInfo findFileUsingPaths(const char* path) const;
300 bool deadStripDylibs() const { return fDeadStripDylibs; }
301 bool allowedUndefined(const char* name) const { return ( fAllowedUndefined.find(name) != fAllowedUndefined.end() ); }
302 bool someAllowedUndefines() const { return (fAllowedUndefined.size() != 0); }
303 LocalSymbolHandling localSymbolHandling() { return fLocalSymbolHandling; }
304 bool keepLocalSymbol(const char* symbolName) const;
305 bool allowTextRelocs() const { return fAllowTextRelocs; }
306 bool warnAboutTextRelocs() const { return fWarnTextRelocs; }
307 bool kextsUseStubs() const { return fKextsUseStubs; }
308 bool usingLazyDylibLinking() const { return fUsingLazyDylibLinking; }
309 bool verbose() const { return fVerbose; }
310 bool makeEncryptable() const { return fEncryptable; }
311 bool needsUnwindInfoSection() const { return fAddCompactUnwindEncoding; }
312 const std::vector<const char*>& llvmOptions() const{ return fLLVMOptions; }
313 const std::vector<const char*>& segmentOrder() const{ return fSegmentOrder; }
314 const std::vector<const char*>* sectionOrder(const char* segName) const;
315 const std::vector<const char*>& dyldEnvironExtras() const{ return fDyldEnvironExtras; }
316 const std::vector<const char*>& astFilePaths() const{ return fASTFilePaths; }
317 bool makeCompressedDyldInfo() const { return fMakeCompressedDyldInfo; }
318 bool hasExportedSymbolOrder();
319 bool exportedSymbolOrder(const char* sym, unsigned int* order) const;
320 bool orderData() { return fOrderData; }
321 bool errorOnOtherArchFiles() const { return fErrorOnOtherArchFiles; }
322 bool markAutoDeadStripDylib() const { return fMarkDeadStrippableDylib; }
323 bool removeEHLabels() const { return fNoEHLabels; }
324 bool useSimplifiedDylibReExports() const { return fUseSimplifiedDylibReExports; }
325 bool objCABIVersion2POverride() const { return fObjCABIVersion2Override; }
326 bool useUpwardDylibs() const { return fCanUseUpwardDylib; }
327 bool fullyLoadArchives() const { return fFullyLoadArchives; }
328 bool loadAllObjcObjectsFromArchives() const { return fLoadAllObjcObjectsFromArchives; }
329 bool autoOrderInitializers() const { return fAutoOrderInitializers; }
330 bool optimizeZeroFill() const { return fOptimizeZeroFill; }
331 bool mergeZeroFill() const { return fMergeZeroFill; }
332 bool logAllFiles() const { return fLogAllFiles; }
333 DebugInfoStripping debugInfoStripping() const { return fDebugInfoStripping; }
334 bool flatNamespace() const { return fFlatNamespace; }
335 bool linkingMainExecutable() const { return fLinkingMainExecutable; }
336 bool implicitlyLinkIndirectPublicDylibs() const { return fImplicitlyLinkPublicDylibs; }
337 bool whyLoad() const { return fWhyLoad; }
338 const char* traceOutputFile() const { return fTraceOutputFile; }
339 bool outputSlidable() const { return fOutputSlidable; }
340 bool haveCmdLineAliases() const { return (fAliases.size() != 0); }
341 const std::vector<AliasPair>& cmdLineAliases() const { return fAliases; }
342 bool makeTentativeDefinitionsReal() const { return fMakeTentativeDefinitionsReal; }
343 const char* dyldInstallPath() const { return fDyldInstallPath; }
344 bool warnWeakExports() const { return fWarnWeakExports; }
345 bool objcGcCompaction() const { return fObjcGcCompaction; }
346 bool objcGc() const { return fObjCGc; }
347 bool objcGcOnly() const { return fObjCGcOnly; }
348 bool canUseThreadLocalVariables() const { return fTLVSupport; }
349 bool addVersionLoadCommand() const { return fVersionLoadCommand; }
350 bool addFunctionStarts() const { return fFunctionStartsLoadCommand; }
351 bool addDataInCodeInfo() const { return fDataInCodeInfoLoadCommand; }
352 bool canReExportSymbols() const { return fCanReExportSymbols; }
353 const char* tempLtoObjectPath() const { return fTempLtoObjectPath; }
354 const char* overridePathlibLTO() const { return fOverridePathlibLTO; }
355 const char* mcpuLTO() const { return fLtoCpu; }
356 bool objcCategoryMerging() const { return fObjcCategoryMerging; }
357 bool pageAlignDataAtoms() const { return fPageAlignDataAtoms; }
358 bool keepDwarfUnwind() const { return fKeepDwarfUnwind; }
359 bool verboseOptimizationHints() const { return fVerboseOptimizationHints; }
360 bool ignoreOptimizationHints() const { return fIgnoreOptimizationHints; }
361 bool generateDtraceDOF() const { return fGenerateDtraceDOF; }
362 bool allowBranchIslands() const { return fAllowBranchIslands; }
363 bool traceSymbolLayout() const { return fTraceSymbolLayout; }
364 bool markAppExtensionSafe() const { return fMarkAppExtensionSafe; }
365 bool checkDylibsAreAppExtensionSafe() const { return fCheckAppExtensionSafe; }
366 bool forceLoadSwiftLibs() const { return fForceLoadSwiftLibs; }
367 bool hasWeakBitTweaks() const;
368 bool forceWeak(const char* symbolName) const;
369 bool forceNotWeak(const char* symbolName) const;
370 bool forceWeakNonWildCard(const char* symbolName) const;
371 bool forceNotWeakNonWildcard(const char* symbolName) const;
372 bool forceCoalesce(const char* symbolName) const;
373 Snapshot& snapshot() const { return fLinkSnapshot; }
374 bool errorBecauseOfWarnings() const;
375 bool needsThreadLoadCommand() const { return fNeedsThreadLoadCommand; }
376 bool needsEntryPointLoadCommand() const { return fEntryPointLoadCommand; }
377 bool needsSourceVersionLoadCommand() const { return fSourceVersionLoadCommand; }
378 bool needsDependentDRInfo() const { return fDependentDRInfo; }
379 bool canUseAbsoluteSymbols() const { return fAbsoluteSymbols; }
380 bool allowSimulatorToLinkWithMacOSX() const { return fAllowSimulatorToLinkWithMacOSX; }
381 uint64_t sourceVersion() const { return fSourceVersion; }
382 uint32_t sdkVersion() const { return fSDKVersion; }
383 const char* demangleSymbol(const char* sym) const;
384 bool pipelineEnabled() const { return fPipelineFifo != NULL; }
385 const char* pipelineFifo() const { return fPipelineFifo; }
386 bool dumpDependencyInfo() const { return (fDependencyInfoPath != NULL); }
387 const char* dependencyInfoPath() const { return fDependencyInfoPath; }
388 bool targetIOSSimulator() const { return fTargetIOSSimulator; }
389 ld::relocatable::File::LinkerOptionsList&
390 linkerOptions() const { return fLinkerOptions; }
391 FileInfo findFramework(const char* frameworkName) const;
392 FileInfo findLibrary(const char* rootName, bool dylibsOnly=false) const;
393 bool armUsesZeroCostExceptions() const;
394 const std::vector<SectionRename>& sectionRenames() const { return fSectionRenames; }
395 const std::vector<SegmentRename>& segmentRenames() const { return fSegmentRenames; }
396 bool moveRoSymbol(const char* symName, const char* filePath, const char*& seg, bool& wildCardMatch) const;
397 bool moveRwSymbol(const char* symName, const char* filePath, const char*& seg, bool& wildCardMatch) const;
398
399 private:
400 typedef std::unordered_map<const char*, unsigned int, ld::CStringHash, ld::CStringEquals> NameToOrder;
401 typedef std::unordered_set<const char*, ld::CStringHash, ld::CStringEquals> NameSet;
402 enum ExportMode { kExportDefault, kExportSome, kDontExportSome };
403 enum LibrarySearchMode { kSearchDylibAndArchiveInEachDir, kSearchAllDirsForDylibsThenAllDirsForArchives };
404 enum InterposeMode { kInterposeNone, kInterposeAllExternal, kInterposeSome };
405
406 class SetWithWildcards {
407 public:
408 void insert(const char*);
409 bool contains(const char*, bool* wildCardMatch=NULL) const;
410 bool containsWithPrefix(const char* symbol, const char* file, bool& wildCardMatch) const;
411 bool containsNonWildcard(const char*) const;
412 bool empty() const { return fRegular.empty() && fWildCard.empty(); }
413 bool hasWildCards() const { return !fWildCard.empty(); }
414 NameSet::iterator regularBegin() const { return fRegular.begin(); }
415 NameSet::iterator regularEnd() const { return fRegular.end(); }
416 void remove(const NameSet&);
417 private:
418 static bool hasWildCards(const char*);
419 bool wildCardMatch(const char* pattern, const char* candidate) const;
420 bool inCharRange(const char*& range, unsigned char c) const;
421
422 NameSet fRegular;
423 std::vector<const char*> fWildCard;
424 };
425
426 struct SymbolsMove {
427 const char* toSegment;
428 SetWithWildcards symbols;
429 };
430
431 void parse(int argc, const char* argv[]);
432 void checkIllegalOptionCombinations();
433 void buildSearchPaths(int argc, const char* argv[]);
434 void parseArch(const char* architecture);
435 FileInfo findFramework(const char* rootName, const char* suffix) const;
436 bool checkForFile(const char* format, const char* dir, const char* rootName,
437 FileInfo& result) const;
438 uint64_t parseVersionNumber64(const char*);
439 uint32_t parseVersionNumber32(const char*);
440 void parseSectionOrderFile(const char* segment, const char* section, const char* path);
441 void parseOrderFile(const char* path, bool cstring);
442 void addSection(const char* segment, const char* section, const char* path);
443 void addSubLibrary(const char* name);
444 void loadFileList(const char* fileOfPaths, ld::File::Ordinal baseOrdinal);
445 uint64_t parseAddress(const char* addr);
446 void loadExportFile(const char* fileOfExports, const char* option, SetWithWildcards& set);
447 void parseAliasFile(const char* fileOfAliases);
448 void parsePreCommandLineEnvironmentSettings();
449 void parsePostCommandLineEnvironmentSettings();
450 void setUndefinedTreatment(const char* treatment);
451 void setMacOSXVersionMin(const char* version);
452 void setIOSVersionMin(const char* version);
453 void setWeakReferenceMismatchTreatment(const char* treatment);
454 void addDylibOverride(const char* paths);
455 void addSectionAlignment(const char* segment, const char* section, const char* alignment);
456 CommonsMode parseCommonsTreatment(const char* mode);
457 Treatment parseTreatment(const char* treatment);
458 void reconfigureDefaults();
459 void checkForClassic(int argc, const char* argv[]);
460 void parseSegAddrTable(const char* segAddrPath, const char* installPath);
461 void addLibrary(const FileInfo& info);
462 void warnObsolete(const char* arg);
463 uint32_t parseProtection(const char* prot);
464 void loadSymbolOrderFile(const char* fileOfExports, NameToOrder& orderMapping);
465 void addSectionRename(const char* srcSegment, const char* srcSection, const char* dstSegment, const char* dstSection);
466 void addSegmentRename(const char* srcSegment, const char* dstSegment);
467 void addSymbolMove(const char* dstSegment, const char* symbolList, std::vector<SymbolsMove>& list, const char* optionName);
468
469
470 // ObjectFile::ReaderOptions fReaderOptions;
471 const char* fOutputFile;
472 std::vector<Options::FileInfo> fInputFiles;
473 cpu_type_t fArchitecture;
474 cpu_subtype_t fSubArchitecture;
475 const char* fArchitectureName;
476 OutputKind fOutputKind;
477 bool fHasPreferredSubType;
478 bool fArchSupportsThumb2;
479 bool fPrebind;
480 bool fBindAtLoad;
481 bool fKeepPrivateExterns;
482 bool fNeedsModuleTable;
483 bool fIgnoreOtherArchFiles;
484 bool fErrorOnOtherArchFiles;
485 bool fForceSubtypeAll;
486 InterposeMode fInterposeMode;
487 bool fDeadStrip;
488 NameSpace fNameSpace;
489 uint32_t fDylibCompatVersion;
490 uint64_t fDylibCurrentVersion;
491 const char* fDylibInstallName;
492 const char* fFinalName;
493 const char* fEntryName;
494 uint64_t fBaseAddress;
495 uint64_t fMaxAddress;
496 uint64_t fBaseWritableAddress;
497 bool fSplitSegs;
498 SetWithWildcards fExportSymbols;
499 SetWithWildcards fDontExportSymbols;
500 SetWithWildcards fInterposeList;
501 SetWithWildcards fForceWeakSymbols;
502 SetWithWildcards fForceNotWeakSymbols;
503 SetWithWildcards fReExportSymbols;
504 SetWithWildcards fForceCoalesceSymbols;
505 NameSet fRemovedExports;
506 NameToOrder fExportSymbolsOrder;
507 ExportMode fExportMode;
508 LibrarySearchMode fLibrarySearchMode;
509 UndefinedTreatment fUndefinedTreatment;
510 bool fMessagesPrefixedWithArchitecture;
511 WeakReferenceMismatchTreatment fWeakReferenceMismatchTreatment;
512 std::vector<const char*> fSubUmbellas;
513 std::vector<const char*> fSubLibraries;
514 std::vector<const char*> fAllowableClients;
515 std::vector<const char*> fRPaths;
516 const char* fClientName;
517 const char* fUmbrellaName;
518 const char* fInitFunctionName;
519 const char* fDotOutputFile;
520 const char* fExecutablePath;
521 const char* fBundleLoader;
522 const char* fDtraceScriptName;
523 const char* fSegAddrTablePath;
524 const char* fMapPath;
525 const char* fDyldInstallPath;
526 const char* fTempLtoObjectPath;
527 const char* fOverridePathlibLTO;
528 const char* fLtoCpu;
529 uint64_t fZeroPageSize;
530 uint64_t fStackSize;
531 uint64_t fStackAddr;
532 uint64_t fSourceVersion;
533 uint32_t fSDKVersion;
534 bool fExecutableStack;
535 bool fNonExecutableHeap;
536 bool fDisableNonExecutableHeap;
537 uint32_t fMinimumHeaderPad;
538 uint64_t fSegmentAlignment;
539 CommonsMode fCommonsMode;
540 enum UUIDMode fUUIDMode;
541 SetWithWildcards fLocalSymbolsIncluded;
542 SetWithWildcards fLocalSymbolsExcluded;
543 LocalSymbolHandling fLocalSymbolHandling;
544 bool fWarnCommons;
545 bool fVerbose;
546 bool fKeepRelocations;
547 bool fWarnStabs;
548 bool fTraceDylibSearching;
549 bool fPause;
550 bool fStatistics;
551 bool fPrintOptions;
552 bool fSharedRegionEligible;
553 bool fPrintOrderFileStatistics;
554 bool fReadOnlyx86Stubs;
555 bool fPositionIndependentExecutable;
556 bool fPIEOnCommandLine;
557 bool fDisablePositionIndependentExecutable;
558 bool fMaxMinimumHeaderPad;
559 bool fDeadStripDylibs;
560 bool fAllowTextRelocs;
561 bool fWarnTextRelocs;
562 bool fKextsUseStubs;
563 bool fUsingLazyDylibLinking;
564 bool fEncryptable;
565 bool fOrderData;
566 bool fMarkDeadStrippableDylib;
567 bool fMakeCompressedDyldInfo;
568 bool fMakeCompressedDyldInfoForceOff;
569 bool fNoEHLabels;
570 bool fAllowCpuSubtypeMismatches;
571 bool fUseSimplifiedDylibReExports;
572 bool fObjCABIVersion2Override;
573 bool fObjCABIVersion1Override;
574 bool fCanUseUpwardDylib;
575 bool fFullyLoadArchives;
576 bool fLoadAllObjcObjectsFromArchives;
577 bool fFlatNamespace;
578 bool fLinkingMainExecutable;
579 bool fForFinalLinkedImage;
580 bool fForStatic;
581 bool fForDyld;
582 bool fMakeTentativeDefinitionsReal;
583 bool fWhyLoad;
584 bool fRootSafe;
585 bool fSetuidSafe;
586 bool fImplicitlyLinkPublicDylibs;
587 bool fAddCompactUnwindEncoding;
588 bool fWarnCompactUnwind;
589 bool fRemoveDwarfUnwindIfCompactExists;
590 bool fAutoOrderInitializers;
591 bool fOptimizeZeroFill;
592 bool fMergeZeroFill;
593 bool fLogObjectFiles;
594 bool fLogAllFiles;
595 bool fTraceDylibs;
596 bool fTraceIndirectDylibs;
597 bool fTraceArchives;
598 bool fOutputSlidable;
599 bool fWarnWeakExports;
600 bool fObjcGcCompaction;
601 bool fObjCGc;
602 bool fObjCGcOnly;
603 bool fDemangle;
604 bool fTLVSupport;
605 bool fVersionLoadCommand;
606 bool fVersionLoadCommandForcedOn;
607 bool fVersionLoadCommandForcedOff;
608 bool fFunctionStartsLoadCommand;
609 bool fFunctionStartsForcedOn;
610 bool fFunctionStartsForcedOff;
611 bool fDataInCodeInfoLoadCommand;
612 bool fDataInCodeInfoLoadCommandForcedOn;
613 bool fDataInCodeInfoLoadCommandForcedOff;
614 bool fCanReExportSymbols;
615 bool fObjcCategoryMerging;
616 bool fPageAlignDataAtoms;
617 bool fNeedsThreadLoadCommand;
618 bool fEntryPointLoadCommand;
619 bool fEntryPointLoadCommandForceOn;
620 bool fEntryPointLoadCommandForceOff;
621 bool fSourceVersionLoadCommand;
622 bool fSourceVersionLoadCommandForceOn;
623 bool fSourceVersionLoadCommandForceOff;
624 bool fDependentDRInfo;
625 bool fDependentDRInfoForcedOn;
626 bool fDependentDRInfoForcedOff;
627 bool fTargetIOSSimulator;
628 bool fExportDynamic;
629 bool fAbsoluteSymbols;
630 bool fAllowSimulatorToLinkWithMacOSX;
631 bool fKeepDwarfUnwind;
632 bool fKeepDwarfUnwindForcedOn;
633 bool fKeepDwarfUnwindForcedOff;
634 bool fVerboseOptimizationHints;
635 bool fIgnoreOptimizationHints;
636 bool fGenerateDtraceDOF;
637 bool fAllowBranchIslands;
638 bool fTraceSymbolLayout;
639 bool fMarkAppExtensionSafe;
640 bool fCheckAppExtensionSafe;
641 bool fForceLoadSwiftLibs;
642 DebugInfoStripping fDebugInfoStripping;
643 const char* fTraceOutputFile;
644 ld::MacVersionMin fMacVersionMin;
645 ld::IOSVersionMin fIOSVersionMin;
646 std::vector<AliasPair> fAliases;
647 std::vector<const char*> fInitialUndefines;
648 NameSet fAllowedUndefined;
649 NameSet fWhyLive;
650 std::vector<ExtraSection> fExtraSections;
651 std::vector<SectionAlignment> fSectionAlignments;
652 std::vector<OrderedSymbol> fOrderedSymbols;
653 std::vector<SegmentStart> fCustomSegmentAddresses;
654 std::vector<SegmentSize> fCustomSegmentSizes;
655 std::vector<SegmentProtect> fCustomSegmentProtections;
656 std::vector<DylibOverride> fDylibOverrides;
657 std::vector<const char*> fLLVMOptions;
658 std::vector<const char*> fLibrarySearchPaths;
659 std::vector<const char*> fFrameworkSearchPaths;
660 std::vector<const char*> fSDKPaths;
661 std::vector<const char*> fDyldEnvironExtras;
662 std::vector<const char*> fSegmentOrder;
663 std::vector<const char*> fASTFilePaths;
664 std::vector<SectionOrderList> fSectionOrder;
665 std::vector< std::vector<const char*> > fLinkerOptions;
666 std::vector<SectionRename> fSectionRenames;
667 std::vector<SegmentRename> fSegmentRenames;
668 std::vector<SymbolsMove> fSymbolsMovesData;
669 std::vector<SymbolsMove> fSymbolsMovesCode;
670 std::vector<SymbolsMove> fSymbolsMovesZeroFill;
671 bool fSaveTempFiles;
672 mutable Snapshot fLinkSnapshot;
673 bool fSnapshotRequested;
674 const char* fPipelineFifo;
675 const char* fDependencyInfoPath;
676 mutable int fDependencyFileDescriptor;
677 };
678
679
680
681 #endif // __OPTIONS__