[PATCH] Static linking binaries with uClibc

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Thu Feb 4 10:46:58 UTC 2010


On Thu, Feb 04, 2010 at 10:31:31AM +0000, Will Newton wrote:
>On Thu, Feb 4, 2010 at 10:22 AM, Bernhard Reutner-Fischer
><rep.dot.nop at gmail.com> wrote:
>
>Hi Bernhard,
>
>> On Wed, Feb 03, 2010 at 09:07:03PM +0100, Bernhard Reutner-Fischer wrote:
>>>On Wed, Feb 03, 2010 at 04:21:29PM +0000, Will Newton wrote:
>>>>Hello,
>>>>
>>>>I have a problem with linking applications statically with uClibc but
>>>>without including the stdio functions. This issue has been brought up
>>>
>>>See http://bugs.uClibc.org/1033
>>>My theory (which is essentially size-neutral) goes like this, and yes,
>>>it's not pretty but seems to work for me:
>>
>> I've attached a possible fix to the PR.
>
>Thanks for working on this.
>
>I think the patch goes a bit too far however. The problem is only with
>symbols that are weak *and* hidden:
>
>libc/misc/internals/__uClibc_main.c:extern void weak_function
>_stdio_init(void) attribute_hidden;
>libc/misc/internals/__uClibc_main.c:extern void weak_function
>_locale_init(void) attribute_hidden;
>libc/misc/internals/shared_flat_add_library.c:extern void _init(void)
>attribute_hidden weak_function;
>libc/misc/internals/shared_flat_add_library.c:extern void _fini(void)
>attribute_hidden weak_function;
>libc/stdlib/_atexit.c:extern void weak_function _stdio_term(void)
>attribute_hidden;
>libc/stdlib/abort.c:extern void weak_function _stdio_term(void)
>attribute_hidden;
>
>__pthread_initialize_minimal and __errno_location are not hidden so do
>not need to be changed.

I didn't try locale or pthread, but i suggest you backout the errno
stuff and run:
#include <unistd.h>
int main(void){return write("toast\n", 6) != 6;}

If you can confirm that either of the locale hunk or the pthread hunk is
not needed, then we'll certainly drop it. Please let me know.
>
>Also the changes to _stdio.c look like they should be in a separate patch.

ah, yes. i've accidentally changed that, it's of course completely
unrelated.


More information about the uClibc mailing list