aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1995-07-11 16:31:39 +0000
committerIan Lance Taylor <ian@airs.com>1995-07-11 16:31:39 +0000
commit6f904fce8786808a6607a9be049a44ae3090720c (patch)
treeb36738347d6e3351f385c491d7ab554a53d846b8 /bfd/elf.c
parent917199fe29a9a6a9921bcdb0b70a266adf483c19 (diff)
downloadfsf-binutils-gdb-6f904fce8786808a6607a9be049a44ae3090720c.zip
fsf-binutils-gdb-6f904fce8786808a6607a9be049a44ae3090720c.tar.gz
fsf-binutils-gdb-6f904fce8786808a6607a9be049a44ae3090720c.tar.bz2
Tue Jul 11 12:29:49 1995 Rick Sladkey <jrs@world.std.com>
* elf.c (_bfd_elf_find_nearest_line): Handle the simple case where there is no debugging information.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c59
1 files changed, 51 insertions, 8 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index e869a4e..b49d9a3 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -15,7 +15,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*
@@ -2589,14 +2589,17 @@ _bfd_elf_set_arch_mach (abfd, arch, machine)
return bfd_default_set_arch_mach (abfd, arch, machine);
}
+/* 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)
+ section,
+ symbols,
+ offset,
+ filename_ptr,
+ functionname_ptr,
+ line_ptr)
bfd *abfd;
asection *section;
asymbol **symbols;
@@ -2605,7 +2608,47 @@ _bfd_elf_find_nearest_line (abfd,
CONST char **functionname_ptr;
unsigned int *line_ptr;
{
- return false;
+ const char *filename;
+ asymbol *func;
+ asymbol **p;
+
+ if (symbols == NULL)
+ return false;
+
+ filename = NULL;
+ func = NULL;
+
+ for (p = symbols; *p != NULL; p++)
+ {
+ elf_symbol_type *q;
+
+ q = (elf_symbol_type *) *p;
+
+ if (bfd_get_section (&q->symbol) != section)
+ continue;
+
+ switch (ELF_ST_TYPE (q->internal_elf_sym.st_info))
+ {
+ default:
+ break;
+ case STT_FILE:
+ filename = bfd_asymbol_name (&q->symbol);
+ break;
+ case STT_FUNC:
+ if (func == NULL
+ || q->symbol.value <= offset)
+ func = (asymbol *) q;
+ break;
+ }
+ }
+
+ if (func == NULL)
+ return false;
+
+ *filename_ptr = filename;
+ *functionname_ptr = bfd_asymbol_name (func);
+ *line_ptr = 0;
+ return true;
}
int