2

when I disassemble an OpenCV dynamic library file (libopencv_imgproc.so), I find that there are a lot of bl instructions which target address are in the .plt section. But, I could'n find its symbol info.

00110ee0 <cvResize>:
  110ee0:   b5f0        push    {r4, r5, r6, r7, lr}
  110ee2:   4603        mov r3, r0
  110ee4:   b0bf        sub sp, #252    ; 0xfc
  ...
  110ef4:   4ca8        ldr r4, [pc, #672]  ; (111198 <cvResize+0x2b8>)
  110ef6:   9500        str r5, [sp, #0]
  110ef8:   f70e ebda   blx 1f6b0 <_init+0x2b4>
  ...

I could not find the address 1f6b0 in the .text section. It actually is in the .plt section. However, I couldn't find it in the symbol table. How can I get these missed symbol info?

1

Doing it the hard way:

  1. disassemble the target PLT stub and figure out what pointer it's using. E.g.:

    359dc:  e28fc601    add ip, pc, #1048576    ; 0x100000
    359e0:  e28ccaa2    add ip, ip, #663552 ; 0xa2000
    359e4:  e5bcf900    ldr pc, [ip, #2304]!    ; 0x900
    

    Here, the ip will be: 0x359e4+0x100000+0xa2000 = 0x1D79E4, so the last LDR will dereference 1D79E4+0x900 = 0x1D82E4.

  2. look up the address in the list of relocs (objdump -dr):

    001d82e4  00005216 R_ARM_JUMP_SLOT   00000000   _ZN2cv10cvarrToMatEPKv
    

Doing it the easy way:

  1. Just use IDA :), or at least a newer objdump which knows about PLT stubs.

    000359dc <_ZN2cv10cvarrToMatEPKvbbi@plt>:
    

Please note that objdump relies on the fact that the order of PLT stubs usually matches the order of relocations in the PLT reloc list. In theory, one can patch a PLT stub after linking so it uses another symbol's pointer.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.