[PATCH] D136122: [BOLT] Ignore duplicate global symbols

Rafael Auler via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 17 19:11:00 PDT 2022


rafauler created this revision.
rafauler added a reviewer: bolt.
Herald added subscribers: treapster, ayermolo.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
rafauler requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.

We noticed some binaries with duplicated global symbol
entries (same name, address and size). Ignore them as it is possibly a
bug in the linker, and continue processing, unless the symbol has a
different size or address.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136122

Files:
  bolt/lib/Rewrite/RewriteInstance.cpp


Index: bolt/lib/Rewrite/RewriteInstance.cpp
===================================================================
--- bolt/lib/Rewrite/RewriteInstance.cpp
+++ bolt/lib/Rewrite/RewriteInstance.cpp
@@ -974,7 +974,15 @@
     if (Name.empty()) {
       UniqueName = "ANONYMOUS." + std::to_string(AnonymousId++);
     } else if (cantFail(Symbol.getFlags()) & SymbolRef::SF_Global) {
-      assert(!BC->getBinaryDataByName(Name) && "global name not unique");
+      if (const BinaryData *BD = BC->getBinaryDataByName(Name)) {
+        assert(BD->getSize() == ELFSymbolRef(Symbol).getSize() &&
+               BD->getAddress() == Address &&
+               "global name not unique, with different size/address");
+        if (opts::Verbosity > 1)
+          errs() << "BOLT-WARNING: ignoring duplicate symbol " << Name << "\n";
+        // Ignore duplicate entry - possibly a bug in the linker
+        continue;
+      }
       UniqueName = Name;
     } else {
       // If we have a local file name, we should create 2 variants for the


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136122.468393.patch
Type: text/x-patch
Size: 1029 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221018/c4d43ba3/attachment.bin>


More information about the llvm-commits mailing list