]> git.saurik.com Git - apple/ld64.git/blob - src/ld/Options.h
8395fc90057d27fc9304da64cd73173181822af4
[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 const std::vector<SectionRename>& sectionRenames() const { return fSectionRenames; }
394 const std::vector<SegmentRename>& segmentRenames() const { return fSegmentRenames; }
395 bool moveRoSymbol(const char* symName, const char* filePath, const char*& seg, bool& wildCardMatch) const;
396 bool moveRwSymbol(const char* symName, const char* filePath, const char*& seg, bool& wildCardMatch) const;
397
398 private:
399 typedef std::unordered_map<const char*, unsigned int, ld::CStringHash, ld::CStringEquals> NameToOrder;
400 typedef std::unordered_set<const char*, ld::CStringHash, ld::CStringEquals> NameSet;
401 enum ExportMode { kExportDefault, kExportSome, kDontExportSome };
402 enum LibrarySearchMode { kSearchDylibAndArchiveInEachDir, kSearchAllDirsForDylibsThenAllDirsForArchives };
403 enum InterposeMode { kInterposeNone, kInterposeAllExternal, kInterposeSome };
404
405 class SetWithWildcards {
406 public:
407 void insert(const char*);
408 bool contains(const char*, bool* wildCardMatch=NULL) const;
409 bool containsWithPrefix(const char* symbol, const char* file, bool& wildCardMatch) const;
410 bool containsNonWildcard(const char*) const;
411 bool empty() const { return fRegular.empty() && fWildCard.empty(); }
412 bool hasWildCards() const { return !fWildCard.empty(); }
413 NameSet::iterator regularBegin() const { return fRegular.begin(); }
414 NameSet::iterator regularEnd() const { return fRegular.end(); }
415 void remove(const NameSet&);
416 private:
417 static bool hasWildCards(const char*);
418 bool wildCardMatch(const char* pattern, const char* candidate) const;
419 bool inCharRange(const char*& range, unsigned char c) const;
420
421 NameSet fRegular;
422 std::vector<const char*> fWildCard;
423 };
424
425 struct SymbolsMove {
426 const char* toSegment;
427 SetWithWildcards symbols;
428 };
429
430 void parse(int argc, const char* argv[]);
431 void checkIllegalOptionCombinations();
432 void buildSearchPaths(int argc, const char* argv[]);
433 void parseArch(const char* architecture);
434 FileInfo findFramework(const char* rootName, const char* suffix) const;
435 bool checkForFile(const char* format, const char* dir, const char* rootName,
436 FileInfo& result) const;
437 uint64_t parseVersionNumber64(const char*);
438 uint32_t parseVersionNumber32(const char*);
439 void parseSectionOrderFile(const char* segment, const char* section, const char* path);
440 void parseOrderFile(const char* path, bool cstring);
441 void addSection(const char* segment, const char* section, const char* path);
442 void addSubLibrary(const char* name);
443 void loadFileList(const char* fileOfPaths, ld::File::Ordinal baseOrdinal);
444 uint64_t parseAddress(const char* addr);
445 void loadExportFile(const char* fileOfExports, const char* option, SetWithWildcards& set);
446 void parseAliasFile(const char* fileOfAliases);
447 void parsePreCommandLineEnvironmentSettings();
448 void parsePostCommandLineEnvironmentSettings();
449 void setUndefinedTreatment(const char* treatment);
450 void setMacOSXVersionMin(const char* version);
451 void setIOSVersionMin(const char* version);
452 void setWeakReferenceMismatchTreatment(const char* treatment);
453 void addDylibOverride(const char* paths);
454 void addSectionAlignment(const char* segment, const char* section, const char* alignment);
455 CommonsMode parseCommonsTreatment(const char* mode);
456 Treatment parseTreatment(const char* treatment);
457 void reconfigureDefaults();
458 void checkForClassic(int argc, const char* argv[]);
459 void parseSegAddrTable(const char* segAddrPath, const char* installPath);
460 void addLibrary(const FileInfo& info);
461 void warnObsolete(const char* arg);
462 uint32_t parseProtection(const char* prot);
463 void loadSymbolOrderFile(const char* fileOfExports, NameToOrder& orderMapping);
464 void addSectionRename(const char* srcSegment, const char* srcSection, const char* dstSegment, const char* dstSection);
465 void addSegmentRename(const char* srcSegment, const char* dstSegment);
466 void addSymbolMove(const char* dstSegment, const char* symbolList, std::vector<SymbolsMove>& list, const char* optionName);
467
468
469 // ObjectFile::ReaderOptions fReaderOptions;
470 const char* fOutputFile;
471 std::vector<Options::FileInfo> fInputFiles;
472 cpu_type_t fArchitecture;
473 cpu_subtype_t fSubArchitecture;
474 const char* fArchitectureName;
475 OutputKind fOutputKind;
476 bool fHasPreferredSubType;
477 bool fArchSupportsThumb2;
478 bool fPrebind;
479 bool fBindAtLoad;
480 bool fKeepPrivateExterns;
481 bool fNeedsModuleTable;
482 bool fIgnoreOtherArchFiles;
483 bool fErrorOnOtherArchFiles;
484 bool fForceSubtypeAll;
485 InterposeMode fInterposeMode;
486 bool fDeadStrip;
487 NameSpace fNameSpace;
488 uint32_t fDylibCompatVersion;
489 uint64_t fDylibCurrentVersion;
490 const char* fDylibInstallName;
491 const char* fFinalName;
492 const char* fEntryName;
493 uint64_t fBaseAddress;
494 uint64_t fMaxAddress;
495 uint64_t fBaseWritableAddress;
496 bool fSplitSegs;
497 SetWithWildcards fExportSymbols;
498 SetWithWildcards fDontExportSymbols;
499 SetWithWildcards fInterposeList;
500 SetWithWildcards fForceWeakSymbols;
501 SetWithWildcards fForceNotWeakSymbols;
502 SetWithWildcards fReExportSymbols;
503 SetWithWildcards fForceCoalesceSymbols;
504 NameSet fRemovedExports;
505 NameToOrder fExportSymbolsOrder;
506 ExportMode fExportMode;
507 LibrarySearchMode fLibrarySearchMode;
508 UndefinedTreatment fUndefinedTreatment;
509 bool fMessagesPrefixedWithArchitecture;
510 WeakReferenceMismatchTreatment fWeakReferenceMismatchTreatment;
511 std::vector<const char*> fSubUmbellas;
512 std::vector<const char*> fSubLibraries;
513 std::vector<const char*> fAllowableClients;
514 std::vector<const char*> fRPaths;
515 const char* fClientName;
516 const char* fUmbrellaName;
517 const char* fInitFunctionName;
518 const char* fDotOutputFile;
519 const char* fExecutablePath;
520 const char* fBundleLoader;
521 const char* fDtraceScriptName;
522 const char* fSegAddrTablePath;
523 const char* fMapPath;
524 const char* fDyldInstallPath;
525 const char* fTempLtoObjectPath;
526 const char* fOverridePathlibLTO;
527 const char* fLtoCpu;
528 uint64_t fZeroPageSize;
529 uint64_t fStackSize;
530 uint64_t fStackAddr;
531 uint64_t fSourceVersion;
532 uint32_t fSDKVersion;
533 bool fExecutableStack;
534 bool fNonExecutableHeap;
535 bool fDisableNonExecutableHeap;
536 uint32_t fMinimumHeaderPad;
537 uint64_t fSegmentAlignment;
538 CommonsMode fCommonsMode;
539 enum UUIDMode fUUIDMode;
540 SetWithWildcards fLocalSymbolsIncluded;
541 SetWithWildcards fLocalSymbolsExcluded;
542 LocalSymbolHandling fLocalSymbolHandling;
543 bool fWarnCommons;
544 bool fVerbose;
545 bool fKeepRelocations;
546 bool fWarnStabs;
547 bool fTraceDylibSearching;
548 bool fPause;
549 bool fStatistics;
550 bool fPrintOptions;
551 bool fSharedRegionEligible;
552 bool fPrintOrderFileStatistics;
553 bool fReadOnlyx86Stubs;
554 bool fPositionIndependentExecutable;
555 bool fPIEOnCommandLine;
556 bool fDisablePositionIndependentExecutable;
557 bool fMaxMinimumHeaderPad;
558 bool fDeadStripDylibs;
559 bool fAllowTextRelocs;
560 bool fWarnTextRelocs;
561 bool fKextsUseStubs;
562 bool fUsingLazyDylibLinking;
563 bool fEncryptable;
564 bool fOrderData;
565 bool fMarkDeadStrippableDylib;
566 bool fMakeCompressedDyldInfo;
567 bool fMakeCompressedDyldInfoForceOff;
568 bool fNoEHLabels;
569 bool fAllowCpuSubtypeMismatches;
570 bool fUseSimplifiedDylibReExports;
571 bool fObjCABIVersion2Override;
572 bool fObjCABIVersion1Override;
573 bool fCanUseUpwardDylib;
574 bool fFullyLoadArchives;
575 bool fLoadAllObjcObjectsFromArchives;
576 bool fFlatNamespace;
577 bool fLinkingMainExecutable;
578 bool fForFinalLinkedImage;
579 bool fForStatic;
580 bool fForDyld;
581 bool fMakeTentativeDefinitionsReal;
582 bool fWhyLoad;
583 bool fRootSafe;
584 bool fSetuidSafe;
585 bool fImplicitlyLinkPublicDylibs;
586 bool fAddCompactUnwindEncoding;
587 bool fWarnCompactUnwind;
588 bool fRemoveDwarfUnwindIfCompactExists;
589 bool fAutoOrderInitializers;
590 bool fOptimizeZeroFill;
591 bool fMergeZeroFill;
592 bool fLogObjectFiles;
593 bool fLogAllFiles;
594 bool fTraceDylibs;
595 bool fTraceIndirectDylibs;
596 bool fTraceArchives;
597 bool fOutputSlidable;
598 bool fWarnWeakExports;
599 bool fObjcGcCompaction;
600 bool fObjCGc;
601 bool fObjCGcOnly;
602 bool fDemangle;
603 bool fTLVSupport;
604 bool fVersionLoadCommand;
605 bool fVersionLoadCommandForcedOn;
606 bool fVersionLoadCommandForcedOff;
607 bool fFunctionStartsLoadCommand;
608 bool fFunctionStartsForcedOn;
609 bool fFunctionStartsForcedOff;
610 bool fDataInCodeInfoLoadCommand;
611 bool fDataInCodeInfoLoadCommandForcedOn;
612 bool fDataInCodeInfoLoadCommandForcedOff;
613 bool fCanReExportSymbols;
614 bool fObjcCategoryMerging;
615 bool fPageAlignDataAtoms;
616 bool fNeedsThreadLoadCommand;
617 bool fEntryPointLoadCommand;
618 bool fEntryPointLoadCommandForceOn;
619 bool fEntryPointLoadCommandForceOff;
620 bool fSourceVersionLoadCommand;
621 bool fSourceVersionLoadCommandForceOn;
622 bool fSourceVersionLoadCommandForceOff;
623 bool fDependentDRInfo;
624 bool fDependentDRInfoForcedOn;
625 bool fDependentDRInfoForcedOff;
626 bool fTargetIOSSimulator;
627 bool fExportDynamic;
628 bool fAbsoluteSymbols;
629 bool fAllowSimulatorToLinkWithMacOSX;
630 bool fKeepDwarfUnwind;
631 bool fKeepDwarfUnwindForcedOn;
632 bool fKeepDwarfUnwindForcedOff;
633 bool fVerboseOptimizationHints;
634 bool fIgnoreOptimizationHints;
635 bool fGenerateDtraceDOF;
636 bool fAllowBranchIslands;
637 bool fTraceSymbolLayout;
638 bool fMarkAppExtensionSafe;
639 bool fCheckAppExtensionSafe;
640 bool fForceLoadSwiftLibs;
641 DebugInfoStripping fDebugInfoStripping;
642 const char* fTraceOutputFile;
643 ld::MacVersionMin fMacVersionMin;
644 ld::IOSVersionMin fIOSVersionMin;
645 std::vector<AliasPair> fAliases;
646 std::vector<const char*> fInitialUndefines;
647 NameSet fAllowedUndefined;
648 NameSet fWhyLive;
649 std::vector<ExtraSection> fExtraSections;
650 std::vector<SectionAlignment> fSectionAlignments;
651 std::vector<OrderedSymbol> fOrderedSymbols;
652 std::vector<SegmentStart> fCustomSegmentAddresses;
653 std::vector<SegmentSize> fCustomSegmentSizes;
654 std::vector<SegmentProtect> fCustomSegmentProtections;
655 std::vector<DylibOverride> fDylibOverrides;
656 std::vector<const char*> fLLVMOptions;
657 std::vector<const char*> fLibrarySearchPaths;
658 std::vector<const char*> fFrameworkSearchPaths;
659 std::vector<const char*> fSDKPaths;
660 std::vector<const char*> fDyldEnvironExtras;
661 std::vector<const char*> fSegmentOrder;
662 std::vector<const char*> fASTFilePaths;
663 std::vector<SectionOrderList> fSectionOrder;
664 std::vector< std::vector<const char*> > fLinkerOptions;
665 std::vector<SectionRename> fSectionRenames;
666 std::vector<SegmentRename> fSegmentRenames;
667 std::vector<SymbolsMove> fSymbolsMovesData;
668 std::vector<SymbolsMove> fSymbolsMovesCode;
669 std::vector<SymbolsMove> fSymbolsMovesZeroFill;
670 bool fSaveTempFiles;
671 mutable Snapshot fLinkSnapshot;
672 bool fSnapshotRequested;
673 const char* fPipelineFifo;
674 const char* fDependencyInfoPath;
675 mutable int fDependencyFileDescriptor;
676 };
677
678
679
680 #endif // __OPTIONS__