- /* Handle long section names. This code must handle section
- names just as they are handled in coff_write_object_contents. */
- if (bfd_coff_long_section_names (abfd))
- {
- asection *o;
-
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- size_t len;
-
- len = strlen (o->name);
- if (len > SCNNMLEN)
- {
- if (bfd_bwrite (o->name, (bfd_size_type) (len + 1), abfd)
- != len + 1)
- return FALSE;
- }
- }
- }
-
- for (p = abfd->outsymbols, i = 0;
- i < limit;
- i++, p++)
- {
- asymbol *q = *p;
- size_t name_length = strlen (q->name);
- coff_symbol_type *c_symbol = coff_symbol_from (q);
- size_t maxlen;
-
- /* Figure out whether the symbol name should go in the string
- table. Symbol names that are short enough are stored
- directly in the syment structure. File names permit a
- different, longer, length in the syment structure. On
- XCOFF, some symbol names are stored in the .debug section
- rather than in the string table. */
-
- if (c_symbol == NULL
- || c_symbol->native == NULL)
- /* This is not a COFF symbol, so it certainly is not a
- file name, nor does it go in the .debug section. */
- maxlen = bfd_coff_force_symnames_in_strings (abfd) ? 0 : SYMNMLEN;
-
- else if (! c_symbol->native->is_sym)
- maxlen = bfd_coff_force_symnames_in_strings (abfd) ? 0 : SYMNMLEN;
-
- else if (bfd_coff_symname_in_debug (abfd,
- &c_symbol->native->u.syment))
- /* This symbol name is in the XCOFF .debug section.
- Don't write it into the string table. */
- maxlen = name_length;
-
- else if (c_symbol->native->u.syment.n_sclass == C_FILE
- && c_symbol->native->u.syment.n_numaux > 0)
- {
- if (bfd_coff_force_symnames_in_strings (abfd))
- {
- if (bfd_bwrite (".file", (bfd_size_type) 6, abfd) != 6)
- return FALSE;
- }
- maxlen = bfd_coff_filnmlen (abfd);
- }
- else
- maxlen = bfd_coff_force_symnames_in_strings (abfd) ? 0 : SYMNMLEN;
-
- if (name_length > maxlen)
- {
- if (bfd_bwrite ((void *) (q->name), (bfd_size_type) name_length + 1,
- abfd) != name_length + 1)
- return FALSE;
- }
- }
- }
- else
- {
- /* We would normally not write anything here, but we'll write
- out 4 so that any stupid coff reader which tries to read the
- string table even when there isn't one won't croak. */
- unsigned int size = STRING_SIZE_SIZE;
- bfd_byte buffer[STRING_SIZE_SIZE];