This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Implement Address Sanitizer for Emscripten
ClosedPublic

Authored by quantum on Jun 24 2019, 3:45 PM.

Details

Summary

This diff enables address sanitizer on Emscripten.

On Emscripten, real memory starts at the value passed to --global-base.

All memory before this is used as shadow memory, and thus the shadow mapping
function is simply dividing by 8.

Event Timeline

quantum created this revision.Jun 24 2019, 3:45 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJun 24 2019, 3:45 PM
sbc100 added inline comments.Jun 25 2019, 8:33 AM
lld/wasm/Writer.cpp
228

Surly if emscripten is passing in --global-base it already knows this value?

Otherwise lgtm. Perhaps split of the lld part into a separate change?

I wonder if we should use the linux/unix convention or edata etext and end? Terrible names obviously but there is precedent. I can't remember why I didn't do that for data_end and heap_base.

If not, then perhaps this should be called data_start to match the existing data_end? Of course this means that command line flag is somewhat misnamed then.

quantum marked an inline comment as done.Jun 25 2019, 10:34 AM

As for the name, I think __global_base matches the command line flag and makes it more clear what controls it, so I lean towards that.

lld/wasm/Writer.cpp
228

In theory, emscripten knows this value. But as some library code needs this information, the alternative would be to have build an object file with this information and link it in. Since we already have __data_end and __heap_base, I think it makes sense for this information to be available too.

sbc100 accepted this revision.Jun 26 2019, 11:47 AM

Remember to remove "A symbol __global_base is added so that code may know where the shadow
memory ends and real memory begins." from the CL description.

This revision is now accepted and ready to land.Jun 26 2019, 11:47 AM
quantum edited the summary of this revision. (Show Details)Jun 26 2019, 12:31 PM