]> git.saurik.com Git - apple/ld64.git/blobdiff - src/ld/passes/got.cpp
ld64-134.9.tar.gz
[apple/ld64.git] / src / ld / passes / got.cpp
index bb94ddff4df855b55fb0760f39dcca5e1236b919..4631d5b1fd1f864365f57fc623f2bb8dd886744f 100644 (file)
@@ -52,8 +52,6 @@ public:
                                        { _fixup.weakImport = weakImport; internal.addAtom(*this); }
 
        virtual const ld::File*                                 file() const                                    { return NULL; }
-       virtual bool                                                    translationUnitSource(const char** dir, const char**) const 
-                                                                                                                                                       { return false; }
        virtual const char*                                             name() const                                    { return _target->name(); }
        virtual uint64_t                                                size() const                                    { return 8; }
        virtual uint64_t                                                objectAddress() const                   { return 0; }
@@ -89,8 +87,21 @@ static bool gotFixup(const Options& opts, ld::Internal& internal, const ld::Atom
                        }
                        if ( targetOfGOT->scope() == ld::Atom::scopeGlobal ) {  
                                // cannot do LEA optimization if target is weak exported symbol
-                               if ( (targetOfGOT->definition() == ld::Atom::definitionRegular) && (targetOfGOT->combine() == ld::Atom::combineByName) )
-                                       *optimizable = false;
+                               if ( (targetOfGOT->definition() == ld::Atom::definitionRegular) && (targetOfGOT->combine() == ld::Atom::combineByName) ) {
+                                       switch ( opts.outputKind() ) {
+                                               case Options::kDynamicExecutable:
+                                               case Options::kDynamicLibrary:
+                                               case Options::kDynamicBundle:
+                                               case Options::kKextBundle:
+                                                       *optimizable = false;
+                                                       break;
+                                               case Options::kStaticExecutable:
+                                               case Options::kDyld:
+                                               case Options::kPreload:
+                                               case Options::kObjectFile:
+                                                       break;
+                                       }
+                               }
                                // cannot do LEA optimization if target is interposable
                                if ( opts.interposable(targetOfGOT->name()) ) 
                                        *optimizable = false;