2015-10-05 137 views
0

我与gcc-3.3.4工作。我正在做的是伪造一些东西。 当我编译使用我的文件gcc -O0 -g -fomit-frame-pointer -I/usr/src/kernel-headers-2.4.26-1/include sleep.c -o sleep.exe 我得到以下问题:编译错误 - 语法错误,并且不完整的类型

msync-sleep.c:47: error: parse error before "wait_queue_head_t" 
msync-sleep.c:47: warning: no semicolon at end of struct or union 
msync-sleep.c:81: error: field `i_sem' has incomplete type 
msync-sleep.c:83: error: field `i_zombie' has incomplete type 
msync-sleep.c:87: error: parse error before "wait_queue_head_t" 
msync-sleep.c:87: warning: no semicolon at end of struct or union 
msync-sleep.c:90: error: parse error before '}' token 
msync-sleep.c:93: error: parse error before "atomic_t" 
msync-sleep.c:93: warning: no semicolon at end of struct or union 
msync-sleep.c:96: error: parse error before '}' token 
msync-sleep.c:103: error: parse error before "atomic_t" 
msync-sleep.c:103: warning: no semicolon at end of struct or union 
msync-sleep.c:105: error: parse error before '}' token 
msync-sleep.c:149: error: field `fake_dentry' has incomplete type 
msync-sleep.c:150: error: field `fake_inode' has incomplete type 
msync-sleep.c:151: error: field `fake_mapping' has incomplete type 
msync-sleep.c:152: error: field `fake_ops' has incomplete type 
msync-sleep.c:153: error: field `dirty_page' has incomplete type 

我认为这个问题是来自我的定义的一部分。这里是我的代码的一部分:

#include <stdio.h>  /* fprintf */ 
#include <stdlib.h>  /* exit */ 
#include <string.h>  /* memset */ 
#include <sys/mman.h>  /* mmap */ 
#include <sys/types.h>  /* pthread types */ 
#include <sys/stat.h>  /* fchmod */ 
#include <pthread.h>  /* thread primitives */ 
#include <fcntl.h>  /* open */ 
#include <unistd.h>  /* ftruncate */ 
#include <errno.h>  /* errno */ 

#include "linux/elf.h"  /* for elf struct defs */ 

#include "asm-i386/unistd.h" /* uselib system call */ 
#include "asm-i386/page.h"  /* PAGE_SIZE */ 

#define LIB_ADDR 0xaabbccdd /* memorable random address */ 
#define LIB_FILE "sleepylib" 
#define UNMAP_FILE "unmapfile" 

/* -------------------------------------------------------- 
    fake struct defs 
    -------------------------------------------------------- */ 
/* all of these only go as far as the last field we need to access */ 

struct list_head { 
    struct list_head  *next; 
    struct list_head  *prev; 
}; 

struct wait_queue_head_t { 
    volatile unsigned int lock; 
    struct list_head  task_list; 
}; 

struct semaphore { 
    volatile int   count; 
    int     sleepers; 
    wait_queue_head_t  wait; 
}; 

struct rw_semaphore { 
    signed long   count; 
    volatile unsigned int wait_lock; 
    struct list_head  wait_list; 
}; 

struct inode { 
    struct list_head  i_hash; 
    struct list_head i_list; 
    struct list_head i_dentry; 

    struct list_head i_dirty_buffers; 
    struct list_head i_dirty_data_buffers; 

    unsigned long  i_ino; 
    volatile int  i_count; 
    unsigned short i_dev; 
    unsigned short i_mode; 
    unsigned short i_nlink; 
    unsigned short i_uid; 
    unsigned short i_gid; 
    unsigned short i_rdev; 
    long long  i_size; 
    long   i_atime; 
    long   i_mtime; 
    long   i_ctime; 
    unsigned int  i_blkbits; 
    unsigned long  i_blksize; 
    unsigned long  i_blocks; 
    unsigned long  i_version; 
    unsigned short  i_bytes; 
    struct semaphore i_sem; 
    struct rw_semaphore i_alloc_sem; 
    struct semaphore i_zombie; 
    void *i_op; 
    void *i_fop; 
    void *i_sb; 
    wait_queue_head_t i_wait; 
    void *i_flock; 
    struct address_space *i_mapping; 
}; 

struct dentry { 
    atomic_t d_count; 
    unsigned int d_flags; 
    struct inode *d_inode; 
}; 

struct page { 
    struct list_head list;   
    struct address_space *mapping;  
    unsigned long index;  
    struct page *next_hash;  
    atomic_t count;   
    unsigned long flags;  
}; 

struct fakes { 
    /* dentry */ 
    struct dentry fake_dentry; 
    struct inode fake_inode; 
    struct address_space fake_mapping; 
    struct address_space_operations fake_ops; 
    struct page dirty_page; 
}; 

感谢您的时间提前。

回答

0

根据this pagewait_queue_head_t可能是一个关键字,所以尽量将其更改为别的东西。

+0

感谢您的回复@Nishant。我试图将它改为像'wait_me'这样的其他东西,但在该行上出现相同的错误。 – HuangJie

+0

我将它重命名为'abc',这些错误消失了。我没有得到一些错误,由于丢失的文件'“ASM-I386/unistd.h中”和“ASM-I386/page.h”'但我可以删除类型'atomic_t'和'结构address_space'后进行编译,这我希望这些文件中 – Nishant

+0

我很抱歉打扰你,但你用'GCC-3.3.4'用'-I/usr/src目录/内核头文件-2.4.26-1/include'试试吗? – HuangJie