]> git.saurik.com Git - apple/dyld.git/commitdiff
dyld-733.8.tar.gz macos-10152 macos-10153 v733.8
authorApple <opensource@apple.com>
Thu, 2 Apr 2020 16:52:21 +0000 (16:52 +0000)
committerApple <opensource@apple.com>
Thu, 2 Apr 2020 16:52:21 +0000 (16:52 +0000)
29 files changed:
dyld3/Closure.cpp
dyld3/Closure.h
dyld3/ClosureBuilder.cpp
dyld3/ClosureBuilder.h
dyld3/ClosureWriter.cpp
dyld3/ClosureWriter.h
src/ImageLoader.h
src/dyld2.cpp
testing/include/test_support.h [new file with mode: 0644]
testing/test-cases/amfi-interpose.dtest/interposer.c [new file with mode: 0644]
testing/test-cases/amfi-interpose.dtest/main.c [new file with mode: 0644]
testing/test-cases/env-DYLD_VERSIONED_FRAMEWORK_PATH.dtest/foo.c [new file with mode: 0644]
testing/test-cases/env-DYLD_VERSIONED_FRAMEWORK_PATH.dtest/main.c [new file with mode: 0644]
testing/test-cases/env-DYLD_VERSIONED_LIBRARY_PATH.dtest/foo.c [new file with mode: 0644]
testing/test-cases/env-DYLD_VERSIONED_LIBRARY_PATH.dtest/main.c [new file with mode: 0644]
unit-tests/test-cases/DYLD_VERSIONED_FRAMEWORK_PATH-basic/Makefile [deleted file]
unit-tests/test-cases/DYLD_VERSIONED_FRAMEWORK_PATH-basic/bar.c [deleted file]
unit-tests/test-cases/DYLD_VERSIONED_FRAMEWORK_PATH-basic/foo.c [deleted file]
unit-tests/test-cases/DYLD_VERSIONED_FRAMEWORK_PATH-basic/main.c [deleted file]
unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-basic/Makefile [deleted file]
unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-basic/bar.c [deleted file]
unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-basic/foo.c [deleted file]
unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-basic/main.c [deleted file]
unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-dyld_env-restrict/Makefile [deleted file]
unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-dyld_env-restrict/foo.c [deleted file]
unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-dyld_env-restrict/main.c [deleted file]
unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-dyld_env/Makefile [deleted file]
unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-dyld_env/foo.c [deleted file]
unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-dyld_env/main.c [deleted file]

index 3e9c9f8c5ec36ea68c46cf5c63687089f4e4a161..21b0c2e9822ef74ae1431261763dbfae0d125c97 100644 (file)
@@ -1155,6 +1155,11 @@ bool LaunchClosure::hasInsertedLibraries() const
     return getFlags().hasInsertedLibraries;
 }
 
+bool LaunchClosure::usedInterposing() const
+{
+    return getFlags().usedInterposing;
+}
+
 bool LaunchClosure::hasInterposings() const
 {
     __block bool result = false;
index 4b4eb39f99a3b0457b7029bd495a722aff66227c..ab1a15fdbfb5c72deb38e4279c5903b46dc5f302 100644 (file)
@@ -709,6 +709,7 @@ struct VIS_HIDDEN LaunchClosure : public Closure
     void                forEachInterposingTuple(void (^handler)(const InterposingTuple& tuple, bool& stop)) const;
     bool                usedAtPaths() const;
     bool                usedFallbackPaths() const;
+    bool                usedInterposing() const;
     bool                selectorHashTable(Array<Image::ObjCSelectorImage>& imageNums,
                                           const ObjCSelectorOpt*& hashTable) const;
     bool                classAndProtocolHashTables(Array<Image::ObjCClassImage>& imageNums,
@@ -730,7 +731,8 @@ private:
                         usedFallbackPaths        :  1,
                         initImageCount           : 16,
                         hasInsertedLibraries     :  1,
-                        padding                  : 13;
+                        usedInterposing          :  1,
+                        padding                  : 12;
     };
     const Flags&        getFlags() const;
 };
index daef7525b68c079c8bdbbb82379f4f16574a0e2e..10da1bf70e887cd4655947005882c249e74f4143 100644 (file)
@@ -1133,6 +1133,7 @@ void ClosureBuilder::addInterposingTuples(LaunchClosureWriter& writer, const Ima
                 goodTuples.push_back(resolvedTuples[i]);
         }
         writer.addInterposingTuples(goodTuples);
+        _interposingTuplesUsed = !goodTuples.empty();
 
         // if the target of the interposing is in the dyld shared cache, add a PatchEntry so the cache is fixed up at launch
         STACK_ALLOC_ARRAY(Closure::PatchEntry, patches, goodTuples.count());
@@ -3173,16 +3174,19 @@ const LaunchClosure* ClosureBuilder::makeLaunchClosure(const LoadedFileInfo& fil
         closureWriter.setBootUUID(bootSessionUUID);
 #endif
 
-     // record any interposing info
-    imageArray->forEachImage(^(const Image* image, bool &stop) {
-        if ( !image->inDyldCache() )
-            addInterposingTuples(closureWriter, image, findLoadedImage(image->imageNum()).loadAddress());
-    });
+    // record any interposing info
+    if ( !_interposingDisabled ) {
+        imageArray->forEachImage(^(const Image* image, bool &stop) {
+            if ( !image->inDyldCache() )
+                addInterposingTuples(closureWriter, image, findLoadedImage(image->imageNum()).loadAddress());
+        });
+    }
 
     // modify fixups in contained Images by applying interposing tuples
     closureWriter.applyInterposing((const LaunchClosure*)closureWriter.currentTypedBytes());
 
     // set flags
+    closureWriter.setUsedInterposing(_interposingTuplesUsed);
     closureWriter.setUsedAtPaths(_atPathUsed);
     closureWriter.setUsedFallbackPaths(_fallbackPathUsed);
     closureWriter.setHasInsertedLibraries(_mainProgLoadIndex > 0);
index ddc5d90b44cfa60787b6c7a14d1b03a4b0df094b..14554bafc62a6da9bbd67e559d6a7d46ec093f0b 100644 (file)
@@ -104,6 +104,7 @@ public:
     ImageNum                    nextFreeImageNum() const { return _startImageNum + _nextIndex; }
 
     void                        setDyldCacheInvalidFormatVersion();
+    void                        disableInterposing() { _interposingDisabled = true; }
 
 
     struct PatchableExport
@@ -344,12 +345,14 @@ private:
     bool                                    _makingCustomerCache            = false;
     bool                                    _allowRelativePaths             = false;
     bool                                    _atPathUsed                     = false;
+    bool                                    _interposingTuplesUsed          = false;
     bool                                    _fallbackPathUsed               = false;
     bool                                    _allowMissingLazies             = false;
     bool                                    _dyldCacheInvalidFormatVersion  = false;
     bool                                    _foundNonCachedImage            = false;    // true means we have one or more images from disk we need to build closure(s) for
     bool                                    _foundDyldCacheRoots            = false;    // true if one or more images are roots of the shared cache
     bool                                    _foundMissingLazyBinds          = false;    // true if one or more images having missing lazy binds
+    bool                                    _interposingDisabled            = false;
     ImageNum                                _libDyldImageNum                = 0;
     ImageNum                                _libSystemImageNum              = 0;
 };
