Bug 66457 - gcc generates an extra "mov ??, %edx" before "call mcount" when "-pg" is enabled in cross compilation
Summary: gcc generates an extra "mov ??, %edx" before "call mcount" when "-pg" is enab...
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.9.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-08 09:51 UTC by Dangyi Liu
Modified: 2015-06-08 13:41 UTC (History)
0 users

See Also:
Host:
Target: i386-jos-elf
Build:
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 Dangyi Liu 2015-06-08 09:51:07 UTC
# On Darwin, with cross compilation, some code omitted
$ echo 'int main(){}' | i386-jos-elf-gcc -pg -m32 -S -x c -o - -
main:
	pushl	%ebp
	movl	%esp, %ebp
.LP0:
	movl	$.LP0,%edx  # this line
	call	_mcount
	popl	%ebp
	ret
	.ident	"GCC: (GNU) 4.9.2"

# On Linux, some code omitted
$ echo 'int main(){}' | gcc -pg -S -m32 -x c -o - -
main:
	pushl	%ebp
	movl	%esp, %ebp
	call	mcount
	popl	%ebp
	ret
	.ident	"GCC: (Ubuntu 4.8.2-19ubuntu1) 4.8.2"


1. It happens only in cross compilation.
2. The target is i386-jos-elf and the host is Darwin.
3. I've tested with GCC version 4.6.1, 4.6.4 and 4.9.2.
4. How can I disable it?
Comment 1 Andrew Pinski 2015-06-08 09:55:07 UTC
Which compiler are you using to compile the cross compiler on Darwin?  I can't tell if you have tried a cross compiler to elf under linux either, only the native one.
Comment 2 Dangyi Liu 2015-06-08 09:58:58 UTC
(In reply to Andrew Pinski from comment #1)
> Which compiler are you using to compile the cross compiler on Darwin?  I
> can't tell if you have tried a cross compiler to elf under linux either,
> only the native one.

I compiled the cross compiler using clang. Now I'm trying to reproduce this bug under Linux.
Comment 3 Dangyi Liu 2015-06-08 10:20:25 UTC
This still happens on Linux.

$ echo 'int main(){}' | ./i386-jos-elf-gcc -pg -m32 -S -x c -o - -
main:
	pushl	%ebp
	movl	%esp, %ebp
.LP0:
	movl	$.LP0,%edx
	call	_mcount
	popl	%ebp
.LCFI2:
	ret
	.ident	"GCC: (GNU) 4.8.4"

$ ./i386-jos-elf-gcc -v
Using built-in specs.
COLLECT_GCC=./i386-jos-elf-gcc
COLLECT_LTO_WRAPPER=/home/leedy/gcc-4.8.4/bin/libexec/gcc/i386-jos-elf/4.8.4/lto-wrapper
Target: i386-jos-elf
Configured with: ../configure --prefix=/home/leedy/gcc-4.8.4/bin --target=i386-jos-elf --disable-werror --disable-libssp --disable-libmudflap --disable-multilib --disable-nls --without-headers --enable-languages=c
Thread model: single
gcc version 4.8.4 (GCC) 


Did I do something wrong during with the configuration?
Comment 4 Andrew Pinski 2015-06-08 10:27:54 UTC
Yes you don't define  NO_PROFILE_COUNTERS .  That is the default i386-elf target defaults to NO_PROFILE_COUNTERS not being defined.
Comment 5 Andrew Pinski 2015-06-08 10:28:10 UTC
Invalid as explained.
Comment 6 Dangyi Liu 2015-06-08 13:41:02 UTC
(In reply to Andrew Pinski from comment #4)
> Yes you don't define  NO_PROFILE_COUNTERS .  That is the default i386-elf
> target defaults to NO_PROFILE_COUNTERS not being defined.

Thank you very much!!! But I don't know how to define this macro during building phase, and I can't find any useful information using Google. Could you help me ?