This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Problem with _bfd_elf_find_nearest_line on ia64
On Mon, Feb 05, 2001 at 01:18:52PM -0800, H . J . Lu wrote:
> On Mon, Feb 05, 2001 at 11:46:30AM +0100, Stephane Carrez wrote:
> >
> > Hi!
> >
> > >>
> > >> Running /work/gnu/src/binutils/ld/testsuite/ld-undefined/undefined.exp ...
> > >> FAIL: undefined function
> > >>
> > >
> > >This problem is caused by _bfd_elf_find_nearest_line in bfd/elf.c. It
> > >calls
> > >
> > >if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
> > > filename_ptr, functionname_ptr,
> > > line_ptr, 0,
> > > &elf_tdata (abfd)->dwarf2_find_line_info))
> > >
> > >If you pass 0 as addr_size to _bfd_dwarf2_find_nearest_line, it will
> > >use the default addr_size, which is 4. It seems incorrect for ia64.
> > >Setting addr_size to 8 fixes the problem. Could someone please fix
> > >it?
> > >
> >
> > The term 'addr_size' is completely missleading. It does not correspond
> > to the target CPU address size. This is the size of offsets in the Dwarf2
> > sections, that is either 32 or 64 (4 or 8 if you like). So, it has nothing
> > to do with the target really.
> >
>
> The problem is somewhere else. It turns out _bfd_dwarf2_find_nearest_line may
> not find the function name. I moved the part of _bfd_elf_find_nearest_line to
> elf_find_function and used it to find the function name if it is not found
> by _bfd_dwarf2_find_nearest_line. Any comments?
>
>
> H.J.
> ---
> 2001-02-05 H.J. Lu <hjl@gnu.org>
>
> * elf.c (elf_find_function): New function.
> (_bfd_elf_find_nearest_line): Call elf_find_function () to find
> the file name and function name.
>
Oops. I found a problem. Here is the updated patch.
H.J.
----
Index: elf.c
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elf.c,v
retrieving revision 1.44
diff -u -p -r1.44 elf.c
--- elf.c 2000/12/22 00:47:45 1.44
+++ elf.c 2001/02/05 21:29:14
@@ -56,6 +56,10 @@ static INLINE int sym_is_global PARAMS (
static boolean elf_map_symbols PARAMS ((bfd *));
static bfd_size_type get_program_header_size PARAMS ((bfd *));
static boolean elfcore_read_notes PARAMS ((bfd *, bfd_vma, bfd_vma));
+static boolean elf_find_function PARAMS ((bfd *, asection *,
+ asymbol **,
+ bfd_vma, const char **,
+ const char **));
/* Swap version information in and out. The version information is
currently size independent. If that ever changes, this code will
@@ -4971,53 +4975,28 @@ _bfd_elf_set_arch_mach (abfd, arch, mach
return bfd_default_set_arch_mach (abfd, arch, machine);
}
-/* Find the nearest line to a particular section and offset, for error
+/* Find the function to a particular section and offset, for error
reporting. */
-boolean
-_bfd_elf_find_nearest_line (abfd,
- section,
- symbols,
- offset,
- filename_ptr,
- functionname_ptr,
- line_ptr)
- bfd *abfd;
+static boolean
+elf_find_function (abfd,
+ section,
+ symbols,
+ offset,
+ filename_ptr,
+ functionname_ptr)
+ bfd *abfd ATTRIBUTE_UNUSED;
asection *section;
asymbol **symbols;
bfd_vma offset;
CONST char **filename_ptr;
CONST char **functionname_ptr;
- unsigned int *line_ptr;
{
- boolean found;
const char *filename;
asymbol *func;
bfd_vma low_func;
asymbol **p;
- if (_bfd_dwarf1_find_nearest_line (abfd, section, symbols, offset,
- filename_ptr, functionname_ptr,
- line_ptr))
- return true;
-
- if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
- filename_ptr, functionname_ptr,
- line_ptr, 0,
- &elf_tdata (abfd)->dwarf2_find_line_info))
- return true;
-
- if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset,
- &found, filename_ptr,
- functionname_ptr, line_ptr,
- &elf_tdata (abfd)->line_info))
- return false;
- if (found)
- return true;
-
- if (symbols == NULL)
- return false;
-
filename = NULL;
func = NULL;
low_func = 0;
@@ -5053,9 +5032,76 @@ _bfd_elf_find_nearest_line (abfd,
if (func == NULL)
return false;
+
+ if (filename_ptr)
+ *filename_ptr = filename;
+ if (functionname_ptr)
+ *functionname_ptr = bfd_asymbol_name (func);
+
+ return true;
+}
+
+/* Find the nearest line to a particular section and offset, for error
+ reporting. */
+
+boolean
+_bfd_elf_find_nearest_line (abfd,
+ section,
+ symbols,
+ offset,
+ filename_ptr,
+ functionname_ptr,
+ line_ptr)
+ bfd *abfd;
+ asection *section;
+ asymbol **symbols;
+ bfd_vma offset;
+ CONST char **filename_ptr;
+ CONST char **functionname_ptr;
+ unsigned int *line_ptr;
+{
+ boolean found;
+
+ if (_bfd_dwarf1_find_nearest_line (abfd, section, symbols, offset,
+ filename_ptr, functionname_ptr,
+ line_ptr))
+ {
+ if (!*functionname_ptr)
+ elf_find_function (abfd, section, symbols, offset,
+ *filename_ptr ? NULL : filename_ptr,
+ functionname_ptr);
+
+ return true;
+ }
+
+ if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
+ filename_ptr, functionname_ptr,
+ line_ptr, 0,
+ &elf_tdata (abfd)->dwarf2_find_line_info))
+ {
+ if (!*functionname_ptr)
+ elf_find_function (abfd, section, symbols, offset,
+ *filename_ptr ? NULL : filename_ptr,
+ functionname_ptr);
+
+ return true;
+ }
+
+ if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset,
+ &found, filename_ptr,
+ functionname_ptr, line_ptr,
+ &elf_tdata (abfd)->line_info))
+ return false;
+ if (found)
+ return true;
+
+ if (symbols == NULL)
+ return false;
+
+ if (! elf_find_function (abfd, section, symbols, offset,
+ filename_ptr, functionname_ptr))
+ return false;
- *filename_ptr = filename;
- *functionname_ptr = bfd_asymbol_name (func);
*line_ptr = 0;
return true;
}