c++ static object destructor

220 views
Skip to first unread message

codefish

unread,
Jun 16, 2010, 9:48:52 AM6/16/10
to android-ndk
hi, all

i used NDK 1.6 r3
my problem is when shared object dlclose(), c++ static object's
destructors are NOT called
i searched this groups but i can't find answer

i read docs/CHANGES.TXT

- __aeabi_atexit(): Fix implementation to properly call C++ static
destructors
when the program exits (or when a shared library is unloaded).

but i can't find blow sections in my shared objects

.init_array INIT_ARRAY
.fini_array FINI_ARRAY

and this is my shared object's dump

ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: DYN (Shared object file)
Machine: ARM
Version: 0x1
Entry point address: 0x11718
Start of program headers: 52 (bytes into file)
Start of section headers: 761828 (bytes into file)
Flags: 0x5000002, has entry point,
Version5 EABI
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 4
Size of section headers: 40 (bytes)
Number of section headers: 30
Section header string table index: 27

Section Headers:
[Nr] Name Type Addr Off Size ES Flg
Lk Inf Al
[ 0] NULL 00000000 000000 000000
00 0 0 0
[ 1] .hash HASH 000000b4 0000b4 002098 04
A 2 0 4
[ 2] .dynsym DYNSYM 0000214c 00214c 0041d0 10
A 3 3 4
[ 3] .dynstr STRTAB 0000631c 00631c 009e06 00
A 0 0 1
[ 4] .rel.dyn REL 00010124 010124 0011a8 08
A 2 0 4
[ 5] .rel.plt REL 000112cc 0112cc 0001b0 08
A 2 6 4
[ 6] .plt PROGBITS 0001147c 01147c 00029c 04
AX 0 0 4
[ 7] .text PROGBITS 00011718 011718 023bf8 00
AX 0 0 4
[ 8] .rodata PROGBITS 00035310 035310 00490c 00
A 0 0 4
[ 9] .ARM.extab PROGBITS 00039c1c 039c1c 002538 00
A 0 0 4
[10] .ARM.exidx ARM_EXIDX 0003c154 03c154 001c90 00
AL 7 0 4
[11] .data.rel.ro PROGBITS 0003ede8 03dde8 0009c0 00
WA 0 0 8
[12] .dynamic DYNAMIC 0003f7a8 03e7a8 0000f0 08
WA 3 0 4
[13] .got PROGBITS 0003f898 03e898 000204 04
WA 0 0 4
[14] .data PROGBITS 0003fa9c 03ea9c 00002c 00
WA 0 0 4
[15] .bss NOBITS 0003fac8 03eac8 000248 00
WA 0 0 8
[16] .comment PROGBITS 00000000 03eac8 00017a
00 0 0 1
[17] .debug_aranges PROGBITS 00000000 03ec48 002290
00 0 0 8
[18] .debug_pubnames PROGBITS 00000000 040ed8 0092be
00 0 0 1
[19] .debug_info PROGBITS 00000000 04a196 029d94
00 0 0 1
[20] .debug_abbrev PROGBITS 00000000 073f2a 00459d
00 0 0 1
[21] .debug_line PROGBITS 00000000 0784c7 015869
00 0 0 1
[22] .debug_frame PROGBITS 00000000 08dd30 0090a4
00 0 0 4
[23] .debug_str PROGBITS 00000000 096dd4 010827 01
MS 0 0 1
[24] .debug_loc PROGBITS 00000000 0a75fb 00f380
00 0 0 1
[25] .debug_ranges PROGBITS 00000000 0b697b 003520
00 0 0 1
[26] .ARM.attributes ARM_ATTRIBUTES 00000000 0b9e9b 00002b
00 0 0 1
[27] .shstrtab STRTAB 00000000 0b9ec6 00011c
00 0 0 1
[28] .symtab SYMTAB 00000000 0ba494 00b4f0 10
29 1845 4
[29] .strtab STRTAB 00000000 0c5984 00c86e
00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor
specific)

There are no section groups in this file.

Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg
Align
EXIDX 0x03c154 0x0003c154 0x0003c154 0x01c90 0x01c90 R
0x4
LOAD 0x000000 0x00000000 0x00000000 0x3dde4 0x3dde4 R E
0x1000
LOAD 0x03dde8 0x0003ede8 0x0003ede8 0x00ce0 0x00f28 RW
0x1000
DYNAMIC 0x03e7a8 0x0003f7a8 0x0003f7a8 0x000f0 0x000f0 RW
0x4

Section to Segment mapping:
Segment Sections...
00 .ARM.exidx

01 .hash .dynsym .dynstr .rel.dyn .rel.plt .plt .text .rodata .ARM.extab .ARM.exidx
02 .data.rel.ro .dynamic .got .data .bss
03 .dynamic

Dynamic section at offset 0x3e7a8 contains 26 entries:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library:
[libISPService.so]
0x00000001 (NEEDED) Shared library: [libc.so]
0x00000001 (NEEDED) Shared library: [libstdc+
+.so]
0x00000001 (NEEDED) Shared library: [libm.so]
0x00000001 (NEEDED) Shared library: [libdl.so]
0x00000001 (NEEDED) Shared library: [liblog.so]
0x00000001 (NEEDED) Shared library:
[libicudata.so]
0x00000001 (NEEDED) Shared library: [libicuuc.so]
0x00000001 (NEEDED) Shared library:
[libicui18n.so]
0x0000000e (SONAME) Library soname:
[libPsEngine.so]
0x00000010 (SYMBOLIC) 0x0
0x00000004 (HASH) 0xb4
0x00000005 (STRTAB) 0x631c
0x00000006 (SYMTAB) 0x214c
0x0000000a (STRSZ) 40454 (bytes)
0x0000000b (SYMENT) 16 (bytes)
0x00000003 (PLTGOT) 0x3f898
0x00000002 (PLTRELSZ) 432 (bytes)
0x00000014 (PLTREL) REL
0x00000017 (JMPREL) 0x112cc
0x00000011 (REL) 0x10124
0x00000012 (RELSZ) 4520 (bytes)
0x00000013 (RELENT) 8 (bytes)
0x00000016 (TEXTREL) 0x0
0x6ffffffa (RELCOUNT) 407
0x00000000 (NULL) 0x0


how can i fix this?

Thanks

David Turner

unread,
Jun 16, 2010, 8:44:11 PM6/16/10
to andro...@googlegroups.com
It is a known bug. The static destructors are called when the program exits(), but not when dlclose() is called.


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


Reply all
Reply to author
Forward
0 new messages