index 7347506c820f8ebd8df98a7e8aac1052ef37e587..f4911bc7077d965d7ee4947d823ca0ab1f97417d 100644 (file)
@@ -521,6 +521,11 @@ void LaunchClosureWriter::setUsedAtPaths(bool value)
     getFlags().usedAtPaths = value;
 }
 
+void LaunchClosureWriter::setUsedInterposing(bool value)
+{
+    getFlags().usedInterposing = value;
+}
+
 void LaunchClosureWriter::setHasInsertedLibraries(bool value)
 {
     getFlags().hasInsertedLibraries = value;
index 1ec0fed81330476ecb64a80859ebd0031e46dd0e..277431896daa46d8787f5565e5f6169cd2208fb2 100644 (file)
@@ -154,6 +154,7 @@ public:
     void                    setStartEntry(Image::ResolvedSymbolTarget start);
     void                    setUsedFallbackPaths(bool);
     void                    setUsedAtPaths(bool);
+    void                    setUsedInterposing(bool);
     void                    setHasInsertedLibraries(bool);
     void                    setMustBeMissingFiles(const Array<const char*>& paths);
     void                    setMustExistFiles(const Array<LaunchClosure::SkippedFile>& files);
index 1a3d41579d9d13a8c7b64b165e7e13d5bdb32017..df2f44b0640aa364d743018088593af3d57982d8 100644 (file)
@@ -313,6 +313,7 @@ public:
                bool                    allowEnvVarsSharedCache;
                bool                    allowClassicFallbackPaths;
                bool                    allowInsertFailures;
+               bool                    allowInterposing;
                bool                    mainExecutableCodeSigned;
                bool                    prebinding;
                bool                    bindFlat;
index 8a438afcfce80b7974f201c1c91ab576a436f179..40fbd5b27780a1c2dbc914dfa32826a306a684aa 100644 (file)
@@ -62,6 +62,7 @@
 #include <kern/kcdata.h>
 #include <sys/attr.h>
 #include <sys/fsgetpath.h>
+#include <System/sys/content_protection.h>
 
 #if TARGET_OS_SIMULATOR
        enum {
                AMFI_DYLD_OUTPUT_ALLOW_FALLBACK_PATHS = (1 << 3),
                AMFI_DYLD_OUTPUT_ALLOW_PRINT_VARS = (1 << 4),
                AMFI_DYLD_OUTPUT_ALLOW_FAILED_LIBRARY_INSERTION = (1 << 5),
+               AMFI_DYLD_OUTPUT_ALLOW_LIBRARY_INTERPOSING = (1 << 6),
        };
        extern "C" int amfi_check_dyld_policy_self(uint64_t input_flags, uint64_t* output_flags);
 #else
        #include <libamfi.h>
 #endif
+
 #include <sandbox.h>
 #include <sandbox/private.h>
 #if __has_feature(ptrauth_calls)
@@ -3813,6 +3816,16 @@ static ImageLoader* loadPhase1(const char* path, const char* orgPath, const Load
                        return image;
        }
 
+#if SUPPORT_VERSIONED_PATHS
+    // <rdar://problem/53215116> DYLD_VERSIONED_FRAMEWORK_PATH fails to load a framework if it does not also exist at the system install path
+    // Scan to see if the dylib appears in a versioned path. Don't worry if we find the newest, that will handled later
+    if ( !context.dontLoad  && (exceptions != NULL) && ((sEnv.DYLD_VERSIONED_FRAMEWORK_PATH != NULL) || (sEnv.DYLD_VERSIONED_LIBRARY_PATH != NULL)) ) {
+        image = loadPhase2(path, orgPath, context, sEnv.DYLD_VERSIONED_FRAMEWORK_PATH, sEnv.DYLD_VERSIONED_LIBRARY_PATH, cacheIndex, exceptions);
+        if ( image != NULL )
+            return image;
+    }
+#endif
+
        return NULL;
 }
 
