This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: problems with ctype...


Roland McGrath writes:

> If there is some simple change that makes it work with more
> binutils versions, I would be happy with that too.

Here is one. I'm using binutils 2.12.90.0.4 like Andreas, on
i486-pc-freebsd-gnu with glibc from 2002-09-10. I get these errors:

i486-pc-freebsd-gnu-gcc -nostdlib -nostartfiles -o /gnu/build/build-glibc/iconv/iconvconfig  -Wl,-dynamic-linker=/gnu/usr/lib/ld.so.1   -Wl,-z,combreloc /gnu/build/build-glibc/csu/crt1.o /gnu/build/build-glibc/csu/crti.o `i486-pc-freebsd-gnu-gcc --print-file-name=crtbegin.o` /gnu/build/build-glibc/iconv/iconvconfig.o /gnu/build/build-glibc/iconv/strtab.o /gnu/build/build-glibc/iconv/xmalloc.o  -Wl,-rpath-link=/gnu/build/build-glibc:/gnu/build/build-glibc/math:/gnu/build/build-glibc/elf:/gnu/build/build-glibc/dlfcn:/gnu/build/build-glibc/nss:/gnu/build/build-glibc/nis:/gnu/build/build-glibc/rt:/gnu/build/build-glibc/resolv:/gnu/build/build-glibc/crypt:/gnu/build/build-glibc/linuxthreads /gnu/build/build-glibc/libc.so.1 /gnu/build/build-glibc/libc_nonshared.a -lgcc `i486-pc-freebsd-gnu-gcc --print-file-name=crtend.o` /gnu/build/build-glibc/csu/crtn.o
/gnu/build/build-glibc/libc.so.1(.data+0xa9c): multiple definition of `__ctype32_b@GLIBC_2.2.6'
/gnu/build/build-glibc/libc.so.1(.data+0xaa4): multiple definition of `__ctype_toupper@GLIBC_2.2.6'
/gnu/build/build-glibc/libc.so.1(*IND*+0x0): multiple definition of `__ctype32_tolower@GLIBC_2.2.6'
/gnu/build/build-glibc/libc.so.1(.data+0xaa8): first defined here
/gnu/build/build-glibc/libc.so.1(.data+0xa98): multiple definition of `__ctype_b@GLIBC_2.2.6'
/gnu/build/build-glibc/libc.so.1(.data+0xaac): multiple definition of `__ctype32_toupper@GLIBC_2.2.6'
/gnu/build/build-glibc/libc.so.1(*IND*+0x0): multiple definition of `__ctype_tolower@GLIBC_2.2.6'
/gnu/build/build-glibc/libc.so.1(.data+0xaa0): first defined here

and nm reveals:

$ nm libc.so.1 | grep __ctype | sort
0001f6e0 W __ctype_get_mb_cur_max
00020d8c T __ctype_b_loc
00020df6 T __ctype_toupper_loc
00020e60 T __ctype_tolower_loc
000ffa98 D __ctype_b
000ffa98 D __ctype_b@GLIBC_2.2.6
000ffa9c D __ctype32_b
000ffa9c D __ctype32_b@GLIBC_2.2.6
000ffaa0 D __ctype_tolower
000ffaa0 D __ctype_tolower@GLIBC_2.2.6
000ffaa4 D __ctype_toupper
000ffaa4 D __ctype_toupper@GLIBC_2.2.6
000ffaa8 D __ctype32_tolower
000ffaa8 D __ctype32_tolower@GLIBC_2.2.6
000ffaac D __ctype32_toupper
000ffaac D __ctype32_toupper@GLIBC_2.2.6

With the patch below, I get

$ nm libc.so.1 | grep _ctype | sort
0001f660 W __ctype_get_mb_cur_max
0001fee0 t _nl_postload_ctype
00020d0c T __ctype_b_loc
00020d76 T __ctype_toupper_loc
00020de0 T __ctype_tolower_loc
00085290 t _nl_cleanup_ctype
000ffa98 D __ctype_b@@GLIBC_2.2.6
000ffa98 d __old_ctype_b
000ffa9c D __ctype32_b@@GLIBC_2.2.6
000ffa9c d __old_ctype32_b
000ffaa0 D __ctype_tolower@@GLIBC_2.2.6
000ffaa0 d __old_ctype_tolower
000ffaa4 D __ctype_toupper@@GLIBC_2.2.6
000ffaa4 d __old_ctype_toupper
000ffaa8 D __ctype32_tolower@@GLIBC_2.2.6
000ffaa8 d __old_ctype32_tolower
000ffaac D __ctype32_toupper@@GLIBC_2.2.6
000ffaac d __old_ctype32_toupper

