[Ns-developers] user-space code integration update
Mathieu Lacage
mathieu.lacage at sophia.inria.fr
Thu Aug 7 09:35:25 PDT 2008
On Thu, 2008-08-07 at 17:17 +0100, Gustavo Carneiro wrote:
> > For replacing many libc functions (e.g. it works for socket
> > functions), you can also use LD_PRELOAD to replace weak
> symbols. I
> > was wondering, what led you down this more complicated path
> instead?
>
>
> because not all symbols are weak and because we don't want to
> replace
> the libc used by ns-3: we want to replace the libc used only
> by the
> simulated programs.
>
> Sure, but does ns-3 use any libc function that you want to override?
yes.
> Also it is possible to access the original libc function (via dlsym
> with RTLD_NEXT).
Yes but I cannot control the callers of the libc functions located in
libstdc++ so, these cannot be changed to use dlsym so, I would need to
detect who is the caller from the callee and call either the original
libc or the ns-3 libc. That makes my head hurt.
The killer, though, with LD_PRELOAD, is that replacing the libc
functions is only part of the problem: you need to be able to virtualize
the data area of all binaries to get a new set of global variables for
each binary. And that requires being able to load the same binary
multiple times in memory which is normally carefully forbidden by the
libc dlopen.
> But don't worry, what matters is that it's done, I'm certainly not
> complaining :-)
There are many other reasons for doing it that way. I believe that I
tried them all and they all failed at some point or another.
Mathieu
More information about the Ns-developers
mailing list