reading elf file (avr target)

diz rael dizraelus@yahoo.com
Tue Apr 11 16:37:00 GMT 2006


I'm trying to get the symbol table out of an object
file. I built libbfd from binutils 2.16.1 (tried 2.15
as well) using --enable-target=avr
--enable-install-libbfd, etc. For some reason it does
not read the sym table correctly and the number of
syms seems wrong (ridiculously large). Dereferencing
any element of the symtab raises a seg. fault. Any
ideas as to why this is happening? The weird thing is
that this code used to work for me before a year ago!
- had an earlier version of the toolchain then.

main program:
vmobj = load_obj(obj_name);
...
nvmsym = get_stab(vmobj, &vmstab);
-------------
bfd *load_obj(char *f)
{
   bfd *file;

   file = bfd_openr(f, "binary");

   if (!file || bfd_check_format(file, bfd_object) ==
0 || bfd_get_file_flags(file) & HAS_SYMS == 0)
	  return NULL;

   return file;
}

int get_stab(bfd *file, asymbol ***stab)
{
   long storage;
   int nsym;

   storage = bfd_get_symtab_upper_bound(file);
   if (storage < 0)
	 return UNKNOWN_SYMTAB_SIZE;

   *stab = (asymbol **) malloc(storage *
sizeof(**stab));
   nsym = bfd_canonicalize_symtab(file, *stab); //
MESSES UP HERE. nsym IS HUGE AND *STAB ENTRIES ARE
INVALID

   return nsym;
}

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Binutils mailing list