segfault when running a simple c program on env build with buildroot
Hello All,
I have a small env built with buildroot based on busybox-1.19.2 and uclibc-0.9.32.
I've included gcc into it and I'm trying to build and run the following program but it segfaults:
sh-4.1# cat test.c
int main() { return 0; }
sh-4.1# gcc -o a test.c
sh-4.1# ls -l a
-rwxr-xr-x 1 root root 11553 Feb 9 07:44 a
sh-4.1# ./a
Segmentation fault
sh-4.1# dmesg | tail -1
<6>[634724.545000] a[24405]: segfault at 0 ip (null) sp bfd8fc7c error 4
my buildroot config is attached and the version in use a snapshot from the date 10/9/2011.
any ideas why?
Eial.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: buildroot.config
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20120209/70e1170b/attachment-0001.ksh>
Le Thu, 09 Feb 2012 16:48:30 +0200,
Eial Czerwacki <[email protected]> a ?crit :
Quoted 2 lines
my buildroot config is attached and the version in use a snapshot from the date 10/9/2011.
What is your hardware platform?
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
Le Thu, 09 Feb 2012 16:48:30 +0200,
Eial Czerwacki <[email protected]> a ?crit :
Quoted 1 line
sh-4.1# gcc -o a
test.c
You're using the native gcc on the target, while Buildroot is mostly designed for cross-compilation. Our native gcc on the target mechanism isn't used/tested a lot, so I would really recommend using the cross-compiler on the build machine to build your applications.
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
Quoted 9 lines · Thomas Petazzoni
Le Thu, 09 Feb 2012 16:48:30 +0200,
Eial Czerwacki <[email protected]> a ?crit :Quoted 2 lines
my buildroot config is attached and the version in use a snapshot from the date 10/9/2011.
What is your hardware platform?
Thomas
any generic Intel/AMD cpu
Quoted 11 lines · Thomas Petazzoni
Le Thu, 09 Feb 2012 16:48:30 +0200,
Eial Czerwacki <[email protected]> a ?crit :Quoted 1 line
sh-4.1# gcc -o a
test.cYou're using the native gcc on the target, while Buildroot is mostly designed for cross-compilation. Our native gcc on the target mechanism isn't used/tested a lot, so I would really recommend using the cross-compiler on the build machine to build your applications.
Thomas
I've compiled iasl, dmidecode and biosdecode with same image, you say that I cannot do that?
I need the bin linked to uclibc and my desktop doesn't support uclibc
Thanks,
Eial.
Le Thu, 09 Feb 2012 17:16:51 +0200,
Eial Czerwacki <[email protected]> a ?crit :
Quoted 5 lines
Quoted 3 lines
What is your hardware platform?
Thomas
any generic Intel/AMD cpu
Sorry this does not exist. Your configuration states i686. If your processor is only i486 or i586 compatible, then those segfaults are expected since the generated code might use instructions that do not exist on your processor.
Quoted 3 lines
I've compiled iasl, dmidecode and biosdecode with same image, you say that I cannot do that?
I need the bin linked to uclibc and my desktop doesn't support uclibc
Buildroot generates for you an uClibc cross-compilation toolchain in output/host/usr/bin that you can use to cross-compile applications for the target platform.
Best regards,
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
Quoted 5 lines · Thomas Petazzoni
Le Thu, 09 Feb 2012 17:16:51 +0200,
Eial Czerwacki <[email protected]> a ?crit :Quoted 2 lines
Quoted 2 lines
What is your hardware platform?
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
Thomas
any generic Intel/AMD cpu
Sorry this does not exist. Your configuration states i686. If your processor is only i486 or i586 compatible, then those segfaults are expected since the generated code might use instructions that do not exist on your processor.
correction, the cpus are any cpus from the last 4-5 years, my cpu is e6600 for the matter.
all of them are i686
Quoted 11 lines
Quoted 3 lines
I've compiled iasl, dmidecode and biosdecode with same image, you say that I cannot do that?
I need the bin linked to uclibc and my desktop doesn't support uclibcBuildroot generates for you an uClibc cross-compilation toolchain in output/host/usr/bin that you can use to cross-compile applications for the target platform.
Best regards,
Thomas
that is what I need.
Eial.
Quoted 29 lines · Eial Czerwacki
Quoted 5 lines · Thomas Petazzoni
Le Thu, 09 Feb 2012 17:16:51 +0200,
Eial Czerwacki <[email protected]> a ?crit :Quoted 2 lines
Quoted 2 lines
What is your hardware platform?
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
Thomas
any generic Intel/AMD cpu
Sorry this does not exist. Your configuration states i686. If your processor is only i486 or i586 compatible, then those segfaults are expected since the generated code might use instructions that do not exist on your processor.
correction, the cpus are any cpus from the last 4-5 years, my cpu is e6600 for the matter.
all of them are i686Quoted 8 lines
Quoted 3 lines
I've compiled iasl, dmidecode and biosdecode with same image, you say that I cannot do that?
I need the bin linked to uclibc and my desktop doesn't support uclibcBuildroot generates for you an uClibc cross-compilation toolchain in output/host/usr/bin that you can use to cross-compile applications for the target platform.
Quoted 9 lines
Quoted 3 lines
Best regards,
Thomas
that is what I need.
Eial.
ok, I've found my issue, for some reason, although I was inside the busybox (using chroot to compile it), configure used the host's compiler and not the uclibc based compiler, passing the --host=i686-unknown-linux-uclibc solved this issue.
Thanks for the help.