automatic reference to memset?
Douglas Richardson
douglas.richardson@gaussvip.com
Fri Sep 27 10:59:00 GMT 2002
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)"
More information about the Gcc-bugs
mailing list