LINUX.ORG.RU

История изменений

Исправление cyber_eagle, (текущая версия) :

#ls

Makefile  obj1.c  obj2.c  obj3.c
#cat Makefile
%.o: %.c
        gcc -fPIC -c $^ -o $@

lib.a: obj1.o obj2.o
         $(AR) crs $@ $^

lib.so: lib.a obj3.o
        gcc -shared $^ -o $@
#cat obj1.c
void testsym1()
{
        printf("1");
}
#cat obj2.c
void testsym2()
{
        printf("2");
}
#cat obj3.c
void testsym3()
{
        printf("3");
}
------------------------------------------------------------------------------------------------

#make lib.so && nm lib.so

0000000000201028 B __bss_start
0000000000201028 b completed.7697
                 w __cxa_finalize@@GLIBC_2.2.5
0000000000000530 t deregister_tm_clones
00000000000005c0 t __do_global_dtors_aux
0000000000200e18 t __do_global_dtors_aux_fini_array_entry
0000000000201020 d __dso_handle
0000000000200e20 d _DYNAMIC
0000000000201028 D _edata
0000000000201030 B _end
000000000000061c T _fini
0000000000000600 t frame_dummy
0000000000200e10 t __frame_dummy_init_array_entry
00000000000006c8 r __FRAME_END__
0000000000201000 d _GLOBAL_OFFSET_TABLE_
                 w __gmon_start__
0000000000000628 r __GNU_EH_FRAME_HDR
00000000000004e8 T _init
                 w _ITM_deregisterTMCloneTable
                 w _ITM_registerTMCloneTable
                 U putchar@@GLIBC_2.2.5
0000000000000570 t register_tm_clones
000000000000060a T testsym3          # <----------- Есть только символ с obj3
0000000000201028 d __TMC_END__
# nm lib.a
obj1.o:
                 U _GLOBAL_OFFSET_TABLE_
                 U putchar
0000000000000000 T testsym1

obj2.o:
                 U _GLOBAL_OFFSET_TABLE_
                 U putchar
0000000000000000 T testsym2

Исправление cyber_eagle, :

#ls

Makefile  obj1.c  obj2.c  obj3.c
#cat Makefile
%.o: %.c
        gcc -fPIC -c $^ -o $@

lib.a: obj1.o obj2.o
         $(AR) crs $@ $^

lib.so: lib.a obj3.o
        gcc -shared $^ -o $@
#cat obj1.c
void testsym1()
{
        printf("1");
}
#cat obj2.c
void testsym2()
{
        printf("2");
}
#cat obj3.c
void testsym3()
{
        printf("3");
}
------------------------------------------------------------------------------------------------

#make lib.so && nm lib.so

0000000000201028 B __bss_start
0000000000201028 b completed.7697
                 w __cxa_finalize@@GLIBC_2.2.5
0000000000000530 t deregister_tm_clones
00000000000005c0 t __do_global_dtors_aux
0000000000200e18 t __do_global_dtors_aux_fini_array_entry
0000000000201020 d __dso_handle
0000000000200e20 d _DYNAMIC
0000000000201028 D _edata
0000000000201030 B _end
000000000000061c T _fini
0000000000000600 t frame_dummy
0000000000200e10 t __frame_dummy_init_array_entry
00000000000006c8 r __FRAME_END__
0000000000201000 d _GLOBAL_OFFSET_TABLE_
                 w __gmon_start__
0000000000000628 r __GNU_EH_FRAME_HDR
00000000000004e8 T _init
                 w _ITM_deregisterTMCloneTable
                 w _ITM_registerTMCloneTable
                 U putchar@@GLIBC_2.2.5
0000000000000570 t register_tm_clones
000000000000060a T testsym3          # <----------- Есть только символ с obj3
0000000000201028 d __TMC_END__
nm lib.a
obj1.o:
                 U _GLOBAL_OFFSET_TABLE_
                 U putchar
0000000000000000 T testsym1

obj2.o:
                 U _GLOBAL_OFFSET_TABLE_
                 U putchar
0000000000000000 T testsym2

Исходная версия cyber_eagle, :

#ls

Makefile  obj1.c  obj2.c  obj3.c
#cat Makefile
%.o: %.c
        gcc -fPIC -c $^ -o $@

lib.a: obj1.o obj2.o
         $(AR) crs $@ $^

lib.so: lib.a obj3.o
        gcc -shared $^ -o $@
#cat obj1.c
void testsym1()
{
        printf("1");
}
#cat obj2.c
void testsym2()
{
        printf("2");
}
#cat obj3.c
void testsym3()
{
        printf("3");
}
------------------------------------------------------------------------------------------------

#make lib.so && nm lib.so

0000000000201028 B __bss_start
0000000000201028 b completed.7697
                 w __cxa_finalize@@GLIBC_2.2.5
0000000000000530 t deregister_tm_clones
00000000000005c0 t __do_global_dtors_aux
0000000000200e18 t __do_global_dtors_aux_fini_array_entry
0000000000201020 d __dso_handle
0000000000200e20 d _DYNAMIC
0000000000201028 D _edata
0000000000201030 B _end
000000000000061c T _fini
0000000000000600 t frame_dummy
0000000000200e10 t __frame_dummy_init_array_entry
00000000000006c8 r __FRAME_END__
0000000000201000 d _GLOBAL_OFFSET_TABLE_
                 w __gmon_start__
0000000000000628 r __GNU_EH_FRAME_HDR
00000000000004e8 T _init
                 w _ITM_deregisterTMCloneTable
                 w _ITM_registerTMCloneTable
                 U putchar@@GLIBC_2.2.5
0000000000000570 t register_tm_clones
000000000000060a T testsym3          # <----------- Есть только символ с obj3
0000000000201028 d __TMC_END__