Always pass lower-case filenames to wine_dll_load().
Clear dlerror() before and after calls to dlopen/dlsym to work around
a glibc bug (thanks to James Abbatiello for tracking the bug).

diff --git a/loader/elf.c b/loader/elf.c
index e0f2e3a..462b48c 100644
--- a/loader/elf.c
+++ b/loader/elf.c
@@ -154,8 +154,10 @@
          points to the ENTIRE DOS filename of the library
          t is returned by HeapAlloc() above and so is also used
          with HeapFree() below */
-	dlhandle = ELFDLL_dlopen(s,RTLD_NOW);
+        dlerror();  /* clear dlerror because of glibc bug */
+	dlhandle = dlopen(s,RTLD_NOW);
 	if (!dlhandle) {
+                dlerror();  /* clear dlerror because of glibc bug */
 		HeapFree( GetProcessHeap(), 0, t );
 		SetLastError( ERROR_FILE_NOT_FOUND );
 		return NULL;
@@ -181,12 +183,19 @@
 		ERR("Can't import from UNIX dynamic libs by ordinal, sorry.\n");
 		return (FARPROC)0;
 	}
+        dlerror();  /* clear dlerror() first */
 	fun = dlsym(wm->dlhandle,funcName);
-	/* we sometimes have an excess '_' at the beginning of the name */
-	if (!fun && (funcName[0]=='_')) {
+        if (!fun)
+        {
+            dlerror();  /* clear dlerror() to avoid glibc bug */
+            /* we sometimes have an excess '_' at the beginning of the name */
+            if (funcName[0]=='_')
+            {
 		funcName++ ;
 		fun = dlsym(wm->dlhandle,funcName);
-	}
+                if (!fun) dlerror();  /* clear dlerror() to avoid glibc bug */
+            }
+        }
 	if (!fun) {
 		/* Function@nrofargs usually marks a stdcall function 
 		 * with nrofargs bytes that are popped at the end
@@ -199,6 +208,7 @@
 			nrofargs = 0;
 			sscanf(t+1,"%d",&nrofargs);
 			fun = dlsym(wm->dlhandle,fn);
+                        if (!fun) dlerror();  /* clear dlerror() to avoid glibc bug */
 			HeapFree( GetProcessHeap(), 0, fn );
 		}
 	}