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.
Details
- Reviewers
sbc100 - Commits
- rG067f005500af: [lld][WebAssembly] Fix segfault in map file support
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
I'm not actually sure how to do that in the .s format, since I found this on a real-world project. Do you know what I should add to the test?
Maybe a DefinedGlobal would do it? You can define wasm globals in .s files (see lld/test/wasm/globals.s).
lld/wasm/MapFile.cpp | ||
---|---|---|
84 | How about if we just have fileOffset default to 0 if chunk is null? I think we still want to include all symbols in the map. |
Yes, almost certainly. I actually ran into another null pointer dereference and had to add another workaround to my local branch as well. I haven't pursued this patch upstream because I still have not been able to create a test case :(
Can we get this landed? Did adding a defined global to a .s file work? (I think maybe you can just add a defined global to lld/test/wasm/map-file.s?
Trying again now, but last time I tried that (a while ago) I couldn't reproduce the issue.
Ok, I was able to reproduce one of the issues by using a wasm global this time. However, I'm having trouble figuring out how to fit printing the global to the map file in with the current infrastructure. Comments would be very appreciated.
Seems reasonable to me. Our map file format is relatively arbitrary AFAICT. Its mostly about conveying the final contents of the linked binary IIUC.
Yes, I think so. I changed this back to skipping symbols without chunks in the because we don't need to demangle global symbols.
How about if we just have fileOffset default to 0 if chunk is null? I think we still want to include all symbols in the map.