Problems with BFD library

John Zoidberg the.real.doctor.zoidberg@gmail.com
Mon Jun 18 14:52:00 GMT 2007
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.



More information about the Binutils mailing list