Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22093

R3 register of ARM-Cortex M4F suddenly changes value right after ldr instruction

$
0
0

I have this really strange bug where an ldr instruction first loads in a valid value into the R3 register, then when I use the debugger to step over one instruction, it all of a sudden contains the value 0x0.
This assembly is generated from C++ by GCC9 for C++17.

The instructions are:

ldr r3, [r7, #12]    ; after this instruction r3 will have value 0x20009da0ldr r3, [r3, #8]     ; after this instruction r3 will have value 0x20003e28ldr r3, [r3]         ; after this instruction r3 will have value 0x00020a2c, the value at this addr is 0000a1a9ldr r3, [r3]         ; after this instruction r3 will suddenly have value 0x00000000ldr r2, [r7, #12]        ldr r2, [r2, #8]         mov r0, r2       blx r3               ; at this point r3 still has value 0x00000000 causing the reset handler to be called

Shouldn't r3 have the value 0x0000a1a9 after the last ldr instruction?

To give some more information, I am developing for Microchip's ATSAMD51J20A using Microchip Studio with GCC9 installed.The code in question where this occurs is:

auto& socket = m_device.get_socket();

where get_socket() has as its return value a reference to an interface class and the actual implementation of get_socket() returns a reference to a class which extends this interface.


Viewing all articles
Browse latest Browse all 22093

Trending Articles