Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARM 'coprocessor' register reads appear to be writing to the wrong location #12

Open
GregIthaca opened this issue Aug 14, 2023 · 0 comments

Comments

@GregIthaca
Copy link

GregIthaca commented Aug 14, 2023

Working with 6.2, configurable machine, ARM Cortex-M. The problem I believe lies here:

stl_p(buf, env->banked_r13[bank_number(ARM_CPU_MODE_USR)]); return 4;

The buf passed to banked_gdb_set_reg is a uint8_t * and this works correctly. However, the buf passed to banked_gdb_get_reg is actually a GByteArray *. The stl_p operation (eventually translated to a memcpy call) writes 4 bytes to the destination of the pointer... which is overwriting the pointer contained in the first member of the GByteArray structure and not actually storing to the byte array. Furthermore, it does not update the length field of the GByteArray. Shortly thereafter, qemu-system-arm terminates with a segmentation violation.

This is pretty easy to reproduce: start the emulator with an appropriate configuration, then (assuming gdb port 1234) connect with arm-none-eabi-gdb:

target remote :1234
info reg

The correct operation here is probably just gdb_get_reg32.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant