AnsweredAssumed Answered

GCC 4.9.4 wait instruction bug?

Question asked by Erik Moqvist on Oct 1, 2017
Latest reply on Feb 22, 2018 by stanish

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!

Outcomes