실제로는 cortex-m4 컨트롤러에서 gcc 작성 공유 객체 (ELF)로로드되는 공유 객체 로더를 작성합니다. 로딩, 의존성 해결 및 재배치 등은 잘 동작합니다. 하지만 공유 객체에는 .dynsym 섹션에 이상한 심볼이 있습니다.이 심볼은 처리 방법을 알지 못합니다. 공유 객체가 __libc_init_array 기능을 주요 기능 및 참조가 필요합니까 왜dynsym 섹션의 Cortex-M4 이상한 심볼에 공유 객체
readelf
Num: Wert Size Typ Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 000005c8 0 SECTION LOCAL DEFAULT 8
2: 00000874 0 SECTION LOCAL DEFAULT 16
3: 00000000 0 NOTYPE GLOBAL DEFAULT UND printf
4: 0000082d 32 FUNC GLOBAL DEFAULT 12 foo3
5: 0000087c 0 NOTYPE GLOBAL DEFAULT 18 __bss_start__
6: 00000000 0 NOTYPE GLOBAL DEFAULT UND __libc_init_array
7: 00000728 0 NOTYPE GLOBAL DEFAULT 12 _mainCRTStartup
8: 000005c8 0 FUNC GLOBAL DEFAULT 8 _init
9: 00000000 0 NOTYPE GLOBAL DEFAULT UND __libc_fini_array
10: 00000000 0 NOTYPE WEAK DEFAULT UND __deregister_frame_info
11: 00000000 0 NOTYPE WEAK DEFAULT UND _ITM_registerTMCloneTable
12: 00000898 0 NOTYPE GLOBAL DEFAULT 18 __bss_end__
13: 00000728 0 NOTYPE GLOBAL DEFAULT 12 _start
14: 00000000 0 NOTYPE WEAK DEFAULT UND software_init_hook
15: 00000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTab
16: 00000000 0 NOTYPE GLOBAL DEFAULT UND memset
17: 00000000 0 NOTYPE GLOBAL DEFAULT UND main
18: 00000000 0 NOTYPE WEAK DEFAULT UND hardware_init_hook
19: 000005e0 0 FUNC GLOBAL DEFAULT 9 _fini
20: 00000000 0 NOTYPE GLOBAL DEFAULT UND atexit
21: 00000000 0 NOTYPE WEAK DEFAULT UND __stack
22: 00000000 0 NOTYPE GLOBAL DEFAULT UND exit
23: 00000000 0 NOTYPE WEAK DEFAULT UND _Jv_RegisterClasses
24: 00000000 0 NOTYPE WEAK DEFAULT UND __register_frame_info
은 libfoo.so --dyn - SYM? 특히 __libc_init_array에 대한 심볼은 나에게 이해가되지 않습니다 ...이 함수는 __preinit_array, _init 및 __init_array를 normaly로 초기화하지만이 작업은 객체 자체가 아닌 내 로더가 수행해야합니다. 그렇지 않으면 잘못 되었습니까?
모든 종속성이있는로드 된 공유 객체를 초기화하는 방법에 대한 단계별 설명서가 있습니까?
이
내가 내 공유 객체를 구축하는 방법, 방법입니다 :gcc -std=gnu99 -W -Wall -Wstrict-prototypes -Wmissing-prototypes -ffunction-sections -fdata-sections -mfloat-abi=soft -mcpu=cortex-m4 -mthumb -mlong-calls -Os -g -c -fPIC -o foo.o foo.c
gcc -shared -fPIC -Wl,-soname,libfoo.so -T./shared.ld -o libfoo.so foo.o
또 다른 문제는이 다음 -mlong - 통화 옵션을 사용하지 않으면, 내 GCC는 .PLT 섹션에서 잘못된 연산 코드를 생성합니다 .. 내가 뭘 잘못하고있어?
편집 : 내 foo.c를은 우리 모두의 verry 간단하다
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
SECTIONS
{
.interp : { *(.interp) }
.note.ABI-tag : { *(.note.ABI-tag) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.dynamic : { *(.dynamic) }
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.rel.dyn : { *(.rel.dyn) }
.rela.dyn : { *(.rela.dyn) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.plt : { *(.plt) }
.got : { *(.got.plt) *(.got) }
.init ALIGN(32/8) :
{
KEEP (*(.init))
}
.fini ALIGN(32/8) :
{
KEEP (*(.fini))
}
.preinit_array ALIGN(32/8) :
{
PROVIDE(__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE(__preinit_array_end = .);
}
.init_array ALIGN(32/8) :
{
PROVIDE(__init_array_start = .);
KEEP (*(.init_array*))
PROVIDE(__init_array_end = .);
}
.fini_array ALIGN(32/8) :
{
PROVIDE(__fini_array_start = .);
KEEP (*(.fini_array*))
PROVIDE(__fini_array_end = .);
}
.text ALIGN(32/8) :
{
*(.text .text.*)
}
.rodata ALIGN(32/8) :
{
*(.rodata .rodata.*)
}
.data ALIGN(32/8) :
{
*(.data .data.*)
}
.bss ALIGN(32/8) :
{
PROVIDE(__bss_start__ = .);
*(.bss .bss.*)
*(COMMON)
PROVIDE(__bss_end__ = .);
}
}
가주의 사항 :이의 printf 에 대한 참조가 설정이 내 shared.ld는
#include <stdio.h>
#include <string.h>
void foo3 (void)
{
printf("Hello from shared-object");
}
입니다 내 주요 프로그램의 printf에 linktime - testingpurpose.
감사합니다 .-)
foo.c 및 shared.ld에 대한 (트리밍 된) 코드도 제공하면 도움이됩니다. – yugr
"-mlong-calls 옵션을 지정하지 않으면 gcc가 .plt 섹션에서 잘못된 opcode를 생성합니다 ... 내가 뭘 잘못하고있는 걸까요?" - 이것이 최근 binutils에서 재생성되면 [버그 신고] (https://sourceware.org/bugzilla/)해야합니다. – yugr
귀하의 툴체인이 공유 라이브러리를 구축 할 수 있는지 궁금합니다. http://stackoverflow.com/questions/18586291/could-not-build-shared-library-using-toolchain-arm-uclinuxeabi에서 제안 사항을 확인할 수 있습니까? – yugr