Bug 2431 - Binaries statically linked with uclibc segfault on __uClibc_main on i686
Summary: Binaries statically linked with uclibc segfault on __uClibc_main on i686
Status: RESOLVED FIXED
Alias: None
Product: uClibc
Classification: Unclassified
Component: Other (show other bugs)
Version: 0.9.31
Hardware: PC Linux
: P5 critical
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-25 00:06 UTC by Lluís
Modified: 2011-01-11 18:54 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lluís 2010-08-25 00:06:31 UTC
Hello,

I'm just trying to link a simple C program writing to stdout with printf, and it segfaults before entering the main(). Any program I tried to built linked with this toolchain, ends in segfault.

My toolchain has gcc 4.5.1 (with ppl), uclibc 0.9.31 (the same happened with 0.9.30.3), binutils 2.20.1, all natively built on i686-linux.

The same combination on x86_64-linux works perfectly.

The command line I use is: gcc -o program -static program.c

Here is the gdb session:
Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
(gdb) bt
#0  0x00000000 in ?? ()
#1  0x08049348 in __uClibc_main ()
#2  0x00000000 in ?? ()
(gdb) f 1
#1  0x08049348 in __uClibc_main ()
(gdb) disassemble 
Dump of assembler code for function __uClibc_main:
........
   0x08049330 <+427>:   sub    %eax,%esi
   0x08049332 <+429>:   sar    $0x2,%esi
   0x08049335 <+432>:   jmp    0x804933f <__uClibc_main+442>
   0x08049337 <+434>:   call   *-0x3c(%ebx,%edi,4)
   0x0804933e <+441>:   inc    %edi
   0x0804933f <+442>:   cmp    %esi,%edi
   0x08049341 <+444>:   jb     0x8049337 <__uClibc_main+434>
   0x08049343 <+446>:   call   0x0
=> 0x08049348 <+451>:   movl   $0x0,(%eax)
   0x0804934e <+457>:   call   0x0
   0x08049353 <+462>:   movl   $0x0,(%eax)
   0x08049359 <+468>:   mov    -0x1c(%ebx),%eax
   0x0804935f <+474>:   push   %ecx
   0x08049360 <+475>:   pushl  (%eax)
.........
Comment 1 Lluís 2010-10-28 22:36:46 UTC
Building with DODEBUG y makes all work.

Maybe it is a gcc problem? This last time when I tried I was using gcc 4.5.1.

As a note apart, uclibc 0.9.30.3 failed in the same way for me.
Comment 2 Bernhard Reutner-Fischer 2010-10-29 09:30:48 UTC
This should be fixed on trunk. Which version are you using?
Comment 3 Lluís 2010-10-29 12:36:37 UTC
I tried only the last released (0.9.31) and 0.9.30.3.
Comment 4 Bernhard Reutner-Fischer 2011-01-11 18:54:14 UTC
This is supposedly fixed for 0.9.32-rc1 onward. Please reopen if you still experience the same problem.
Thanks for the report!