[llvm-commits] [llvm] r64616 - /llvm/trunk/tools/gold/gold-plugin.cpp

Nick Lewycky nicholas at mxc.ca
Sun Feb 15 14:49:17 PST 2009


Author: nicholas
Date: Sun Feb 15 16:49:17 2009
New Revision: 64616

URL: http://llvm.org/viewvc/llvm-project?rev=64616&view=rev
Log:
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.

Modified:
    llvm/trunk/tools/gold/gold-plugin.cpp

Modified: llvm/trunk/tools/gold/gold-plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=64616&r1=64615&r2=64616&view=diff

==============================================================================
--- llvm/trunk/tools/gold/gold-plugin.cpp (original)
+++ llvm/trunk/tools/gold/gold-plugin.cpp Sun Feb 15 16:49:17 2009
@@ -290,7 +290,11 @@
          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;
         }





More information about the llvm-commits mailing list