A glibc 2.1 patch for STB_LOCAL

H . J . Lu hjl@valinux.com
Mon May 22 16:39:00 GMT 2000


I sent in a binutils patch to implement undefined symbols with
non-default visibility attributes. As the result, there may be
entries in dynamic relocation record for local symbols. glibc 2.2
has no problems. Glibc 2.1 needs the following patch to work.

BTW, I don't think gcc is using undefined symbols with non-default
visibility attributes. It only uses defined symbols with non-default
visibility attributes. 


-- 
H.J. Lu (hjl@gnu.org)
---
2000-05-22  H.J. Lu  <hjl@gnu.org>

	* elf/dl-reloc.c (RESOLVE): Short circuit STB_LOCAL.

Index: elf/dl-reloc.c
===================================================================
RCS file: /work/cvs/gnu/glibc-2.1/elf/dl-reloc.c,v
retrieving revision 1.1.1.16
diff -u -p -r1.1.1.16 dl-reloc.c
--- elf/dl-reloc.c	2000/01/12 16:45:39	1.1.1.16
+++ elf/dl-reloc.c	2000/05/22 23:16:34
@@ -71,11 +71,13 @@ _dl_relocate_object (struct link_map *l,
 
     /* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code.  */
 #define RESOLVE(ref, version, flags) \
-    ((version) != NULL && (version)->hash != 0				      \
-     ? _dl_lookup_versioned_symbol (strtab + (*ref)->st_name, (ref), scope,   \
-				    l->l_name, (version), (flags))	      \
-     : _dl_lookup_symbol (strtab + (*ref)->st_name, (ref), scope,	      \
-			  l->l_name, (flags)))
+    (ELFW(ST_BIND) ((*ref)->st_info) != STB_LOCAL			      \
+     ? ((version) != NULL && (version)->hash != 0			      \
+	? _dl_lookup_versioned_symbol (strtab + (*ref)->st_name, (ref),	      \
+				       scope, l->l_name, (version), (flags))  \
+	: _dl_lookup_symbol (strtab + (*ref)->st_name, (ref), scope,	      \
+			     l->l_name, (flags)))			      \
+     : l->l_addr)
 
 #include "dynamic-link.h"
     ELF_DYNAMIC_RELOCATE (l, lazy, consider_profiling);


More information about the Libc-hacker mailing list