This is the mail archive of the libc-alpha@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]

Re: RFC: The CPU run-time library for C


On Mon, Dec 3, 2018 at 10:32 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Mon, Dec 3, 2018 at 10:20 AM Szabolcs Nagy <Szabolcs.Nagy@arm.com> wrote:
> >
> > On 03/12/18 17:46, H.J. Lu wrote:
> > > 4. It should be binary compatible with all existing glibc binaries so
> > > that LD_PRELOAD=libcpu-rt-c.so” can be used to override functions in
> > > libc.so.
> >
> > is that possible in the presence of multiple
> > symbol versions for the same symbol?
> >
> > (e.g. if i want to do this for the math library,
> > now that we have separate svid vs non-svid compat
> > symbols it's not clear to me if you could get the
> > right symbol version with preloading)
>
> In this case, the CPU run-time library needs to provide
> a compat symbol so that reference to the compat symbol
> works correctly with LD_PRELOAD.  I believe it is doable.

Here is a test:

[hjl@gnu-cfl-1 preload-2]$ make
gcc -fno-builtin -g   -c -o foo.o foo.c
gcc -fno-builtin -g -fPIC   -c -o bar-old.o bar-old.c
gcc -shared -o libbar-old.so bar-old.o
-Wl,-soname,libbar.so,--version-script=libbar-old.map
gcc -o foo-old foo.o libbar-old.so -Wl,-R,.
gcc -fno-builtin -g -fPIC   -c -o bar-new.o bar-new.c
gcc -shared -o libbar-new.so bar-new.o
-Wl,-soname,libbar.so,--version-script=libbar.map
gcc -o foo-new foo.o libbar-new.so -Wl,-R,.
gcc -fno-builtin -g -fPIC   -c -o preload.o preload.c
gcc -shared -o preload.so preload.o -Wl,--version-script=libbar.map
ln -sf libbar-old.so libbar.so
./foo-old
libbar.so: bar
LD_PRELOAD=./preload.so ./foo-old
preload.so: old_bar
ln -sf libbar-new.so libbar.so
./foo-new
libbar.so: new_bar
LD_PRELOAD=./preload.so ./foo-new
preload.so: new_bar
./foo-old
libbar.so: old_bar
LD_PRELOAD=./preload.so ./foo-old
preload.so: old_bar
[hjl@gnu-cfl-1 preload-2]$

--
H.J.

Attachment: test.tar.xz
Description: application/xz


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