[PATCH] D88369: [lld][WebAssembly] Fix segfault in map file support
Thomas Lively via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 26 16:33:19 PDT 2020
tlively created this revision.
tlively added a reviewer: sbc100.
Herald added subscribers: llvm-commits, ecnelises, sunfish, jgravelle-google, dschuff.
Herald added a project: LLVM.
tlively requested review of this revision.
Herald added a subscriber: aheejin.
The code previously assumed that `getChunk` would return a non-null pointer for
every symbol, but in fact it only returns non-null pointers for DefinedFunction
and DefinedData symbols. This patch fixes the segfault by checking whether
`getChunk` returns a null for each symbol and skipping the mapping output for
any symbols for which it does.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D88369
Files:
lld/wasm/MapFile.cpp
Index: lld/wasm/MapFile.cpp
===================================================================
--- lld/wasm/MapFile.cpp
+++ lld/wasm/MapFile.cpp
@@ -76,8 +76,11 @@
std::vector<std::string> str(syms.size());
parallelForEachN(0, syms.size(), [&](size_t i) {
raw_string_ostream os(str[i]);
- auto &chunk = *syms[i]->getChunk();
- uint64_t fileOffset = chunk.outputSec->getOffset() + chunk.outputOffset;
+ auto *chunk = syms[i]->getChunk();
+ // TODO: Handle symbol types besides DefinedFunction and DefinedData
+ if (!chunk)
+ return;
+ uint64_t fileOffset = chunk->outputSec->getOffset() + chunk->outputOffset;
uint64_t vma = -1;
uint64_t size = 0;
if (auto *DD = dyn_cast<DefinedData>(syms[i])) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88369.294524.patch
Type: text/x-patch
Size: 746 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200926/a8438555/attachment.bin>
More information about the llvm-commits
mailing list