Problems with BFD library
Kai Tietz
Kai.Tietz@onevision.com
Mon Jun 18 14:59:00 GMT 2007
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
More information about the Binutils
mailing list