Fix dlerror(3).

Add unit tests for dlerror(3) in various situations. I think We're at least
as good as glibc now.

Also factor out the ScopedPthreadMutexLock and use it here too.

Bug: http://code.google.com/p/android/issues/detail?id=38398
Change-Id: I040938b4366ab836e3df46d1d8055b92f4ea6ed8
diff --git a/linker/Android.mk b/linker/Android.mk
index 99618f5..503da86 100644
--- a/linker/Android.mk
+++ b/linker/Android.mk
@@ -4,7 +4,7 @@
 LOCAL_SRC_FILES:= \
 	arch/$(TARGET_ARCH)/begin.S \
 	debugger.c \
-	dlfcn.c \
+	dlfcn.cpp \
 	linker.cpp \
 	linker_environ.c \
 	linker_format.c \