[lld-macho] Avoid using bump-alloc in TrieBuider

The code can be used in multi-threads and the allocator is not thread safe.

fixes PR/54378

Reviewed By: int3, #lld-macho

Differential Revision: https://reviews.llvm.org/D121638
This commit is contained in:
Vy Nguyen 2022-03-14 17:22:24 -04:00 committed by Jez Ng
parent edd3e705bb
commit e049a87f04
2 changed files with 7 additions and 1 deletions

View File

@ -145,8 +145,13 @@ void TrieNode::writeTo(uint8_t *buf) const {
}
}
TrieNode::~TrieNode() {
for (TrieNode *node : nodes)
delete node;
}
TrieNode *TrieBuilder::makeNode() {
auto *node = make<TrieNode>();
auto *node = new TrieNode();
nodes.emplace_back(node);
return node;
}

View File

@ -22,6 +22,7 @@ class Symbol;
class TrieBuilder {
public:
~TrieBuilder();
void setImageBase(uint64_t addr) { imageBase = addr; }
void addSymbol(const Symbol &sym) { exported.push_back(&sym); }
// Returns the size in bytes of the serialized trie.