Peter Tribble wrote:
> I've been tinkering with a java jni interface to /proc and thought - wouldn't
> it be nice to convert the project id to a project name when I display it?
>
> That's easy - call getprojbyid(). However, that requires libproject.so, and
> where that comes, several kitchen sinks follow.
>
> It's not *just* the fact that I pull in a dozen extra libraries. I'm also
> seeing
> strange breakage in my application with some java versions.
>
> So, is there a particular reason why the name <-> id lookup functions
> for projects are hidden away in their own library rather than in libc like
> other lookups? (For example, converting between a zone name and
> a zone id is in libc.)
All of the OSnet libraries employ lazy loading, thus under normal use only
the libraries you need get loaded. For example, a dummy C program that
references getprojbyid() only has a dependency on libc and libproject, and
only these two libraries get loaded at runtime:
chaz 1074. cat xxx.c
extern void getprojbyid();
void main(){getprojbyid(0, 0, 0, 0);}
chaz 1075. cc -o xxx xxx.c -lproject
chaz 1076. elfdump -d xxx | fgrep NEEDED
[0] NEEDED 0x14c libproject.so.1
[1] NEEDED 0x165 libc.so.1
chaz 1077. LD_DEBUG=files ./xxx 2>&1 | fgrep analyzing
01136: file=xxx; analyzing [ RTLD_LAZY RTLD_GLOBAL ....
01136: file=/usr/lib/libproject.so.1; analyzing [ RTLD_LAZY RTLD_GLOBAL ....
01136: file=/lib/libc.so.1; analyzing [ RTLD_NOW RTLD_GLOBAL ....
I suspect your java environment is using dlopen(RTLD_NOW)? which is the
same as setting LD_BIND_NOW, which results in all dependencies being loaded
and relocated:
chaz 1079. LD_BIND_NOW=yes LD_DEBUG=files ./xxx 2>&1 | fgrep analyzing | wc -l
23
As for the "strange breakage", perhaps there's some binding interaction that's
causing an issue? You can use LD_DEBUG=bindings and try and wade through the
output to see who is calling who, but this can be daunting. Or, throw lari(1)
at the debugging output. This utility tries to uncover "interesting" issues,
like multiply defined symbols. Sometimes the results are interesting, sometimes
they're down right scary.
--
Rod.