Reputation: 19
I am trying to emulate a 'C' program by using qemu instruction level simulator.The 'C' program is compiled by issuing the following command
arm-none-linux-gnueabi-gcc -g ex_qsort.c -o ex_qsort_lin_work
I then start qemu with the following command
"qemu-arm -g 1234 -L /path/to/codesourcery/arm-none-linux-gnueabi/libc ./ex_qsort_lin_work"
Then I connect to the program using gdb. I am trying to access program memory location and change the assembly code. But when i try to access the memory I get the following error
(gdb) x 0x00008510
0x8510 <main+76>: 0xe3530004
(gdb) set *(0x8510) = 0xe3530002
Cannot access memory at address 0x8510
I am not sure why this error occurs . Gdb does not give any other warning . When i start gdb I have the sysroot pointed to the arm library. However when i check for the shared libarary I get the following message
(gdb) info sharedlibrary
From To Syms Read Shared Object Library
0xf67d67d0 0xf67f0f58 Yes (*) /path/to/codesourcery/arm-none-linux-gnueabi/libc/lib/ld-linux.so.3
(*): Shared library is missing debugging information.
Not sure if this causes the problem. Statically linking the libraries also does not help My aim is to change the instruction at a given address
Upvotes: 0
Views: 2376
Reputation: 126546
The issue is that the memory you are trying to modify is read-only. It looks like you're trying to modify code in the text segment of the executable, which is normally mapped read-only, so that is not unexpected. If you want to be able to modify it, it needs to be mapped as writable.
You can build an executable with a writable text segment (so it will load as writable by default) by linking with the -N
flag -- use either -Xlinker -N
or -Wl,-N
on your gcc command line.
Upvotes: 1