[llvm] r240372 - Handle multiple symbols having the same address.

Rafael Espindola rafael.espindola at gmail.com
Mon Jun 22 20:36:09 PDT 2015


Author: rafael
Date: Mon Jun 22 22:36:08 2015
New Revision: 240372

URL: http://llvm.org/viewvc/llvm-project?rev=240372&view=rev
Log:
Handle multiple symbols having the same address.
I will add an explicit test in a second, but this fixes the bots.

Modified:
    llvm/trunk/lib/Object/SymbolSize.cpp

Modified: llvm/trunk/lib/Object/SymbolSize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/SymbolSize.cpp?rev=240372&r1=240371&r2=240372&view=diff
==============================================================================
--- llvm/trunk/lib/Object/SymbolSize.cpp (original)
+++ llvm/trunk/lib/Object/SymbolSize.cpp Mon Jun 22 22:36:08 2015
@@ -28,6 +28,8 @@ static int compareAddress(const SymEntry
     return A->Address - B->Address;
   if (A->Section < B->Section)
     return -1;
+  if (A->Section == B->Section)
+    return 0;
   return 1;
 }
 
@@ -73,7 +75,13 @@ llvm::object::computeSymbolSizes(const O
     auto &P = Addresses[I];
     if (P.I == O.symbol_end())
       continue;
-    uint64_t Size = Addresses[I + 1].Address - P.Address;
+
+    // If multiple symbol have the same address, give both the same size.
+    unsigned NextI = I + 1;
+    while (NextI < N && Addresses[NextI].Address == P.Address)
+      ++NextI;
+
+    uint64_t Size = Addresses[NextI].Address - P.Address;
     P.Address = Size;
   }
 





More information about the llvm-commits mailing list