Re: Initialization of static anonymous-namespace members from a dynamicallyloaded lib

Discussion in 'C++' started by Alf P. Steinbach /Usenet, Jan 9, 2011.

  1. * m0shbear, on 09.01.2011 21:56:
    > Given
    > // foo.cpp
    > #include<map>
    > namespace {
    > int init_s();
    > std::map<int,int> m;
    > int dummy = init_s();
    > int init_s() {
    > m[1] = 2;
    > m[5] = 4;
    > return 0;
    > }
    > };
    > // ...
    > int Foo::bar() {
    > return m[5];
    > }
    > // ...
    >
    > // foo.h
    > class Foo {
    > //...
    > int bar();
    > // ...
    > };
    >
    > If foo.o is linked at build time, the compiler automagically adds the
    > call to init_s() in the libc++ static init. But if it is dynamically
    > loaded, this condition is guaranteed to be satisfied. Or is it? I
    > don't want to waste memory by having an individual copy of supposedly
    > static data, yet I don't want UB from guessing and hoping.
    >
    > Is it even possible to have file-scope non-POD statics upon whose
    > operations do not invoke UB, inside a d-l lib?


    The C++ standard does not address or even acknowledge the existence of
    dynamically loaded libraries except that one can interpret some wording about
    delayed initialization as pertaining to dynamically loaded libraries.

    Anyway, the short of it is that in Windows you can generally rely on techniques
    such as above, but not in *nix.


    Cheers & hth.,

    - Alf

    --
    blog at <url: http://alfps.wordpress.com>
     
    Alf P. Steinbach /Usenet, Jan 9, 2011
    #1
    1. Advertising

  2. Alf P. Steinbach /Usenet

    James Kanze Guest

    Re: Initialization of static anonymous-namespace members from adynamically loaded lib

    On Jan 9, 9:00 pm, "Alf P. Steinbach /Usenet" <alf.p.steinbach
    > wrote:
    > * m0shbear, on 09.01.2011 21:56:


    [...]
    > > Is it even possible to have file-scope non-POD statics upon
    > > whose operations do not invoke UB, inside a d-l lib?


    > The C++ standard does not address or even acknowledge the
    > existence of dynamically loaded libraries except that one can
    > interpret some wording about delayed initialization as
    > pertaining to dynamically loaded libraries.


    Yes, but most C++ compilers do permit dynamically loaded
    objects. (I don't know of any that can dynamically load a
    library. But despite the name, under Windows, a DLL is not a
    library.)

    > Anyway, the short of it is that in Windows you can generally
    > rely on techniques such as above, but not in *nix.


    Under which Unix does it fail? I've used the technique a lot
    under various Unices, and I've never known it to fail. (I can
    guarantee that it works correctly under Solaris and Linux,
    because those are the Unices I currently have access to, but I
    can't remember every seeing it fail.)

    --
    James Kanze
     
    James Kanze, Jan 9, 2011
    #2
    1. Advertising

  3. * James Kanze, on 10.01.2011 00:03:
    > On Jan 9, 9:00 pm, "Alf P. Steinbach /Usenet"<alf.p.steinbach
    > > wrote:
    >> * m0shbear, on 09.01.2011 21:56:

    >
    > [...]
    >>> Is it even possible to have file-scope non-POD statics upon
    >>> whose operations do not invoke UB, inside a d-l lib?

    >
    >> The C++ standard does not address or even acknowledge the
    >> existence of dynamically loaded libraries except that one can
    >> interpret some wording about delayed initialization as
    >> pertaining to dynamically loaded libraries.

    >
    > Yes, but most C++ compilers do permit dynamically loaded
    > objects.


    What's that "but"?

    Yes, but -- I like large steaks with fries and beer!


    > (I don't know of any that can dynamically load a
    > library. But despite the name, under Windows, a DLL is not a
    > library.)


    Windows Dynamically Loaded Library, *nix Shared Library.

    You mean despite the names we shouldn't talk about them as "libraries".

    This terminological subtlety, where you seem to have invented your very own
    terminology (confusingly using the same word as others but with a different
    meaning) reminds me of a certain person that I killfiled yesterday.


    >> Anyway, the short of it is that in Windows you can generally
    >> rely on techniques such as above, but not in *nix.

    >
    > Under which Unix does it fail? I've used the technique a lot
    > under various Unices, and I've never known it to fail. (I can
    > guarantee that it works correctly under Solaris and Linux,
    > because those are the Unices I currently have access to, but I
    > can't remember every seeing it fail.)


    Hm. I'm glad to hear that it works. Maybe what I thought I knew is wrong. At
    least, googling "static initialization problem in shared libraries in Linux"
    didn't find any of that, except some mention of problems with very old version
    of g++ (2.95 or earlier) -- perhaps that's where I got wrong idea from?


    Cheers,

    - Alf

    --
    blog at <url: http://alfps.wordpress.com>
     
    Alf P. Steinbach /Usenet, Jan 10, 2011
    #3
  4. Alf P. Steinbach /Usenet

    James Kanze Guest

    Re: Initialization of static anonymous-namespace members from adynamically loaded lib

    On Jan 10, 12:05 am, "Alf P. Steinbach /Usenet"
    <> wrote:
    > * James Kanze, on 10.01.2011 00:03:


    > > On Jan 9, 9:00 pm, "Alf P. Steinbach /Usenet"<alf.p.steinbach
    > > > wrote:
    > >> * m0shbear, on 09.01.2011 21:56:


    > > [...]
    > >>> Is it even possible to have file-scope non-POD statics upon
    > >>> whose operations do not invoke UB, inside a d-l lib?


    > >> The C++ standard does not address or even acknowledge the
    > >> existence of dynamically loaded libraries except that one can
    > >> interpret some wording about delayed initialization as
    > >> pertaining to dynamically loaded libraries.


    > > Yes, but most C++ compilers do permit dynamically loaded
    > > objects.


    > What's that "but"?


    That most C++ compilers do permit dynamically loaded objects. So
    it makes sense to speak about the concept in C++. Like
    threading, for example.

    > > (I don't know of any that can dynamically load a
    > > library. But despite the name, under Windows, a DLL is not a
    > > library.)


    > Windows Dynamically Loaded Library, *nix Shared Library.


    What's a Unix shared library? I've never heard the term before.
    (Under Unix, the files are normally called shared objects, or
    simply .so files. The header of the Posix specification of
    dlopen says "dlopen -- gain access to an executable object
    file".)

    Neither name is particularly good: they behave like object
    files, not libraries, and the significant point isn't that they
    are shared, but that they are dynamically loaded.

    > You mean despite the names we shouldn't talk about them as
    > "libraries".


    Ideally, no. Practically, I think DLL is to ingrained for us to
    change it. But I do constantly see people getting confused
    about the issue.

    > This terminological subtlety, where you seem to have invented
    > your very own terminology (confusingly using the same word as
    > others but with a different meaning) reminds me of a certain
    > person that I killfiled yesterday.


    Except that I got this point of view from discussions in the
    C committee. It's certainly not my own. And calling DLL's
    libraries does cause problems: we see postings all the time from
    people who don't understand how libraries work, because they've
    been brought up to believe that the behavior of a DLL is what
    a library does.

    > >> Anyway, the short of it is that in Windows you can generally
    > >> rely on techniques such as above, but not in *nix.


    > > Under which Unix does it fail? I've used the technique a lot
    > > under various Unices, and I've never known it to fail. (I can
    > > guarantee that it works correctly under Solaris and Linux,
    > > because those are the Unices I currently have access to, but I
    > > can't remember every seeing it fail.)


    > Hm. I'm glad to hear that it works. Maybe what I thought
    > I knew is wrong. At least, googling "static initialization
    > problem in shared libraries in Linux" didn't find any of that,
    > except some mention of problems with very old version of g++
    > (2.95 or earlier) -- perhaps that's where I got wrong idea
    > from?


    I think that it didn't work in some very old versions of Unix
    (going back 15 or 20 years or more). But they certainly work
    under Solaris and Linux, and have for a long time; I'm pretty
    sure the same is true for AIX and HP-UX, although it's been some
    time since I've used them.

    On the other hand, Posix doesn't say anything about it, at least
    not that I can find. (But then, Posix doesn't say anything
    about C++ in general.)

    --
    James Kanze
     
    James Kanze, Jan 10, 2011
    #4
  5. * James Kanze, on 10.01.2011 11:26:
    > On Jan 10, 12:05 am, "Alf P. Steinbach /Usenet"
    > <> wrote:
    >> * James Kanze, on 10.01.2011 00:03:

    >
    >>> On Jan 9, 9:00 pm, "Alf P. Steinbach /Usenet"<alf.p.steinbach
    >>> > wrote:
    >>>> * m0shbear, on 09.01.2011 21:56:

    >
    >>> [...]
    >>>>> Is it even possible to have file-scope non-POD statics upon
    >>>>> whose operations do not invoke UB, inside a d-l lib?

    >
    >>>> The C++ standard does not address or even acknowledge the
    >>>> existence of dynamically loaded libraries except that one can
    >>>> interpret some wording about delayed initialization as
    >>>> pertaining to dynamically loaded libraries.

    >
    >>> Yes, but most C++ compilers do permit dynamically loaded
    >>> objects.

    >
    >> What's that "but"?

    >
    > That most C++ compilers do permit dynamically loaded objects. So
    > it makes sense to speak about the concept in C++. Like
    > threading, for example.


    Of course it makes sense to talk about it.

    That's why we're talking about it.

    Exactly who do you think had said it does not make sense to talk about it?


    >>> (I don't know of any that can dynamically load a
    >>> library. But despite the name, under Windows, a DLL is not a
    >>> library.)

    >
    >> Windows Dynamically Loaded Library, *nix Shared Library.

    >
    > What's a Unix shared library? I've never heard the term before.


    Try <url: http://www.google.com/search?q=%22shared+library%22>.


    > (Under Unix, the files are normally called shared objects, or
    > simply .so files. The header of the Posix specification of
    > dlopen says "dlopen -- gain access to an executable object
    > file".)


    It's a pleasure to be able to teach you something basic in a thread where you've
    shown me wrong about something basic. :)


    > Neither name is particularly good: they behave like object
    > files, not libraries, and the significant point isn't that they
    > are shared, but that they are dynamically loaded.
    >
    >> You mean despite the names we shouldn't talk about them as
    >> "libraries".

    >
    > Ideally, no. Practically, I think DLL is to ingrained for us to
    > change it. But I do constantly see people getting confused
    > about the issue.
    >
    >> This terminological subtlety, where you seem to have invented
    >> your very own terminology (confusingly using the same word as
    >> others but with a different meaning) reminds me of a certain
    >> person that I killfiled yesterday.

    >
    > Except that I got this point of view from discussions in the
    > C committee. It's certainly not my own. And calling DLL's
    > libraries does cause problems: we see postings all the time from
    > people who don't understand how libraries work, because they've
    > been brought up to believe that the behavior of a DLL is what
    > a library does.


    Ah, they've been doing that song-and-dance routine for you, dazzling &
    misleading you.

    Means you were correct about something and someone tried to wiggle out of it.

    Again, try <url: http://www.google.com/search?q=%22shared+library%22>.


    >>>> Anyway, the short of it is that in Windows you can generally
    >>>> rely on techniques such as above, but not in *nix.

    >
    >>> Under which Unix does it fail? I've used the technique a lot
    >>> under various Unices, and I've never known it to fail. (I can
    >>> guarantee that it works correctly under Solaris and Linux,
    >>> because those are the Unices I currently have access to, but I
    >>> can't remember every seeing it fail.)

    >
    >> Hm. I'm glad to hear that it works. Maybe what I thought
    >> I knew is wrong. At least, googling "static initialization
    >> problem in shared libraries in Linux" didn't find any of that,
    >> except some mention of problems with very old version of g++
    >> (2.95 or earlier) -- perhaps that's where I got wrong idea
    >> from?

    >
    > I think that it didn't work in some very old versions of Unix
    > (going back 15 or 20 years or more). But they certainly work
    > under Solaris and Linux, and have for a long time; I'm pretty
    > sure the same is true for AIX and HP-UX, although it's been some
    > time since I've used them.
    >
    > On the other hand, Posix doesn't say anything about it, at least
    > not that I can find. (But then, Posix doesn't say anything
    > about C++ in general.)


    Cheers,

    - Alf

    --
    blog at <url: http://alfps.wordpress.com>
     
    Alf P. Steinbach /Usenet, Jan 10, 2011
    #5
  6. Alf P. Steinbach /Usenet

    James Kanze Guest

    Re: Initialization of static anonymous-namespace members from adynamically loaded lib

    On Jan 10, 11:01 am, "Alf P. Steinbach /Usenet"
    <> wrote:
    > * James Kanze, on 10.01.2011 11:26:
    > > On Jan 10, 12:05 am, "Alf P. Steinbach /Usenet"
    > > <> wrote:
    > >> * James Kanze, on 10.01.2011 00:03:


    > >>> On Jan 9, 9:00 pm, "Alf P. Steinbach /Usenet"<alf.p.steinbach
    > >>> > wrote:
    > >>>> * m0shbear, on 09.01.2011 21:56:


    > >>> [...]
    > >>> (I don't know of any that can dynamically load a
    > >>> library. But despite the name, under Windows, a DLL is not a
    > >>> library.)


    > >> Windows Dynamically Loaded Library, *nix Shared Library.


    > > What's a Unix shared library? I've never heard the term before.


    > Try <url:http://www.google.com/search?q=%22shared+library%22>.


    You can find anything using Google:). It never occured to me.
    I guess just basing my knowledge on the Posix standard and the
    Sun manual. And conversations with other Unix specialists:
    after all, .so didn't come from shared library, but from shared
    object.

    The fact remains that in computer science, "library" means (or
    always used to mean) a collection of object files, each of which
    was included only if it resolved an unresolved external. When
    dynamically linking, it's all or nothing.

    Anyway, trying your link, I see that it's not just newbes using
    the term, even if Posix and Sun don't. The Linux and gcc
    communities seem to have adopted it. Which makes me think that
    I'm fighting a loosing battle for linguistic purity. The fact
    remains that the behavior *is* different from that traditionally
    associated with libraries, and that we do get questions (or
    complaints) from people surprised that static libraries don't
    behave the same as the dynamically linked stuff. (Hmm. I think
    in the future, I'll just call it "dynamically linked stuff", and
    avoid the issue of whether it is a library or not:).)

    --
    James Kanze
     
    James Kanze, Jan 10, 2011
    #6
  7. Alf P. Steinbach /Usenet

    Paul Guest

    Re: Initialization of static anonymous-namespace members from a dynamically loaded lib

    "James Kanze" <> wrote in message
    news:...
    > On Jan 10, 11:01 am, "Alf P. Steinbach /Usenet"
    > <> wrote:
    >> * James Kanze, on 10.01.2011 11:26:
    >> > On Jan 10, 12:05 am, "Alf P. Steinbach /Usenet"
    >> > <> wrote:
    >> >> * James Kanze, on 10.01.2011 00:03:

    >
    >> >>> On Jan 9, 9:00 pm, "Alf P. Steinbach /Usenet"<alf.p.steinbach
    >> >>> > wrote:
    >> >>>> * m0shbear, on 09.01.2011 21:56:

    >
    >> >>> [...]
    >> >>> (I don't know of any that can dynamically load a
    >> >>> library. But despite the name, under Windows, a DLL is not a
    >> >>> library.)

    >
    >> >> Windows Dynamically Loaded Library, *nix Shared Library.

    >
    >> > What's a Unix shared library? I've never heard the term before.

    >
    >> Try <url:http://www.google.com/search?q=%22shared+library%22>.

    >
    > You can find anything using Google:). It never occured to me.
    > I guess just basing my knowledge on the Posix standard and the
    > Sun manual. And conversations with other Unix specialists:
    > after all, .so didn't come from shared library, but from shared
    > object.
    >
    > The fact remains that in computer science, "library" means (or
    > always used to mean) a collection of object files, each of which
    > was included only if it resolved an unresolved external. When
    > dynamically linking, it's all or nothing.
    >

    No you are completely WRONG !
    http://en.wikipedia.org/wiki/Library_(computing)
     
    Paul, Jan 10, 2011
    #7
  8. Alf P. Steinbach /Usenet

    Paul Guest

    Re: Initialization of static anonymous-namespace members from a dynamically loaded lib

    "James Kanze" <> wrote in message
    news:...
    > On Jan 10, 11:01 am, "Alf P. Steinbach /Usenet"
    > <> wrote:
    >> * James Kanze, on 10.01.2011 11:26:
    >> > On Jan 10, 12:05 am, "Alf P. Steinbach /Usenet"
    >> > <> wrote:
    >> >> * James Kanze, on 10.01.2011 00:03:

    >
    >> >>> On Jan 9, 9:00 pm, "Alf P. Steinbach /Usenet"<alf.p.steinbach
    >> >>> > wrote:
    >> >>>> * m0shbear, on 09.01.2011 21:56:

    >
    >> >>> [...]
    >> >>> (I don't know of any that can dynamically load a
    >> >>> library. But despite the name, under Windows, a DLL is not a
    >> >>> library.)

    >
    >> >> Windows Dynamically Loaded Library, *nix Shared Library.

    >
    >> > What's a Unix shared library? I've never heard the term before.

    >
    >> Try <url:http://www.google.com/search?q=%22shared+library%22>.

    >
    > You can find anything using Google:). It never occured to me.
    > I guess just basing my knowledge on the Posix standard and the
    > Sun manual. And conversations with other Unix specialists:
    > after all, .so didn't come from shared library, but from shared
    > object.
    >
    > The fact remains that in computer science, "library" means (or
    > always used to mean) a collection of object files, each of which
    > was included only if it resolved an unresolved external. When
    > dynamically linking, it's all or nothing.
    >

    No you are completely WRONG !
    http://en.wikipedia.org/wiki/Library_(computing)
     
    Paul, Jan 10, 2011
    #8
  9. Alf P. Steinbach /Usenet

    Paul Guest

    Re: Initialization of static anonymous-namespace members from a dynamically loaded lib

    "James Kanze" <> wrote in message
    news:...
    > On Jan 10, 11:01 am, "Alf P. Steinbach /Usenet"
    > <> wrote:
    >> * James Kanze, on 10.01.2011 11:26:
    >> > On Jan 10, 12:05 am, "Alf P. Steinbach /Usenet"
    >> > <> wrote:
    >> >> * James Kanze, on 10.01.2011 00:03:

    >
    >> >>> On Jan 9, 9:00 pm, "Alf P. Steinbach /Usenet"<alf.p.steinbach
    >> >>> > wrote:
    >> >>>> * m0shbear, on 09.01.2011 21:56:

    >
    >> >>> [...]
    >> >>> (I don't know of any that can dynamically load a
    >> >>> library. But despite the name, under Windows, a DLL is not a
    >> >>> library.)

    >
    >> >> Windows Dynamically Loaded Library, *nix Shared Library.

    >
    >> > What's a Unix shared library? I've never heard the term before.

    >
    >> Try <url:http://www.google.com/search?q=%22shared+library%22>.

    >
    > You can find anything using Google:). It never occured to me.
    > I guess just basing my knowledge on the Posix standard and the
    > Sun manual. And conversations with other Unix specialists:
    > after all, .so didn't come from shared library, but from shared
    > object.
    >
    > The fact remains that in computer science, "library" means (or
    > always used to mean) a collection of object files, each of which
    > was included only if it resolved an unresolved external. When
    > dynamically linking, it's all or nothing.
    >

    No you are completely WRONG !
    http://en.wikipedia.org/wiki/Library_(computing)
     
    Paul, Jan 10, 2011
    #9
  10. Re: Initialization of static anonymous-namespace members from adynamically loaded lib

    On Jan 10, 2:51 pm, James Kanze <> wrote:
    >
    > The fact remains that in computer science, "library" means (or
    > always used to mean) a collection of object files, each of which
    > was included only if it resolved an unresolved external.  When
    > dynamically linking, it's all or nothing.


    Apparently, even computer scientists are not consistent with the use
    of "library".
    I have a textbook here that uses the term "shared library" for those
    entities that get linked into the executable at load time.
    The book is
    Linkers and Loaders; Academic Press; John R. Levine; 1-55860-496-0

    Bart v Ingen Schenau
     
    Bart van Ingen Schenau, Jan 11, 2011
    #10
  11. Alf P. Steinbach /Usenet

    Ian Collins Guest

    Re: Initialization of static anonymous-namespace members from adynamically loaded lib

    On 01/11/11 11:28 PM, Bart van Ingen Schenau wrote:
    > On Jan 10, 2:51 pm, James Kanze<> wrote:
    >>
    >> The fact remains that in computer science, "library" means (or
    >> always used to mean) a collection of object files, each of which
    >> was included only if it resolved an unresolved external. When
    >> dynamically linking, it's all or nothing.

    >
    > Apparently, even computer scientists are not consistent with the use
    > of "library".
    > I have a textbook here that uses the term "shared library" for those
    > entities that get linked into the executable at load time.
    > The book is
    > Linkers and Loaders; Academic Press; John R. Levine; 1-55860-496-0


    I have a CC man page that says:

    -G Build a dynamic shared library instead of an executable
    file; see the ld(1) man page and the C++ User's Guide.

    gcc's man page has several references, including:

    -static-libgcc
    On systems that provide libgcc as a shared library,

    --
    Ian Collins
     
    Ian Collins, Jan 11, 2011
    #11
  12. Alf P. Steinbach /Usenet

    James Kanze Guest

    Re: Initialization of static anonymous-namespace members from adynamically loaded lib

    On Jan 11, 10:28 am, Bart van Ingen Schenau <>
    wrote:
    > On Jan 10, 2:51 pm, James Kanze <> wrote:
    > > The fact remains that in computer science, "library" means (or
    > > always used to mean) a collection of object files, each of which
    > > was included only if it resolved an unresolved external. When
    > > dynamically linking, it's all or nothing.


    > Apparently, even computer scientists are not consistent with the use
    > of "library".


    That was, I think, the point of Alf's responding with a Google
    search reference. Finding one (or even a lot) of such uses
    wouldn't really surprise me, but some of the were definitly from
    people who knew what they were talking about.

    > I have a textbook here that uses the term "shared library" for those
    > entities that get linked into the executable at load time.
    > The book is
    > Linkers and Loaders; Academic Press; John R. Levine; 1-55860-496-0


    Who is a recognized expert in the field.

    All I can say is that the meaning has changed. I learned most
    of this stuff a long time ago, and back then, library very
    definitely had the meaning I associate with it. (The
    conversations I remember in the C committee also go back some in
    time.) And in the Unix world, we spoke of "shared objects", and
    not shared libraries. IMHO, we've lost something in loosing
    this distinction.

    --
    James Kanze
     
    James Kanze, Jan 11, 2011
    #12
  13. Alf P. Steinbach /Usenet

    Paul Guest

    Re: Initialization of static anonymous-namespace members from a dynamically loaded lib

    "James Kanze" <> wrote in message
    news:...
    > On Jan 11, 10:28 am, Bart van Ingen Schenau <>
    > wrote:
    >> On Jan 10, 2:51 pm, James Kanze <> wrote:
    >> > The fact remains that in computer science, "library" means (or
    >> > always used to mean) a collection of object files, each of which
    >> > was included only if it resolved an unresolved external. When
    >> > dynamically linking, it's all or nothing.

    >
    >> Apparently, even computer scientists are not consistent with the use
    >> of "library".

    >
    > That was, I think, the point of Alf's responding with a Google
    > search reference. Finding one (or even a lot) of such uses
    > wouldn't really surprise me, but some of the were definitly from
    > people who knew what they were talking about.
    >
    >> I have a textbook here that uses the term "shared library" for those
    >> entities that get linked into the executable at load time.
    >> The book is
    >> Linkers and Loaders; Academic Press; John R. Levine; 1-55860-496-0

    >
    > Who is a recognized expert in the field.
    >
    > All I can say is that the meaning has changed. I learned most
    > of this stuff a long time ago, and back then, library very
    > definitely had the meaning I associate with it. (The
    > conversations I remember in the C committee also go back some in
    > time.) And in the Unix world, we spoke of "shared objects", and
    > not shared libraries. IMHO, we've lost something in loosing
    > this distinction.
    >
    > --
    > James Kanze
    >


    What part of "YOU ARE WRONG" do you not understand?

    Who cares if IYHO you have lost something when you were wrong about what you
    think you've lost.
     
    Paul, Jan 11, 2011
    #13
  14. Alf P. Steinbach /Usenet

    Balog Pal Guest

    Re: Initialization of static anonymous-namespace members from a dynamically loaded lib

    "James Kanze" <>
    > All I can say is that the meaning has changed. I learned most
    > of this stuff a long time ago, and back then, library very
    > definitely had the meaning I associate with it. (The
    > conversations I remember in the C committee also go back some in
    > time.) And in the Unix world, we spoke of "shared objects", and
    > not shared libraries. IMHO, we've lost something in loosing
    > this distinction.


    Yeah, as I see it, the meaning of term "library" got diluted. Not for really
    good. The original name "shared object" made more sense.

    And the windoze name DLL meaning 'Dynamic Link Library' is plain broken, as
    windows never had the linker involved at execution time, the DLL is handled
    by the module loader and only involves the segment/address fixups. DLL may
    come without a single symbol exported binding entry points just through
    ordinals. If export names are provided they are not by the system but by the
    client progam to get an address. (compilers can use a trick through
    "implib", providing stubs and jmp tables, but the idea is the same in the
    deep.)
     
    Balog Pal, Jan 11, 2011
    #14
  15. Re: Initialization of static anonymous-namespace members from adynamically loaded lib

    On Jan 10, 8:51 am, James Kanze <> wrote:
    > On Jan 10, 11:01 am, "Alf P. Steinbach /Usenet"
    > <> wrote:
    > > * James Kanze, on 10.01.2011 11:26:
    > > > On Jan 10, 12:05 am, "Alf P. Steinbach /Usenet"
    > > > <>  wrote:
    > > >> * James Kanze, on 10.01.2011 00:03:
    > > >>> On Jan 9, 9:00 pm, "Alf P. Steinbach /Usenet"<alf.p.steinbach
    > > >>> >   wrote:
    > > >>>> * m0shbear, on 09.01.2011 21:56:
    > > >>>       [...]
    > > >>>   (I don't know of any that can dynamically load a
    > > >>> library.  But despite the name, under Windows, a DLL is not a
    > > >>> library.)
    > > >> Windows Dynamically Loaded Library, *nix Shared Library.
    > > > What's a Unix shared library?  I've never heard the term before.

    > > Try <url:http://www.google.com/search?q=%22shared+library%22>.

    >
    > You can find anything using Google:).  It never occured to me.
    > I guess just basing my knowledge on the Posix standard and the
    > Sun manual.  And conversations with other Unix specialists:
    > after all, .so didn't come from shared library, but from shared
    > object.


    I would also point out that the Unix convention (I think) is to
    prefix the library file with 'lib'. I'm not sure how far back in
    history that convention spans but it would seem to indicate some
    cognition of the "library" sense. Such as "library archive" and
    "library shared object" for lib*.a and lib*.so respectively.

    > The fact remains that in computer science, "library" means (or
    > always used to mean) a collection of object files, each of which
    > was included only if it resolved an unresolved external.  When
    > dynamically linking, it's all or nothing.


    So the Standard Template Library (STL) is a collection of object
    files? Or the name violates the computer science sense?

    > Anyway, trying your link, I see that it's not just newbes using
    > the term, even if Posix and Sun don't.  The Linux and gcc
    > communities seem to have adopted it.  Which makes me think that
    > I'm fighting a loosing battle for linguistic purity. The fact


    The French have been doing that for a long long time ... ;-)

    KHD
     
    Keith H Duggar, Jan 11, 2011
    #15
  16. Alf P. Steinbach /Usenet

    James Kanze Guest

    Re: Initialization of static anonymous-namespace members from adynamically loaded lib

    On Jan 11, 6:07 pm, "Balog Pal" <> wrote:
    > "James Kanze" <>


    > > All I can say is that the meaning has changed. I learned most
    > > of this stuff a long time ago, and back then, library very
    > > definitely had the meaning I associate with it. (The
    > > conversations I remember in the C committee also go back some in
    > > time.) And in the Unix world, we spoke of "shared objects", and
    > > not shared libraries. IMHO, we've lost something in loosing
    > > this distinction.


    > Yeah, as I see it, the meaning of term "library" got diluted.
    > Not for really good. The original name "shared object" made
    > more sense.


    Well, the most important single point is that it is dynamically
    linked; sharing was the original motive, but a lot of "shared
    objects" (e.g. plugins) aren't shared today. On the other hand,
    I do think we've lost something concerning the word library:
    originally, libraries where handled one way, and object files
    another. Now, static libraries are handled one way, and object
    files and dynamic libraries another. Seems less clear (or at
    least more verbose) to me.

    > And the windoze name DLL meaning 'Dynamic Link Library' is
    > plain broken, as windows never had the linker involved at
    > execution time, the DLL is handled by the module loader and
    > only involves the segment/address fixups.


    That's not really relevant. I don't think any system actually
    invokes the linker when loading a dynamic object. I don't think
    early SunOS did any fixups: the loaded object had to be position
    independent code, and it used some sort of fixed table of
    addresses at the beginning (I think---I'm not sure about the
    second part). Ideally, you should be able to map the object
    directly, without copying it into virtual memory in any way. (I
    don't think modern object file formats support this, but I've
    used some in the past that did.)

    --
    James Kanze
     
    James Kanze, Jan 12, 2011
    #16
  17. Alf P. Steinbach /Usenet

    James Kanze Guest

    Re: Initialization of static anonymous-namespace members from adynamically loaded lib

    On Jan 11, 6:43 pm, Keith H Duggar <> wrote:
    > On Jan 10, 8:51 am, James Kanze <> wrote:
    > > On Jan 10, 11:01 am, "Alf P. Steinbach /Usenet"
    > > <> wrote:
    > > > * James Kanze, on 10.01.2011 11:26:
    > > > > On Jan 10, 12:05 am, "Alf P. Steinbach /Usenet"
    > > > > <> wrote:
    > > > >> * James Kanze, on 10.01.2011 00:03:
    > > > >>> On Jan 9, 9:00 pm, "Alf P. Steinbach /Usenet"<alf.p.steinbach
    > > > >>> > wrote:
    > > > >>>> * m0shbear, on 09.01.2011 21:56:
    > > > >>> [...]
    > > > >>> (I don't know of any that can dynamically load a
    > > > >>> library. But despite the name, under Windows, a DLL is not a
    > > > >>> library.)
    > > > >> Windows Dynamically Loaded Library, *nix Shared Library.
    > > > > What's a Unix shared library? I've never heard the term before.
    > > > Try <url:http://www.google.com/search?q=%22shared+library%22>.


    > > You can find anything using Google:). It never occured to me.
    > > I guess just basing my knowledge on the Posix standard and the
    > > Sun manual. And conversations with other Unix specialists:
    > > after all, .so didn't come from shared library, but from shared
    > > object.


    > I would also point out that the Unix convention (I think) is to
    > prefix the library file with 'lib'. I'm not sure how far back in
    > history that convention spans but it would seem to indicate some
    > cognition of the "library" sense. Such as "library archive" and
    > "library shared object" for lib*.a and lib*.so respectively.


    Yes. Good point: the Unix conventions are ambiguous. Of
    course, in the end, it is neither a library (an ranlib'ed
    archive, under Unix) nor an object file, but something rather
    different from both. And while it works more like an object
    file than a library, in most cases, it's used more like
    a library---the file has some functions I want to call, so
    I link against it, in order to get those functions. (In most
    cases, as long as we're only talking about functions, and not
    static initializers, the fact that I get everything, and not
    just what I actually need, makes no real difference to me.)

    > > The fact remains that in computer science, "library" means (or
    > > always used to mean) a collection of object files, each of which
    > > was included only if it resolved an unresolved external. When
    > > dynamically linking, it's all or nothing.


    > So the Standard Template Library (STL) is a collection of object
    > files? Or the name violates the computer science sense?


    Or we're dealing with something new:). But in fact, I was
    being too restrictive: you can have libraries with other things
    than object files; the definition of library I used is really
    only relevant to linkables.

    There is a sense that STL violates the older conventions for
    libraries. On the other hand, there doesn't seem to be another
    word that fits, either. So some word will have to have its
    meaning expanded, and library seems appropriate.

    --
    James Kanze
     
    James Kanze, Jan 12, 2011
    #17
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JFCM
    Replies:
    4
    Views:
    5,756
  2. mark fine
    Replies:
    1
    Views:
    476
    Michael Jørgensen
    Nov 9, 2004
  3. est
    Replies:
    1
    Views:
    634
    Diez B. Roggisch
    Feb 16, 2008
  4. Rit
    Replies:
    23
    Views:
    961
    Mike Schilling
    Jan 3, 2010
  5. NAKAMURA, Hiroshi
    Replies:
    0
    Views:
    141
    NAKAMURA, Hiroshi
    Jul 6, 2004
Loading...

Share This Page