Why entry of DT_INIT_ARRAY not relocated

0

Backgroud

We self implements a runtime linker on android to test loading shared library.

The problem is:

When I load libc++.so, I call DT_INIT_ARRAY functions, I found the entry in DT_INIT_ARRAY is not relocated, which caused crash at address 0x6d810. the address is just the entry of INIT_ARRAY. But load another library(libc.so) is ok (i can see relocation for INIT_ARRAY). What's the root cause?

no relocation information with "readelf -r *.so | grep b74" where 'b74' is prefix of INIT_ARRAY address 0xb7468, just show as below:

000b7b74  00002916 R_ARM_JUMP_SLOT        00000000   __fwrite_chk@LIBC_N

I expect I can see the relocation info for address 0xb7468(but another shared lib I can see the relocation info for INIT_ARRAY).

Backtrace

signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr **0x6d810**
F DEBUG   :     eax 0006d810  ebx e8ec5ff4  ecx 00000001  edx e89b0da8
F DEBUG   :     edi fff98e50  esi 10000200
F DEBUG   :     ebp fff98b88  esp fff9800c  eip 0006d810

Readelf -d:

Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libc.so]
 0x00000001 (NEEDED)                     Shared library: [libm.so]
 0x00000001 (NEEDED)                     Shared library: [libdl.so]
 0x0000000e (SONAME)                     Library soname: [libc++.so]
 0x0000001e (FLAGS)                      BIND_NOW
 0x6ffffffb (FLAGS_1)                    Flags: NOW
 0x6000000f (Operating System specific: 6000000f)        0x2b0dc
 0x60000010 (Operating System specific: 60000010)        0x1e5e
 0x00000013 (RELENT)                     8 (bytes)
 0x6fffe000 (Operating System specific: 6fffe000)        0x2cf3c
 0x6fffe001 (Operating System specific: 6fffe001)        0x128
 0x6fffe003 (Operating System specific: 6fffe003)        0x4
 0x00000017 (JMPREL)                     0x2d064
 0x00000002 (PLTRELSZ)                   3472 (bytes)
 0x00000003 (PLTGOT)                     0xb7830
 0x00000014 (PLTREL)                     REL
 0x00000006 (SYMTAB)                     0x2e9c
 0x0000000b (SYMENT)                     16 (bytes)
 0x00000005 (STRTAB)                     0x1112c
 0x0000000a (STRSZ)                      106413 (bytes)
 0x6ffffef5 (GNU_HASH)                   0xd57c
 0x00000019 (INIT_ARRAY)                 0xb7468
 0x0000001b (INIT_ARRAYSZ)               4 (bytes)
 0x0000001a (FINI_ARRAY)                 0xb4000
 0x0000001c (FINI_ARRAYSZ)               8 (bytes)
 0x6ffffff0 (VERSYM)                     0xc29c
 0x6ffffffe (VERNEED)                    0xd51c
 0x6fffffff (VERNEEDNUM)                 2
 0x00000000 (NULL)                       0x0

Objdump -D:

000b7468 <.init_array>:
188732    b7468:   **0006d810**    andeq   sp, r6, r0, lsl r8
android
operating-system
dynamic-linking
libc
libc++
asked on Stack Overflow Feb 3, 2019 by taoozh • edited Feb 3, 2019 by Masoud Mokhtari

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0