Bug 8388 - ARM v4t LDR and LDM of pc should not change mode
Summary: ARM v4t LDR and LDM of pc should not change mode
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: sim (show other bugs)
Version: 5.3
: P3 enhancement
Target Milestone: ---
Assignee: Nick Clifton
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-14 13:08 UTC by dmcq
Modified: 2014-03-14 15:22 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
diff.txt (729 bytes, application/octet-stream)
, dmcq
Details

Note You need to log in before you can comment on or make changes to this bug.
Description dmcq 2003-07-14 13:08:00 UTC
[Converted from Gnats 1283]

In ARM v4 the LDR and LDM and the Thumb v4 POP instructions should not affect the ARM/Thumb mode. This facility was introduced in the v5 architecture (and is implemented in ARM9E but not ARM9 I believe!)

The ARM simulator currently always switches mode depending on whether the bit is set irrespective of whether it is v4 or v5.

Release:
GDB-5.3

Environment:
I'm not actually running gdb or *nix - I'm running the ARM simulator on its own.

How-To-Repeat:
You'd need to switch the v5 switch off and run with thumb enabled to exhibit the problem. calling a routine in ARM mode with bit 0 set should then crash whereas it shouldn't on v4 (t should on v5).
Comment 1 dmcq 2003-07-14 13:08:00 UTC
Fix:
I've attached a diff file showing how I got round the problem with changes to, the new versions are in the arm2 directory.

The diffs were with

sim/arm/armemu   1.30
sim/arm/armemu.h 1.15

in redhat src/sim/arm
Comment 2 Nick Clifton 2014-03-14 14:05:06 UTC
Hi David,

  Thanks for the bug report and patch.  I have now applied your fix to the sources, along with this changelog entry:

Cheers
  Nick

2014-03-14  David McQuillan  <dmcq@tao-group.com>

	PR sim/8388
	* armemu.c (WriteR15Load): New function.  Determines if the state
	can be changed upon a write to R15.
	(LoadMult): Use WriteR15Load.
	* armemu.h (WRITEDESTB): Use WriteR15Load.
Comment 3 Sourceware Commits 2014-03-14 15:22:47 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".

The branch, master has been updated
       via  8d052926671eb0e8c83ffab6d15a98790c215a36 (commit)
       via  b9366cf3955d81e26537ea1932b183dbdf237361 (commit)
      from  e5b98723a5f36c5bc32d465deefd20c334627f5a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8d052926671eb0e8c83ffab6d15a98790c215a36

commit 8d052926671eb0e8c83ffab6d15a98790c215a36
Author: Nick Clifton <nickc@redhat.com>
Date:   Fri Mar 14 15:21:23 2014 +0000

    Add support for instruction level tracing to the ARM simulator.
    
    	* wrapper.c (op_print): New function.
    	(sim_dis_read): New function.
    	(print_insn): New function - disassembles the given instruction.
    	(sim_trace): Note that tracing is now allowed.
    	(sim_create_inferior): Default to emulating v6.
    	Initialise the disassembler machinery.
    	(sim_target_parse_command_line): Add support for -t -d and -z
    	options.
    	(sim_target_display_usage): Note existence of -d and -z options.
    	(sim_open): Parse -t -d and -z options.
    	* armemu.h: Add exports of trace, disas and trace_funcs.
    	Add prototype for print_insn.
    	* armemu.c (ARMul_Emulate26): Add tracing code.
    	Delete unused variables.
    	* thumbemu (handle_v6_thumb_insn): Delete unused variable Rd.
    	Move Rm variable into switch cases.
    	Add tracing code.
    
    	* armcopro.c (XScale_cp15_init): Add a return value.
    	(XScale_cp13_init): Likewise.
    	(XScale_cp14_init): Likewise.
    	(XScale_cp15_LDC): Delete unused function.
    	(XScale_cp15_STC): Likewise.
    	* maverick.c: Delete comment inside comment.
    	(DSPInit): Delete unused function.
    	(DSPMCR4): Fix compile time warning about missing parenthesis.
    	(DSPMCR5): Likewise.
    	(DSPCDP6): Delete unused variable opcode2.

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b9366cf3955d81e26537ea1932b183dbdf237361

commit b9366cf3955d81e26537ea1932b183dbdf237361
Author: David McQuillan <dmcq@tao-group.com>
Date:   Fri Mar 14 14:03:29 2014 +0000

    Prevent writes to R15 via LDR or LDM from changing the ARM/Thumb state in pre-v5 architectures.
    
    	PR sim/8388
    	* armemu.c (WriteR15Load): New function.  Determines if the state
    	can be changed upon a write to R15.
    	(LoadMult): Use WriteR15Load.
    	* armemu.h (WRITEDESTB): Use WriteR15Load.

-----------------------------------------------------------------------

Summary of changes:
 sim/arm/ChangeLog  |   39 +++++++++++++++++
 sim/arm/armcopro.c |   34 +++------------
 sim/arm/armemu.c   |   67 ++++++++++++++++++++++-------
 sim/arm/armemu.h   |   10 ++++-
 sim/arm/maverick.c |   23 +++-------
 sim/arm/thumbemu.c |   70 +++++++++++++++++++-----------
 sim/arm/wrapper.c  |  120 +++++++++++++++++++++++++++++++++++++++++++++++----
 7 files changed, 267 insertions(+), 96 deletions(-)