新人贴,关于bfd的问题

不知道为什么,bfd_openr读出的段是空的,printf的内容有点多,随意加的,见谅…代码如下:
#include <stdio.h>
#include <stdlib.h>
#include <dwarf.h>
#include <libdwarf.h>
#include <linux/elf.h>
#include <bfd.h>
struct reg *reg_head = NULL;
struct reg *reg_thread = NULL;
struct thread_info head = NULL;
struct bfd
core_bfd;
void get_reg(bfd *abfd,asection *asect,void *reg_t){
printf(“get_reg is on\n”);
const char *name =NULL;
if(!strncmp(asect->name,“.reg/”,5)){
name= asect->name + 5;
printf(“section:%s\n”,asect->name);
}
}

int init_reg_1(){
asection *p;
if(core_bfd->sections == NULL){
printf(“the core has no sections\n”);
return 0;
}
printf(“init_reg_1 is on\n”);
for(p = core_bfd->sections; p!=NULL; p=p->next){
//get_reg(core_bfd,p,reg_head);
printf(“the \n”);
}
//bfd_map_over_sections(core_bfd,get_reg,&reg_head);
printf(“***********\n”);
reg_thread = reg_head;
}

int open_core(char *core){
core_bfd = bfd_openr(core,NULL);
if(core_bfd==NULL){
printf(“core dump open error\n”);
return -1;
}
printf(“%d\n”,core_bfd->id);
printf(“%s\n”,core_bfd->filename);

if(core_bfd->sections==NULL){
printf(“no sections\n”);
return 1;
}
return 1;
}

struct thread_info* get_all_thread_info(char *file, char * core){
int ret = 0;
ret = open_core(core);
if(ret==-1){
printf(“open core is fails\n”);
return NULL;
}
else {
printf(“open core success\n”);
init_reg_1();
}
return NULL;
}

int main(int argc,char *argv){
head = get_all_thread_info(argv[1],argv[2]);
printf(“to be continue…\n”);
return 0;
}