[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#862514: Gcc creates illegal instructions when combining C + ASM on arm on sid



Hello Jussi,

On Sun, May 14, 2017 at 12:09:42AM +0300, Jussi Pakkanen wrote:
> Package: gcc
> Version: 6.3.0-4
> 
> Gcc creates binaries that fail with "invalid instruction". To
> reproduce create the following main.c:
> 
>  int get_retval(void);
> 
> int main(int argc, char **argv) {
>   return get_retval();
> }
> 
> and the following retval-arm.S
> 
> .text
> .globl get_retval
> 
> get_retval:
>         mov     r0, #0
>         bx      lr
> 
> Compile like this:
> 
> gcc -o prog main.c retval-arm.S

I cannot reproduce this on a Marvell Armada XP Development Board
(DB-MV784MP-GP) (i.e. abel.debian.org) using gcc 4:6.3.0-4. Can you
please provide the output of

	objdump -d 

?

> The result crashes. However if you add -march=armv7 the executable
> works (-march=native crashes also).
> 
> This only happens on GCC using the version in Sid. It works when using
> any version of Clang and also when using GCC in Jessie.
> 
> Originally reported here: https://github.com/mesonbuild/meson/issues/1776

Looking there I wonder about:

	The assembly output as written by gdb at the point of crash
	looks like this:

	0x54aaaf48      mrc2   15, 7, r6, cr5, cr15, {7} 

because 0x54aaaf48 isn't a mrc2 instruction, neither using Thumb nor
Arm ISA. Also the bug report mentions that when compiling for armv5 the
compiler warns about the target CPU not supporting Thumb.
(I'd expect the mrc2 instruction above to compile to fef56fff for both
ARM and Thumb.)

Given that the Raspberry Pi uses an ARM1176JZF-S (i.e. ARMv6) and MRC2
is only supported since ARMv6T2 (in Thumb), I wonder if the problem is
somewhere there.

Best regards
Uwe

Attachment: signature.asc
Description: PGP signature


Reply to: