My question is related to In the ARM ABI, how are global variables accessed? but is somewhat different.
I'm trying to debug an issue and for that I went looking in the build outputs of my project. I consider an ARM cortex-M processor.
I have a global variable and I wanted to see in the disassembly code where is accessed. I looked at the map file and saw it indeed appears as a symbol. However, as suggested in the referenced question, I cannot see its label or it address in my disassembly.
I presume this means it is always accessed via some other address + a shift.
Presumably there are many load access occurrences. Is there any effective way to locate access to this global variable in the disassembly?
Edit per Comments:
- I have the source code. I'm looking at the disassembly for debugging something.
- I'm not using gcc but clang
- the code is bare metal Code that uses interrupts and no dynamic memory allocations.
My motivation is two fold:
- First I wish to expand my horizons and learn.
- I wonder regarding access times. When looking at the disassembly, it seems access to global a is more involved and requires more instructions than local variables.
ldr RX, [PC, #YY]as you can see in the accepted answer to your reference question. At the value [PC, #YY] is the address of the global. System to system, a global maybe relative or absolute. The '[PC,#YY]' places the absolute address in a relative code section; this is typical, but you could be REing a system with relative access.volatile]...staticandstructwith class).