[llvm] [llvm-symbolizer] nfc, use map instead of vector (PR #69552)

Serge Pavlov via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 24 08:55:13 PDT 2023


================
@@ -134,7 +120,10 @@ Error SymbolizableObjectFile::addCoffExportSymbols(
     uint32_t NextOffset = I != E ? I->Offset : Export.Offset + 1;
     uint64_t SymbolStart = ImageBase + Export.Offset;
     uint64_t SymbolSize = NextOffset - Export.Offset;
-    Symbols.push_back({SymbolStart, SymbolSize, Export.Name, 0});
+    // If the SymbolStart exists, use the one with the large Size.
+    // This helps us avoid symbols with no size information (Size = 0).
+    if (!Symbols.count(SymbolStart) || SymbolSize >= Symbols[SymbolStart].Size)
+      Symbols[SymbolStart] = {SymbolSize, Export.Name, 0};
----------------
spavloff wrote:

What will happen if two symbols have the same address? For example:

```
	.data
	.globl	aaa
	.globl	bbb
	.p2align	2
aaa:
bbb:
	.long	0
	.size	aaa, 4
	.size	bbb, 1
```

https://github.com/llvm/llvm-project/pull/69552


More information about the llvm-commits mailing list