GCC 4.9.4 wait instruction bug?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

GCC 4.9.4 wait instruction bug?

跳至解决方案
1,553 次查看
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!

标签 (1)
1 解答
1,094 次查看
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

在原帖中查看解决方案

4 回复数
1,094 次查看
alexanderfedoto
NXP Employee
NXP Employee
1,095 次查看
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,094 次查看
jschloss
Contributor III

Hi, has this been fixed in 2017.R1? 

0 项奖励
1,094 次查看
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