It seems to me that a local_symbol should not be merely cast as symbol in gas/symbols.c, as it's done in a couple of places. Or perhaps I'm missing something...
Created attachment 2041 [details] Proposed fix. I believe that the function local_symbol_convert should do the proper conversion.
Comment on attachment 2041 [details] Proposed fix. Index: gas/symbols.c =================================================================== retrieving revision 1.3 diff -p -u -w -r1.3 symbols.c --- gas/symbols.c 26 Oct 2006 19:49:25 -0000 1.3 +++ gas/symbols.c 12 Oct 2007 21:57:51 -0000 @@ -477,9 +477,10 @@ colon (sym_name) /* Just seen "x:" - ra #ifdef BFD_ASSEMBLER else if (! flag_keep_locals && bfd_is_local_label_name (stdoutput, sym_name)) { - symbolP = (symbolS *) local_symbol_make (sym_name, now_seg, + symbolP = local_symbol_convert ( + local_symbol_make (sym_name, now_seg, (valueT) frag_now_fix (), - frag_now); + frag_now)); } #endif /* BFD_ASSEMBLER */ else @@ -565,9 +566,10 @@ symbol_find_or_make (name) if (symbolP != NULL) return symbolP; - symbolP = (symbolS *) local_symbol_make (name, undefined_section, + symbolP = local_symbol_convert ( + local_symbol_make (name, undefined_section, (valueT) 0, - &zero_address_frag); + &zero_address_frag)); return symbolP; } #endif
The code you are patching is perfectly good as is.
Interesting, for it seems that unless local_symbol_convert is used, the frag information is lost and it results in an assertion at elf_common when the symbol is local (starting with "." or "L")...
Yes, it is possible that local_symbol_convert needs to be called at some other place in the gas code, but not here (see the comment above struct local_symbol in struc-symbol.h). I can't tell where because you haven't explained exactly what is going wrong, or better, provided a test case. I also gather you are using an old source code base by the "#ifdef BFD_ASSEMBLER" in your patch. Mysterious bug reports against some unknown old version of binutils don't help us make a better binutils..