This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
RE: automatic reference to memset?
- From: Shaya Potter <spotter at cs dot columbia dot edu>
- To: Douglas Richardson <douglas dot richardson at gaussvip dot com>
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: 27 Sep 2002 13:57:40 -0400
- Subject: RE: automatic reference to memset?
- Organization:
- References: <AA067AE32DECD511B8A00002555878BC161F78@mailsrv2.magellan.com>
It's not a kernel module problem, it was the fact that memset isn't a
builtin in gcc 2.95 and therefore when using the gcc extension of
char devpts[15] = "/dev/pts" it requires memset therefore there's a
undefined symbol that has to be resolved.
fixing it is easy enough, and since gcc 2.96 and 3.2 have it as a
builtin, not even a problem for those.
On Fri, 2002-09-27 at 13:52, Douglas Richardson wrote:
> To build a linux kernel module you must define a few things and include a
> few header files.
>
> The book "Linux Device Drivers" will show you how to write a simple module
> quickly. You can view the book in PDF form at
> http://www.xml.com/ldd/chapter/book/bookindexpdf.html.
>
> Douglas Richardson.
>
> -----Original Message-----
> From: Shaya Potter [mailto:spotter@cs.columbia.edu]
> Sent: Thursday, September 26, 2002 23:55
> To: gcc-bugs@gcc.gnu.org
> Subject: automatic reference to memset?
>
>
> with the gcc included in debian ("2.95.4" a "debian prerelease") causes
> gcc to cause a reference to memset to be automatically included. Which
> is very bad as this code is meant to be a snippet of code in a kernel
> module, where obviously memset wont resolve. I remove the devpts
> decleration than there is no problem, so I'm guessing its related to the
> fact that I declare it to be size 15 and I initilize it to a value.
> However, with red hat's gcc "2.96" and debian's gcc-3.2 (also called a
> "debian prerelease") the code seems to compile normally.
>
> this is driving me crazy, so if anyone can help I'd appreciate it
>
> the sample code
>
> extern int original_open(char *, int, int);
>
> int zap_hook_open(char *filename, int flags, int mode)
> {
> unsigned int fd;
> char devpts[15] = "/dev/pts/";
> char pts[4];
>
> fd = original_open(filename, flags, mode);
>
> return fd;
> }
>
> the .s produced
>
> .file "test.c"
> .version "01.01"
> gcc2_compiled.:
> .section .rodata
> .LC0:
> .string "/dev/pts/"
> .globl memset
> .text
> .align 4
> .globl zap_hook_open
> .type zap_hook_open,@function
> zap_hook_open:
> pushl %ebp
> movl %esp,%ebp
> subl $40,%esp
> movl $.LC0,%eax
> movl (%eax),%edx
> movl %edx,-20(%ebp)
> movl 4(%eax),%edx
> movl %edx,-16(%ebp)
> movzwl 8(%eax),%eax
> movw %ax,-12(%ebp)
> leal -10(%ebp),%eax
> addl $-4,%esp
> pushl $5
> pushl $0
> pushl %eax
> call memset
> addl $16,%esp
> addl $-4,%esp
> movl 16(%ebp),%eax
> pushl %eax
> movl 12(%ebp),%eax
> pushl %eax
> movl 8(%ebp),%eax
> pushl %eax
> call original_open
> addl $16,%esp
> movl %eax,-4(%ebp)
> movl -4(%ebp),%edx
> movl %edx,%eax
> jmp .L2
> .p2align 4,,7
> .L2:
> leave
> ret
> .Lfe1:
> .size zap_hook_open,.Lfe1-zap_hook_open
> .ident "GCC: (GNU) 2.95.4 20011002 (Debian prerelease)"