This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Sun compiler, value field in stab is zero
- From: Gabriel Marin <mgabi at cs dot rice dot edu>
- To: binutils at sources dot redhat dot com
- Date: Tue, 15 Apr 2003 11:53:37 -0500
- Subject: Sun compiler, value field in stab is zero
Hi,
The code in _bfd_stab_section_find_nearest_line() expects to find the
absolute start address of routines in the value field of the stab's
N_FUN
entries.
Sun compiler does not generate these values, hence these fields are
always zero in binaries compiled with the Sun compiler.
As a result, bfd_find_nearest_line does not find the source line info
correctly.
This patch searches the symbol table for the routine symbols and compute
their absolute start address from there.
ChangeLog:
2003-04-15 Gabriel Marin <mgabi at rice dot edu>
* syms.c (_bfd_stab_section_find_nearest_line): Sun compiler
does not set the 'value' field for the N_FUN entries of the stab.
Compute the values of these entries using the symbol table
information.
Index: bfd/syms.c
===================================================================
RCS file: /cvs/src/src/bfd/syms.c,v
retrieving revision 1.29
diff -c -3 -p -r1.29 syms.c
*** bfd/syms.c 28 Feb 2003 23:43:35 -0000 1.29
--- bfd/syms.c 15 Apr 2003 16:17:57 -0000
*************** _bfd_stab_section_find_nearest_line (abf
*** 1220,1227 ****
++i;
info->indextablesize = i;
! qsort (info->indextable, (size_t) i, sizeof (struct indexentry),
! cmpindexentry);
*pinfo = (PTR) info;
}
--- 1220,1267 ----
++i;
info->indextablesize = i;
!
! /* For binaries produced by the Sun compiler the field 'value'
! * in stabs is zero for all N_FUN entries. In this case the
! * find_nearest_line always returns the last N_SLINE entry in the stabs
! * because the binary search will always stop just at the end of the
! * table, before the last entry which has a special value (0xFFFFFFFF)
! * and after all the other entries with a value zero.
! * Try to find the value for each entry by searching in the symbols
! * array. This search is done only once so we can live with a linear,
! * unoptimized search. It is also possible to organize the symbols in
! * another data structure using the name as a key (hashtable or sorted
! * list).
! * In stabs, the function name has this format: symbolName:F... or
! * symbolName:P.... We are interested only in the entries
! * with the first format.
! */
! for (i=0 ; i<info->indextablesize ; i++)
! {
! char* pos;
! int k;
! asymbol *sym;
! if (info->indextable[i].val==0 && info->indextable[i].function_name
! && ((pos=strchr(info->indextable[i].function_name, ':'))==NULL
! || *(pos+1)=='F') )
! {
! if (pos) *pos = '\0';
! /* search for the symbol with this name */
! for (k=0 ; symbols[k] != NULL ; k++)
! {
! sym = symbols[k];
! if (!strcmp(info->indextable[i].function_name, sym->name))
! {
! info->indextable[i].val =
! sym->value + sym->section->vma;
! break;
! }
! }
! if (pos) *pos = ':';
! }
! }
! qsort (info->indextable, (size_t) info->indextablesize,
! sizeof (struct indexentry), cmpindexentry);
*pinfo = (PTR) info;
}