public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: kirill@il.ibm.com To: gcc-gnats@gcc.gnu.org Cc: zautner@il.ibm.com Subject: c++/8029: g++ produces ICE on kernel asm implementations of string functions Date: Wed, 25 Sep 2002 02:06:00 -0000 [thread overview] Message-ID: <20020925085731.24700.qmail@sources.redhat.com> (raw) >Number: 8029 >Category: c++ >Synopsis: g++ produces ICE on kernel asm implementations of string functions >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: ice-on-legal-code >Submitter-Id: net >Arrival-Date: Wed Sep 25 02:06:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Kirill Shoikhet >Release: gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-110) >Organization: >Environment: RedHat 7.2 or 7.3 >Description: main.cpp: In function `int main ()': main.cpp:5: Internal error: Segmentation fault. Please submit a full bug report. See <URL:http://bugzilla.redhat.com/bugzilla/> for instructions. >How-To-Repeat: The main.ii file produced by the following command which produces the above error g++ -c -D__KERNEL__ -I /usr/src/linux/include main.c -save-temps >Fix: >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/plain; name="main.ii" Content-Disposition: inline; filename="main.ii" # 1 "main.c" # 1 "/usr/src/linux/include/linux/string.h" 1 # 1 "/usr/src/linux/include/linux/types.h" 1 # 1 "/usr/src/linux/include/linux/config.h" 1 # 1 "/usr/src/linux/include/linux/autoconf.h" 1 # 1 "/usr/src/linux/include/linux/rhconfig.h" 1 # 13 "/usr/src/linux/include/linux/rhconfig.h" # 1 "/boot/kernel.h" 1 # 14 "/usr/src/linux/include/linux/rhconfig.h" 2 # 2 "/usr/src/linux/include/linux/autoconf.h" 2 # 5 "/usr/src/linux/include/linux/config.h" 2 # 6 "/usr/src/linux/include/linux/types.h" 2 # 1 "/usr/src/linux/include/linux/posix_types.h" 1 # 1 "/usr/src/linux/include/linux/stddef.h" 1 # 5 "/usr/src/linux/include/linux/posix_types.h" 2 # 36 "/usr/src/linux/include/linux/posix_types.h" typedef struct { unsigned long fds_bits [(1024/(8 * sizeof(unsigned long)))]; } __kernel_fd_set; typedef void (*__kernel_sighandler_t)(int); typedef int __kernel_key_t; # 1 "/usr/src/linux/include/asm/posix_types.h" 1 # 10 "/usr/src/linux/include/asm/posix_types.h" typedef unsigned short __kernel_dev_t; typedef unsigned long __kernel_ino_t; typedef unsigned short __kernel_mode_t; typedef unsigned short __kernel_nlink_t; typedef long __kernel_off_t; typedef int __kernel_pid_t; typedef unsigned short __kernel_ipc_pid_t; typedef unsigned short __kernel_uid_t; typedef unsigned short __kernel_gid_t; typedef unsigned int __kernel_size_t; typedef int __kernel_ssize_t; typedef int __kernel_ptrdiff_t; typedef long __kernel_time_t; typedef long __kernel_suseconds_t; typedef long __kernel_clock_t; typedef int __kernel_daddr_t; typedef char * __kernel_caddr_t; typedef unsigned short __kernel_uid16_t; typedef unsigned short __kernel_gid16_t; typedef unsigned int __kernel_uid32_t; typedef unsigned int __kernel_gid32_t; typedef unsigned short __kernel_old_uid_t; typedef unsigned short __kernel_old_gid_t; typedef long long __kernel_loff_t; typedef struct { int val[2]; } __kernel_fsid_t; # 47 "/usr/src/linux/include/linux/posix_types.h" 2 # 9 "/usr/src/linux/include/linux/types.h" 2 # 1 "/usr/src/linux/include/asm/types.h" 1 typedef unsigned short umode_t; typedef __signed__ char __s8; typedef unsigned char __u8; typedef __signed__ short __s16; typedef unsigned short __u16; typedef __signed__ int __s32; typedef unsigned int __u32; typedef __signed__ long long __s64; typedef unsigned long long __u64; typedef signed char s8; typedef unsigned char u8; typedef signed short s16; typedef unsigned short u16; typedef signed int s32; typedef unsigned int u32; typedef signed long long s64; typedef unsigned long long u64; typedef u32 dma_addr_t; # 10 "/usr/src/linux/include/linux/types.h" 2 typedef __kernel_fd_set fd_set; typedef __kernel_dev_t dev_t; typedef __kernel_ino_t ino_t; typedef __kernel_mode_t mode_t; typedef __kernel_nlink_t nlink_t; typedef __kernel_off_t off_t; typedef __kernel_pid_t pid_t; typedef __kernel_daddr_t daddr_t; typedef __kernel_key_t key_t; typedef __kernel_suseconds_t suseconds_t; typedef __kernel_uid32_t uid_t; typedef __kernel_gid32_t gid_t; typedef __kernel_uid16_t uid16_t; typedef __kernel_gid16_t gid16_t; typedef __kernel_old_uid_t old_uid_t; typedef __kernel_old_gid_t old_gid_t; # 45 "/usr/src/linux/include/linux/types.h" typedef __kernel_loff_t loff_t; # 54 "/usr/src/linux/include/linux/types.h" typedef __kernel_size_t size_t; typedef __kernel_ssize_t ssize_t; typedef __kernel_ptrdiff_t ptrdiff_t; typedef __kernel_time_t time_t; typedef __kernel_clock_t clock_t; typedef __kernel_caddr_t caddr_t; typedef unsigned char u_char; typedef unsigned short u_short; typedef unsigned int u_int; typedef unsigned long u_long; typedef unsigned char unchar; typedef unsigned short ushort; typedef unsigned int uint; typedef unsigned long ulong; typedef __u8 u_int8_t; typedef __s8 int8_t; typedef __u16 u_int16_t; typedef __s16 int16_t; typedef __u32 u_int32_t; typedef __s32 int32_t; typedef __u8 uint8_t; typedef __u16 uint16_t; typedef __u32 uint32_t; typedef __u64 uint64_t; typedef __u64 u_int64_t; typedef __s64 int64_t; # 123 "/usr/src/linux/include/linux/types.h" struct ustat { __kernel_daddr_t f_tfree; __kernel_ino_t f_tinode; char f_fname[6]; char f_fpack[6]; }; # 9 "/usr/src/linux/include/linux/string.h" 2 # 1 "/usr/src/linux/include/linux/stddef.h" 1 # 10 "/usr/src/linux/include/linux/string.h" 2 extern "C" { extern char * ___strtok; extern char * strpbrk(const char *,const char *); extern char * strtok(char *,const char *); extern char * strsep(char **,const char *); extern __kernel_size_t strspn(const char *,const char *); # 1 "/usr/src/linux/include/asm/string.h" 1 # 1 "/usr/src/linux/include/linux/config.h" 1 # 6 "/usr/src/linux/include/asm/string.h" 2 # 33 "/usr/src/linux/include/asm/string.h" static inline char * strcpy(char * dest,const char *src) { int d0, d1, d2; __asm__ __volatile__( "1:\tlodsb\n\t" "stosb\n\t" "testb %%al,%%al\n\t" "jne 1b" : "=&S" (d0), "=&D" (d1), "=&a" (d2) :"0" (src),"1" (dest) : "memory"); return dest; } static inline char * strncpy(char * dest,const char *src,size_t count) { int d0, d1, d2, d3; __asm__ __volatile__( "1:\tdecl %2\n\t" "js 2f\n\t" "lodsb\n\t" "stosb\n\t" "testb %%al,%%al\n\t" "jne 1b\n\t" "rep\n\t" "stosb\n" "2:" : "=&S" (d0), "=&D" (d1), "=&c" (d2), "=&a" (d3) :"0" (src),"1" (dest),"2" (count) : "memory"); return dest; } static inline char * strcat(char * dest,const char * src) { int d0, d1, d2, d3; __asm__ __volatile__( "repne\n\t" "scasb\n\t" "decl %1\n" "1:\tlodsb\n\t" "stosb\n\t" "testb %%al,%%al\n\t" "jne 1b" : "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3) : "0" (src), "1" (dest), "2" (0), "3" (0xffffffff):"memory"); return dest; } static inline char * strncat(char * dest,const char * src,size_t count) { int d0, d1, d2, d3; __asm__ __volatile__( "repne\n\t" "scasb\n\t" "decl %1\n\t" "movl %8,%3\n" "1:\tdecl %3\n\t" "js 2f\n\t" "lodsb\n\t" "stosb\n\t" "testb %%al,%%al\n\t" "jne 1b\n" "2:\txorl %2,%2\n\t" "stosb" : "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3) : "0" (src),"1" (dest),"2" (0),"3" (0xffffffff), "g" (count) : "memory"); return dest; } static inline int strcmp(const char * cs,const char * ct) { int d0, d1; register int __res; __asm__ __volatile__( "1:\tlodsb\n\t" "scasb\n\t" "jne 2f\n\t" "testb %%al,%%al\n\t" "jne 1b\n\t" "xorl %%eax,%%eax\n\t" "jmp 3f\n" "2:\tsbbl %%eax,%%eax\n\t" "orb $1,%%al\n" "3:" :"=a" (__res), "=&S" (d0), "=&D" (d1) :"1" (cs),"2" (ct)); return __res; } static inline int strncmp(const char * cs,const char * ct,size_t count) { register int __res; int d0, d1, d2; __asm__ __volatile__( "1:\tdecl %3\n\t" "js 2f\n\t" "lodsb\n\t" "scasb\n\t" "jne 3f\n\t" "testb %%al,%%al\n\t" "jne 1b\n" "2:\txorl %%eax,%%eax\n\t" "jmp 4f\n" "3:\tsbbl %%eax,%%eax\n\t" "orb $1,%%al\n" "4:" :"=a" (__res), "=&S" (d0), "=&D" (d1), "=&c" (d2) :"1" (cs),"2" (ct),"3" (count)); return __res; } static inline char * strchr(const char * s, int c) { int d0; register char * __res; __asm__ __volatile__( "movb %%al,%%ah\n" "1:\tlodsb\n\t" "cmpb %%ah,%%al\n\t" "je 2f\n\t" "testb %%al,%%al\n\t" "jne 1b\n\t" "movl $1,%1\n" "2:\tmovl %1,%0\n\t" "decl %0" :"=a" (__res), "=&S" (d0) : "1" (s),"0" (c)); return __res; } static inline char * strrchr(const char * s, int c) { int d0, d1; register char * __res; __asm__ __volatile__( "movb %%al,%%ah\n" "1:\tlodsb\n\t" "cmpb %%ah,%%al\n\t" "jne 2f\n\t" "leal -1(%%esi),%0\n" "2:\ttestb %%al,%%al\n\t" "jne 1b" :"=g" (__res), "=&S" (d0), "=&a" (d1) :"0" (0),"1" (s),"2" (c)); return __res; } static inline size_t strlen(const char * s) { int d0; register int __res; __asm__ __volatile__( "repne\n\t" "scasb\n\t" "notl %0\n\t" "decl %0" :"=c" (__res), "=&D" (d0) :"1" (s),"a" (0), "0" (0xffffffff)); return __res; } static inline void * __memcpy(void * to, const void * from, size_t n) { int d0, d1, d2; __asm__ __volatile__( "rep ; movsl\n\t" "testb $2,%b4\n\t" "je 1f\n\t" "movsw\n" "1:\ttestb $1,%b4\n\t" "je 2f\n\t" "movsb\n" "2:" : "=&c" (d0), "=&D" (d1), "=&S" (d2) :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from) : "memory"); return (to); } static inline void * __constant_memcpy(void * to, const void * from, size_t n) { switch (n) { case 0: return to; case 1: *(unsigned char *)to = *(const unsigned char *)from; return to; case 2: *(unsigned short *)to = *(const unsigned short *)from; return to; case 3: *(unsigned short *)to = *(const unsigned short *)from; *(2+(unsigned char *)to) = *(2+(const unsigned char *)from); return to; case 4: *(unsigned long *)to = *(const unsigned long *)from; return to; case 6: *(unsigned long *)to = *(const unsigned long *)from; *(2+(unsigned short *)to) = *(2+(const unsigned short *)from); return to; case 8: *(unsigned long *)to = *(const unsigned long *)from; *(1+(unsigned long *)to) = *(1+(const unsigned long *)from); return to; case 12: *(unsigned long *)to = *(const unsigned long *)from; *(1+(unsigned long *)to) = *(1+(const unsigned long *)from); *(2+(unsigned long *)to) = *(2+(const unsigned long *)from); return to; case 16: *(unsigned long *)to = *(const unsigned long *)from; *(1+(unsigned long *)to) = *(1+(const unsigned long *)from); *(2+(unsigned long *)to) = *(2+(const unsigned long *)from); *(3+(unsigned long *)to) = *(3+(const unsigned long *)from); return to; case 20: *(unsigned long *)to = *(const unsigned long *)from; *(1+(unsigned long *)to) = *(1+(const unsigned long *)from); *(2+(unsigned long *)to) = *(2+(const unsigned long *)from); *(3+(unsigned long *)to) = *(3+(const unsigned long *)from); *(4+(unsigned long *)to) = *(4+(const unsigned long *)from); return to; } { int d0, d1, d2; switch (n % 4) { case 0: __asm__ __volatile__( "rep ; movsl" "" : "=&c" (d0), "=&D" (d1), "=&S" (d2) : "0" (n/4),"1" ((long) to),"2" ((long) from) : "memory");; return to; case 1: __asm__ __volatile__( "rep ; movsl" "\n\tmovsb" : "=&c" (d0), "=&D" (d1), "=&S" (d2) : "0" (n/4),"1" ((long) to),"2" ((long) from) : "memory");; return to; case 2: __asm__ __volatile__( "rep ; movsl" "\n\tmovsw" : "=&c" (d0), "=&D" (d1), "=&S" (d2) : "0" (n/4),"1" ((long) to),"2" ((long) from) : "memory");; return to; default: __asm__ __volatile__( "rep ; movsl" "\n\tmovsw\n\tmovsb" : "=&c" (d0), "=&D" (d1), "=&S" (d2) : "0" (n/4),"1" ((long) to),"2" ((long) from) : "memory");; return to; } } } # 335 "/usr/src/linux/include/asm/string.h" extern void __struct_cpy_bug (void); # 345 "/usr/src/linux/include/asm/string.h" static inline void * memmove(void * dest,const void * src, size_t n) { int d0, d1, d2; if (dest<src) __asm__ __volatile__( "rep\n\t" "movsb" : "=&c" (d0), "=&S" (d1), "=&D" (d2) :"0" (n),"1" (src),"2" (dest) : "memory"); else __asm__ __volatile__( "std\n\t" "rep\n\t" "movsb\n\t" "cld" : "=&c" (d0), "=&S" (d1), "=&D" (d2) :"0" (n), "1" (n-1+(const char *)src), "2" (n-1+(char *)dest) :"memory"); return dest; } static inline void * memchr(const void * cs,int c,size_t count) { int d0; register void * __res; if (!count) return 0; __asm__ __volatile__( "repne\n\t" "scasb\n\t" "je 1f\n\t" "movl $1,%0\n" "1:\tdecl %0" :"=D" (__res), "=&c" (d0) : "a" (c),"0" (cs),"1" (count)); return __res; } static inline void * __memset_generic(void * s, char c,size_t count) { int d0, d1; __asm__ __volatile__( "rep\n\t" "stosb" : "=&c" (d0), "=&D" (d1) :"a" (c),"1" (s),"0" (count) :"memory"); return s; } # 408 "/usr/src/linux/include/asm/string.h" static inline void * __constant_c_memset(void * s, unsigned long c, size_t count) { int d0, d1; __asm__ __volatile__( "rep ; stosl\n\t" "testb $2,%b3\n\t" "je 1f\n\t" "stosw\n" "1:\ttestb $1,%b3\n\t" "je 2f\n\t" "stosb\n" "2:" : "=&c" (d0), "=&D" (d1) :"a" (c), "q" (count), "0" (count/4), "1" ((long) s) :"memory"); return (s); } static inline size_t strnlen(const char * s, size_t count) { int d0; register int __res; __asm__ __volatile__( "movl %2,%0\n\t" "jmp 2f\n" "1:\tcmpb $0,(%0)\n\t" "je 3f\n\t" "incl %0\n" "2:\tdecl %1\n\t" "cmpl $-1,%1\n\t" "jne 1b\n" "3:\tsubl %2,%0" :"=a" (__res), "=&d" (d0) :"c" (s),"1" (count)); return __res; } extern char *strstr(const char *cs, const char *ct); static inline void * __constant_c_and_count_memset(void * s, unsigned long pattern, size_t count) { switch (count) { case 0: return s; case 1: *(unsigned char *)s = pattern; return s; case 2: *(unsigned short *)s = pattern; return s; case 3: *(unsigned short *)s = pattern; *(2+(unsigned char *)s) = pattern; return s; case 4: *(unsigned long *)s = pattern; return s; } { int d0, d1; switch (count % 4) { case 0: __asm__ __volatile__( "rep ; stosl" "" : "=&c" (d0), "=&D" (d1) : "a" (pattern),"0" (count/4),"1" ((long) s) : "memory"); return s; case 1: __asm__ __volatile__( "rep ; stosl" "\n\tstosb" : "=&c" (d0), "=&D" (d1) : "a" (pattern),"0" (count/4),"1" ((long) s) : "memory"); return s; case 2: __asm__ __volatile__( "rep ; stosl" "\n\tstosw" : "=&c" (d0), "=&D" (d1) : "a" (pattern),"0" (count/4),"1" ((long) s) : "memory"); return s; default: __asm__ __volatile__( "rep ; stosl" "\n\tstosw\n\tstosb" : "=&c" (d0), "=&D" (d1) : "a" (pattern),"0" (count/4),"1" ((long) s) : "memory"); return s; } } } # 515 "/usr/src/linux/include/asm/string.h" static inline void * memscan(void * addr, int c, size_t size) { if (!size) return addr; __asm__("repnz; scasb\n\t" "jnz 1f\n\t" "dec %%edi\n" "1:" : "=D" (addr), "=c" (size) : "0" (addr), "1" (size), "a" (c)); return addr; } # 28 "/usr/src/linux/include/linux/string.h" 2 # 48 "/usr/src/linux/include/linux/string.h" extern int strnicmp(const char *, const char *, __kernel_size_t); # 79 "/usr/src/linux/include/linux/string.h" extern int __builtin_memcmp(const void *,const void *,__kernel_size_t); } # 2 "main.c" 2 int main() { int kuku = strlen("kjfdjhg"); return kuku; }
next reply other threads:[~2002-09-25 9:06 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-09-25 2:06 kirill [this message] 2002-11-24 14:22 bangerth
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20020925085731.24700.qmail@sources.redhat.com \ --to=kirill@il.ibm.com \ --cc=gcc-gnats@gcc.gnu.org \ --cc=zautner@il.ibm.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).