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: __libc symbols


> I have a question concerning glibc internals. I am currently porting the
> dcethreads package (DCE threads emulation on the top of Pthreads) found 
> in sourceforge to the most recent glibc. 

[snip] 

> That kind of code compiled fine up to FC1. But with recent glibc (for
> instance glibc-2.3.3-200405070341 on FC2), ld complains when linking to
> the
> libdcethreads that the __libc symbols are not found: 
> 
> /opt/dce/lib/libdcethreads.so: undefined reference to `__libc_tcdrain'
> /opt/dce/lib/libdcethreads.so: undefined reference to `__libc_fsync'
> /opt/dce/lib/libdcethreads.so: undefined reference to `__libc_fcntl'
> /opt/dce/lib/libdcethreads.so: undefined reference to `__libc_accept'
> /opt/dce/lib/libdcethreads.so: undefined reference to `__libc_read'
> /opt/dce/lib/libdcethreads.so: undefined reference to `__libc_send'
> ...

Ok I believe I found out where the problem is. 
In former glibc, the __libc symbols were exported:
RedHat9$  nm /lib/tls/libc.so.6 | grep __libc_read
420d1c90 t __GI___libc_read
420d1c90 T __libc_read
420d78a0 T __libc_readv

On newer glibc, the __libc symbols are local: 
FC2$ nm /lib/tls/libc.so.6 | grep __libc_read
00749050 t __GI___libc_read
00749050 t __libc_read
0074f5d0 t __libc_readv


> I wonder what is the best way to port this jacket to recent glibc? 
> 
> And second, what's the name of the internal glibc function? Is it now 
> close@@GLIBC_2.0 instead of __libc_close ? 

I proceeded that way: 

- for the functions that are true CP, I do not provide any wrappers. 
- for the functions that are CP with Pthreads, but not with DCEthreads, I
provided a wraper as follows: 

#define NON_CANCELABLE_SYSCALL(res_type, name, glibc_name, param_list,
params) \
res_type glibc_name param_list;                                         \
res_type                                                                \
pthd4_##name param_list
\
{                                                                       \
  res_type result;                                                      \
  int      oldtype;                                                     \
  pthread_setcanceltype (PTHREAD_CANCEL_DISABLE, &oldtype);             \
  result = glibc_name params;                                           \
  pthread_setcanceltype (oldtype, NULL);                                \
  return result;                                                        \
}                                                                       \
strong_alias(pthd4_##name, name)

For the nonsyscall, I used the weak symbol (shown as 'W' with nm) found in
the glibc that has the same address as the corresponding __libc function.
For instance: 

/* close(2).  */
NON_CANCELABLE_SYSCALL (int, close, __close, (int fd), (fd))


I think that should be OK.
Any thoughts on that? 


Cheers,
Loic. 

-- 
--
// Sender address goes to /dev/null (!!) 
// Use my 32/64 bits, ANSI C89, compliant email-address instead:   

unsigned y[]=
{0,34432,26811,16721,41866,63119,61007,48155,26147,10986};
void x(z){putchar(z);}; unsigned t; 
main(i){if(i<10){t=(y[i]*47560)%65521;x(t>>8);x(t&255);main(++i);}}

GMX ProMail mit bestem Virenschutz http://www.gmx.net/de/go/mail
+++ Empfehlung der Redaktion +++ Internet Professionell 10/04 +++


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