Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between "program counter" and "start address"

Tags:

c

embedded

gdb

I am using GDB to load an executable on an embedded device. When loading the executable, GDB says:

xPSR: 0x01000000 pc: 0xf0094902 msp: 0x2001b508
Loading section .text, size 0x16240 lma 0x8000000
Loading section .data, size 0x8f0 lma 0x8016240
Start address 0x8000000, load size 92976

As I understand, the pc is the instruction pointer. I am assuming that "start address" is the starting address for the pc. However, in the information GDB is giving me, the start address (0x8000000, which is incidentally the same as .text) is not the same as the pc (0xf0094902).

What is the difference between pc and start address? Does is make sense to have the start address be the same as .text?

like image 982
Randomblue Avatar asked Mar 22 '12 13:03

Randomblue


2 Answers

I assume the program counter is the current value after you loaded but before you started running. When you start running, then depending on the processor of course, but it most likely describes the address to start executing that loaded code, the address to set the program counter before allowing the processor to run again. If you run then stop quickly you should see something in the .text range for the pc 0x80000000 + 0x16240

like image 91
old_timer Avatar answered Nov 03 '22 18:11

old_timer


The "start address" referred to here is the start of the binary image, not the execution start address. The start address for execution is whatever is held in the reset vector (assuming you are using Cortex-M3 as before?).

like image 34
Clifford Avatar answered Nov 03 '22 18:11

Clifford