]> git.saurik.com Git - apple/ld64.git/blobdiff - src/ld/Options.h
ld64-274.2.tar.gz
[apple/ld64.git] / src / ld / Options.h
index bc70e7feabb904b57feee80c7c4dde1e1ed22559..e257e30fde636ad3d2335fe84326a44b13f63159 100644 (file)
@@ -86,6 +86,7 @@ public:
        enum CommonsMode { kCommonsIgnoreDylibs, kCommonsOverriddenByDylibs, kCommonsConflictsDylibsError };
        enum UUIDMode { kUUIDNone, kUUIDRandom, kUUIDContent };
        enum LocalSymbolHandling { kLocalSymbolsAll, kLocalSymbolsNone, kLocalSymbolsSelectiveInclude, kLocalSymbolsSelectiveExclude };
+       enum BitcodeMode { kBitcodeProcess, kBitcodeAsData, kBitcodeMarker, kBitcodeStrip };
        enum DebugInfoStripping { kDebugInfoNone, kDebugInfoMinimal, kDebugInfoFull };
 #if SUPPORT_APPLE_TV
        enum Platform { kPlatformUnknown, kPlatformOSX, kPlatformiOS, kPlatformWatchOS, kPlatform_tvOS };
@@ -146,11 +147,23 @@ public:
         // the source, which dies with the stack frame.
         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; };
 
+               FileInfo &operator=(FileInfo other) {
+                       std::swap(path, other.path);
+                       std::swap(fileLen, other.fileLen);
+                       std::swap(modTime, other.modTime);
+                       std::swap(options, other.options);
+                       std::swap(ordinal, other.ordinal);
+                       std::swap(fromFileList, other.fromFileList);
+                       std::swap(inputFileSlot, other.inputFileSlot);
+                       std::swap(readyToParse, other.readyToParse);
+                       return *this;
+               }
+
         // Create an empty FileInfo. The path can be set implicitly by checkFileExists().
-        FileInfo() : path(NULL), fileLen(0), modTime(0), options(), fromFileList(false) {};
+        FileInfo() : path(NULL), fileLen(0), modTime(-1), options(), fromFileList(false) {};
         
         // Create a FileInfo for a specific path, but does not stat the file.
-        FileInfo(const char *_path) : path(strdup(_path)), fileLen(0), modTime(0), options(), fromFileList(false) {};
+        FileInfo(const char *_path) : path(strdup(_path)), fileLen(0), modTime(-1), options(), fromFileList(false) {};
 
         ~FileInfo() { if (path) ::free((void*)path); }
         
@@ -162,7 +175,7 @@ public:
         
         // Returns true if a previous call to checkFileExists() succeeded.
         // Returns false if the file does not exist of checkFileExists() has never been called.
