This is the mail archive of the libc-hacker@sources.redhat.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]
Other format: [Raw text]

[PATCH] Fix glibc binary compatibility problems


Hi!

Current glibc has:
readelf -a /lib/i686/libc.so.6 | grep gethostent_r | less
  1062: 420f87e0   198 FUNC    GLOBAL DEFAULT   11 gethostent_r@GLIBC_2.0
  1380: 420f87e0   198 FUNC    LOCAL  DEFAULT   11 __old_gethostent_r
  1494: 420f8720   187 FUNC    LOCAL  HIDDEN   11 gethostent_r@@GLIBC_2.1.2
  2108: 420f8720   187 FUNC    LOCAL  HIDDEN   11 __gethostent_r
  3441: 420f87e0   198 FUNC    GLOBAL DEFAULT   11 gethostent_r@GLIBC_2.0
and similarly for all other get*ent_r functions, plus _IO_wfile_jumps
is not exported either but used to be (@@GLIBC_2.2).
in get*ent_r case the problem is:
extern int __getgrent_r (struct group *__resultbuf, char *buffer,
                         size_t __buflen, struct group **__result)
     __attribute__ ((visibility ("hidden")));
int
__getgrent_r (struct group *resbuf, char *buffer, size_t buflen,
                              struct group **result )
{
...
}
__asm__ (".symver " "__getgrent_r" "," "getgrent_r" "@@" "GLIBC_2.1.2");

gcc adds .hidden __getgrent_r at the point __getgrent_r is defined, which
is before the .symver and .symver copies the visibility attributes to the
getgrent_r@@GLIBC_2.1.2 symbol.
The following patch fixes this by using an extra alias in between (neither .set
nor = copies visibility attributes (of course alternatively the actual
function could be __new_getgrent_r and then have a .hidden alias
__getgrent_r)). Also, removes attribute_hidden from _IO_wfile_jumps which
should be exported (glibc uses INTUSE(_IO_wfile_jumps) everywhere anyway),
fixes a warning I introduced in my _IO_wfile_setbuf_mmap patch and also
I have noticed that _IO_WSETBUF for normal files uses _IO_new_file_setbuf
handler and that _IO_wfile_setbuf is completely unused. It seems strange
that setvbuf etc. functions call _IO_new_file_setbuf twice for wide streams
and don't do anything with the wide stuff.

2002-06-07  Jakub Jelinek  <jakub@redhat.com>

	* libio/libioP.h (_IO_wfile_jumps): Remove attribute_hidden.
	* libio/wfileops.c (_IO_wfile_setbuf): Add INTDEF.
	(_IO_wfile_jumps): Use _IO_wfile_setbuf, not _IO_new_file_setbuf
	as _IO_WSETBUF handler.
	(_IO_wfile_jumps_mmap): Cast _IO_wfile_setbuf_mmap to _IO_setbuf_t
	to avoid warnings.
	* nss/getXXbyYY_r.c (NEW, NEW1): Define.
	(NEW (REENTRANT_NAME)): Strong alias to INTERNAL (REENTRANT_NAME).
	(REENTRANT_NAME@@GLIBC_2.1.2): Use NEW (REENTRANT_NAME).
	* nss/getXXent_r.c (NEW, NEW1): Define.
	(NEW (REENTRANT_GETNAME)): Strong alias to
	INTERNAL (REENTRANT_GETNAME).
	(REENTRANT_GETNAME@@GLIBC_2.1.2): Use NEW (REENTRANT_GETNAME).

