GCC 4.9.4 wait instruction bug?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

GCC 4.9.4 wait instruction bug?

Jump to solution
2,019 Views
erikmoqvist
Contributor I

Hello,

I'm using powerpc-eabivle-gcc 4.9.2 (S32DS 1.1), but want to switch to 4.9.4 (S32DS 1.2). However, it seems there is a problem with the wait-instruction encoding in 4.9.4. To illustrate the problem the file test.c (see below) is compiled with gcc 4.9.2 and 4.9.4, and the object files are disassembled to show the difference in the instructions.

The C source file test.c:

int test()
{
    asm volatile ("wait");
}

Output using GCC 4.9.2:

$ powerpc-eabivle-gcc -mvle -O2 -c -o test-4.9.2.o test.c
$ powerpc-eabivle-objdump -d test-4.9.2.o > test-4.9.2.o.dis

$ cat test-4.9.2.o.dis

test-4.9.2.o: file format elf32-powerpc


Disassembly of section .text:

00000000 <test>:
0: 7c 00 00 7c wait
4: 00 04 se_blr

Output using GCC 4.9.4:

$ powerpc-eabivle-gcc -mvle -O2 -c -o test-4.9.4.o test.c
$ powerpc-eabivle-objdump -d test-4.9.4.o > test-4.9.4.o.dis

$ cat test-4.9.4.o.dis

test-4.9.4.o: file format elf32-powerpc


Disassembly of section .text:

00000000 <test>:
0: 7c 00 00 3c .long 0x7c00003c
4: 00 04 se_blr

For some reason the wait-instruction becomes 0x7c00007c with 4.9.2 and 0x7c00003c with 4.9.4. Also note that the disassembler fails to decode the 4.9.4 instruction and outputs a general .long value.

Is this the expected behavior, a bug in gcc/binutils, or something else? Looks like a bug to me.

Thanks!

Labels (1)
1 Solution
1,560 Views
stanish
NXP Employee
NXP Employee

Hello Erik,

Thanks for this report.

The correct opcode for wait instruction is  0x7C00007C 

I'd recommend you to use a direct instruction opcode as a workaround:

__asm (".long 0x7C00007C")

I'm going to log this issue as a defect into our defect tracking database

Stan

View solution in original post

4 Replies
1,560 Views
alexanderfedoto
NXP Employee
NXP Employee
1,561 Views
stanish
NXP Employee
NXP Employee

Hello Erik,

Thanks for this report.

The correct opcode for wait instruction is  0x7C00007C 

I'd recommend you to use a direct instruction opcode as a workaround:

__asm (".long 0x7C00007C")

I'm going to log this issue as a defect into our defect tracking database

Stan

1,560 Views
jschloss
Contributor III

Hi, has this been fixed in 2017.R1? 

0 Kudos
Reply
1,560 Views
stanish
NXP Employee
NXP Employee

Hi,

This fix is NOT available in the latest version of S32DS 2017.R1.

Anyway the issue has been already fixed but haven't released it yet.

Currently the product team is scheduling when and how to release this update.

Stan