diff options
Diffstat (limited to 'bfd/syms.c')
-rw-r--r-- | bfd/syms.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -1238,9 +1238,11 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound, for (; stab < (indexentry+1)->stab; stab += STABSIZE) { - boolean done; + boolean done, saw_line, saw_func; bfd_vma val; + saw_line = false; + saw_func = false; done = false; switch (stab[TYPEOFF]) @@ -1261,7 +1263,11 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound, /* A line number. The value is relative to the start of the current function. */ val = indexentry->val + bfd_get_32 (abfd, stab + VALOFF); - if (val <= offset) + /* If this line starts before our desired offset, or if it's + the first line we've been able to find, use it. The + !saw_line check works around a bug in GCC 2.95.3, which emits + the first N_SLINE late. */ + if (!saw_line || val <= offset) { *pline = bfd_get_16 (abfd, stab + DESCOFF); @@ -1274,11 +1280,14 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound, } if (val > offset) done = true; + saw_line = true; break; case N_FUN: case N_SO: - done = true; + if (saw_func || saw_line) + done = true; + saw_func = true; break; } @@ -1288,7 +1297,8 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound, *pfound = true; - if (IS_ABSOLUTE_PATH(file_name) || directory_name == NULL) + if (file_name == NULL || IS_ABSOLUTE_PATH (file_name) + || directory_name == NULL) *pfilename = file_name; else { |