@@ -5083,6 +5096,11 @@ static void configureProcessRestrictions(const macho_header* mainExecutableMH, c
                gLinkContext.allowEnvVarsSharedCache    = (amfiOutputFlags & AMFI_DYLD_OUTPUT_ALLOW_CUSTOM_SHARED_CACHE);
                gLinkContext.allowClassicFallbackPaths  = (amfiOutputFlags & AMFI_DYLD_OUTPUT_ALLOW_FALLBACK_PATHS);
                gLinkContext.allowInsertFailures        = (amfiOutputFlags & AMFI_DYLD_OUTPUT_ALLOW_FAILED_LIBRARY_INSERTION);
+#ifdef AMFI_RETURNS_INTERPOSING_FLAG
+               gLinkContext.allowInterposing           = (amfiOutputFlags & AMFI_DYLD_OUTPUT_ALLOW_LIBRARY_INTERPOSING);
+#else
+               gLinkContext.allowInterposing           = true;
+#endif
        }
        else {
 #if __MAC_OS_X_VERSION_MIN_REQUIRED
@@ -5112,6 +5130,7 @@ static void configureProcessRestrictions(const macho_header* mainExecutableMH, c
                gLinkContext.allowEnvVarsSharedCache     = !libraryValidation || !usingSIP;
                gLinkContext.allowClassicFallbackPaths   = !isRestricted;
                gLinkContext.allowInsertFailures         = false;
+               gLinkContext.allowInterposing            = true;
 #else
                halt("amfi_check_dyld_policy_self() failed\n");
 #endif
@@ -5793,7 +5812,11 @@ static bool closureValid(const dyld3::closure::LaunchClosure* mainClosure, const
                        dyld::log("dyld: closure %p not used because is used default fallback paths, but process does not allow that\n", mainClosure);
                return false;
        }
-
+       if ( mainClosure->usedInterposing() && !gLinkContext.allowInterposing ) {
+               if ( gLinkContext.verboseWarnings )
+                       dyld::log("dyld: closure %p not used because is uses interposing, but process does not allow that\n", mainClosure);
+               return false;
+       }
        return !foundFileThatInvalidatesClosure;
 }
 
@@ -6009,6 +6032,8 @@ static const dyld3::closure::LaunchClosure* buildLaunchClosure(const uint8_t* ma
                                                                                   archs, pathOverrides, atPathHanding, gLinkContext.allowEnvVarsPath, errorInfo);
        if (sForceInvalidSharedCacheClosureFormat)
                builder.setDyldCacheInvalidFormatVersion();
+       if ( !gLinkContext.allowInterposing )
+               builder.disableInterposing();
        const dyld3::closure::LaunchClosure* result = builder.makeLaunchClosure(mainFileInfo, gLinkContext.allowInsertFailures);
        if ( builder.diagnostics().hasError() ) {
                const char* errMsg = builder.diagnostics().errorMessage();
@@ -6057,7 +6082,11 @@ static const dyld3::closure::LaunchClosure* buildLaunchClosure(const uint8_t* ma
                putHexByte(mypid, s);
                *s = '\0';
                strlcat(closurePathTemp, pidBuf, PATH_MAX);
+#if __MAC_OS_X_VERSION_MIN_REQUIRED
                int fd = ::open(closurePathTemp, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR);
+#else
+               int fd = ::open_dprotected_np(closurePathTemp, O_WRONLY|O_CREAT, PROTECTION_CLASS_D, 0, S_IRUSR|S_IWUSR);
+#endif
                if ( fd != -1 ) {
                        ::ftruncate(fd, result->size());
                        ::write(fd, result, result->size());
@@ -6613,20 +6642,24 @@ reloadAllImages:
                                link(image, sEnv.DYLD_BIND_AT_LAUNCH, true, ImageLoader::RPathChain(NULL, NULL), -1);
                                image->setNeverUnloadRecursive();
                        }
-                       // only INSERTED libraries can interpose
-                       // register interposing info after all inserted libraries are bound so chaining works
-                       for(unsigned int i=0; i < sInsertedDylibCount; ++i) {
-                               ImageLoader* image = sAllImages[i+1];
-                               image->registerInterposing(gLinkContext);
+                       if ( gLinkContext.allowInterposing ) {
+                               // only INSERTED libraries can interpose
+                               // register interposing info after all inserted libraries are bound so chaining works
+                               for(unsigned int i=0; i < sInsertedDylibCount; ++i) {
+                                       ImageLoader* image = sAllImages[i+1];
+                                       image->registerInterposing(gLinkContext);
+                               }
                        }
                }
 
-               // <rdar://problem/19315404> dyld should support interposition even without DYLD_INSERT_LIBRARIES
-               for (long i=sInsertedDylibCount+1; i < sAllImages.size(); ++i) {
-                       ImageLoader* image = sAllImages[i];
-                       if ( image->inSharedCache() )
-                               continue;
-                       image->registerInterposing(gLinkContext);
+               if ( gLinkContext.allowInterposing ) {
+                       // <rdar://problem/19315404> dyld should support interposition even without DYLD_INSERT_LIBRARIES
+                       for (long i=sInsertedDylibCount+1; i < sAllImages.size(); ++i) {
+                               ImageLoader* image = sAllImages[i];
+                               if ( image->inSharedCache() )
+                                       continue;
+                               image->registerInterposing(gLinkContext);
+                       }
                }
        #if SUPPORT_ACCELERATE_TABLES
                if ( (sAllCacheImagesProxy != NULL) && ImageLoader::haveInterposingTuples() ) {
diff --git a/testing/include/test_support.h b/testing/include/test_support.h
new file mode 100644 (file)
index 0000000..5f3fc83
--- /dev/null
@@ -0,0 +1,74 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <mach-o/dyld.h>
+#include <sys/param.h>
+
+#if __LP64__
+extern struct mach_header_64 __dso_handle;
+#else
+extern struct mach_header __dso_handle;
+#endif
+
+static bool sIsATTY = false;
+static const char * sTestName = NULL;
+static uint64_t sTestCount = 0;
+
+__attribute__((constructor))
+static
+void BEGIN(int argc, const char* argv[], const char* envp[])  {
+    // Set up values we need to print in PASS() and FAIL()
+    sIsATTY = isatty(fileno(stdout));
+    sTestName = argv[0];
+    // Early returnif this not the main executbale, we only need to print the [BEGIN] line once
+    if (__dso_handle.filetype != MH_EXECUTE) {
+        return;
+    }
+    printf("[BEGIN]");
+    for (uint32_t i = 0; envp[i] != NULL; ++i) {
+        if (strncmp("DYLD_", envp[i], 5) == 0) {
+            printf(" %s", envp[i]);
+        }
+    }
+    char buffer[MAXPATHLEN];
+    uint32_t bufsize = MAXPATHLEN;
+    if (_NSGetExecutablePath(buffer, &bufsize) == 0) {
+        printf(" %s", buffer);
+    } else {
+        printf(" %s", argv[0]);
+    }
+    for (uint32_t i = 1; i < argc; ++i) {
+        printf (" %s", argv[i]);
+    }
+    printf("\n");
+}
+
+__attribute__((format(printf, 1, 2)))
+static
+void PASS(const char *format, ...)  {
+    if (sIsATTY) {
+        printf("[\033[0;32mPASS\033[0m] %s (%llu): ", sTestName, sTestCount++);
+    } else {
+        printf("[PASS] %s (%llu): ", sTestName, sTestCount++);
+    }
+    va_list args;
+    va_start (args, format);
+    vprintf (format, args);
+    va_end (args);
+    printf("\n");
+}
+
+__attribute__((format(printf, 1, 2)))
+static
+void FAIL(const char *format, ...) {
+    if (sIsATTY) {
+        printf("[\033[0;31mFAIL\033[0m] %s (%llu): ", sTestName, sTestCount++);
+    } else {
+        printf("[FAIL] %s (%llu): ", sTestName, sTestCount++);
+    }
+    va_list args;
+    va_start (args, format);
+    vprintf (format, args);
+    va_end (args);
+    printf("\n");
+}
diff --git a/testing/test-cases/amfi-interpose.dtest/interposer.c b/testing/test-cases/amfi-interpose.dtest/interposer.c
new file mode 100644 (file)
index 0000000..a9e5c36
--- /dev/null
@@ -0,0 +1,21 @@
+#include <stdlib.h>
+#include <string.h>
+#include <mach-o/dyld-interposing.h>
+
+
+
+void* mymalloc(size_t size)
+{
+    // bump ptr allocate twice the size and fills with '#'
+    char* result = malloc(size*2);
+    memset(result, '#', size*2);
+    return result;
+}
+
+void myfree(void* p)
+{
+    free(p);
+}
+
+DYLD_INTERPOSE(mymalloc, malloc)
+DYLD_INTERPOSE(myfree, free)
diff --git a/testing/test-cases/amfi-interpose.dtest/main.c b/testing/test-cases/amfi-interpose.dtest/main.c
new file mode 100644 (file)
index 0000000..d35a65e
--- /dev/null
@@ -0,0 +1,48 @@
+// BOOT_ARGS: dyld_flags=2
+
+// BUILD:  $CC interposer.c -dynamiclib -o $BUILD_DIR/libmyalloc.dylib -install_name $RUN_DIR/libmyalloc.dylib
+// BUILD:  $CC main.c $BUILD_DIR/libmyalloc.dylib  -o $BUILD_DIR/amfi-interpose.exe
+// BUILD:  $DYLD_ENV_VARS_ENABLE $BUILD_DIR/amfi-interpose.exe
+
+// RUN:  DYLD_AMFI_FAKE=0x7F  ./amfi-interpose.exe
+// RUN:  DYLD_AMFI_FAKE=0x3F  ./amfi-interpose.exe
+
+//
+// Tests that AMFI_DYLD_OUTPUT_ALLOW_LIBRARY_INTERPOSING bit from AMFI blocks interposing
+//
+
+#include <stdio.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <libamfi.h>
+
+int main()
+{
+    printf("[BEGIN] amfi-interpose\n");
+
+    // interposed malloc() doubles alloction size and prefills allocation with '#'
+    char* p1 = malloc(10);
+    bool interposed = (strncmp(p1, "####################", 20) == 0);
+
+    const char* amfiBits = getenv("DYLD_AMFI_FAKE");
+    if ( amfiBits == NULL ) {
+        printf("[FAIL] amfi-interpose: DYLD_AMFI_FAKE not setn\n");
+        return 0;
+    }
+#ifdef AMFI_RETURNS_INTERPOSING_FLAG
+    bool allowInterposing = (strcmp(amfiBits, "0x7F") == 0);
+#else
+    bool allowInterposing = true;
+#endif
+
+    if ( interposed == allowInterposing )
+        printf("[PASS] amfi-interpose\n");
+    else if ( interposed )
+        printf("[FAIL] amfi-interpose: malloc interposed, but amfi said to block it\n");
+    else
+        printf("[FAIL] amfi-interpose: malloc not interposed, but amfi said to allow it\n");
+
+       return 0;
+}
diff --git a/testing/test-cases/env-DYLD_VERSIONED_FRAMEWORK_PATH.dtest/foo.c b/testing/test-cases/env-DYLD_VERSIONED_FRAMEWORK_PATH.dtest/foo.c
new file mode 100644 (file)
index 0000000..01c576d
--- /dev/null
@@ -0,0 +1,5 @@
+
+int foo()
+{
+       return RESULT;
+}
diff --git a/testing/test-cases/env-DYLD_VERSIONED_FRAMEWORK_PATH.dtest/main.c b/testing/test-cases/env-DYLD_VERSIONED_FRAMEWORK_PATH.dtest/main.c
new file mode 100644 (file)
index 0000000..2fbce3a
--- /dev/null
@@ -0,0 +1,65 @@
+
+// BUILD_ONLY: MacOSX
+// BUILD:  mkdir -p $BUILD_DIR/Foo.framework $BUILD_DIR/alt11/Foo.framework/Versions/A $BUILD_DIR/alt9/Foo.framework
+// BUILD:  mkdir -p $BUILD_DIR/alt12/Foo.framework $BUILD_DIR/Bar.framework $BUILD_DIR/alt11/Bar.framework/Versions/A
+// BUILD:  mkdir -p $BUILD_DIR/Foo2.framework $BUILD_DIR/alt12/Foo2.framework
+// BUILD:  $CC foo.c -dynamiclib -DRESULT=9  -current_version 9  -install_name $RUN_DIR/Foo.framework/Foo -o $BUILD_DIR/alt9/Foo.framework/Foo
+// BUILD:  $CC foo.c -dynamiclib -DRESULT=10 -current_version 10 -install_name $RUN_DIR/Foo.framework/Foo -o $BUILD_DIR/Foo.framework/Foo
+// BUILD:  $CC foo.c -dynamiclib -DRESULT=11 -current_version 11 -install_name $RUN_DIR/Foo.framework/Foo -o $BUILD_DIR/alt11/Foo.framework/Versions/A/Foo
+// BUILD:  $CC foo.c -dynamiclib -DRESULT=12 -current_version 12 -install_name $RUN_DIR/Foo.framework/Foo -o $BUILD_DIR/alt12/Foo.framework/Foo
+
+// BUILD:  $CC foo.c -dynamiclib -DRESULT=10 -current_version 10 -install_name $RUN_DIR/Foo2.framework/Foo2 -o $BUILD_DIR/Foo2.framework/Foo2
+// BUILD:  $CC foo.c -dynamiclib -DRESULT=12 -current_version 12 -install_name $RUN_DIR/Foo2.framework/Foo2 -o $BUILD_DIR/alt12/Foo2.framework/Foo2
+
+// BUILD:  $CC main.c            -o $BUILD_DIR/env-DYLD_VERSIONED_FRAMEWORK_PATH.exe $BUILD_DIR/Foo.framework/Foo
+// BUILD:  $CC main.c            -o $BUILD_DIR/env-DYLD_VERSIONED_FRAMEWORK_PATH-missing.exe -Wl,-dyld_env,DYLD_VERSIONED_FRAMEWORK_PATH=@loader_path/alt12 $BUILD_DIR/Foo2.framework/Foo2
+
+// BUILD:  cd $BUILD_DIR/alt11/Foo.framework && ln -sf Versions/A/Foo
+// BUILD:  rm -rf $BUILD_DIR/Foo2.framework
+// BUILD:  $DYLD_ENV_VARS_ENABLE $BUILD_DIR/env-DYLD_VERSIONED_FRAMEWORK_PATH.exe
+
+// RUN: ./env-DYLD_VERSIONED_FRAMEWORK_PATH.exe 10
+// RUN: DYLD_VERSIONED_FRAMEWORK_PATH=$RUN_DIR/alt11 ./env-DYLD_VERSIONED_FRAMEWORK_PATH.exe 11 "alt11/Foo.framework/Versions/A/Foo"
+// RUN: DYLD_VERSIONED_FRAMEWORK_PATH=$RUN_DIR/alt9 ./env-DYLD_VERSIONED_FRAMEWORK_PATH.exe 10
+// RUN: DYLD_VERSIONED_FRAMEWORK_PATH=$RUN_DIR/alt9:$RUN_DIR/alt11 ./env-DYLD_VERSIONED_FRAMEWORK_PATH.exe 11
+// RUN: DYLD_VERSIONED_FRAMEWORK_PATH=$RUN_DIR/alt11:$RUN_DIR/alt12 ./env-DYLD_VERSIONED_FRAMEWORK_PATH.exe 12
+// FIXME: Forcibly disable testing with closures since macOS does not use them and they are currently broken
+// RUN: DYLD_USE_CLOSURES=0 ./env-DYLD_VERSIONED_FRAMEWORK_PATH-missing.exe 12
+
+#include <stdio.h>  // fprintf(), NULL
+#include <stdlib.h> // exit(), EXIT_SUCCESS
+#include <dlfcn.h>
+#include <string.h>
+#include <stdlib.h> // for atoi()
+
+#include "test_support.h"
+
+extern int foo();
+
+int main(int argc, const char* argv[])
+{
+       if ( argc > 2 ) {
+               bool found = false;
+               uint32_t count = _dyld_image_count();
+               for(uint32_t i=0; i < count; ++i) {
+                       const char*  name = _dyld_get_image_name(i);
+            if ( strstr(name, argv[2]) != NULL ) {
+                               found = true;
+            }
+               }
+               if ( !found ) {
+                       FAIL("Dylib has wrong path");
+                       return EXIT_SUCCESS;
+               }
+       }
+
+       int expectedResult = atoi(argv[1]);
+       int actualResult = foo();
+    if ( actualResult != expectedResult ) {
+               FAIL("Using wrong dylib. foo() returned %d, expected %d", actualResult, expectedResult);
+    } else {
+               PASS("Success");
+    }
+       return 0;
+}
+
diff --git a/testing/test-cases/env-DYLD_VERSIONED_LIBRARY_PATH.dtest/foo.c b/testing/test-cases/env-DYLD_VERSIONED_LIBRARY_PATH.dtest/foo.c
new file mode 100644 (file)
index 0000000..01c576d
--- /dev/null
@@ -0,0 +1,5 @@
+
+int foo()
+{
+       return RESULT;
+}
diff --git a/testing/test-cases/env-DYLD_VERSIONED_LIBRARY_PATH.dtest/main.c b/testing/test-cases/env-DYLD_VERSIONED_LIBRARY_PATH.dtest/main.c
new file mode 100644 (file)
index 0000000..b0a7e64
--- /dev/null
@@ -0,0 +1,87 @@
+// BUILD_ONLY: MacOSX
+// BUILD:  mkdir -p $BUILD_DIR/alt11 $BUILD_DIR/alt9 $BUILD_DIR/alt12
+// BUILD:  $CC foo.c -dynamiclib -DRESULT=9  -current_version 9  -install_name $RUN_DIR/libfoo.dylib -o $BUILD_DIR/alt9/libfoo.dylib
+// BUILD:  $CC foo.c -dynamiclib -DRESULT=10 -current_version 10 -install_name $RUN_DIR/libfoo.dylib -o $BUILD_DIR/libfoo.dylib
+// BUILD:  $CC foo.c -dynamiclib -DRESULT=11 -current_version 11 -install_name $RUN_DIR/libfoo.dylib -o $BUILD_DIR/alt11/libfoo.dylib
+// BUILD:  $CC foo.c -dynamiclib -DRESULT=12 -current_version 12 -install_name $RUN_DIR/libfoo.dylib -o $BUILD_DIR/alt12/libfoo.dylib
+
+// BUILD:  $CC foo.c -dynamiclib -DRESULT=10 -current_version 10 -install_name $RUN_DIR/libfoo2.dylib -o $BUILD_DIR/libfoo2.dylib
+// BUILD:  $CC foo.c -dynamiclib -DRESULT=12 -current_version 12 -install_name $RUN_DIR/libfoo2.dylib -o $BUILD_DIR/alt12/libfoo2.dylib
+
+// BUILD:  $CC main.c            -o $BUILD_DIR/env-DYLD_VERSIONED_LIBRARY_PATH.exe $BUILD_DIR/libfoo.dylib
+// BUILD:  $CC main.c            -o $BUILD_DIR/env-DYLD_VERSIONED_LIBRARY_PATH-10.exe $BUILD_DIR/libfoo.dylib
+// BUILD:  $CC main.c            -o $BUILD_DIR/env-DYLD_VERSIONED_LIBRARY_PATH-11.exe $BUILD_DIR/libfoo.dylib -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt11
+// BUILD:  $CC main.c            -o $BUILD_DIR/env-DYLD_VERSIONED_LIBRARY_PATH-911.exe $BUILD_DIR/libfoo.dylib -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt9 -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt11
+// BUILD:  $CC main.c            -o $BUILD_DIR/env-DYLD_VERSIONED_LIBRARY_PATH-911b.exe $BUILD_DIR/libfoo.dylib -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt9:@loader_path/alt11
+// BUILD:  $CC main.c            -o $BUILD_DIR/env-DYLD_VERSIONED_LIBRARY_PATH-911c.exe $BUILD_DIR/libfoo.dylib -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@executable_path/alt9:@executable_path/alt11
+// BUILD:  $CC main.c            -o $BUILD_DIR/env-DYLD_VERSIONED_LIBRARY_PATH-1112.exe $BUILD_DIR/libfoo.dylib -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt11 -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt12
+// BUILD:  $CC main.c            -o $BUILD_DIR/env-DYLD_VERSIONED_LIBRARY_PATH-1112b.exe $BUILD_DIR/libfoo.dylib -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt11:@loader_path/alt12
+// BUILD:  $CC main.c            -o $BUILD_DIR/env-DYLD_VERSIONED_LIBRARY_PATH-1211.exe $BUILD_DIR/libfoo.dylib -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt12 -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt11
+// BUILD:  $CC main.c            -o $BUILD_DIR/env-DYLD_VERSIONED_LIBRARY_PATH-1211b.exe $BUILD_DIR/libfoo.dylib -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt12:@loader_path/alt11
+// BUILD:  $CC main.c            -o $BUILD_DIR/env-DYLD_VERSIONED_LIBRARY_PATH-missing.exe $BUILD_DIR/libfoo2.dylib -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt12
+// BUILD:  $CC main.c            -o $BUILD_DIR/env-DYLD_VERSIONED_LIBRARY_PATH-dlopen.exe -DUSE_DLOPEN -DRUN_DIR="$RUN_DIR" -DDYLIB_NAME="libfoo.dylib"
+// BUILD:  $CC main.c            -o $BUILD_DIR/env-DYLD_VERSIONED_LIBRARY_PATH-missing-dlopen.exe -DUSE_DLOPEN -DRUN_DIR="$RUN_DIR" -DDYLIB_NAME="libfoo2.dylib"
+
+// BUILD:  rm -rf $BUILD_DIR/libfoo2.dylib
+
+// BUILD:  $DYLD_ENV_VARS_ENABLE $BUILD_DIR/env-DYLD_VERSIONED_LIBRARY_PATH.exe
+// BUILD:  $DYLD_ENV_VARS_ENABLE $BUILD_DIR/env-DYLD_VERSIONED_LIBRARY_PATH-11.exe
+
+// RUN: ./env-DYLD_VERSIONED_LIBRARY_PATH.exe 10
+// RUN: DYLD_VERSIONED_LIBRARY_PATH=$RUN_DIR/alt11 ./env-DYLD_VERSIONED_LIBRARY_PATH.exe 11
+// RUN: DYLD_VERSIONED_LIBRARY_PATH=$RUN_DIR/alt9 ./env-DYLD_VERSIONED_LIBRARY_PATH.exe 10
+// RUN: DYLD_VERSIONED_LIBRARY_PATH=$RUN_DIR/alt9:$RUN_DIR/alt11 ./env-DYLD_VERSIONED_LIBRARY_PATH.exe 11
+// RUN: DYLD_VERSIONED_LIBRARY_PATH=$RUN_DIR/alt11:$RUN_DIR/alt12 ./env-DYLD_VERSIONED_LIBRARY_PATH.exe 12
+// RUN: ./env-DYLD_VERSIONED_LIBRARY_PATH-10.exe 10
+// RUN: ./env-DYLD_VERSIONED_LIBRARY_PATH-11.exe 11
+// RUN: ./env-DYLD_VERSIONED_LIBRARY_PATH-911.exe 11
+// RUN: ./env-DYLD_VERSIONED_LIBRARY_PATH-911b.exe 11
+// RUN: ./env-DYLD_VERSIONED_LIBRARY_PATH-911c.exe 11
+// RUN: ./env-DYLD_VERSIONED_LIBRARY_PATH-1112.exe 12
+// RUN: ./env-DYLD_VERSIONED_LIBRARY_PATH-1112b.exe 12
+// RUN: ./env-DYLD_VERSIONED_LIBRARY_PATH-1211.exe 12
+// RUN: ./env-DYLD_VERSIONED_LIBRARY_PATH-1211b.exe 12
+// RUN: DYLD_VERSIONED_LIBRARY_PATH=$RUN_DIR/alt9 ./env-DYLD_VERSIONED_LIBRARY_PATH-11.exe 11
+// RUN: DYLD_VERSIONED_LIBRARY_PATH=$RUN_DIR/alt12 ./env-DYLD_VERSIONED_LIBRARY_PATH-11.exe 12
+// FIXME: Forcibly disable testing with closures since macOS does not use them and they are currently broken
+// RUN: DYLD_USE_CLOSURES=0 ./env-DYLD_VERSIONED_LIBRARY_PATH-missing.exe 12
+
+// RUN: DYLD_USE_CLOSURES=0 ./env-DYLD_VERSIONED_LIBRARY_PATH-dlopen.exe 10
+// RUN: DYLD_USE_CLOSURES=0 DYLD_VERSIONED_LIBRARY_PATH=$RUN_DIR/alt11 ./env-DYLD_VERSIONED_LIBRARY_PATH-dlopen.exe 11
+// RUN: DYLD_USE_CLOSURES=0 DYLD_VERSIONED_LIBRARY_PATH=$RUN_DIR/alt9 ./env-DYLD_VERSIONED_LIBRARY_PATH-dlopen.exe 10
+// RUN: DYLD_USE_CLOSURES=0 DYLD_VERSIONED_LIBRARY_PATH="/AppleInternal/CoreOS/tests/dyld/env-DYLD_VERSIONED_LIBRARY_PATH/alt12" ./env-DYLD_VERSIONED_LIBRARY_PATH-missing-dlopen.exe 12
+
+#include <stdio.h>  // fprintf(), NULL
+#include <stdlib.h> // exit(), EXIT_SUCCESS
+#include <string.h>
+#include <stdlib.h> // for atoi()
+
+#include "test_support.h"
+
+#if USE_DLOPEN
+#include <dlfcn.h>
+#else
+extern int foo();
+#endif
+
+int main(int argc, const char* argv[])
+{
+    int expectedResult = atoi(argv[1]);
+#if USE_DLOPEN
+    void * handle = dlopen(RUN_DIR "/" DYLIB_NAME, RTLD_LAZY);
+    if (!handle) {
+        FAIL("dlopen(\"%s\") failed with error \"%s\"", RUN_DIR "/" DYLIB_NAME, dlerror());
+    }
+    int (*foo)() = dlsym(handle, "foo");
+    if (!foo) {
+        FAIL("dlsym(\"foo\") failed with error \"%s\"", dlerror());
+    }
+#endif
+    int actualResult = foo();
+    if ( actualResult != expectedResult ) {
+        FAIL("Using wrong dylib. foo() returned %d, expected %d", actualResult, expectedResult);
+    } else {
+        PASS("Success");
+    }
+    return 0;
+}
diff --git a/unit-tests/test-cases/DYLD_VERSIONED_FRAMEWORK_PATH-basic/Makefile b/unit-tests/test-cases/DYLD_VERSIONED_FRAMEWORK_PATH-basic/Makefile
deleted file mode 100644 (file)
index 67ef91c..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-##
-# Copyright (c) 2010 Apple Inc. All rights reserved.
-#
-# @APPLE_LICENSE_HEADER_START@
-# 
-# This file contains Original Code and/or Modifications of Original Code
-# as defined in and that are subject to the Apple Public Source License
-# Version 2.0 (the 'License'). You may not use this file except in
-# compliance with the License. Please obtain a copy of the License at
-# http://www.opensource.apple.com/apsl/ and read it before using this
-# file.
-# 
-# The Original Code and all software distributed under the License are
-# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
-# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
-# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
-# Please see the License for the specific language governing rights and
-# limitations under the License.
-# 
-# @APPLE_LICENSE_HEADER_END@
-##
-TESTROOT = ../..
-include ${TESTROOT}/include/common.makefile
-
-PWD = $(shell pwd)
-
-ifeq "$(OS_NAME)" "iPhoneOS"
-       CHECK = check-ios
-else
-       CHECK = check-macosx
-endif
-
-
-all-check: all $(CHECK)
-
-check: $(CHECK)
-
-check-ios:
-       ./main 10
-
-check-macosx:
-       ./main 10
-       export DYLD_VERSIONED_FRAMEWORK_PATH="${PWD}/alt11" && ./main 11 "alt11/Foo.framework/Versions/A/Foo"
-       export DYLD_VERSIONED_FRAMEWORK_PATH="${PWD}/alt9" && ./main 10
-       export DYLD_VERSIONED_FRAMEWORK_PATH="${PWD}/alt9:${PWD}/alt11" && ./main 11
-       export DYLD_VERSIONED_FRAMEWORK_PATH="${PWD}/alt11:${PWD}/alt12" && ./main 12
-
-all: 
-       mkdir -p Foo.framework alt11/Foo.framework/Versions/A alt9/Foo.framework alt12/Foo.framework Bar.framework alt11/Bar.framework/Versions/A/
-       ${CC} ${CCFLAGS} -dynamiclib bar.c -DRESULT=10 -current_version 10 -install_name "${PWD}/Bar.framework/Bar" -o Bar.framework/Bar
-       ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=10 -current_version 10 -install_name "${PWD}/Foo.framework/Foo" -o Foo.framework/Foo
-       ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main main.c Bar.framework/Bar Foo.framework/Foo
-       ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=11 -current_version 11 -install_name "${PWD}/Foo.framework/Foo" -o alt11/Foo.framework/Versions/A/Foo
-       ${CC} ${CCFLAGS} -dynamiclib bar.c -DRESULT=11 -current_version 11 -install_name "${PWD}/Bar.framework/Foo" -o alt11/Bar.framework/Versions/A/Bar
-       cd alt11/Foo.framework && ln -sf Versions/A/Foo
-       cd alt11/Bar.framework && ln -sf Versions/A/Bar
-       ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=9  -current_version 9  -install_name "${PWD}/Foo.framework/Foo" -o alt9/Foo.framework/Foo
-       ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=12 -current_version 12 -install_name "${PWD}/Foo.framework/Foo" -o alt12/Foo.framework/Foo  
-
-
-clean:
-       ${RM} -rf main Foo.framework Bar.framework alt9 alt11 alt12
-
diff --git a/unit-tests/test-cases/DYLD_VERSIONED_FRAMEWORK_PATH-basic/bar.c b/unit-tests/test-cases/DYLD_VERSIONED_FRAMEWORK_PATH-basic/bar.c
deleted file mode 100644 (file)
index 4684921..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-
-int bar()
-{
-       return 0;
-}
diff --git a/unit-tests/test-cases/DYLD_VERSIONED_FRAMEWORK_PATH-basic/foo.c b/unit-tests/test-cases/DYLD_VERSIONED_FRAMEWORK_PATH-basic/foo.c
deleted file mode 100644 (file)
index 01c576d..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-
-int foo()
-{
-       return RESULT;
-}
diff --git a/unit-tests/test-cases/DYLD_VERSIONED_FRAMEWORK_PATH-basic/main.c b/unit-tests/test-cases/DYLD_VERSIONED_FRAMEWORK_PATH-basic/main.c
deleted file mode 100644 (file)
index 26a1e09..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2010 Apple Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
- * 
- * The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
- * limitations under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
- */
-#include <stdio.h>  // fprintf(), NULL
-#include <stdlib.h> // exit(), EXIT_SUCCESS
-#include <dlfcn.h>
-#include <string.h>
-#include <stdlib.h> // for atoi()
-#include <mach-o/dyld.h>
-
-#include "test.h" // PASS(), FAIL(), XPASS(), XFAIL()
-
-
-
-extern int foo();
-
-int main(int argc, const char* argv[])
-{
-       if ( argc > 2 ) {
-               bool found = false;
-               uint32_t count = _dyld_image_count();
-               for(uint32_t i=0; i < count; ++i) {
-                       const char*  name = _dyld_get_image_name(i);
-                       if ( strstr(name, argv[2]) != NULL )
-                               found = true;
-                       //fprintf(stderr, "image[%d]=%s\n", i, name);
-               }
-               if ( !found ) {
-                       FAIL("DYLD_VERSIONED_FRAMEWORK_PATH-basic dylib has wrong path");
-                       return EXIT_SUCCESS;
-               }
-       }
-       
-       int expectedResult = atoi(argv[1]);
-       int actualResult = foo();
-       //fprintf(stderr, "foo() returned %d, expected %d\n", actualResult, expectedResult);
-       if ( actualResult != expectedResult )
-               FAIL("DYLD_VERSIONED_FRAMEWORK_PATH-basic using wrong dylib. foo() returned %d, expected %d", actualResult, expectedResult);
-       else
-               PASS("DYLD_VERSIONED_FRAMEWORK_PATH-basic");
-               
-       return EXIT_SUCCESS;
-}
-
diff --git a/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-basic/Makefile b/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-basic/Makefile
deleted file mode 100644 (file)
index 4206cb7..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-##
-# Copyright (c) 2010 Apple Inc. All rights reserved.
-#
-# @APPLE_LICENSE_HEADER_START@
-# 
-# This file contains Original Code and/or Modifications of Original Code
-# as defined in and that are subject to the Apple Public Source License
-# Version 2.0 (the 'License'). You may not use this file except in
-# compliance with the License. Please obtain a copy of the License at
-# http://www.opensource.apple.com/apsl/ and read it before using this
-# file.
-# 
-# The Original Code and all software distributed under the License are
-# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
-# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
-# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
-# Please see the License for the specific language governing rights and
-# limitations under the License.
-# 
-# @APPLE_LICENSE_HEADER_END@
-##
-TESTROOT = ../..
-include ${TESTROOT}/include/common.makefile
-
-PWD = $(shell pwd)
-
-ifeq "$(OS_NAME)" "iPhoneOS"
-       CHECK = check-ios
-else
-       CHECK = check-macosx
-endif
-
-all-check: all check
-
-check: $(CHECK)
-
-check-ios:
-       ./main 10
-
-check-macosx:
-       ./main 10
-       export DYLD_VERSIONED_LIBRARY_PATH="${PWD}/alt11" && ./main 11
-       export DYLD_VERSIONED_LIBRARY_PATH="${PWD}/alt9" && ./main 10
-       export DYLD_VERSIONED_LIBRARY_PATH="${PWD}/alt9:${PWD}/alt11" && ./main 11
-       export DYLD_VERSIONED_LIBRARY_PATH="${PWD}/alt11:${PWD}/alt12" && ./main 12
-
-all: 
-       mkdir -p alt11 alt9 alt12
-       ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=10 -current_version 10 -o "${PWD}/libfoo.dylib"
-       ${CC} ${CCFLAGS} -dynamiclib bar.c -DRESULT=10 -current_version 10 -o "${PWD}/libbar.dylib"
-       ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main main.c libbar.dylib libfoo.dylib
-       ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=11 -current_version 11 -install_name "${PWD}/libfoo.dylib" -o alt11/libfoo.dylib  
-       ${CC} ${CCFLAGS} -dynamiclib bar.c -DRESULT=11 -current_version 11 -install_name "${PWD}/libbar.dylib" -o alt11/libbar.dylib
-       ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=9  -current_version 9  -install_name "${PWD}/libfoo.dylib" -o alt9/libfoo.dylib
-       ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=12 -current_version 12 -install_name "${PWD}/libfoo.dylib" -o alt12/libfoo.dylib  
-
-
-clean:
-       ${RM} -rf main libfoo.dylib libbar.dylib alt9 alt11 alt12
-
diff --git a/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-basic/bar.c b/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-basic/bar.c
deleted file mode 100644 (file)
index c57608f..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-
-int bar()
-{
-       return RESULT;
-}
diff --git a/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-basic/foo.c b/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-basic/foo.c
deleted file mode 100644 (file)
index 01c576d..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-
-int foo()
-{
-       return RESULT;
-}
diff --git a/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-basic/main.c b/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-basic/main.c
deleted file mode 100644 (file)
index a903b04..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2010 Apple Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
- * 
- * The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
- * limitations under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
- */
-#include <stdio.h>  // fprintf(), NULL
-#include <stdlib.h> // exit(), EXIT_SUCCESS
-#include <dlfcn.h>
-#include <string.h>
-#include <stdlib.h> // for atoi()
-
-#include "test.h" // PASS(), FAIL(), XPASS(), XFAIL()
-
-
-
-extern int foo();
-
-int main(int argc, const char* argv[])
-{
-       int expectedResult = atoi(argv[1]);
-       int actualResult = foo();
-       //fprintf(stderr, "foo() returned %d, expected %d\n", actualResult, expectedResult);
-       if ( actualResult != expectedResult )
-               FAIL("DYLD_VERSIONED_LIBRARY_PATH-basic using wrong dylib. foo() returned %d, expected %d", actualResult, expectedResult);
-       else
-               PASS("DYLD_VERSIONED_LIBRARY_PATH-basic");
-               
-       return EXIT_SUCCESS;
-}
-
diff --git a/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-dyld_env-restrict/Makefile b/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-dyld_env-restrict/Makefile
deleted file mode 100644 (file)
index eeaef6e..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-##
-# Copyright (c) 2010 Apple Inc. All rights reserved.
-#
-# @APPLE_LICENSE_HEADER_START@
-# 
-# This file contains Original Code and/or Modifications of Original Code
-# as defined in and that are subject to the Apple Public Source License
-# Version 2.0 (the 'License'). You may not use this file except in
-# compliance with the License. Please obtain a copy of the License at
-# http://www.opensource.apple.com/apsl/ and read it before using this
-# file.
-# 
-# The Original Code and all software distributed under the License are
-# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
-# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
-# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
-# Please see the License for the specific language governing rights and
-# limitations under the License.
-# 
-# @APPLE_LICENSE_HEADER_END@
-##
-TESTROOT = ../..
-include ${TESTROOT}/include/common.makefile
-
-PWD = $(shell pwd)
-
-all-check: all check
-
-check:
-       ./main10 10
-       ./main11 11
-       ./main911 11
-       ./main911b 11
-       ./main1112 12
-       ./main1112b 12
-       ./main1211 12
-       ./main1211b 12
-
-all: 
-       mkdir -p alt11 alt9 alt12
-       ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=10 -current_version 10 -o "${PWD}/libfoo.dylib"
-       ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=11 -current_version 11 -install_name "${PWD}/libfoo.dylib" -o alt11/libfoo.dylib  
-       ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=9  -current_version 9  -install_name "${PWD}/libfoo.dylib" -o alt9/libfoo.dylib  
-       ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=12 -current_version 12 -install_name "${PWD}/libfoo.dylib" -o alt12/libfoo.dylib  
-       ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main10 main.c libfoo.dylib -Wl,-sectcreate,__RESTRICT,__restrict,/dev/null
-       ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main11 main.c libfoo.dylib -Wl,-sectcreate,__RESTRICT,__restrict,/dev/null -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt11
-       ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main911 main.c libfoo.dylib -Wl,-sectcreate,__RESTRICT,__restrict,/dev/null -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt9 -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt11
-       ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main911b main.c libfoo.dylib -Wl,-sectcreate,__RESTRICT,__restrict,/dev/null -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt9:@loader_path/alt11
-       ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main1112 main.c libfoo.dylib -Wl,-sectcreate,__RESTRICT,__restrict,/dev/null -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt11 -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt12
-       ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main1112b main.c libfoo.dylib -Wl,-sectcreate,__RESTRICT,__restrict,/dev/null -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt11:@loader_path/alt12
-       ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main1211 main.c libfoo.dylib -Wl,-sectcreate,__RESTRICT,__restrict,/dev/null -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt12 -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt11
-       ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main1211b main.c libfoo.dylib -Wl,-sectcreate,__RESTRICT,__restrict,/dev/null -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt12:@loader_path/alt11
-
-
-clean:
-       ${RM} -rf libfoo.dylib alt9 alt11 alt12 main10 main11 main9 main911 main911b main1112 main1112b main1211 main1211b
-
diff --git a/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-dyld_env-restrict/foo.c b/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-dyld_env-restrict/foo.c
deleted file mode 100644 (file)
index 01c576d..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-
-int foo()
-{
-       return RESULT;
-}
diff --git a/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-dyld_env-restrict/main.c b/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-dyld_env-restrict/main.c
deleted file mode 100644 (file)
index a903b04..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2010 Apple Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
- * 
- * The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
- * limitations under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
- */
-#include <stdio.h>  // fprintf(), NULL
-#include <stdlib.h> // exit(), EXIT_SUCCESS
-#include <dlfcn.h>
-#include <string.h>
-#include <stdlib.h> // for atoi()
-
-#include "test.h" // PASS(), FAIL(), XPASS(), XFAIL()
-
-
-
-extern int foo();
-
-int main(int argc, const char* argv[])
-{
-       int expectedResult = atoi(argv[1]);
-       int actualResult = foo();
-       //fprintf(stderr, "foo() returned %d, expected %d\n", actualResult, expectedResult);
-       if ( actualResult != expectedResult )
-               FAIL("DYLD_VERSIONED_LIBRARY_PATH-basic using wrong dylib. foo() returned %d, expected %d", actualResult, expectedResult);
-       else
-               PASS("DYLD_VERSIONED_LIBRARY_PATH-basic");
-               
-       return EXIT_SUCCESS;
-}
-
diff --git a/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-dyld_env/Makefile b/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-dyld_env/Makefile
deleted file mode 100644 (file)
index 357a34e..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-##
-# Copyright (c) 2010 Apple Inc. All rights reserved.
-#
-# @APPLE_LICENSE_HEADER_START@
-# 
-# This file contains Original Code and/or Modifications of Original Code
-# as defined in and that are subject to the Apple Public Source License
-# Version 2.0 (the 'License'). You may not use this file except in
-# compliance with the License. Please obtain a copy of the License at
-# http://www.opensource.apple.com/apsl/ and read it before using this
-# file.
-# 
-# The Original Code and all software distributed under the License are
-# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
-# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
-# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
-# Please see the License for the specific language governing rights and
-# limitations under the License.
-# 
-# @APPLE_LICENSE_HEADER_END@
-##
-TESTROOT = ../..
-include ${TESTROOT}/include/common.makefile
-
-PWD = $(shell pwd)
-
-all-check: all check
-
-check:
-       ./main10 10
-       ./main11 11
-       ./main911 11
-       ./main911b 11
-       ./main911c 11
-       ./main1112 12
-       ./main1112b 12
-       ./main1211 12
-       ./main1211b 12
-       export DYLD_LIBRARY_PATH=./alt9 && ./main11 9
-
-all: 
-       mkdir -p alt11 alt9 alt12
-       ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=10 -current_version 10 -o "${PWD}/libfoo.dylib"
-       ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=11 -current_version 11 -install_name "${PWD}/libfoo.dylib" -o alt11/libfoo.dylib  
-       ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=9  -current_version 9  -install_name "${PWD}/libfoo.dylib" -o alt9/libfoo.dylib  
-       ${CC} ${CCFLAGS} -dynamiclib foo.c -DRESULT=12 -current_version 12 -install_name "${PWD}/libfoo.dylib" -o alt12/libfoo.dylib  
-       ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main10 main.c libfoo.dylib 
-       ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main11 main.c libfoo.dylib -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt11
-       ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main911 main.c libfoo.dylib -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt9 -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt11
-       ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main911b main.c libfoo.dylib -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt9:@loader_path/alt11
-       ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main911c main.c libfoo.dylib -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@executable_path/alt9:@executable_path/alt11
-       ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main1112 main.c libfoo.dylib -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt11 -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt12
-       ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main1112b main.c libfoo.dylib -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt11:@loader_path/alt12
-       ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main1211 main.c libfoo.dylib -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt12 -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt11
-       ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main1211b main.c libfoo.dylib -Wl,-dyld_env,DYLD_VERSIONED_LIBRARY_PATH=@loader_path/alt12:@loader_path/alt11
-
-
-clean:
-       ${RM} -rf libfoo.dylib alt9 alt11 alt12 main10 main11 main9 main911 main911b main911c main1112 main1112b main1211 main1211b
-
diff --git a/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-dyld_env/foo.c b/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-dyld_env/foo.c
deleted file mode 100644 (file)
index 01c576d..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-
-int foo()
-{
-       return RESULT;
-}
diff --git a/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-dyld_env/main.c b/unit-tests/test-cases/DYLD_VERSIONED_LIBRARY_PATH-dyld_env/main.c
deleted file mode 100644 (file)
index a903b04..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2010 Apple Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
- * 
- * The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
- * limitations under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
- */
-#include <stdio.h>  // fprintf(), NULL
-#include <stdlib.h> // exit(), EXIT_SUCCESS
-#include <dlfcn.h>
-#include <string.h>
-#include <stdlib.h> // for atoi()
-
-#include "test.h" // PASS(), FAIL(), XPASS(), XFAIL()
-
-
-
-extern int foo();
-
-int main(int argc, const char* argv[])
-{
-       int expectedResult = atoi(argv[1]);
-       int actualResult = foo();
-       //fprintf(stderr, "foo() returned %d, expected %d\n", actualResult, expectedResult);
-       if ( actualResult != expectedResult )
-               FAIL("DYLD_VERSIONED_LIBRARY_PATH-basic using wrong dylib. foo() returned %d, expected %d", actualResult, expectedResult);
-       else
-               PASS("DYLD_VERSIONED_LIBRARY_PATH-basic");
-               
-       return EXIT_SUCCESS;
-}
-