- 论坛徽章:
- 0
|
在Redhat linux , 内核版本linux 2.4.20, gcc version 3.2.2 20030222. 附件中
存有源程序,编译出现以下错误。
[root@localhost idetect]# gcc listCache.C -o listCache
/tmp/ccCS4cpL.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
还望哪位大侠不吝赐教!!!
代码我也一并贴上
//idetect.h文件
#include <stdio.h>
#define PAGE_SIZE 4096
#define PG_slab 7
struct doublelink {
unsigned int next;
unsigned int prev;
} Proc_init;
struct task_temp {
unsigned int next;
unsigned int prev;
} Proc_task;
typedef struct {
volatile unsigned long lock;
} spinlock_t;
struct kmem_cache_t {
/* 1) each alloc & free */
/* full, partial first, then free */
struct doublelink slabs;
struct doublelink *firstnotfull;
unsigned int objsize;
unsigned int flags; /* constant flags */
unsigned int num; /* # of objs per slab */
spinlock_t spinlock;
#ifdef CONFIG_SMP
unsigned int batchcount;
#endif
/* 2) slab additions /removals */
/* order of pgs per slab (2^n) */
unsigned int gfporder;
/* force GFP flags, e.g. GFP_DMA */
unsigned int gfpflags;
size_t colour; /* cache colouring range */
unsigned int colour_off; /* colour offset */
unsigned int colour_next; /* cache colouring */
kmem_cache_t *slabp_cache;
unsigned int growing;
unsigned int dflags; /* dynamic flags */
/* constructor func */
void (*ctor)(void *, kmem_cache_t *, unsigned long);
/* de-constructor func */
void (*dtor)(void *, kmem_cache_t *, unsigned long);
unsigned long failures;
/* 3) cache creation/removal */
char name[CACHE_NAMELEN];
struct doublelink next;
#ifdef CONFIG_SMP
/* 4) per-cpu data */
cpucache_t *cpudata[NR_CPUS];
#endif
#if STATS
unsigned long num_active;
unsigned long num_allocations;
unsigned long high_mark;
unsigned long grown;
unsigned long reaped;
unsigned long errors;
#ifdef CONFIG_SMP
atomic_t allochit;
atomic_t allocmiss;
atomic_t freehit;
atomic_t freemiss;
#endif
#endif
} ;
struct vma_temp {
unsigned int next;
unsigned int prev;
} vma_task;
struct mypage {
unsigned int list_next;
unsigned int list_prev;
unsigned int mapping;
unsigned int index;
unsigned int next_hash;
unsigned int count;
unsigned long flags;
unsigned int lru_next;
unsigned int lru_prev;
unsigned int pte_union;
unsigned int direct_union;
unsigned char age;
// unsigned int pprev_hash;
unsigned int buffer_head;
unsigned int virtuall;
} memmap;
union swap_header {
struct
{
char reserved[PAGE_SIZE - 10];
char magic[10]; /* SWAP-SPACE or SWAPSPACE2 */
} magic;
struct
{
char bootbits[1024]; /* Space for disklabel etc. */
unsigned int version;
unsigned int last_page;
unsigned int nr_badpages;
unsigned int padding[125];
unsigned int badpages[1];
} info;
};
//listCache.c
#include "idetect.h"
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#define KERN 0xc0000000
#define PAGES_NR 16384 //total number of page frames in node
#define MEMMAP 0xc1000030 //the address of the global mem_map array
#define MEMIMG "/dev/mem"
/*
程序作用是查找kmem_cache_t结构,输出其名字。linux2.4下适用。
*/
const char * pfenum;
void print_usage (FILE* stream, int exit_code){
fprintf(stream, "Usage: %s options \n", pfenum);
fprintf(stream,
" -h --help Display this usage information\n"
" -a --all Display files used in the past\n");
exit (exit_code);
}
int main(int argc, char *argv[]){
FILE *fd;
struct kmem_cache_t kmem_cache;
int kernoff;
int next_option;
const char* const short_options = "h:a";
const struct option long_options[] = {
{ "help", 0, NULL, 'h' },
{ "all", 0, NULL, 'a' },
{ NULL, 0, NULL, 0 }
};
do {
next_option = getopt_long (argc, argv, short_options,
long_options, NULL);
switch (next_option){
case 'h': /* -h or --help */
print_usage (stdout, 0);
case 'a':{
fd=fopen(MEMIMG,"r");
fseek(fd,0,SEEK_SET);
kernoff=0x0;
struct mypage pagex;
int licz3;
//开始循环
for(licz3=0;licz3<PAGES_NR;licz3++){
fseek(fd,(MEMMAP+kernoff-KERN)+licz3*sizeof(struct mypage),SEEK_SET);
fread(&pagex,sizeof(struct mypage),1,fd);
if(pagex.flags&&PG_slab){
fseek(fd, pagex.list_next + kernoff - KERN,SEEK_SET);
fread(&kmem_cache, sizeof(struct kmem_cache_t), 1,fd);
printf("This page belongs to kmemcache:s%, absolute address in: x%",\
kmem_cache.name, pagex.list_prev );
}
}
break;
} /* -a or --all */
//read file and file head
//===========
case '?':
print_usage (stderr, 1);
case -1:
break;
default:
abort ();
}
}
while (next_option != -1);
return 0;
} |
|