News for hackers. Stuff that matters.
Re:How statically linked programs run on Linux by caf on Sunday November 17, 2013 @09:26PM (#6752149)
It's not shared state - dynamic libraries don't share any more state between processes than static libraries do.

Those features use dynamic linking so that they can load only the necessary implementations at runtime - eg if you aren't using LDAP name lookups, then the NSS won't load the library that does LDAP name lookups.

Re:How statically linked programs run on Linux by amscanne on Sunday November 17, 2013 @10:07PM (#6752255)
> It's not shared state - dynamic libraries don't share any more state between processes than static libraries do.

The above sentence could be misconstrued.

I assume when you say static libraries, you mean standard shared libraries (i.e. those listed when you run ldd). Not statically-linked libraries?

Re:How statically linked programs run on Linux by caf on Sunday November 17, 2013 @11:30PM (#6752540)
Shared libraries on Linux only share read-only text and data, which should not be application-visible.

If you want to share state between processes, the library must explicitly set up a shared mapping - but of course a statically linked library can do this just as well.

Re:How statically linked programs run on Linux by amscanne on Monday November 18, 2013 @11:33PM (#6759288)
Yes, I know. My point was related to the terminology re: static, dynamic, shared, etc.

A statically-linked library won't share any state with other users of the library. It's statically-linked into the binary. State will be shared only with the instances of the same binary.

Re:How statically linked programs run on Linux by caf on Wednesday November 20, 2013 @07:12PM (#6772237)
It is irrelevant whether the library is statically-linked into the binary or not - a statically-linked library can share state with instances of that library linked into other binaries just as easily as a dynamically-linked library can. In both cases the library must explicitly set up some shared state.
Re:How statically linked programs run on Linux by johntb86 on Sunday November 17, 2013 @09:38PM (#6752166)
Hopefully Linux doesn't allow anything like Windows' shared data sections: http://msdn.microsoft.com/en-us/library/h90dkhs0(v=vs.90).as...
Re:How statically linked programs run on Linux by amscanne on Sunday November 17, 2013 @09:54PM (#6752210)
AFAIK there's no shared, writable section in ELF.

But of course you could still easily mmap() a file to achieve the same thing (even from the shared library .init functions).

I can understand that the shared section might be abused by goofy programmers ("Hey guys! We don't need to open a file for storage, we can just build it into the DDL!") ... but is there a reason you think it's a bad idea otherwise?