This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Problems with BFD library
- From: Kai Tietz <Kai dot Tietz at onevision dot com>
- To: "John Zoidberg" <the dot real dot doctor dot zoidberg at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Mon, 18 Jun 2007 16:59:27 +0200
- Subject: Re: Problems with BFD library
binutils-owner@sourceware.org wrote on 18.06.2007 16:52:48:
> 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;
> }
May use after bfd_openr just "bfd_check_format (ibfd, bfd_object);". This
may helps to load the object itself into memory ;)
Cheers,
i.A. Kai Tietz
| (\_/) This is Bunny. Copy and paste Bunny
| (='.'=) into your signature to help him gain
| (")_(") world domination.
------------------------------------------------------------------------------------------
OneVision Software Entwicklungs GmbH & Co. KG
Dr.-Leo-Ritter-StraÃe 9 - 93049 Regensburg
Tel: +49.(0)941.78004.0 - Fax: +49.(0)941.78004.489 - www.OneVision.com
Commerzbank Regensburg - BLZ 750 400 62 - Konto 6011050
Handelsregister: HRA 6744, Amtsgericht Regensburg
KomplementÃrin: OneVision Software Entwicklungs Verwaltungs GmbH
Dr.-Leo-Ritter-StraÃe 9 â 93049 Regensburg
Handelsregister: HRB 8932, Amtsgericht Regensburg - GeschÃftsfÃhrer:
Ulrike DÃhler, Manuela Kluger