[patch] Fix PR tdep/12352: Handle str pc, [Rd, #imm] in displaced stepping
Ulrich Weigand
uweigand@de.ibm.com
Wed Feb 9 13:51:00 GMT 2011
Yao Qi wrote:
> I am afraid they are not equal to each other. The intention of this
> complicated insn sequence is used to compute the implementation-defined
> constant offset of `str pc'. See more explanations below.
>
> http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204g/Cihbjifh.html
>
> Section "Saving from r15"
> [...]
> If you do save from r15, the value saved is the address of the current
> instruction, plus an implementation-defined constant. The constant is
> always the same for a particular processor.
> If your assembled code might be used on different processors, you can
> find out what the constant is at runtime using code like the following:
>
> SUB R1, PC, #4 ; R1 = address of following STR instruction
> STR PC, [R0] ; Store address of STR instruction + offset,
> LDR R0, [R0] ; then reload it
> SUB R0, R0, R1 ; Calculate the offset as the difference
Yes, I'm aware of that. However, my understanding is that this special
definition of STR PC applies to *all* variants of STR, including PUSH
(PUSH { PC } is just another mnemonic for STR PC, [ SP, #-4 ]).
If you look at the formal semantics definition in the ARM reference
manual, all variants of STR (including PUSH) use the pseudo-code macro
"PCStoreValue" to implement storing of the PC, which is defined to
include the implementation-defined constant ...
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
More information about the Gdb-patches
mailing list