DynamoRIO / DynamoRIO/dynamorio
Usage error: encoding failed re-relativizing rip-relative address for base_unittests with native_exec
- Dominant language
- C
- Stars
- 3.2k
- Forks
- 629
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 31
Description
_From [zhao...@google.com](https://code.google.com/u/106321947286816917100/) on November 21, 2013 15:12:25_
~/Workspace/LLVM/dr/exports/bin64/drrun -early -debug -msgbox_mask 0xf -native_exec_list base_unittests -native_exec_retakeover -native_exec_opt -disable_traces -c ~/Workspace/LLVM/llvm-build/lib/clang/3.4/lib/linux/libclang_rt.msandr-x86_64.so -- ./out/Debug/base_unittests
When enable native_exec, initialize_plt_stub_template is called to initialize the plt stub template.
instrlist_append(ilist, INSTR_CREATE_mov_imm(dc, opnd_create_reg(DR_REG_R11), OPND_CREATE_INTPTR(0)));
instrlist_append(ilist, INSTR_CREATE_jmp_ind(dc, opnd_create_rel_addr(0, OPSZ_PTR)));
The second instr INSTR_CREATE_jmp_ind(dc, opnd_create_rel_addr(0, OPSZ_PTR)) causes problem.
(gdb) where
#0 instr_allocate_raw_bits (dcontext=0xffffffffffffffff, instr=0x7f6f4cd40900, num_bytes=6) at /home/zhaoqin/Workspace/LLVM/dr/core/x86/instr.c:2624
#1 0x0000000071255917 in private_instr_encode (dcontext=0xffffffffffffffff, instr=0x7f6f4cd40900, always_cache=false)
at /home/zhaoqin/Workspace/LLVM/dr/core/x86/instr.c:2002
#2 0x0000000071256fb5 in instr_length (dcontext=0xffffffffffffffff, instr=0x7f6f4cd40900) at /home/zhaoqin/Workspace/LLVM/dr/core/x86/instr.c:2790
#3 0x00000000712340fd in instrlist_encode_to_copy (dcontext=0xffffffffffffffff, ilist=0x7f6f4cd41248, copy_pc=0x7161f240 "", final_pc=0x0,
max_pc=0x7161f250 "", has_instr_jmp_targets=false) at /home/zhaoqin/Workspace/LLVM/dr/core/x86/encode.c:2827
#4 0x0000000071310287 in initialize_plt_stub_template () at /home/zhaoqin/Workspace/LLVM/dr/core/unix/native_elf.c:190
In instr_allocate_raw_bits:
byte \* new_bits = (byte *) heap_alloc(dcontext, num_bytes HEAPACCT(ACCT_IR));
...
instr->bytes = new_bits;
(gdb) p new_bits
$18 = (byte *) 0x7f6f4cd613d8
so later in copy_and_re_relativize_raw_instr:
where it tries to encode it to 0x7161f24a , the target is
(gdb) p target
$24 = (byte *) 0x7f6f00000000
```
Start Addr End Addr Size Offset objfile
0x71000000 0x713bd000 0x3bd000 0x0 /usr/local/google/home/zhaoqin/Workspace/LLVM/dr/exports/lib64/debug/libdynamorio.so.4.1
0x715bd000 0x71605000 0x48000 0x3bd000 /usr/local/google/home/zhaoqin/Workspace/LLVM/dr/exports/lib64/debug/libdynamorio.so.4.1
...
0x7f6f4cd55000 0x7f6f4cd63000 0xe000 0x0
0x7f6f4cd63000 0x7f6f4cd65000 0x2000 0x0
0x7f6f4cd65000 0x7f6f4cd66000 0x1000 0x0
...
0x7f6fc53cf000 0x7f6fccb30000 0x7761000 0x0 /usr/local/google/home/zhaoqin/Workspace/Chrome/chromium.git/src/out/Debug/base_unittests
0x7f6fccb30000 0x7f6fce24e000 0x171e000 0x7761000 /usr/local/google/home/zhaoqin/Workspace/Chrome/chromium.git/src/out/Debug/base_unittests
```
So it is the result of separate library from the heap used by DR.
_Original issue: http://code.google.com/p/dynamorio/issues/detail?id=1326_
Contributor guide
Assessment
This issue has not been assessed yet.