Bug 3724 - [ARM]Illegal instruction when profiling optimized code on arm-linux
: [ARM]Illegal instruction when profiling optimized code on arm-linux
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: target
: 3.0
: P2 critical
: 3.4.0
Assigned To: Not yet assigned to anyone
:
: wrong-code
:
:
  Show dependency treegraph
 
Reported: 2001-07-17 18:16 UTC by philr
Modified: 2004-12-13 15:36 UTC (History)
4 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: arm-unknown-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description philr 2001-07-17 18:16:01 UTC
I can run code compiled with -O or -pg, but if I use both, an illegal
instruction halts the program after the first profiled function returns.

Release:
3.0

Environment:
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: arm-unknown-linux-gnu

glibc-2.2.3 (happens under glibc-2.1.3 as well) on an Intel Assabet dev board.

How-To-Repeat:
On host:

$ arm-linux-gcc -v -save-temps -O -pg test.c
Reading specs from /usr/arm_tools/lib/gcc-lib/arm-linux/3.0/specs
Configured with: ../gcc-3.0/configure --target=arm-linux --host=i686-pc-linux
--prefix=/usr/arm_tools --enable-languages=c,c++
Thread model: posix
gcc version 3.0
 /usr/arm_tools/lib/gcc-lib/arm-linux/3.0/cpp0 -lang-c -v -iprefix
/usr/local/bin/../lib/gcc-lib/arm-linux/3.0/ -D__GNUC__=3 -D__GNUC_MINOR__=0
-D__GNUC_PATCHLEVEL__=0 -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__
-D__ELF__ -D__unix -D__linux -Asystem=unix -Asystem=posix -Acpu=arm
-Amachine=arm -D__CHAR_UNSIGNED__ -D__OPTIMIZE__ -D__STDC_HOSTED__=1
-D__ARM_ARCH_3__ -D__APCS_32__ -D__ARMEL__ -D__arm__ test.c test.i
GNU CPP version 3.0 (cpplib) (ARM GNU/Linux with ELF)
ignoring nonexistent directory "/usr/local/lib/gcc-lib/arm-linux/3.0/include"
ignoring nonexistent directory
"/usr/local/lib/gcc-lib/arm-linux/3.0/../../../../arm-linux/sys-include"
ignoring nonexistent directory
"/usr/local/lib/gcc-lib/arm-linux/3.0/../../../../arm-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/arm_tools/lib/gcc-lib/arm-linux/3.0/include
 /usr/arm_tools/lib/../arm-linux/sys-include
 /usr/arm_tools/lib/../arm-linux/include
End of search list.
 /usr/arm_tools/lib/gcc-lib/arm-linux/3.0/cc1 -fpreprocessed test.i -quiet
-dumpbase test.c -O -version -p -o test.s
GNU CPP version 3.0 (cpplib) (ARM GNU/Linux with ELF)
GNU C version 3.0 (arm-linux)
        compiled by GNU C version 3.0.
 /usr/arm_tools/lib/gcc-lib/arm-linux/3.0/../../../../arm-linux/bin/as -o
test.o test.s

$ cat test.i
# 1 "test.c"
void func() {} int main() { func(); }

On target:
$ ./a.out
a.out (268): undefined instruction: pc=4011fd0c
Code: 30292a20 7c7c2029 (616d2a20) 6e656c78 203d2120
Illegal instruction
$
Comment 1 philb 2001-07-18 08:15:48 UTC
From: Philip Blundell <philb@gnu.org>
To: philr@iobjects.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: optimization/3724: Illegal instruction when profiling optimized code on arm-linux 
Date: Wed, 18 Jul 2001 08:15:48 +0100

 --==_Exmh_-1086092172P
 Content-Type: text/plain; charset=us-ascii
 
 >glibc-2.2.3 (happens under glibc-2.1.3 as well) on an Intel Assabet dev board.
 >>Description:
 >I can run code compiled with -O or -pg, but if I use both, an illegal instruct
 >ion halts the program after the first profiled function returns.
 
 I think the bug is actually in glibc.  You might find that you can use 
 "-fno-omit-frame-pointer" as a workaround.
 
 p.
 
 
 
 --==_Exmh_-1086092172P
 Content-Type: application/pgp-signature
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.0.5 (GNU/Linux)
 Comment: Exmh version 2.1.1 10/15/1999 (debian)
 
 iD8DBQE7VTekVTLPJe9CT30RAmyhAJ9gvQ2dqjiLcdSRH57VX2/wh0s9BACfXwSy
 I+SHPoIC7ZW768uzbGl1Mgc=
 =FLSf
 -----END PGP SIGNATURE-----
 
 --==_Exmh_-1086092172P--
Comment 2 Richard Earnshaw 2002-04-02 05:34:00 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: The problem is that we are compiling f() to 
    
    f:
    	bl	mcount
    	mov	pc, lr
    
    Which is clearly broken, since lr is corrupted by the mcount
    call.
Comment 3 CVS Commits 2003-06-14 17:12:07 UTC
Subject: Bug 3724

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	rearnsha@gcc.gnu.org	2003-06-14 17:11:58

Modified files:
	gcc            : ChangeLog 
	gcc/config/arm : linux-elf.h 

Log message:
	PR target/3724
	* arm/linux-elf.h (PROFILE_HOOK): Define.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=1.18214&r2=1.18215
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/arm/linux-elf.h.diff?cvsroot=gcc&r1=1.39&r2=1.40

Comment 4 Richard Earnshaw 2003-06-14 17:15:58 UTC
Fixed.
Comment 5 Andrew Pinski 2004-12-13 15:36:34 UTC
*** Bug 18929 has been marked as a duplicate of this bug. ***