From 5e071a18ce88d93fcffaebb9e0f62524ae504908 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 11 Aug 2016 15:02:45 -0700 Subject: [PATCH] dlerror returns char*, not const char*. http://pubs.opengroup.org/onlinepubs/9699919799/functions/dlerror.html: char *dlerror(void); ... The application shall not modify the string returned. Change-Id: I5e684bfd3930c39a2a30ea6fd005a5d5d3e5b181 --- libc/include/dlfcn.h | 2 +- libdl/libdl.c | 2 +- linker/dlfcn.cpp | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libc/include/dlfcn.h b/libc/include/dlfcn.h index a53f664f2..9aa4a1f26 100644 --- a/libc/include/dlfcn.h +++ b/libc/include/dlfcn.h @@ -51,7 +51,7 @@ typedef struct { void* dlopen(const char* filename, int flag); int dlclose(void* _Nonnull handle); -const char* dlerror(void); +char* dlerror(void); void* dlsym(void* handle, const char* _Nonnull symbol); void* dlvsym(void* handle, const char* _Nonnull symbol, const char* _Nonnull version) __INTRODUCED_IN(24); int dladdr(const void* addr, Dl_info* _Nonnull info); diff --git a/libdl/libdl.c b/libdl/libdl.c index b62ee5ccb..4cc4deac8 100644 --- a/libdl/libdl.c +++ b/libdl/libdl.c @@ -25,7 +25,7 @@ void* dlopen(const char* filename __unused, int flag __unused) { return 0; } -const char* dlerror(void) { return 0; } +char* dlerror(void) { return 0; } void* dlsym(void* handle __unused, const char* symbol __unused) { return 0; } diff --git a/linker/dlfcn.cpp b/linker/dlfcn.cpp index 4d9a2184d..3ac61d7ea 100644 --- a/linker/dlfcn.cpp +++ b/linker/dlfcn.cpp @@ -33,10 +33,10 @@ static pthread_mutex_t g_dl_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; -static const char* __bionic_set_dlerror(char* new_value) { +static char* __bionic_set_dlerror(char* new_value) { char** dlerror_slot = &reinterpret_cast(__get_tls())[TLS_SLOT_DLERROR]; - const char* old_value = *dlerror_slot; + char* old_value = *dlerror_slot; *dlerror_slot = new_value; return old_value; } @@ -52,8 +52,8 @@ static void __bionic_format_dlerror(const char* msg, const char* detail) { __bionic_set_dlerror(buffer); } -const char* dlerror() { - const char* old_value = __bionic_set_dlerror(nullptr); +char* dlerror() { + char* old_value = __bionic_set_dlerror(nullptr); return old_value; }