and the link error disappears. The patch works if one uses
1) versioned_symbol instead of compat_symbol,
2) __old_ctype_xxx instead of __ctype_xxx for the variable names.
With just 1) _or_ 2) but not both, the link error persists.

This is simply the technique used by sys_sigabbrev, ported to
ctype-info.c.

Bruno


2002-09-18  Bruno Haible  <bruno@clisp.org>

	* ctype/ctype-info.c (__old_ctype_b): Renamed from __ctype_b.
	(__old_ctype32_b): Renamed from __ctype32_b..
	(__old_ctype_tolower): Renamed from __ctype_tolower.
	(__old_ctype_toupper): Renamed from __ctype_toupper.
	(__old_ctype32_tolower): Renamed from __ctype32_tolower.
	(__old_ctype32_toupper): Renamed from __ctype32_toupper.
	Use versioned_symbol instead of compat_symbol.

*** glibc-cvs/ctype/ctype-info.c.bak	Fri Sep  6 16:29:55 2002
--- glibc-cvs/ctype/ctype-info.c	Wed Sep 18 01:06:14 2002
***************
*** 48,65 ****
  
  #define b(t,x,o) (((const t *) _nl_C_LC_CTYPE_##x) + o)
  
! const unsigned short int *__ctype_b = b (unsigned short int, class, 128);
! const __uint32_t *__ctype32_b = b (__uint32_t, class32, 0);
! const __int32_t *__ctype_tolower = b (__int32_t, tolower, 128);
! const __int32_t *__ctype_toupper = b (__int32_t, toupper, 128);
! const __uint32_t *__ctype32_tolower = b (__uint32_t, tolower, 128);
! const __uint32_t *__ctype32_toupper = b (__uint32_t, toupper, 128);
  
! compat_symbol (libc, __ctype_b, __ctype_b, GLIBC_2_0);
! compat_symbol (libc, __ctype_tolower, __ctype_tolower, GLIBC_2_0);
! compat_symbol (libc, __ctype_toupper, __ctype_toupper, GLIBC_2_0);
! compat_symbol (libc, __ctype32_b, __ctype32_b, GLIBC_2_0);
! compat_symbol (libc, __ctype32_tolower, __ctype32_tolower, GLIBC_2_2);
! compat_symbol (libc, __ctype32_toupper, __ctype32_toupper, GLIBC_2_2);
  
  #endif
--- 48,65 ----
  
  #define b(t,x,o) (((const t *) _nl_C_LC_CTYPE_##x) + o)
  
! const unsigned short int *__old_ctype_b = b (unsigned short int, class, 128);
! const __uint32_t *__old_ctype32_b = b (__uint32_t, class32, 0);
! const __int32_t *__old_ctype_tolower = b (__int32_t, tolower, 128);
! const __int32_t *__old_ctype_toupper = b (__int32_t, toupper, 128);
! const __uint32_t *__old_ctype32_tolower = b (__uint32_t, tolower, 128);
! const __uint32_t *__old_ctype32_toupper = b (__uint32_t, toupper, 128);
  
! versioned_symbol (libc, __old_ctype_b, __ctype_b, GLIBC_2_0);
! versioned_symbol (libc, __old_ctype_tolower, __ctype_tolower, GLIBC_2_0);
! versioned_symbol (libc, __old_ctype_toupper, __ctype_toupper, GLIBC_2_0);
! versioned_symbol (libc, __old_ctype32_b, __ctype32_b, GLIBC_2_0);
! versioned_symbol (libc, __old_ctype32_tolower, __ctype32_tolower, GLIBC_2_2);
! versioned_symbol (libc, __old_ctype32_toupper, __ctype32_toupper, GLIBC_2_2);
  
  #endif


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