diff options
| author | Dima Zavin <dima@android.com> | 2009-05-20 18:28:09 -0700 |
|---|---|---|
| committer | Dima Zavin <dima@android.com> | 2009-05-27 20:16:19 -0700 |
| commit | 2e85579c34047c305caf15fb0ebe02bf3d001d0e (patch) | |
| tree | 0fb54231b64d077f94b567acfbae3ecaaec672bc /linker/linker_debug.h | |
| parent | 49e55332784b82f7112ee7c1ea3c176c9dc32d7a (diff) | |
| download | bionic-2e85579c34047c305caf15fb0ebe02bf3d001d0e.zip bionic-2e85579c34047c305caf15fb0ebe02bf3d001d0e.tar.gz bionic-2e85579c34047c305caf15fb0ebe02bf3d001d0e.tar.bz2 | |
linker: Make the errors reported by dlopen/dlsym be more useful.
Changed it so that when the linker generates error messages, they are
scribbled away into a buffer that dlfcn and friends can read from.
Since the error messages are generetad with snprintf, and snprintf
MAY call malloc during some code paths, we now link against a version
of libc that does not contain malloc/free/realloc/calloc. We then define
malloc and friends in the dynamic loader, and make them abort() if they
are ever called.
Signed-off-by: Dima Zavin <dima@android.com>
Diffstat (limited to 'linker/linker_debug.h')
| -rw-r--r-- | linker/linker_debug.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/linker/linker_debug.h b/linker/linker_debug.h index 3cc1343..3f4fc4c 100644 --- a/linker/linker_debug.h +++ b/linker/linker_debug.h @@ -55,17 +55,16 @@ #define TRUE 1 #define FALSE 0 - -#define __PRINTVF(v,f,x...) do { \ - (debug_verbosity > (v)) && (printf(x), ((f) && fflush(stdout))); \ - } while (0) /* Only use printf() during debugging. We have seen occasional memory * corruption when the linker uses printf(). */ #if LINKER_DEBUG extern int debug_verbosity; #warning "*** LINKER IS USING printf(); DO NOT CHECK THIS IN ***" -#define _PRINTVF(v,f,x...) __PRINTVF(v,f,x) +#define _PRINTVF(v,f,x...) \ + do { \ + (debug_verbosity > (v)) && (printf(x), ((f) && fflush(stdout))); \ + } while (0) #else /* !LINKER_DEBUG */ #define _PRINTVF(v,f,x...) do {} while(0) #endif /* LINKER_DEBUG */ @@ -75,8 +74,9 @@ extern int debug_verbosity; #define TRACE(x...) _PRINTVF(1, TRUE, x) #define WARN(fmt,args...) \ _PRINTVF(-1, TRUE, "%s:%d| WARNING: " fmt, __FILE__, __LINE__, ## args) -#define ERROR(fmt,args...) \ - __PRINTVF(-1, TRUE, "%s:%d| ERROR: " fmt, __FILE__, __LINE__, ## args) +#define ERROR(fmt,args...) \ + _PRINTVF(-1, TRUE, "%s:%d| ERROR: " fmt, __FILE__, __LINE__, ## args) + #if TRACE_DEBUG #define DEBUG(x...) _PRINTVF(2, TRUE, "DEBUG: " x) |
