Don't discard definitions of common symbols. Not sure if this is the right fix.

Before this change, the program:
  int var;
  int main(void) { return 0; }
when run under 'nm -g' would show 'U var' with the gold plugin and
'B var' with gcc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64616 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nick Lewycky 2009-02-15 22:49:17 +00:00
parent 225f747486
commit e0afaa301d

View File

@ -290,7 +290,11 @@ ld_plugin_status all_symbols_read_hook(void) {
E = Modules.end(); I != E; ++I) {
(*get_symbols)(I->handle, I->syms.size(), &I->syms[0]);
for (unsigned i = 0, e = I->syms.size(); i != e; i++) {
if (I->syms[i].resolution == LDPR_PREVAILING_DEF) {
(*message)(LDPL_WARNING, "def: %d visibility: %d resolution %d",
I->syms[i].def, I->syms[i].visibility, I->syms[i].resolution);
if (I->syms[i].resolution == LDPR_PREVAILING_DEF ||
(I->syms[i].def == LDPK_COMMON &&
I->syms[i].resolution == LDPR_RESOLVED_IR)) {
lto_codegen_add_must_preserve_symbol(cg, I->syms[i].name);
anySymbolsPreserved = true;
}