Bug 1033 - i686 + static link + not calling any stdio functions = segfault
Summary: i686 + static link + not calling any stdio functions = segfault
Status: RESOLVED FIXED
Alias: None
Product: uClibc
Classification: Unclassified
Component: Other (show other bugs)
Version: 0.9.31
Hardware: PC Linux
: P4 major
Target Milestone: ---
Assignee: Bernhard Reutner-Fischer
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2010-02-03 18:53 UTC by Anders Eriksson
Modified: 2010-05-17 13:57 UTC (History)
2 users (show)

See Also:
Host:
Target: i686, kernel 2.6.31
Build: Same as target


Attachments
possible fix (6.08 KB, patch)
2010-02-04 10:17 UTC, Bernhard Reutner-Fischer
Details
possible fix, without pthreads handling (5.25 KB, patch)
2010-02-04 13:25 UTC, Bernhard Reutner-Fischer
Details
Alternative fix (1.14 KB, patch)
2010-05-16 05:14 UTC, Denys Vlasenko
Details

Note You need to log in before you can comment on or make changes to this bug.
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