-        bool missing() const { return modTime==0; }
+        bool missing() const { return modTime == -1; }
        };
 
        struct ExtraSection {
@@ -247,6 +260,7 @@ public:
        bool                                            preferSubArchitecture() const { return fHasPreferredSubType; }
        cpu_subtype_t                           subArchitecture() const { return fSubArchitecture; }
        bool                                            allowSubArchitectureMismatches() const { return fAllowCpuSubtypeMismatches; }
+       bool                                            enforceDylibSubtypesMatch() const { return fEnforceDylibSubtypesMatch; }
        bool                                            forceCpuSubtypeAll() const { return fForceSubtypeAll; }
        const char*                                     architectureName() const { return fArchitectureName; }
        void                                            setArchitecture(cpu_type_t, cpu_subtype_t subtype, Options::Platform platform);
@@ -278,6 +292,7 @@ public:
        bool                                            ignoreOtherArchInputFiles() const { return fIgnoreOtherArchFiles; }
        bool                                            traceDylibs() const     { return fTraceDylibs; }
        bool                                            traceArchives() const { return fTraceArchives; }
+       bool                                            traceEmitJSON() const { return fTraceEmitJSON; }
        bool                                            deadCodeStrip() const   { return fDeadStrip; }
        UndefinedTreatment                      undefinedTreatment() const { return fUndefinedTreatment; }
        ld::MacVersionMin                       macosxVersionMin() const { return fMacVersionMin; }
@@ -311,7 +326,8 @@ public:
        CommonsMode                                     commonsMode() const { return fCommonsMode; }
        bool                                            warnCommons() const { return fWarnCommons; }
        bool                                            keepRelocations();
-       FileInfo                                        findFile(const std::string &path) const;
+       FileInfo                                        findFile(const std::string &path, const ld::dylib::File* fromDylib=nullptr) const;
+       bool                                            findFile(const std::string &path, const std::vector<std::string> &tbdExtensions, FileInfo& result) const;
        UUIDMode                                        UUIDMode() const { return fUUIDMode; }
        bool                                            warnStabs();
        bool                                            pauseAtEnd() { return fPause; }
@@ -341,7 +357,7 @@ public:
        const std::vector<DylibOverride>&       dylibOverrides() const { return fDylibOverrides; }
        const char*                                     generatedMapPath() const { return fMapPath; }
        bool                                            positionIndependentExecutable() const { return fPositionIndependentExecutable; }
-       Options::FileInfo                       findFileUsingPaths(const std::string &path) const;
+       Options::FileInfo                       findIndirectDylib(const std::string& installName, const ld::dylib::File* fromDylib) const;
        bool                                            deadStripDylibs() const { return fDeadStripDylibs; }
        bool                                            allowedUndefined(const char* name) const { return ( fAllowedUndefined.find(name) != fAllowedUndefined.end() ); }
        bool                                            someAllowedUndefines() const { return (fAllowedUndefined.size() != 0); }
@@ -396,6 +412,10 @@ public:
        bool                                            addFunctionStarts() const { return fFunctionStartsLoadCommand; }
        bool                                            addDataInCodeInfo() const { return fDataInCodeInfoLoadCommand; }
        bool                                            canReExportSymbols() const { return fCanReExportSymbols; }
+       const char*                                     ltoCachePath() const { return fLtoCachePath; }
+       int                                                     ltoPruneInterval() const { return fLtoPruneInterval; }
+       int                                                     ltoPruneAfter() const { return fLtoPruneAfter; }
+       unsigned                                        ltoMaxCacheSize() const { return fLtoMaxCacheSize; }
        const char*                                     tempLtoObjectPath() const { return fTempLtoObjectPath; }
        const char*                                     overridePathlibLTO() const { return fOverridePathlibLTO; }
        const char*                                     mcpuLTO() const { return fLtoCpu; }
@@ -412,13 +432,20 @@ public:
        bool                                            forceLoadSwiftLibs() const { return fForceLoadSwiftLibs; }
        bool                                            bundleBitcode() const { return fBundleBitcode; }
        bool                                            hideSymbols() const { return fHideSymbols; }
+       bool                                            verifyBitcode() const { return fVerifyBitcode; }
        bool                                            renameReverseSymbolMap() const { return fReverseMapUUIDRename; }
+       bool                                            deduplicateFunctions() const { return fDeDupe; }
+       bool                                            verboseDeduplicate() const { return fVerboseDeDupe; }
        const char*                                     reverseSymbolMapPath() const { return fReverseMapPath; }
        std::string                                     reverseMapTempPath() const { return fReverseMapTempPath; }
        bool                                            ltoCodegenOnly() const { return fLTOCodegenOnly; }
        bool                                            ignoreAutoLink() const { return fIgnoreAutoLink; }
+       bool                                            allowDeadDuplicates() const { return fAllowDeadDups; }
+       bool                                            allowWeakImports() const { return fAllowWeakImports; }
+       BitcodeMode                                     bitcodeKind() const { return fBitcodeKind; }
        bool                                            sharedRegionEncodingV2() const { return fSharedRegionEncodingV2; }
        bool                                            useDataConstSegment() const { return fUseDataConstSegment; }
+       bool                                            useTextExecSegment() const { return fUseTextExecSegment; }
        bool                                            hasWeakBitTweaks() const;
        bool                                            forceWeak(const char* symbolName) const;
        bool                                            forceNotWeak(const char* symbolName) const;
@@ -454,6 +481,11 @@ public:
        std::vector<std::string>        writeBitcodeLinkOptions() const;
        std::string                                     getSDKVersionStr() const;
        std::string                                     getPlatformStr() const;
+       uint8_t                                         maxDefaultCommonAlign() const { return fMaxDefaultCommonAlign; }
+       bool                                            hasDataSymbolMoves() const { return !fSymbolsMovesData.empty(); }
+       bool                                            hasCodeSymbolMoves() const { return !fSymbolsMovesCode.empty(); }
+
+       static uint32_t                         parseVersionNumber32(const char*);
 
 private:
        typedef std::unordered_map<const char*, unsigned int, ld::CStringHash, ld::CStringEquals> NameToOrder;
@@ -496,9 +528,9 @@ private:
        bool                                            checkForFile(const char* format, const char* dir, const char* rootName,
                                                                                         FileInfo& result) const;
        uint64_t                                        parseVersionNumber64(const char*);
-       uint32_t                                        parseVersionNumber32(const char*);
        std::string                                     getVersionString32(uint32_t ver) const;
        std::string                                     getVersionString64(uint64_t ver) const;
+       bool                                            parsePackedVersion32(const std::string& versionStr, uint32_t &result);
        void                                            parseSectionOrderFile(const char* segment, const char* section, const char* path);
        void                                            parseOrderFile(const char* path, bool cstring);
        void                                            addSection(const char* segment, const char* section, const char* path);
@@ -587,6 +619,10 @@ private:
        const char*                                                     fSegAddrTablePath;
        const char*                                                     fMapPath;
        const char*                                                     fDyldInstallPath;
+       const char*                                                     fLtoCachePath;
+       int                                                                     fLtoPruneInterval;
+       int                                                                     fLtoPruneAfter;
+       unsigned                                                        fLtoMaxCacheSize;
        const char*                                                     fTempLtoObjectPath;
        const char*                                                     fOverridePathlibLTO;
        const char*                                                     fLtoCpu;
@@ -635,6 +671,7 @@ private:
        bool                                                            fMakeCompressedDyldInfoForceOff;
        bool                                                            fNoEHLabels;
        bool                                                            fAllowCpuSubtypeMismatches;
+       bool                                                            fEnforceDylibSubtypesMatch;
        bool                                                            fUseSimplifiedDylibReExports;
        bool                                                            fObjCABIVersion2Override;
        bool                                                            fObjCABIVersion1Override;
@@ -662,6 +699,7 @@ private:
        bool                                                            fTraceDylibs;
        bool                                                            fTraceIndirectDylibs;
        bool                                                            fTraceArchives;
+       bool                                                            fTraceEmitJSON;
        bool                                                            fOutputSlidable;
        bool                                                            fWarnWeakExports;
        bool                                                            fObjcGcCompaction;
@@ -707,13 +745,20 @@ private:
        bool                                                            fUseDataConstSegment;
        bool                                                            fUseDataConstSegmentForceOn;
        bool                                                            fUseDataConstSegmentForceOff;
+       bool                                                            fUseTextExecSegment;
        bool                                                            fBundleBitcode;
        bool                                                            fHideSymbols;
+       bool                                                            fVerifyBitcode;
        bool                                                            fReverseMapUUIDRename;
+       bool                                                            fDeDupe;
+       bool                                                            fVerboseDeDupe;
        const char*                                                     fReverseMapPath;
        std::string                                                     fReverseMapTempPath;
        bool                                                            fLTOCodegenOnly;
        bool                                                            fIgnoreAutoLink;
+       bool                                                            fAllowDeadDups;
+       bool                                                            fAllowWeakImports;
+       BitcodeMode                                                     fBitcodeKind;
        Platform                                                        fPlatform;
        DebugInfoStripping                                      fDebugInfoStripping;
        const char*                                                     fTraceOutputFile;
@@ -744,13 +789,13 @@ private:
        std::vector<SegmentRename>                      fSegmentRenames;
        std::vector<SymbolsMove>                        fSymbolsMovesData;
        std::vector<SymbolsMove>                        fSymbolsMovesCode;
-       std::vector<SymbolsMove>                        fSymbolsMovesZeroFill;
        bool                                                            fSaveTempFiles;
     mutable Snapshot                                   fLinkSnapshot;
     bool                                                               fSnapshotRequested;
     const char*                                                        fPipelineFifo;
        const char*                                                     fDependencyInfoPath;
        mutable int                                                     fDependencyFileDescriptor;
+       uint8_t                                                         fMaxDefaultCommonAlign;
 };