Skip to content

Commit

Permalink
darwinbuild-26.4
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.macosforge.org/repository/darwinbuild/trunk@985 10a61168-4876-4dac-953b-31e694342555
  • Loading branch information
kvanvechten committed Nov 17, 2011
1 parent cab07b0 commit 00778cf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Darwin Build Scripts Change History
-----------------------------------
Release 26.4 [17-Nov-2011]
- darwintrace: files opened with fopen(3) are missing from trace log

Release 26.3 [11-Nov-2011]
- darwintrace: darwintrace_make_environ bug unsets DYLD_INSERT_LIBRARIES

Expand Down
36 changes: 26 additions & 10 deletions darwintrace/darwintrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,18 @@
#define dprintf(...)
#endif

#define LION_OR_LATER (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
__MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)

#define DARWINTRACE_INTERPOSE(_replacement,_replacee) \
__attribute__((used)) static struct{ const void* replacement; const void* replacee; } _interpose_##_replacee \
__attribute__ ((section ("__DATA,__interpose"))) = { (const void*)(unsigned long)&_replacement, (const void*)(unsigned long)&_replacee };
__attribute__((used)) static struct { \
const void* replacement; \
const void* replacee; \
} _interpose_##_replacee \
__attribute__ ((section ("__DATA,__interpose"))) = { \
(const void*)(unsigned long)&_replacement, \
(const void*)(unsigned long)&_replacee \
}

static int darwintrace_fd = -2;
static char darwintrace_progname[DARWINTRACE_BUFFER_SIZE];
Expand Down Expand Up @@ -332,7 +341,11 @@ int darwintrace_open(const char* path, int flags, ...) {
darwintrace_free_path(redirpath, path);
return result;
}
DARWINTRACE_INTERPOSE(darwintrace_open, open)
DARWINTRACE_INTERPOSE(darwintrace_open, open);
#if LION_OR_LATER
extern int __open_nocancel(const char* path, int flags, ...);
DARWINTRACE_INTERPOSE(darwintrace_open, __open_nocancel);
#endif


/*
Expand Down Expand Up @@ -362,7 +375,7 @@ ssize_t darwintrace_readlink(const char * path, char * buf, size_t bufsiz) {
darwintrace_free_path(redirpath, path);
return result;
}
DARWINTRACE_INTERPOSE(darwintrace_readlink, readlink)
DARWINTRACE_INTERPOSE(darwintrace_readlink, readlink);

static inline int has_prefix(const char *s, const char *p) {
return (strncmp(s, p, strlen(p)) == 0);
Expand Down Expand Up @@ -444,7 +457,7 @@ static void darwintrace_free_environ(char *const envp[]) {
free((char*)envp);
}

void darwintrace_log_exec(const char* redirpath, char* const argv[]) {
static void darwintrace_log_exec(const char* redirpath, char* const argv[]) {
darwintrace_setup();
if (darwintrace_fd >= 0) {
struct stat sb;
Expand Down Expand Up @@ -574,10 +587,9 @@ int darwintrace_execve(const char* path, char* const argv[], char* const envp[])
darwintrace_free_path(redirpath, path);
return result;
}
DARWINTRACE_INTERPOSE(darwintrace_execve, execve)
DARWINTRACE_INTERPOSE(darwintrace_execve, execve);

#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
__MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_7
#if LION_OR_LATER
/* weak import __posix_spawn which only exists on 10.7 or later */
extern __attribute__((weak_import))
int __posix_spawn(pid_t * __restrict, const char * __restrict,
Expand All @@ -598,7 +610,7 @@ int darwintrace_posix_spawn(pid_t * __restrict pid,
darwintrace_free_path(redirpath, path);
return result;
}
DARWINTRACE_INTERPOSE(darwintrace_posix_spawn, __posix_spawn)
DARWINTRACE_INTERPOSE(darwintrace_posix_spawn, __posix_spawn);
#endif

/*
Expand All @@ -613,4 +625,8 @@ int darwintrace_close(int fd) {

return close(fd);
}
DARWINTRACE_INTERPOSE(darwintrace_close, close)
DARWINTRACE_INTERPOSE(darwintrace_close, close);
#if LION_OR_LATER
extern int __close_nocancel(int);
DARWINTRACE_INTERPOSE(darwintrace_close, __close_nocancel);
#endif

0 comments on commit 00778cf

Please sign in to comment.