2 # Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
4 # @APPLE_LICENSE_HEADER_START@
6 # This file contains Original Code and/or Modifications of Original Code
7 # as defined in and that are subject to the Apple Public Source License
8 # Version 2.0 (the 'License'). You may not use this file except in
9 # compliance with the License. Please obtain a copy of the License at
10 # http://www.opensource.apple.com/apsl/ and read it before using this
13 # The Original Code and all software distributed under the License are
14 # distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 # EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 # INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 # Please see the License for the specific language governing rights and
19 # limitations under the License.
21 # @APPLE_LICENSE_HEADER_END@
24 include ${TESTROOT}/include/common.makefile
27 ### This test case is to verify that dyld cannot be tricked into loading
28 ### the "same" library twice.
30 ### The tricky scenario is:
31 ### 1) a library dyld is to load is specified with a symlink path
32 ### 2) the library the that is the target of the symlink is already loaded
33 ### via a different path. In this case becuase of DYLD_LIBRARY_PATH.
43 export DYLD_LIBRARY_PATH="`pwd`/fake" && ./main
46 all: main real/liblink.dylib real/libtest.dylib fake/libtest.dylib
49 main: main.c stub/libtest.dylib stub/liblink.dylib real/libbase.dylib
50 ${CC} ${CCFLAGS} -I${TESTROOT}/include -o main main.c stub/libtest.dylib stub/liblink.dylib real/libbase.dylib
52 stub/libtest.dylib: test.c
54 ${CC} ${CCFLAGS} -I${TESTROOT}/include -dynamiclib test.c -DDO_NOTHING -o stub/libtest.dylib -install_name "`pwd`/real/libtest.dylib"
56 stub/liblink.dylib: link.c
58 ${CC} ${CCFLAGS} -I${TESTROOT}/include -dynamiclib link.c -o stub/liblink.dylib -install_name "`pwd`/real/liblink.dylib"
61 real/libbase.dylib: base.c
63 ${CC} ${CCFLAGS} -I${TESTROOT}/include -dynamiclib base.c -o "`pwd`/real/libbase.dylib"
65 real/libtest.dylib: test.c real/libbase.dylib
67 ${CC} ${CCFLAGS} -I${TESTROOT}/include -dynamiclib test.c real/libbase.dylib -o "`pwd`/real/libtest.dylib"
69 real/liblink.dylib: link.c
71 cd real && ln -s libtest.dylib liblink.dylib
74 fake/libtest.dylib: test.c real/libbase.dylib
76 ${CC} ${CCFLAGS} -I${TESTROOT}/include -dynamiclib test.c real/libbase.dylib -o "`pwd`/fake/libtest.dylib" -install_name "`pwd`/real/libtest.dylib"
82 ${RM} ${RMFLAGS} *~ main real stub fake