Daniel Jacobowitz wrote: > On Thu, Nov 16, 2006 at 08:53:01PM +0000, Pedro Alves wrote: >> Hi all, >> >> The TLS without debugging info support introduced a bug for coff based >> targets. >> While printing for example a global symbol's value I am getting a >> segfault in parse.c:write_exp_msymbol, >> at: >> if (SYMBOL_BFD_SECTION (msymbol)->flags & SEC_THREAD_LOCAL) >> >> The problem is that minimal symbols may not have a bfd section set. >> >> The attached patch fixes it, but is it correct? >> I see in coffread.c, that prim_record_minimal_symbol_and_info is always >> called with a NULL >> bfd section, whilst in elfread.c, is is not. Is this a limitation of the >> coff format? Should coffread.c >> be fixed instead? > > Honestly, I'm not quite sure. You've got the section index, so maybe > in prim_record_minimal_symbol_and_info it could fill in a NULL > bfd_section from the objfile sections table? > Like in the attached patch1.diff? Or, it isn't safe to index the objfile->sections by section index, and we have to look them up linearly? That is what patch2.diff does. In that version, I've repeated the search on coffread.c, caching the last section looked up. Only slightly tested, but I got around around 50% cache hit on a few exes. (Premature optimization?) If v1 is the way to go, do we still need both 'int section' and 'asection *bfd_section' passed in to prim_record_minimal_symbol_and_info? Both versions also fix the segfault that started this thread. Cheers, Pedro Alves --- patch v1 2006-11-16 Pedro Alves * minsyms.c (prim_record_minimal_symbol_and_info): If bfd_section is NULL, get it from the objfile sections table. --- patch v2 2006-11-16 Pedro Alves * minsyms.c (prim_record_minimal_symbol_and_info): If bfd_section is NULL, get it from the objfile sections table. * coffread.c (coff_symtab_read): Get the bfd_section from the objfile sections table, caching the result.