View | Details | Raw Unified | Return to issue 5568
Collapse All | Expand All

(-)checkdll/checkdll.c (-43 / +34 lines)
Lines 65-71 Link Here
65
#include <errno.h>
65
#include <errno.h>
66
#include <unistd.h>
66
#include <unistd.h>
67
#ifdef MACOSX
67
#ifdef MACOSX
68
#include <CoreFoundation/CoreFoundation.h>
68
#include <mach-o/dyld.h>
69
#else
69
#else
70
#include <dlfcn.h>
70
#include <dlfcn.h>
71
#endif
71
#endif
Lines 90-99 Link Here
90
{
90
{
91
	int 	rc;
91
	int 	rc;
92
#ifdef MACOSX
92
#ifdef MACOSX
93
    CFStringRef	    bundlePath;
93
	struct mach_header *pLib;
94
    CFURLRef        bundleURL;
95
    CFBundleRef     bundle;
96
    CFStringRef	    symbolName;
97
#else
94
#else
98
	void	*phandle;
95
	void	*phandle;
99
#endif
96
#endif
Lines 115-159 Link Here
115
112
116
#ifdef MACOSX
113
#ifdef MACOSX
117
114
118
    /* Convert char pointers to CFStringRefs */
115
        // Check if library is already loaded
119
    bundlePath = CFStringCreateWithCStringNoCopy(NULL, argv[1],
116
        pLib = NSAddImage(argv[1], NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED);
120
        CFStringGetSystemEncoding(), kCFAllocatorNull);
117
        if (!pLib) {
121
    symbolName = CFStringCreateWithCStringNoCopy(NULL, psymbol,
118
                // Check DYLD_LIBRARY_PATH
122
        CFStringGetSystemEncoding(), kCFAllocatorNull);
119
                pLib = NSAddImage(argv[1], NSADDIMAGE_OPTION_WITH_SEARCHING);
123
120
        }
124
    /* Get the framework's URL using its path */
121
        if (pLib) {
125
    if ((bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
122
                // Prefix symbol name with '_'
126
        bundlePath, kCFURLPOSIXPathStyle, true)) != NULL) {
123
                char *name = malloc(1+strlen(psymbol)+1);
127
	        /* Load the framework */
124
                NSSymbol *symbol;
128
            if ((bundle = CFBundleCreate( kCFAllocatorDefault,
125
                void *address = NULL;
129
                bundleURL)) != NULL) {
126
                strcpy(name, "_");
130
                    /* Load the shared library */
127
                strcat(name, psymbol);
131
                    if (CFBundleLoadExecutable(bundle)) {
128
                symbol = NSLookupSymbolInImage(pLib, name, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND);
132
                        if ((pfun = CFBundleGetFunctionPointerForName(bundle,
129
                free(name);
133
                            symbolName)) != NULL) {
130
                if (symbol) address = NSAddressOfSymbol(symbol);
134
	                            printf(": ok\n");
131
                if (address != NULL) {
135
                                CFRelease(bundlePath);
132
                        printf(": ok\n");
136
                                CFRelease(bundleURL);
133
#ifdef NO_UNLOAD_CHECK
137
                                CFRelease(bundle);
134
                        _exit(0);
138
                                CFRelease(symbolName);
135
#else
139
			                    return 0;
136
                        // Mac OS X can't unload dylibs
140
                        }
137
#endif
141
                        else
138
                        return 0;
142
	                        printf(": ERROR: symbol %s not found\n", psymbol);
139
                } else {
143
                    }
140
                        printf(": ERROR: symbol %s not found\n", psymbol);
144
                    /* No message printed since CFLog prints its own message */
141
                }
145
            }
142
        } else {
146
            else
143
                printf(": ERROR: %s is not a valid dylib name\n", argv[1]);
147
	            printf(": ERROR: %s is not a bundle\n", argv[1]);
144
        }
148
	}
149
    else
150
	    printf(": ERROR: %s is not a valid bundle name\n", argv[1]);
151
152
    CFRelease(bundlePath);
153
    if (bundleURL != NULL) CFRelease(bundleURL);
154
    if (bundle != NULL) CFRelease(bundle);
155
    CFRelease(symbolName);
156
	return 3;
145
	return 3;
146
147
        // fixme use NSLinkEditError() for better error messages
157
148
158
#else /* MACOSX */
149
#else /* MACOSX */
159
150
(-)mkdepend/def.h (+7 lines)
Lines 47-53 Link Here
47
#endif
47
#endif
48
#include <sys/types.h>
48
#include <sys/types.h>
49
#include <fcntl.h>
49
#include <fcntl.h>
50
50
#include <sys/stat.h>
51
#include <sys/stat.h>
52
53
#ifdef MACOSX
54
/* Need to define these because sys/stat.h is bad */
55
#define	S_IFDIR	 0040000		/* directory */
56
#define	S_IFREG	 0100000		/* regular */
57
#endif  /* MACOSX */
51
58
52
#define MAXDEFINES	512
59
#define MAXDEFINES	512
53
#define MAXFILES	2048  /* Increased from 512. -mcafee */
60
#define MAXFILES	2048  /* Increased from 512. -mcafee */

Return to issue 5568