This is the mail archive of the binutils@sources.redhat.com 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]

Re: newbie: problems initializing a bfd*


"George Hicken" <gh299@ecs.soton.ac.uk> writes:

> I am new the the bfd and am having problems initializing a bfd* with it.
> I have read the docs but they weren't that helpful with the problem.
> 
> The following code encapsulates where I am going wrong:
> 
> int main(int argc, char **argv) {
> 	long storage_needed;
> 	asymbol **symbol_table;
> 	long number_of_symbols;
> 	bfd* abfd;
> 
> 	bfd_init();
> 
> 	// have tried bfd_openr with elf32-i386 for the target
> 	// and that didn't help, didn't help
> 	abfd = bfd_openr("object_file.o", NULL); 
> 	
> 	if (!abfd)
> 		return 1;
>       
> 	storage_needed = bfd_get_symtab_upper_bound (abfd);
> 	
> 	return 0;
> }
> 
> I get an exception in _bfd_elf_get_symtab_upper_bound
> 
> System:
> Red Hat Linux 7.2
> Binutils snapshot 011128 (compiled sucessfully with gcc 3.0.2)
> 
> I have also looked through objdump.c to see if that helped. I 
> couldn't see any major difference in the way I am using the openr 
> function (I assume that this is where the problem is) or any 
> intialization that I was missing.
> 
> Any help would be great.

You need to call bfd_check_format() before calling
bfd_get_symtab_upper_bound().

Ian


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