|
15 | 15 | // |
16 | 16 | //===----------------------------------------------------------------------===// |
17 | 17 |
|
| 18 | +#include "llvm/ADT/SmallSet.h" |
18 | 19 | #include "llvm/ADT/StringSwitch.h" |
19 | 20 | #include "llvm/BinaryFormat/COFF.h" |
20 | 21 | #include "llvm/BinaryFormat/MachO.h" |
@@ -1615,15 +1616,18 @@ static void dumpSymbolsFromDLInfoMachO(MachOObjectFile &MachO, |
1615 | 1616 | } |
1616 | 1617 | // See if these addresses are already in the symbol table. |
1617 | 1618 | unsigned FunctionStartsAdded = 0; |
| 1619 | + // The addresses from FoundFns come from LC_FUNCTION_STARTS. Its contents |
| 1620 | + // are delta encoded addresses from the start of __TEXT, ending when zero |
| 1621 | + // is found. Because of this, the addresses should be unique, and even if |
| 1622 | + // we create fake entries on SymbolList in the second loop, SymbolAddresses |
| 1623 | + // should not need to be updated there. |
| 1624 | + SmallSet<uint64_t, 32> SymbolAddresses; |
| 1625 | + for (const auto &S : SymbolList) |
| 1626 | + SymbolAddresses.insert(S.Address); |
1618 | 1627 | for (uint64_t f = 0; f < FoundFns.size(); f++) { |
1619 | | - bool found = false; |
1620 | | - for (unsigned J = 0; J < SymbolList.size() && !found; ++J) { |
1621 | | - if (SymbolList[J].Address == FoundFns[f] + BaseSegmentAddress) |
1622 | | - found = true; |
1623 | | - } |
1624 | | - // See this address is not already in the symbol table fake up an |
1625 | | - // nlist for it. |
1626 | | - if (!found) { |
| 1628 | + // See if this address is already in the symbol table, otherwise fake up |
| 1629 | + // an nlist for it. |
| 1630 | + if (!SymbolAddresses.contains(FoundFns[f] + BaseSegmentAddress)) { |
1627 | 1631 | NMSymbol F = {}; |
1628 | 1632 | F.Name = "<redacted function X>"; |
1629 | 1633 | F.Address = FoundFns[f] + BaseSegmentAddress; |
|
0 commit comments