aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1994-08-25 15:58:43 +0000
committerIan Lance Taylor <ian@airs.com>1994-08-25 15:58:43 +0000
commit6d04c6d475c350f7490a5ac95cb45d7b396744de (patch)
tree85812128d45d83b8c2de08114d4129ab9b35633b /bfd
parent715cde57f8aba52a2f4f32ef6fd7f01eb3411048 (diff)
downloadfsf-binutils-gdb-6d04c6d475c350f7490a5ac95cb45d7b396744de.zip
fsf-binutils-gdb-6d04c6d475c350f7490a5ac95cb45d7b396744de.tar.gz
fsf-binutils-gdb-6d04c6d475c350f7490a5ac95cb45d7b396744de.tar.bz2
* coffgen.c (coff_find_nearest_line): Look for the best C_FILE,
not merely the first.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog3
-rw-r--r--bfd/coffgen.c48
2 files changed, 32 insertions, 19 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index df27096..1bc2c1c 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,8 @@
Thu Aug 25 10:44:53 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+ * coffgen.c (coff_find_nearest_line): Look for the best C_FILE,
+ not merely the first.
+
* coffgen.c (coff_write_alien_symbol): If we are not using the
symbol, clear the name so that it is not put in the string table.
From Antti.Miettinen@ntc.nokia.com.
diff --git a/bfd/coffgen.c b/bfd/coffgen.c
index 1b8a48b..44d1323 100644
--- a/bfd/coffgen.c
+++ b/bfd/coffgen.c
@@ -1644,37 +1644,47 @@ coff_find_nearest_line (abfd, section, ignore_symbols, offset, filename_ptr,
if (p < pend)
{
+ bfd_vma maxdiff;
+
/* Look through the C_FILE symbols to find the best one. */
*filename_ptr = (char *) p->u.syment._n._n_n._n_offset;
- i = 0;
+ maxdiff = (bfd_vma) 0 - (bfd_vma) 1;
while (1)
{
combined_entry_type *p2;
- /* Avoid endless loops on erroneous files by ensuring that
- we always move forward in the file. */
- if (i >= p->u.syment.n_value)
- break;
-
- i = p->u.syment.n_value;
- if (i >= cof->raw_syment_count)
- break;
-
- p = cof->raw_syments + i;
- if (p->u.syment.n_sclass != C_FILE)
- break;
-
- for (p2 = p; p2 < pend; p2 += 1 + p2->u.syment.n_numaux)
+ for (p2 = p + 1 + p->u.syment.n_numaux;
+ p2 < pend;
+ p2 += 1 + p2->u.syment.n_numaux)
{
- if (section ==
- coff_section_from_bfd_index (abfd, p2->u.syment.n_scnum))
+ if (p2->u.syment.n_scnum > 0
+ && (section
+ == coff_section_from_bfd_index (abfd,
+ p2->u.syment.n_scnum)))
break;
+ if (p2->u.syment.n_sclass == C_FILE)
+ {
+ p2 = pend;
+ break;
+ }
}
+
if (p2 < pend
- && offset < p2->u.syment.n_value)
+ && offset >= p2->u.syment.n_value
+ && offset - p2->u.syment.n_value < maxdiff)
+ {
+ *filename_ptr = (char *) p->u.syment._n._n_n._n_offset;
+ maxdiff = offset - p2->u.syment.n_value;
+ }
+
+ /* Avoid endless loops on erroneous files by ensuring that
+ we always move forward in the file. */
+ if (p - cof->raw_syments >= p->u.syment.n_value)
break;
- *filename_ptr = (char *) p->u.syment._n._n_n._n_offset;
+ p = cof->raw_syments + p->u.syment.n_value;
+ if (p > pend || p->u.syment.n_sclass != C_FILE)
+ break;
}
}