This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug sim/18407] New: Bfin simulator - error in handling >>> (S), when shift value > 16
- From: "igorr at gitatechnologies dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Wed, 13 May 2015 05:32:35 +0000
- Subject: [Bug sim/18407] New: Bfin simulator - error in handling >>> (S), when shift value > 16
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=18407
Bug ID: 18407
Summary: Bfin simulator - error in handling >>> (S), when shift
value > 16
Product: gdb
Version: 7.9
Status: NEW
Severity: normal
Priority: P2
Component: sim
Assignee: unassigned at sourceware dot org
Reporter: igorr at gitatechnologies dot com
CC: vapier at gentoo dot org
Target Milestone: ---
1. Let's compile the following code:
$ cat > test1.s
.global __start
__start:
LINK 0xc ;
R1 = 2 ;
R1 = R1 >>> 1;
R1 = 2;
R1 = R1 >> 1;
R1 = 2;
R1 = R1 >>> 1 (S);
R1 = 2;
.byte 0x82, 0xc6, 0xf9, 0x43 ;
UNLINK;
RTS;
$ bfin-linux-uclibc-gcc -nostdlib test1.s -o test1
2. Run objdump on it:
bfin-linux-uclibc-objdump -d test1
test1: file format elf32-bfinfdpic
Disassembly of section .text:
00000074 <__start>:
74: 00 e8 03 00 LINK 0xc; /* (12) */
78: 11 60 R1 = 0x2 (X); /* R1=0x2( 2) */
7a: 82 c6 f9 03 R1 = R1 >>> 0x1;
7e: 11 60 R1 = 0x2 (X); /* R1=0x2( 2) */
80: 82 c6 f9 83 R1 = R1 >> 0x1;
84: 11 60 R1 = 0x2 (X); /* R1=0x2( 2) */
86: 82 c6 f9 43 R1 = R1 << 0x3f (S);
8a: 11 60 R1 = 0x2 (X); /* R1=0x2( 2) */
8c: 82 c6 f9 43 R1 = R1 << 0x3f (S);
90: 01 e8 00 00 UNLINK;
94: 10 00 RTS;
3. Bug/Feature (binutils?) R1 = R1 >>> 1(S) is displayed as R1 = R1 << 0x3f
(S);
4. Let's compile and run this code on VisualDSP++ environment simulator.
in all 4 cases R1 will get the value 0x1 after the shift
5. Let's run the same test in bfin-simulator:
$ bfin-linux-uclibc-gdb test1
GNU gdb (GDB) 7.9
...<skip>
Reading symbols from test1...(no debugging symbols found)...done.
(gdb) b *0x74
Breakpoint 1 at 0x74
(gdb) set disassemble-next-line on
(gdb) target sim
Connected to the simulator.
(gdb) load
Loading section .text, size 0x24 lma 0x74
Start address 0x74
Transfer rate: 288 bits in <1 sec.
(gdb) r
Starting program: ./test1
Breakpoint 1, 0x00000074 in _start ()
=> 0x00000074 <_start+0>: 00 e8 03 00 LINK 0xc; /* (12)
*/
(gdb) display/x $r1
1: /x $r1 = 0x0
(gdb) si
0x00000078 in _start ()
=> 0x00000078 <_start+4>: 11 60 R1 = 0x2 (X); /*
R1=0x2( 2) */
1: /x $r1 = 0x0
(gdb) si
0x0000007a in _start ()
=> 0x0000007a <_start+6>: 82 c6 f9 03 R1 = R1 >>> 0x1;
1: /x $r1 = 0x2
(gdb) si
0x0000007e in _start ()
=> 0x0000007e <_start+10>: 11 60 R1 = 0x2 (X); /*
R1=0x2( 2) */
1: /x $r1 = 0x1
(gdb) si
0x00000080 in _start ()
=> 0x00000080 <_start+12>: 82 c6 f9 83 R1 = R1 >> 0x1;
1: /x $r1 = 0x2
(gdb) si
0x00000084 in _start ()
=> 0x00000084 <_start+16>: 11 60 R1 = 0x2 (X); /*
R1=0x2( 2) */
1: /x $r1 = 0x1
(gdb) si
0x00000086 in _start ()
=> 0x00000086 <_start+18>: 82 c6 f9 43 R1 = R1 << 0x3f (S);
1: /x $r1 = 0x2
(gdb) si
0x0000008a in _start ()
=> 0x0000008a <_start+22>: 11 60 R1 = 0x2 (X); /*
R1=0x2( 2) */
1: /x $r1 = 0x7fffffff
(gdb)
6. Bug. After the last shift R1 should be equal to 0x1. Saturated shift Right
is treated as saturated shift left.
--
You are receiving this mail because:
You are on the CC list for the bug.