This is the mail archive of the libc-help@sourceware.org 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]

weak symbols and glibc versioning


Hello all,

I have a program for which I'd like to use "new" glibc features like
accept4.
Now, this program must work with an old glibc which doesn't provide
those functions.

My approach was to create an accept4() weak replacement function so that
when glibc is updated, the program will use glibc one instead (either
its fake one or the real syscall if the kernel was also updated).

The problem is that it doesn't work. It will always use my alternate
implementation even on a system which does support accept4. I suspect
that glibc is also defining it as weak, and thus "loses".

Then I turned to the other weak feature: check if the symbol is a null
pointer before calling.
However, that also failed. If I compile the binary in the "old" box, the
symbol is always NULL. If I compile in the newer, it doesn't run in the
old one, since it "needs a newer GLIB".

Comparing nm output, I have deduced that the new system doesn't pick
glib's accept4 because it's listed in the elf file as 'accept4' instead
of 'accept4@@GLIB_2.10".
I was able by adding __asm__(".symver accept4,accept4@@GLIBC_2.10"); to
change that symbol into accept4@GLIBC_2.10 (which also doesn't work) by
adding __asm__(".symver accept4,accept4@GLIBC_2.10"); but if I try to
change it into accept4@@GLIBC_2.10 the compiler refuses to do so
(invalid attempt to declare external version name as default in symbol
`accept4@@GLIBC_2.10').

I think there must be an easy way to do this, but I'm missing the key.
How am I supposed to implement the above?

Thanks,


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