Re: [DynInst_API:] rewritten binary returning symbol lookup error.


Date: Thu, 09 Jan 2014 11:36:48 -0600
From: "J. Benton" <bentonj@xxxxxxxxx>
Subject: Re: [DynInst_API:] rewritten binary returning symbol lookup error.
On 1/9/14, 11:20 AM, Bill Williams wrote:
> On 01/09/2014 11:16 AM, J. Benton wrote:
>> On 1/9/14, 10:49 AM, Bill Williams wrote:
>>> On 01/09/2014 02:55 AM, J. Benton wrote:
>>>> Hi everyone,
>>>>
>>>> I'm wondering if you could help me.  Using the examples in the
>>>> programmer's manual as a guide, I generated a simple snippet,
>>>> inserting
>>>> a printf call upon each call to a function. After the binary is
>>>> rewritten I get this error when it is executed:
>>>>
>>>> symbol lookup error: /usr/lib/libdyninstAPI_RT.so: undefined symbol:
>>>> sizeOfAnyHeap1
>>>>
>>>> /usr/lib/libdyninstAPI_RT.so exists.  I've set DYNINST_LIB to
>>>> /usr/lib.
>>>>
>>>> Any ideas?
>>>>
>>> sizeOfAnyHeap1 should show up in an nm of your libdyninstAPI_RT.so,
>>> and libdyninstAPI_RT.so should show up in an ldd of your rewritten
>>> binary, assuming that everything is working correctly. Are either of
>>> those not the case for you?
>>
>> That's a good point. The rewritten binary does not include any libraries
>> in the ldd list.  Modifying the binary generates an empty list in the
>> ldd, even when the original includes a few.
>>
> ...okay, that's weird, and something that should throw some red flags
> to STDERR during the rewriting process I'd expect. If you're not
> getting any errors during the process, can you set
> SYMTAB_DEBUG_REWRITE=1 in your environment, regenerate the modified
> binary, and send us the log that produces?
>
> Also, what version of Dyninst are you working with?

I'm working with Dyninst 8.1.2.  While toying with it, I modded the
program to only insert a printf at "main".

Here's the output:

 createSymbolTables for dc
::driver for emitElf64
Emitting to temporary file dcLKORnw
section .interp addr = 400238 off = 270 size = 1c
section .note.ABI-tag addr = 400254 off = 1254 size = 20
section .note.gnu.build-id addr = 400274 off = 1274 size = 24
section .gnu.hash addr = 400298 off = 1298 size = 38
section .dynsym addr = 4002d0 off = 12d0 size = 498
section .dynstr addr = 400768 off = 1768 size = 1f1
section .gnu.version addr = 40095a off = 195a size = 62
section .gnu.version_r addr = 4009c0 off = 19c0 size = 60
section .rela.dyn addr = 400a20 off = 1a20 size = 90
section .rela.plt addr = 400ab0 off = 1ab0 size = 408
section .init addr = 400eb8 off = 1eb8 size = 1a
section .plt addr = 400ee0 off = 1ee0 size = 2c0
section .text addr = 4011a0 off = 21a0 size = 63d4
section .fini addr = 407574 off = 8574 size = 9
section .rodata addr = 407580 off = 8580 size = da1
section .eh_frame_hdr addr = 408324 off = 9324 size = 36c
section .eh_frame addr = 408690 off = 9690 size = 1464
section .init_array addr = 609e10 off = ae10 size = 8
section .fini_array addr = 609e18 off = ae18 size = 8
section .jcr addr = 609e20 off = ae20 size = 8
section .dynamic addr = 609e28 off = ae28 size = 1d0
section .got addr = 609ff8 off = aff8 size = 8
section .got.plt addr = 60a000 off = b000 size = 170
section .data addr = 60a170 off = b170 size = 24
section .bss addr = 60a1a0 off = b194 size = 8a8
new section .dyninstInst addr = 700000 off = c000 size = 5d0
new section .gnu.hash addr = 7005d0 off = c5d0 size = 490
new section .dynsym addr = 700a60 off = ca60 size = 1068
new section .dynstr addr = 701ac8 off = dac8 size = 80c
new section .gnu.version addr = 7022d4 off = e2d4 size = 15e
new section .gnu.version_r addr = 702432 off = e432 size = 60
new section .rela.dyn addr = 702492 off = e492 size = c0
new section .rela.plt addr = 702552 off = e552 size = 408
new section .dynamic addr = 70295a off = e95a size = 1d0
section .gnu_debuglink addr = 0 off = eb2a size = 34
Existing program header: type 6, offset 0x40, addr 0x3ff040
Existing program header: type 3, offset 0x270, addr 0x400238
Existing program header: type 1, offset 0x0, addr 0x3ff000
Added New program header : offset 0x700000,addr 0x700000 file Size
0x2b2a memsize 0x2b2a
Existing program header: type 1, offset 0xc000, addr 0x700000
Existing program header: type 2, offset 0xe95a, addr 0x70295a
Existing program header: type 4, offset 0x1254, addr 0x400254
Existing program header: type 1685382480, offset 0x9324, addr 0x408324
Existing program header: type 1685382481, offset 0x0, addr 0x0
Existing program header: type 1685382482, offset 0xae10, addr 0x609e10

[← Prev in Thread] Current Thread [Next in Thread→]