when generating the app.out linking with the lib, the code in lib isfully included into the app.out? - VxWorks

This is a discussion on when generating the app.out linking with the lib, the code in lib isfully included into the app.out? - VxWorks ; when generating the app.out linking with the lib, the code in lib is fully included into the app.out? So I carry out the following test. 1. Generating the lib For example, there are two file funcOne.c, funcs.c in the libtest.a. ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: when generating the app.out linking with the lib, the code in lib isfully included into the app.out?

  1. when generating the app.out linking with the lib, the code in lib isfully included into the app.out?

    when generating the app.out linking with the lib, the code in lib
    is fully included into the app.out? So I carry out the following test.
    1. Generating the lib
    For example, there are two file funcOne.c, funcs.c in the libtest.a.
    Following is the code:
    ///////////////////////////////////////////////////////////////////////
    /* file funcOne.c */
    void func1()
    {
    printf("this is libtest func1! ");
    }

    void functest()
    {
    printf("is this func downloaded into target ?");
    }
    ///////////////////////////////////////////////////////////////////////
    /* file funcs.c */

    void func2()
    {
    printf("this is libtest func2! ");
    }

    ///////////////////////////////////////////////////////////////////////
    2. main routine only called the one routine in lib
    Then I generate the app.out.In my application, the main routine only
    calls the func1,not calls functest and func2
    the following is the code:

    ///////////////////////////////////////////////////////////////////////
    /* funcOne.h */
    extern void func1();
    extern void func2();

    ///////////////////////////////////////////////////////////////////////
    /* mainfunc.c*/

    #include "funcOne.h"

    int main()
    {
    printf("no lib included!");
    func1();
    return 0;
    }
    ///////////////////////////////////////////////////////////////////////
    3.see the sysmbol of app.out using nmpentium.
    ///////////////////////////////////////////////////////////////////////
    command:
    nmpentium --line-numbers app.out >app.txt
    the content of app.txt:
    00000048 D _GLOBAL_$F$func1
    00000000 D _GLOBAL_$F$main
    00000000 d __FRAME_BEGIN__
    00000048 d __FRAME_BEGIN__
    00000000 t __gnu_compiled_c
    000000ec t __gnu_compiled_c
    00000060 t __gnu_compiled_c
    000000b0 D _ctors d:\tornado\target\proj\libtest\PENTIUMgnu/../
    funcOne.c:4
    000000b4 D _dtors d:\tornado\target\proj\\libtest\PENTIUMgnu/../
    funcOne.c:4
    00000080 T func1 d:\tornado\target\proj\libtest\PENTIUMgnu/../
    funcOne.c:2
    000000d0 T functest d:\tornado\target\proj\libtest\PENTIUMgnu/../
    funcOne.c:7
    00000000 t gcc2_compiled.
    00000060 t gcc2_compiled.
    000000ec t gcc2_compiled.
    00000020 T main d:\tornado\target\proj\app\PENTIUMgnu/../mainFunc.c:3
    U printf d:\tornado\target\proj\app\PENTIUMgnu/../mainFunc.c:
    4
    ///////////////////////////////////////////////////////////////////////

    At last, the app.out only includes the func1 and functest routine when
    the main routine only calls func1.
    question :
    functest routine is not referenced in my application. Why the app.out
    includes the functest?
    But except the func2!
    Any one can give the reason. Thanks!

    Environment:TORNADO 2.2
    Host :windows xp
    bsbcpentium

  2. Re: when generating the app.out linking with the lib, the code in libis fully included into the app.out?

    On Aug 14, 5:15 pm, lje9292...@yahoo.com.cn wrote:
    > when generating the app.out linking with the lib, the code in lib
    > is fully included into the app.out? So I carry out the following test.
    > 1. Generating the lib
    > For example, there are two file funcOne.c, funcs.c in the libtest.a.
    > Following is the code:
    > ///////////////////////////////////////////////////////////////////////
    > /* file funcOne.c */
    > void func1()
    > {
    > printf("this is libtest func1! ");
    >
    > }
    >
    > void functest()
    > {
    > printf("is this func downloaded into target ?");}
    >
    > ///////////////////////////////////////////////////////////////////////
    > /* file funcs.c */
    >
    > void func2()
    > {
    > printf("this is libtest func2! ");
    >
    > }
    >
    > ///////////////////////////////////////////////////////////////////////
    > 2. main routine only called the one routine in lib
    > Then I generate the app.out.In my application, the main routine only
    > calls the func1,not calls functest and func2
    > the following is the code:
    >
    > ///////////////////////////////////////////////////////////////////////
    > /* funcOne.h */
    > extern void func1();
    > extern void func2();
    >
    > ///////////////////////////////////////////////////////////////////////
    > /* mainfunc.c*/
    >
    > #include "funcOne.h"
    >
    > int main()
    > {
    > printf("no lib included!");
    > func1();
    > return 0;}
    >
    > ///////////////////////////////////////////////////////////////////////
    > 3.see the sysmbol of app.out using nmpentium.
    > ///////////////////////////////////////////////////////////////////////
    > command:
    > nmpentium --line-numbers app.out >app.txt
    > the content of app.txt:
    > 00000048 D _GLOBAL_$F$func1
    > 00000000 D _GLOBAL_$F$main
    > 00000000 d __FRAME_BEGIN__
    > 00000048 d __FRAME_BEGIN__
    > 00000000 t __gnu_compiled_c
    > 000000ec t __gnu_compiled_c
    > 00000060 t __gnu_compiled_c
    > 000000b0 D _ctors d:\tornado\target\proj\libtest\PENTIUMgnu/../
    > funcOne.c:4
    > 000000b4 D _dtors d:\tornado\target\proj\\libtest\PENTIUMgnu/../
    > funcOne.c:4
    > 00000080 T func1 d:\tornado\target\proj\libtest\PENTIUMgnu/../
    > funcOne.c:2
    > 000000d0 T functest d:\tornado\target\proj\libtest\PENTIUMgnu/../
    > funcOne.c:7
    > 00000000 t gcc2_compiled.
    > 00000060 t gcc2_compiled.
    > 000000ec t gcc2_compiled.
    > 00000020 T main d:\tornado\target\proj\app\PENTIUMgnu/../mainFunc.c:3
    > U printf d:\tornado\target\proj\app\PENTIUMgnu/../mainFunc.c:
    > 4
    > ///////////////////////////////////////////////////////////////////////
    >
    > At last, the app.out only includes the func1 and functest routine when
    > the main routine only calls func1.
    > question :
    > functest routine is not referenced in my application. Why the app.out
    > includes the functest?
    > But except the func2!
    > Any one can give the reason. Thanks!
    >
    > Environment:TORNADO 2.2
    > Host :windows xp
    > bsbcpentium


    Hi,

    Because func1 and functest are preasent in the same file funcOne.c.

    In your main function, you are calling func1() . Then the object file
    where func1() definition is present will be linked into app.out. As
    funcOne.o will have func1() and functest() definition, your app.out
    has these two symbols.

    In your app.out, func2() is not there because you are not using any
    symbol from file funcs.c.

    You can check this by calling only func2() in your main. your app.out
    contains only symbol func2().

    Hope it clarifies your doubt !

    Regards
    Satish.

  3. Re: when generating the app.out linking with the lib, the code in libis fully included into the app.out?

    On 818, 213, satish....@gmail.com wrote:
    > On Aug 14, 5:15 pm, lje9292...@yahoo.com.cn wrote:
    >
    >
    >
    > > when generating the app.out linking with the lib, the code in lib
    > > is fully included into the app.out? So I carry out the following test.
    > > 1. Generating the lib
    > > For example, there are two file funcOne.c, funcs.c in the libtest.a.
    > > Following is the code:
    > > ///////////////////////////////////////////////////////////////////////
    > > /* file funcOne.c */
    > > void func1()
    > > {
    > > printf("this is libtest func1! ");

    >
    > > }

    >
    > > void functest()
    > > {
    > > printf("is this func downloaded into target ?");}

    >
    > > ///////////////////////////////////////////////////////////////////////
    > > /* file funcs.c */

    >
    > > void func2()
    > > {
    > > printf("this is libtest func2! ");

    >
    > > }

    >
    > > ///////////////////////////////////////////////////////////////////////
    > > 2. main routine only called the one routine in lib
    > > Then I generate the app.out.In my application, the main routine only
    > > calls the func1,not calls functest and func2
    > > the following is the code:

    >
    > > ///////////////////////////////////////////////////////////////////////
    > > /* funcOne.h */
    > > extern void func1();
    > > extern void func2();

    >
    > > ///////////////////////////////////////////////////////////////////////
    > > /* mainfunc.c*/

    >
    > > #include "funcOne.h"

    >
    > > int main()
    > > {
    > > printf("no lib included!");
    > > func1();
    > > return 0;}

    >
    > > ///////////////////////////////////////////////////////////////////////
    > > 3.see the sysmbol of app.out using nmpentium.
    > > ///////////////////////////////////////////////////////////////////////
    > > command
    > > nmpentium --line-numbers app.out >app.txt
    > > the content of app.txt:
    > > 00000048 D _GLOBAL_$F$func1
    > > 00000000 D _GLOBAL_$F$main
    > > 00000000 d __FRAME_BEGIN__
    > > 00000048 d __FRAME_BEGIN__
    > > 00000000 t __gnu_compiled_c
    > > 000000ec t __gnu_compiled_c
    > > 00000060 t __gnu_compiled_c
    > > 000000b0 D _ctors d:\tornado\target\proj\libtest\PENTIUMgnu/../
    > > funcOne.c:4
    > > 000000b4 D _dtors d:\tornado\target\proj\\libtest\PENTIUMgnu/../
    > > funcOne.c:4
    > > 00000080 T func1 d:\tornado\target\proj\libtest\PENTIUMgnu/../
    > > funcOne.c:2
    > > 000000d0 T functest d:\tornado\target\proj\libtest\PENTIUMgnu/../
    > > funcOne.c:7
    > > 00000000 t gcc2_compiled.
    > > 00000060 t gcc2_compiled.
    > > 000000ec t gcc2_compiled.
    > > 00000020 T main d:\tornado\target\proj\app\PENTIUMgnu/../mainFunc.c:3
    > > U printf d:\tornado\target\proj\app\PENTIUMgnu/../mainFunc.c:
    > > 4
    > > ///////////////////////////////////////////////////////////////////////

    >
    > > At last, the app.out only includes the func1 and functest routine when
    > > the main routine only calls func1.
    > > question :
    > > functest routine is not referenced in my application. Why the app.out
    > > includes the functest?
    > > But except the func2!
    > > Any one can give the reason. Thanks!

    >
    > > Environment:TORNADO 2.2
    > > Host :windows xp
    > > bsbcpentium

    >
    > Hi,
    >
    > Because func1 and functest are preasent in the same file funcOne.c.
    >
    > In your main function, you are calling func1() . Then the object file
    > where func1() definition is present will be linked into app.out. As
    > funcOne.o will have func1() and functest() definition, your app.out
    > has these two symbols.
    >
    > In your app.out, func2() is not there because you are not using any
    > symbol from file funcs.c.
    >
    > You can check this by calling only func2() in your main. your app.out
    > contains only symbol func2().
    >
    > Hope it clarifies your doubt !
    >
    > Regards
    > Satish.


    Thanks. It' s right! Because the link is based on the function. if the
    function is inlcudeed in a large file. The other code of this file
    will be linked into the app.out.
    If the file is not the archive,but the other source file, then the
    file will be linked into the app.out fully? Or only the called part
    will be linked into the app.out?
    Expect your reply!

  4. Re: when generating the app.out linking with the lib, the code in libis fully included into the app.out?

    On Aug 18, 6:50 pm, lje9292...@yahoo.com.cn wrote:
    > On 818, 213, satish....@gmail.com wrote:
    >
    >
    >
    >
    >
    > > On Aug 14, 5:15 pm, lje9292...@yahoo.com.cn wrote:

    >
    > > > when generating the app.out linking with the lib, the code in lib
    > > > is fully included into the app.out? So I carry out the following test..
    > > > 1. Generating the lib
    > > > For example, there are two file funcOne.c, funcs.c in the libtest.a.
    > > > Following is the code:
    > > > ///////////////////////////////////////////////////////////////////////
    > > > /* file funcOne.c */
    > > > void func1()
    > > > {
    > > > printf("this is libtest func1! ");

    >
    > > > }

    >
    > > > void functest()
    > > > {
    > > > printf("is this func downloaded into target ?");}

    >
    > > > ///////////////////////////////////////////////////////////////////////
    > > > /* file funcs.c */

    >
    > > > void func2()
    > > > {
    > > > printf("this is libtest func2! ");

    >
    > > > }

    >
    > > > ///////////////////////////////////////////////////////////////////////
    > > > 2. main routine only called the one routine in lib
    > > > Then I generate the app.out.In my application, the main routine only
    > > > calls the func1,not calls functest and func2
    > > > the following is the code:

    >
    > > > ///////////////////////////////////////////////////////////////////////
    > > > /* funcOne.h */
    > > > extern void func1();
    > > > extern void func2();

    >
    > > > ///////////////////////////////////////////////////////////////////////
    > > > /* mainfunc.c*/

    >
    > > > #include "funcOne.h"

    >
    > > > int main()
    > > > {
    > > > printf("no lib included!");
    > > > func1();
    > > > return 0;}

    >
    > > > ///////////////////////////////////////////////////////////////////////
    > > > 3.see the sysmbol of app.out using nmpentium.
    > > > ///////////////////////////////////////////////////////////////////////
    > > > command
    > > > nmpentium --line-numbers app.out >app.txt
    > > > the content of app.txt:
    > > > 00000048 D _GLOBAL_$F$func1
    > > > 00000000 D _GLOBAL_$F$main
    > > > 00000000 d __FRAME_BEGIN__
    > > > 00000048 d __FRAME_BEGIN__
    > > > 00000000 t __gnu_compiled_c
    > > > 000000ec t __gnu_compiled_c
    > > > 00000060 t __gnu_compiled_c
    > > > 000000b0 D _ctors d:\tornado\target\proj\libtest\PENTIUMgnu/../
    > > > funcOne.c:4
    > > > 000000b4 D _dtors d:\tornado\target\proj\\libtest\PENTIUMgnu/../
    > > > funcOne.c:4
    > > > 00000080 T func1 d:\tornado\target\proj\libtest\PENTIUMgnu/../
    > > > funcOne.c:2
    > > > 000000d0 T functest d:\tornado\target\proj\libtest\PENTIUMgnu/../
    > > > funcOne.c:7
    > > > 00000000 t gcc2_compiled.
    > > > 00000060 t gcc2_compiled.
    > > > 000000ec t gcc2_compiled.
    > > > 00000020 T main d:\tornado\target\proj\app\PENTIUMgnu/../mainFunc.c:3
    > > > U printf d:\tornado\target\proj\app\PENTIUMgnu/../mainFunc.c:
    > > > 4
    > > > ///////////////////////////////////////////////////////////////////////

    >
    > > > At last, the app.out only includes the func1 and functest routine when
    > > > the main routine only calls func1.
    > > > question :
    > > > functest routine is not referenced in my application. Why the app.out
    > > > includes the functest?
    > > > But except the func2!
    > > > Any one can give the reason. Thanks!

    >
    > > > Environment:TORNADO 2.2
    > > > Host :windows xp
    > > > bsbcpentium

    >
    > > Hi,

    >
    > > Because func1 and functest are preasent in the same file funcOne.c.

    >
    > > In your main function, you are calling func1() . Then the object file
    > > where func1() definition is present will be linked into app.out. As
    > > funcOne.o will have func1() and functest() definition, your app.out
    > > has these two symbols.

    >
    > > In your app.out, func2() is not there because you are not using any
    > > symbol from file funcs.c.

    >
    > > You can check this by calling only func2() in your main. your app.out
    > > contains only symbol func2().

    >
    > > Hope it clarifies your doubt !

    >
    > > Regards
    > > Satish.

    >
    > Thanks. It' s right! Because the link is based on the function. if the
    > function is inlcudeed in a large file. The other code of this file
    > will be linked into the app.out.
    > If the file is not the archive,but the other source file, then the
    > file will be linked into the app.out fully? Or only the called part
    > will be linked into the app.out?
    > Expect your reply!- Hide quoted text -
    >
    > - Show quoted text -


    Hi,

    I think file will be linked fully. You can test in following way.

    Just compile your files funcOne.c and funcs.c in your test project
    and call respective functions in your main and check it.

    Regards
    Satish.

  5. Re: when generating the app.out linking with the lib, the code in libis fully included into the app.out?

    On 819, 1138, satish....@gmail.com wrote:
    > On Aug 18, 6:50 pm, lje9292...@yahoo.com.cn wrote:
    >
    >
    >
    > > On 818, 213, satish....@gmail.com wrote:

    >
    > > > On Aug 14, 5:15 pm, lje9292...@yahoo.com.cn wrote:

    >
    > > > > when generating the app.out linking with the lib, the code in lib
    > > > > is fully included into the app.out? So I carry out the following test.
    > > > > 1. Generating the lib
    > > > > For example, there are two file funcOne.c, funcs.c in the libtest.a.
    > > > > Following is the code:
    > > > > ///////////////////////////////////////////////////////////////////////
    > > > > /* file funcOne.c */
    > > > > void func1()
    > > > > {
    > > > > printf("this is libtest func1! ");

    >
    > > > > }

    >
    > > > > void functest()
    > > > > {
    > > > > printf("is this func downloaded into target ?");}

    >
    > > > > ///////////////////////////////////////////////////////////////////////
    > > > > /* file funcs.c */

    >
    > > > > void func2()
    > > > > {
    > > > > printf("this is libtest func2! ");

    >
    > > > > }

    >
    > > > > ///////////////////////////////////////////////////////////////////////
    > > > > 2. main routine only called the one routine in lib
    > > > > Then I generate the app.out.In my application, the main routine only
    > > > > calls the func1,not calls functest and func2
    > > > > the following is the code:

    >
    > > > > ///////////////////////////////////////////////////////////////////////
    > > > > /* funcOne.h */
    > > > > extern void func1();
    > > > > extern void func2();

    >
    > > > > ///////////////////////////////////////////////////////////////////////
    > > > > /* mainfunc.c*/

    >
    > > > > #include "funcOne.h"

    >
    > > > > int main()
    > > > > {
    > > > > printf("no lib included!");
    > > > > func1();
    > > > > return 0;}

    >
    > > > > ///////////////////////////////////////////////////////////////////////
    > > > > 3.see the sysmbol of app.out using nmpentium.
    > > > > ///////////////////////////////////////////////////////////////////////
    > > > > command
    > > > > nmpentium --line-numbers app.out >app.txt
    > > > > the content of app.txt:
    > > > > 00000048 D _GLOBAL_$F$func1
    > > > > 00000000 D _GLOBAL_$F$main
    > > > > 00000000 d __FRAME_BEGIN__
    > > > > 00000048 d __FRAME_BEGIN__
    > > > > 00000000 t __gnu_compiled_c
    > > > > 000000ec t __gnu_compiled_c
    > > > > 00000060 t __gnu_compiled_c
    > > > > 000000b0 D _ctors d:\tornado\target\proj\libtest\PENTIUMgnu/.../
    > > > > funcOne.c:4
    > > > > 000000b4 D _dtors d:\tornado\target\proj\\libtest\PENTIUMgnu/.../
    > > > > funcOne.c:4
    > > > > 00000080 T func1 d:\tornado\target\proj\libtest\PENTIUMgnu/.../
    > > > > funcOne.c:2
    > > > > 000000d0 T functest d:\tornado\target\proj\libtest\PENTIUMgnu/.../
    > > > > funcOne.c:7
    > > > > 00000000 t gcc2_compiled.
    > > > > 00000060 t gcc2_compiled.
    > > > > 000000ec t gcc2_compiled.
    > > > > 00000020 T main d:\tornado\target\proj\app\PENTIUMgnu/../mainFunc.c:3
    > > > > U printf d:\tornado\target\proj\app\PENTIUMgnu/../mainFunc.c:
    > > > > 4
    > > > > ///////////////////////////////////////////////////////////////////////

    >
    > > > > At last, the app.out only includes the func1 and functest routine when
    > > > > the main routine only calls func1.
    > > > > question :
    > > > > functest routine is not referenced in my application. Why the app.out
    > > > > includes the functest?
    > > > > But except the func2!
    > > > > Any one can give the reason. Thanks!

    >
    > > > > Environment:TORNADO 2.2
    > > > > Host :windows xp
    > > > > bsbcpentium

    >
    > > > Hi,

    >
    > > > Because func1 and functest are preasent in the same file funcOne.c.

    >
    > > > In your main function, you are calling func1() . Then the object file
    > > > where func1() definition is present will be linked into app.out. As
    > > > funcOne.o will have func1() and functest() definition, your app.out
    > > > has these two symbols.

    >
    > > > In your app.out, func2() is not there because you are not using any
    > > > symbol from file funcs.c.

    >
    > > > You can check this by calling only func2() in your main. your app.out
    > > > contains only symbol func2().

    >
    > > > Hope it clarifies your doubt !

    >
    > > > Regards
    > > > Satish.

    >
    > > Thanks. It' s right! Because the link is based on the function. if the
    > > function is inlcudeed in a large file. The other code of this file
    > > will be linked into the app.out.
    > > If the file is not the archive,but the other source file, then the
    > > file will be linked into the app.out fully? Or only the called part
    > > will be linked into the app.out?
    > > Expect your reply!- Hide quoted text -

    >
    > > - Show quoted text -

    >
    > Hi,
    >
    > I think file will be linked fully. You can test in following way.
    >
    > Just compile your files funcOne.c and funcs.c in your test project
    > and call respective functions in your main and check it.
    >
    > Regards
    > Satish.


    Yesyou are right.
    Thanks!

+ Reply to Thread