--- coffgen.c.orig 2008-09-30 13:52:37.485748195 +0200 +++ coffgen.c 2008-09-30 14:14:54.080753833 +0200 @@ -1133,6 +1133,28 @@ } else { + /* If the symbol class has been changed (eg objcopy/ld script/etc) + * we cannot retain the sclass from the original symbol. Only + * adjust symbol visibility for simply defined weak, local, and + * global symbols. + */ + switch (c_symbol->native->u.syment.n_sclass) { +#ifdef COFF_WITH_PE + case C_NT_WEAK: +#endif + case C_WEAKEXT: + case C_EXT: + case C_STAT: + /* If it's defined and not common, change the visibility */ + if (c_symbol->native->u.syment.n_scnum != 0 && + symbol->flags & (BSF_WEAK|BSF_LOCAL|BSF_GLOBAL)) + c_symbol->native->u.syment.n_sclass = + (symbol->flags & BSF_WEAK) && obj_pe (abfd) ? C_NT_WEAK : + (symbol->flags & BSF_WEAK) ? C_WEAKEXT : + (symbol->flags & BSF_LOCAL) ? C_STAT : + C_EXT; + } + if (!coff_write_native_symbol (abfd, c_symbol, &written, &string_size, &debug_string_section, &debug_string_size))