arm - Information about Section Index field (st_shndx) in Section SHT_DYNSYM & SHT_SYMTAB -
toolchain: product: arm compiler 5.04 component: arm compiler 5.04 update 1 (build 49)
from elf portable formats specification, version 1.1,
section index field (st_shndx) contains: every symbol table entry ‘‘defined’’ in relation section; member holds relevant section header table index.
i compiling simple object (exports 1 global data & routine) understand various fields of elf
source code (test.c):
__declspec(dllexport) int x21 = 0x100; __declspec(dllexport) void bar21(void) { x21++; }
build script used (build.bat)
armcc -c test.c armlink --bpabi --dll -o test.dll test.o fromelf -cdrsy -o test.txt test.dll
my query usage of st_shndx field of dynsym section & symtab section.
output file (removed few sections keep short)
** section #1 'er_ro' (sht_progbits) [shf_alloc + shf_execinstr] size : 24 bytes (alignment 4) address: 0x00008000 $a .text bar21 0x00008000: e59f000c .... ldr r0,[pc,#12] ; [0x8014] = 0 0x00008004: e5901000 .... ldr r1,[r0,#0] 0x00008008: e2811001 .... add r1,r1,#1 0x0000800c: e5801000 .... str r1,[r0,#0] 0x00008010: e12fff1e ../. bx lr $d 0x00008014: 00000000 .... dcd 0 ** section #2 'er_rw' (sht_progbits) [shf_alloc + shf_write] size : 4 bytes (alignment 4) address: 0x00000000 0x000000: 00 01 00 00 .... ** section #3 '.dynstr' (sht_strtab) size : 32 bytes ** section #4 '.dynsym' (sht_dynsym) size : 80 bytes (alignment 4) string table #3 '.dynstr' last local symbol no. 1 symbol table .dynsym (4 symbols, 1 local) # symbol name value bind sec type vis size ======================================================================== 1 .data 0x00000000 lc 1 sect de 0x4 2 shared_2.dll 0x00000000 gb abs data de 3 x21 0x00000000 gb 1 data pr 0x4 4 bar21 0x00008000 gb 2 code pr 0x14 ** section #5 '.hash' (sht_hash) size : 40 bytes (alignment 4) symbol table #4 '.dynsym' <section truncated> ** section #7 '.version' (sht_gnu_versym) size : 10 bytes (alignment 4) symbol table #4 '.dynsym' <section truncated> ** section #8 '.version_d' (sht_gnu_verdef) size : 56 bytes (alignment 4) string table #3 '.dynstr' <section truncated> ** section #9 '.dynamic' (sht_dynamic) size : 120 bytes (alignment 4) string table #3 '.dynstr' <section truncated> ** section #10 '.debug_frame' (sht_progbits) size : 68 bytes ** section #11 '.symtab' (sht_symtab) size : 176 bytes (alignment 4) string table #12 '.strtab' last local symbol no. 6 symbol table .symtab (10 symbols, 6 local) # symbol name value bind sec type vis size ======================================================================== 1 $a 0x00008000 lc 1 -- de 2 $d 0x00008014 lc 1 -- de 3 $d.realdata 0x00000000 lc 2 -- de 4 shared_2.c 0x00000000 lc abs file de 5 .text 0x00008000 lc 1 sect de 6 .data 0x00000000 lc 2 sect de 0x4 7 buildattributes$$arm_isav4$s$pe$a:l22$x:l11$s22$ieee1$~iw$usesv6$~stkckd$usesv7$~shl$ospace$eba8$standardlib$req8$pres8$eabiv2 0x00000000 gb abs -- hi 8 shared_2.dll 0x00000000 gb abs data de 9 x21 0x00000000 gb 2 data pr 0x4 10 bar21 0x00008000 gb 1 code pr 0x14
section 1 code area (bar21 routine present here)
section 2 rw area (x21 variable present here)
now, if see st_shndx (section index -- marked "sec" in output above) field in dynsym section & symtab section these 2 variables different.
for example: x21 in dynsym points section 1 (code area) & in symtab, points section 2 (rw area)
can me understand why? or guide me resource can more information on this.
regards, raju udava
Comments
Post a Comment