This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Problems with BFD library
- From: "John Zoidberg" <the dot real dot doctor dot zoidberg at gmail dot com>
- To: binutils at sourceware dot org
- Date: Mon, 18 Jun 2007 14:52:48 +0000
- Subject: 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.