0

(I'm on Debian 7, arm64)

In order to force vmware-networks to output the log instead of dumping it, I want to modify the logging function. Using IDA on my Windows machine, I found the instruction at .text:0000000000068900 jz loc_689A4.

When running gdb /usr/bin/vmware-networks, the instruction appears:

(gdb) x 0x68900
0x68900:        0x009e840f
(gdb) x/i 0x68900
0x68900:     je     0x689a4

But when trying to breakpoint, I get

(gdb) break *0x68900
Breakpoint 1 at 0x68900
(gdb) run --start
Starting program: /usr/bin/vmware-networks --start
Warning:
Cannot insert breakpoint 1.
Error accessing memory address 0x68900: Input/output error.

and when trying to hot-wire the instruction before going "run", I get (gdb) set *0x68900= 0x009e850f Cannot access memory at address 0x68900

Why is that, and how can I fix it? And yes, I'm running on root, so there (normally) shouldn't be any problems.

Skynet
  • 558
  • 3
  • 16
  • Exact duplicate of [912808](http://stackoverflow.com/questions/912808/after-setting-a-breakpoint-in-qt-gdb-says-error-accessing-memory-address) (same error, and Qt is irrelevant in that question)(googled for `root gdb can't insert breakpoint "input/output"`, first hit for me) –  Jan 01 '13 at 16:10
  • Nope, it is not. See below. – Skynet Jan 01 '13 at 18:02
  • I only see a blank input field ;) Are you typing up an answer? –  Jan 01 '13 at 18:03
  • you're faster than I could type :D – Skynet Jan 01 '13 at 18:08
  • Ah. Well, it is exactly the same issue, it's just that [the best answer](http://stackoverflow.com/a/912870/824425) wasn't chosen ;) That answer mentions that the "breakpoint addresses will be wrong since they're not relocated." –  Jan 01 '13 at 18:33
  • However, this doesn't tell anything about how to actually resolve the relocation – Skynet Jan 01 '13 at 19:28
  • He does. His example is exactly what you do: put a breakpoint on the entry point (or an early function like main), start the process (which breaks on the entry point, at which point relocation and linking is completed), and then install the breakpoint(s) of interest. –  Jan 01 '13 at 20:14
  • He has symbols to set breakpoints on - I don't so I have to do the math myself. – Skynet Jan 02 '13 at 09:34

1 Answers1

0

The problem is that this binary is relocatable. break main followed by run gives you both the old main location as well as the relocated one:

(gdb) break main
Breakpoint 1 at 0x1e990
(gdb) run --start
Starting program: /usr/bin/vmware-networks --start
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, 0x00007ffff7f1a990 in main ()

=> voila, we have a relocation offset of 0x7FFFF7EFC000. Add this to any "old" offset and you have the relocated one for inspecting, editing etc:

(gdb) x/i 0x7FFFF7F64900
0x7ffff7f64900:      je     0x7ffff7f649a4

Relocate the whole binary in IDA so that you have got the proper offsets there, if you want and you're done there, too.

Skynet
  • 558
  • 3
  • 16