Questions about linking. - Minix

This is a discussion on Questions about linking. - Minix ; For example,there are two object files: a1.o and a2.o . I think one object file shoud be composed of text segment,data segment and bss segment. Underside are the structure pictures of a1.o and a2.o: |--------| |--------| | bss1| |bss2 | ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: Questions about linking.

  1. Questions about linking.

    For example,there are two object files: a1.o and a2.o .
    I think one object file shoud be composed of text segment,data segment
    and bss segment.
    Underside are the structure pictures of a1.o and a2.o:

    |--------| |--------|
    | bss1| |bss2 |
    |--------| |--------|
    |data1| |data2|
    |--------| |--------|
    |text1 | |text2 |
    |--------| |--------|

    If a1.o is linked with a2.o, and create the file a .
    Which is the structure of a ?

    |--------|
    |bss2 | |---------|
    |bss1 | | bss2 |
    |--------| | data2|
    |data2| | text2 |
    |data1| |---------|
    |--------| | bss1|
    |text2 | | data1|
    |text1 | | text1 |
    |--------| |---------|

    (1) (2)

    Another question: For a library file, how the picture it is ?
    Can you draw it for me?

    Does Minix3.1.1 support dynamic linking?
    (Supposeing it does) When one executeable is running, he want to
    dynamically link a lib. Does someone can tell me how he do it?

    Thanks.
    Lxbcyllt.


  2. Re: Questions about linking.

    Diagram (1) is how it is done. When an executable is loaded it is
    allocated 2 segments in it's own LDT (5 in reality, but only 2 are
    relevant). These are the text and data segment, stack and bss are
    loaded into data segment. This segment must be of continuous memory so
    having the parts all split up as is (2) wouldn't make sense at all.
    -ivan


  3. Re: Questions about linking.


    Ivan Kelly 写道:

    > Diagram (1) is how it is done.


    If a1.o and a2.o are included in a liba.a,then the structure of liba.a
    likes diagram (1) too.
    Is right?

    Thanks.
    Lxbcyllt.


  4. Re: Questions about linking.

    lxbcyllt@jx163.com wrote:
    > Ivan Kelly 写道:
    >
    >
    >>Diagram (1) is how it is done.

    >
    >
    > If a1.o and a2.o are included in a liba.a,then the structure of liba.a
    > likes diagram (1) too.
    > Is right?
    >
    > Thanks.
    > Lxbcyllt.
    >


    Minix 3 doesn't support dynamic linking; we don't even have a ld.so

    Also, there is no virtual memory support, so memory is a issue.

  5. Re: Questions about linking.

    > Minix 3 doesn't support dynamic linking; we don't even have a ld.so
    Thanks for above help.

    My other question is about static linking.

    For example, if one library (i.e. liba.a) include two functions : f1( )
    and f2( ), one object file which calls f1( ) is statically linked with
    liba.a to get a executable, then is the f1( ) linked into the
    executable or the whole liba.a ?

    In other words, does the linker select the necessary stuff , not the
    whole, to get the executable?
    If so,is it applied to the LIB's global variables which are accessed by
    a object file?

    Are all the global variables which come from different object files
    collected in the LIB's data segment by the linker ?

    Thanks.
    lxbcyllt.


  6. Re: Questions about linking.

    lxbcyllt@jx163.com wrote:
    >> Minix 3 doesn't support dynamic linking; we don't even have a ld.so

    > Thanks for above help.
    >
    > My other question is about static linking.
    >
    > For example, if one library (i.e. liba.a) include two functions : f1( )
    > and f2( ), one object file which calls f1( ) is statically linked with
    > liba.a to get a executable, then is the f1( ) linked into the
    > executable or the whole liba.a ?
    >
    > In other words, does the linker select the necessary stuff , not the
    > whole, to get the executable?
    > If so,is it applied to the LIB's global variables which are accessed by
    > a object file?
    >
    > Are all the global variables which come from different object files
    > collected in the LIB's data segment by the linker ?



    Libraries are a collection of objects (archive of object files).
    Each objects, usually but not necessarily, contains a function and data.
    During the linking phase the linker searches the libraries for
    unresolved symbols and when it finds them extracts a copy of the object
    file which is then linked as any object file in input to the linker.

    If a global variable is found in the library the relevant object file is
    retrieved from the archive and linked.

    Ciao
    Giovanni
    --
    A computer is like an air conditioner,
    it stops working when you open Windows.
    Registered Linux user #337974

+ Reply to Thread