Re: [PATCH/RFC] m68k: Add -ffreestanding to KBUILD_CFLAGS

From: Geert Uytterhoeven
Date: Fri Apr 12 2013 - 15:48:08 EST


On Thu, Apr 11, 2013 at 8:04 PM, Geert Uytterhoeven
<geert@xxxxxxxxxxxxxx> wrote:
> On Wed, Apr 10, 2013 at 5:22 PM, Michal Marek <mmarek@xxxxxxx> wrote:
>> Subject: [PATCH] m68k: Remove inline strlen() implementation
>>
>> GCC can replace a strncat() call with constant second argument into a
>> strlen + store, which results in a link error:
>>
>> ERROR: "strlen" [net/ipv4/ip_tunnel.ko] undefined!
>>
>> The inline function is a simple for loop in C. Other architectures
>> either use an asm optimized variant, or use the generic function from
>> lib/string.c.
>>
>> Reported-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
>> Signed-off-by: Michal Marek <mmarek@xxxxxxx>
>
> Thanks, this one works. Let me do some measurements...

No visible impact on size for a typical build; the increase in .text
is offset by
the decrease in .data:

- .text : 0x00001000 - 0x002aab64 (2727 KiB)
- .data : 0x002ad938 - 0x00392148 ( 915 KiB)
+ .text : 0x00001000 - 0x002aac74 (2728 KiB)
+ .data : 0x002ada48 - 0x00392148 ( 914 KiB)

On Wed, Apr 10, 2013 at 5:22 PM, Michal Marek <mmarek@xxxxxxx> wrote:
> On Wed, Apr 10, 2013 at 04:19:14PM +0200, Geert Uytterhoeven wrote:
>> Thanks for the patch, but modpost still fails with
>>
>> ERROR: "strlen" [net/ipv4/ip_tunnel.ko] undefined!
>
> OK OK, I am convinced. Then how about this? If you prefer speed over
> size, the the other option is to add
>
> size_t strlen(const char *s)
> {
> return __kernel_strlen(s);
> }
> EXPORT_SYMBOL(strlen);
>
> to arch/m68k/lib/string.c.

Interestingly, this also doesn't work. It turns out none of the
symbols defined in
this file (currently strcpy and strcat) end up in vmlinux.

As we've been stripping code from string.c, we've been left with just
a few symbols
that are typically never referenced, so the whole string.o in
arch/m68k/lib/lib.a
is not included in the final vmlinux.

So more stringectomy to do...

> On a related note, arch/m68k/lib/string.c is
> built only in the CONFIG_MMU case, whereas asm/string.h is shared.

So due to the above, this difference is mostly moot ;-)

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/