This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Problems with BFD library


I've been banging my head on the wall but can't still figure it out
what is wrong with this piece of code.
I just want to know how many sections an ELF file has.
The call bfd_count_sections keeps returning 0 sections!!! Even though
I initialize the magic numbers table.

#include <stdio.h>
#include "bfd.h"
int main(int argc, char *argv[])
{
     bfd *ibfd;
     char *filename;
     filename = argv[1];

     bfd_init();
     ibfd = bfd_openr(filename, NULL);
     int sections_count=bfd_count_sections(ibfd);
     printf("%s section count %d\n",argv[1],sections_count);

     bfd_close(ibfd);
     return 0;
}


I build this code with: gcc bfdtool.c -o bfdtool -lbfd.



Thank you for any help.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]