This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] _dl_{,v}sym fix


Hi!

Following patch fixes the following testcase:

===
#include <dlfcn.h>
#include <stdlib.h>

int main()
{
  void *sym;
  void *handle = dlopen (NULL, RTLD_LAZY);
  if (!handle)
    {
      printf ("%s\n", dlerror());
      return 1;
    }

  sym = dlsym (handle, "main");
  if (!sym)
    {
      printf ("%s\n", dlerror());
      return 1;
    }

  dlclose (handle);

  return 0;
}
===

It matches the common usage of _dl_lookup* functions where the symbol is
checked for non-zero, not the return value because it may be 0.

2000-05-09  Jakub Jelinek  <jakub@redhat.com>

	* elf/dl-sym.c (_dl_sym): Test ref not result for non-zero.
	(_dl_vsym): Likewise.
	Reported by Owen Taylor <otaylor@redhat.com>.

--- libc/elf/dl-sym.c.jj	Mon May  8 21:28:14 2000
+++ libc/elf/dl-sym.c	Tue May  9 12:08:23 2000
@@ -74,7 +74,7 @@ RTLD_NEXT used in code not dynamically l
 	}
     }
 
-  if (result)
+  if (ref)
     return DL_SYMBOL_ADDRESS (result, ref);
 
   return NULL;
@@ -130,7 +130,7 @@ RTLD_NEXT used in code not dynamically l
 					    map->l_local_scope, &vers, 0);
     }
 
-  if (result)
+  if (ref)
     return DL_SYMBOL_ADDRESS (result, ref);
   return NULL;
 }

	Jakub

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]