if ((internal_f->f_flags & F_EXEC) != 0)
abfd->flags |= D_PAGED;
- bfd_get_symcount(abfd) = internal_f->f_nsyms;
+ obj_conv_table_size (abfd) = bfd_get_symcount(abfd) = internal_f->f_nsyms;
if (internal_f->f_nsyms)
abfd->flags |= HAS_SYMS;
}
else if (symbol->flags & BSF_DEBUGGING)
{
- /* Remove the symbol name so that it does not take up any space.
- COFF won't know what to do with it anyhow. */
- symbol->name = "";
+ /* There isn't much point to writing out a debugging symbol
+ unless we are prepared to convert it into COFF debugging
+ format. So, we just ignore them. */
+ return true;
}
else
{
for (internal_ptr = internal; internal_ptr < internal_end;
internal_ptr ++)
{
- if (internal_ptr->u.syment.n_sclass == C_FILE) {
+ if (internal_ptr->u.syment.n_sclass == C_FILE
+ && internal_ptr->u.syment.n_numaux > 0) {
/* make a file symbol point to the name in the auxent, since
the text ".file" is redundant */
if ((internal_ptr+1)->u.auxent.x_file.x_n.x_zeroes == 0) {
static CONST char *cache_function;
static unsigned int line_base = 0;
- unsigned int i = 0;
+ unsigned int i;
coff_data_type *cof = coff_data(abfd);
/* Run through the raw syments if available */
combined_entry_type *p;
+ combined_entry_type *pend;
alent *l;
if (cof == NULL)
return false;
+ /* Find the first C_FILE symbol. */
p = cof->raw_syments;
+ pend = p + cof->raw_syment_count;
+ while (p < pend)
+ {
+ if (p->u.syment.n_sclass == C_FILE)
+ break;
+ p += 1 + p->u.syment.n_numaux;
+ }
- for (i = 0; i < cof->raw_syment_count; i++) {
- if (p->u.syment.n_sclass == C_FILE) {
- /* File name has been moved into symbol */
+ if (p < pend)
+ {
+ /* Look through the C_FILE symbols to find the best one. */
*filename_ptr = (char *) p->u.syment._n._n_n._n_offset;
- break;
+ i = 0;
+ 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)
+ {
+ if (section ==
+ coff_section_from_bfd_index (abfd, p2->u.syment.n_scnum))
+ break;
+ }
+ if (p2 < pend
+ && offset < p2->u.syment.n_value)
+ break;
+
+ *filename_ptr = (char *) p->u.syment._n._n_n._n_offset;
+ }
}
- p += 1 + p->u.syment.n_numaux;
- }
+
/* Now wander though the raw linenumbers of the section */
/*
If this is the same BFD as we were previously called with and this is
if (coff->native) {
combined_entry_type *s = coff->native;
s = s + 1 + s->u.syment.n_numaux;
+
+ /* In XCOFF a debugging symbol can follow the function
+ symbol. */
+ if (s->u.syment.n_scnum == N_DEBUG)
+ s = s + 1 + s->u.syment.n_numaux;
+
/*
S should now point to the .bf of the function
*/
}
}
else {
- if (l->u.offset > offset)
+ if (l->u.offset + bfd_get_section_vma (abfd, section) > offset)
break;
*line_ptr = l->line_number + line_base - 1;
}