From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5202 invoked by alias); 11 Apr 2006 14:43:38 -0000 Received: (qmail 5194 invoked by uid 22791); 11 Apr 2006 14:43:38 -0000 X-Spam-Check-By: sourceware.org Received: from web52705.mail.yahoo.com (HELO web52705.mail.yahoo.com) (206.190.48.228) by sourceware.org (qpsmtpd/0.31) with SMTP; Tue, 11 Apr 2006 14:43:36 +0000 Received: (qmail 54525 invoked by uid 60001); 11 Apr 2006 14:43:30 -0000 Message-ID: <20060411144330.54523.qmail@web52705.mail.yahoo.com> Received: from [71.193.16.238] by web52705.mail.yahoo.com via HTTP; Tue, 11 Apr 2006 07:43:30 PDT Date: Tue, 11 Apr 2006 16:37:00 -0000 From: diz rael Subject: reading elf file (avr target) To: binutils@sourceware.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2006-04/txt/msg00156.txt.bz2 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