Re: [2.6 patch] kill IN_STRING_C

From: linux-os
Date: Mon Nov 08 2004 - 18:02:08 EST

On Mon, 8 Nov 2004, Adrian Bunk wrote:

If you don't compile the code as it would be compiled inside the kernel,
that's your fault...

Please reply only if you can reproduce this with
#include <linux/string.h>, #include <linux/kernel.h> _and_ a gcc command
line as it would be in the kernel - everything else is useless.

I attached a script that duplicates the gcc command line for the
compile and also generates the 'C' code.

Script started on Mon 08 Nov 2004 05:50:54 PM EST
# sh -v

cat >xxx.c <<EOF
KERN=/usr/src/linux-`uname -r`
uname -r
touch xxx.o.d
gcc -Wp,-MD,xxx.o.d -nostdinc -iwithprefix include -D__KERNEL__ -I${KERN}/include -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -O2 -fomit-frame-pointer -Wdeclaration-after-statement -pipe -msoft-float -mpreferred-stack-boundary=2 -march=pentium4 -I${KERN}/include/asm-i386/mach-generic -I${KERN}/include/asm-i386/mach-default -DKVER6 -DMAJOR_NR=178 -DTRUE=1 -DFALSE=0 -DMODULE -DKBUILD_BASENAME=xxx -DKBUILD_MODNAME=Junk -S -o xxx xxx.c
cat xxx
.file "xxx.c"
.section .rodata
.type hello, @object
.size hello, 6
.string "Hello"
.globl xxx
.type xxx, @function
subl $268, %esp
movl %ebx, 264(%esp)
movl $hello, 4(%esp)
leal 8(%esp), %ebx
movl %ebx, (%esp)
call strcpy
movl %ebx, (%esp)
call printk
movl 264(%esp), %ebx
xorl %eax, %eax
addl $268, %esp
.size xxx, .-xxx
.type strcpy, @function
subl $8, %esp
movl 12(%esp), %ecx
movl %esi, (%esp)
movl %edi, 4(%esp)
movl 16(%esp), %esi
movl %ecx, %edi
1: lodsb
testb %al,%al
jne 1b
movl %ecx, %eax
movl (%esp), %esi
movl 4(%esp), %edi
addl $8, %esp
.size strcpy, .-strcpy
.section .note.GNU-stack,"",@progbits
.ident "GCC: (GNU) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)"

# exit

Script done on Mon 08 Nov 2004 05:51:03 PM EST

It clearly invents strcpy, having never been referenced in the

Dick Johnson
Penguin : Linux version 2.6.9 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by John Ashcroft.
98.36% of all statistics are fiction.

Description: Bourne shell script