This is the mail archive of the gdb-prs@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

sim/1282: Thumb add pc,rn should not word align pc


>Number:         1282
>Category:       sim
>Synopsis:       Thumb add pc,rn should not word align pc
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 14 12:08:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     dmcq@tao-group.com
>Release:        GDB-5.3
>Organization:
>Environment:
I'm running the ARM simulator in my own environment and don't actually use GDB or any *nix.
>Description:
The Thumb 'add pc,rn' instruction should I believe jump to the address of the add op+4+contents of rn. However the simulator rounds the result down to a word boundary. I've tested on an ARM7 processor and it gave me my expected results.

The instruction was used to avoid having fixups or affecting r14 in a long branch.
>How-To-Repeat:
If you could run this thumb subroutine somehow:

    .align 4
    mov r0,#2
    add r15, r0
    add r0,#2
    add r0, #2
    add r0, #2
    add r0, #2
    mov r15, r14

it should return 6 and not 8.
>Fix:
I've found this using the latest versions in

    src/sim/arm

The logical place for a fix is

    thumbemu.c 1.5

in the code for 'Format 5' ADD, but it would be out of step with how that's written.

I've attached a proposed fix in diff.txt where the arm2 directory holds the new code for

    armemu.c 1.30
    armemu.h 1.15

where I instead change the code to only do the rounding down in those thumb operation equivalents that should round down, i.e. ADD rn,pc,#imm and LDR rn,[pc,#imm] - so it is a bit less certain of just affecting what should be affected than doing something in thumbemu.c.
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]