--- libc/libio/libioP.h.jj	Tue Apr 30 12:52:49 2002
+++ libc/libio/libioP.h	Fri Jun  7 11:52:12 2002
@@ -427,7 +427,7 @@ extern void _IO_default_imbue __P ((_IO_
 
 extern struct _IO_jump_t _IO_file_jumps;
 extern struct _IO_jump_t _IO_file_jumps_mmap attribute_hidden;
-extern struct _IO_jump_t _IO_wfile_jumps attribute_hidden;
+extern struct _IO_jump_t _IO_wfile_jumps;
 extern struct _IO_jump_t _IO_wfile_jumps_mmap attribute_hidden;
 extern struct _IO_jump_t _IO_old_file_jumps attribute_hidden;
 extern struct _IO_jump_t _IO_streambuf_jumps;
--- libc/libio/wfileops.c.jj	Wed Jun  5 12:07:43 2002
+++ libc/libio/wfileops.c	Fri Jun  7 11:57:00 2002
@@ -68,6 +68,7 @@ _IO_wfile_setbuf (fp, p, len)
 
   return fp;
 }
+INTDEF(_IO_wfile_setbuf)
 
 
 static _IO_FILE * _IO_wfile_setbuf_mmap __P ((_IO_FILE *, wchar_t *,
@@ -866,7 +867,7 @@ struct _IO_jump_t _IO_wfile_jumps =
   JUMP_INIT(xsgetn, INTUSE(_IO_file_xsgetn)),
   JUMP_INIT(seekoff, INTUSE(_IO_wfile_seekoff)),
   JUMP_INIT(seekpos, _IO_default_seekpos),
-  JUMP_INIT(setbuf, _IO_new_file_setbuf),
+  JUMP_INIT(setbuf, (_IO_setbuf_t) INTUSE(_IO_wfile_setbuf)),
   JUMP_INIT(sync, (_IO_sync_t) INTUSE(_IO_wfile_sync)),
   JUMP_INIT(doallocate, _IO_wfile_doallocate),
   JUMP_INIT(read, INTUSE(_IO_file_read)),
@@ -892,7 +893,7 @@ struct _IO_jump_t _IO_wfile_jumps_mmap =
   JUMP_INIT(xsgetn, INTUSE(_IO_file_xsgetn)),
   JUMP_INIT(seekoff, INTUSE(_IO_wfile_seekoff)),
   JUMP_INIT(seekpos, _IO_default_seekpos),
-  JUMP_INIT(setbuf, _IO_wfile_setbuf_mmap),
+  JUMP_INIT(setbuf, (_IO_setbuf_t) _IO_wfile_setbuf_mmap),
   JUMP_INIT(sync, (_IO_sync_t) INTUSE(_IO_wfile_sync)),
   JUMP_INIT(doallocate, _IO_wfile_doallocate),
   JUMP_INIT(read, INTUSE(_IO_file_read)),
--- libc/nss/getXXbyYY_r.c.jj	Tue Apr 30 12:53:15 2002
+++ libc/nss/getXXbyYY_r.c	Fri Jun  7 11:35:43 2002
@@ -63,6 +63,8 @@
 #define APPEND_R1(name) name##_r
 #define INTERNAL(name) INTERNAL1 (name)
 #define INTERNAL1(name) __##name
+#define NEW(name) NEW1 (name)
+#define NEW1(name) __new_##name
 
 #ifdef USE_NSCD
 # define NSCD_NAME ADD_NSCD (REENTRANT_NAME)
@@ -257,7 +259,12 @@ OLD (REENTRANT_NAME) (ADD_PARAMS, LOOKUP
 do_symbol_version (OLD (REENTRANT_NAME), REENTRANT_NAME, GLIBC_2_0);
 #endif
 
+/* As INTERNAL (REENTRANT_NAME) may be hidden, we need an alias
+   in between so that the REENTRANT_NAME@@GLIBC_2.1.2 is not
+   hidden too.  */
+strong_alias (INTERNAL (REENTRANT_NAME), NEW (REENTRANT_NAME));
+
 #define do_default_symbol_version(real, name, version) \
   versioned_symbol (libc, real, name, version)
-do_default_symbol_version (INTERNAL (REENTRANT_NAME),
+do_default_symbol_version (NEW (REENTRANT_NAME),
 			   REENTRANT_NAME, GLIBC_2_1_2);
--- libc/nss/getXXent_r.c.jj	Tue Apr 30 12:53:15 2002
+++ libc/nss/getXXent_r.c	Fri Jun  7 11:39:51 2002
@@ -53,6 +53,8 @@
 #define INTERNAL(Name) CONCAT2_2 (__, Name)
 #define CONCAT2_1(Pre, Post) CONCAT2_2 (Pre, Post)
 #define CONCAT2_2(Pre, Post) Pre##Post
+#define NEW(name) NEW1 (name)
+#define NEW1(name) __new_##name
 
 #define SETFUNC_NAME_STRING STRINGIZE (SETFUNC_NAME)
 #define GETFUNC_NAME_STRING STRINGIZE (REENTRANT_GETNAME)
@@ -189,7 +191,12 @@ OLD (REENTRANT_GETNAME) (LOOKUP_TYPE *re
 do_symbol_version (OLD (REENTRANT_GETNAME), REENTRANT_GETNAME, GLIBC_2_0);
 #endif
 
+/* As INTERNAL (REENTRANT_GETNAME) may be hidden, we need an alias
+   in between so that the REENTRANT_GETNAME@@GLIBC_2.1.2 is not
+   hidden too.  */
+strong_alias (INTERNAL (REENTRANT_GETNAME), NEW (REENTRANT_GETNAME));
+
 #define do_default_symbol_version(real, name, version) \
   versioned_symbol (libc, real, name, version)
-do_default_symbol_version (INTERNAL (REENTRANT_GETNAME),
+do_default_symbol_version (NEW (REENTRANT_GETNAME),
 			   REENTRANT_GETNAME, GLIBC_2_1_2);


	Jakub


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