Bug 1033

Summary: i686 + static link + not calling any stdio functions = segfault
Product: uClibc Reporter: Anders Eriksson <denblomstertid>
Component: OtherAssignee: Bernhard Reutner-Fischer <aldot>
Status: RESOLVED FIXED    
Severity: major CC: aldot, uclibc-cvs
Priority: P4 Keywords: patch
Version: 0.9.31   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: Target: i686, kernel 2.6.31
Build: Same as target
Attachments: possible fix
possible fix, without pthreads handling
Alternative fix

Description Anders Eriksson 2010-02-03 18:53:35 UTC
Statically linking (with i686-uclibc-gcc -static) and not making use of any stdio functions seems to always prodiuce programs that segfault. Buildroot was used to build the toolchain, with standard settings.

This is probably related to http://lists.uclibc.org/pipermail/uclibc/2008-December/041623.html
Comment 1 Bernhard Reutner-Fischer 2010-02-03 19:18:50 UTC
http://gcc.gnu.org/PR32219

We can workaround it, but it's not really pretty (using a table to store the addr, and checking that instead seems to work for me. Let me have a look..)
Comment 2 Bernhard Reutner-Fischer 2010-02-03 20:05:40 UTC
trivial testcase:

#include <unistd.h>
#include <stdio.h>

int main(void)
{
	write(1, "write\n", 6);
#ifdef USE_STDIO
	puts("stdio");
#endif
	return 0;
}
Comment 3 Bernhard Reutner-Fischer 2010-02-04 10:17:16 UTC
Created attachment 1033 [details]
possible fix

Please test this patch against master.
Comment 4 Bernhard Reutner-Fischer 2010-02-04 13:25:02 UTC
Created attachment 1039 [details]
possible fix, without pthreads handling
Comment 5 Bernhard Reutner-Fischer 2010-02-21 10:14:41 UTC
Anders,

do you have DOPIC set in your .config?
Comment 6 Denys Vlasenko 2010-05-16 05:14:32 UTC
Created attachment 1735 [details]
Alternative fix
Comment 7 Bernhard Reutner-Fischer 2010-05-17 13:55:46 UTC
(In reply to comment #6)
> Created attachment 1735 [details]
> Alternative fix

applied as 2e53dd645d5348f207cec7f8595969dc566c5a55