Handle passive segments in wasm-emscripten-finalize#2217
Handle passive segments in wasm-emscripten-finalize#2217tlively merged 6 commits intoWebAssembly:masterfrom
Conversation
quantum5
left a comment
There was a problem hiding this comment.
Looks fine to me, but I don't really understand binaryen that well.
| } | ||
| if not is_passive: | ||
| extension_arg_map.update({ | ||
| '.mem.out': ['--separate-data-segments', mem_file], |
There was a problem hiding this comment.
What's the indentation we are supposed to use here? This file looks like it's 2 space indented, but this is 4 spaces indented.
There was a problem hiding this comment.
I think it uses four here because it is a continuation of an expression from the previous line. Flake8 doesn't complain at any rate.
| } | ||
|
|
||
| std::vector<Address> getSegmentOffsets(Module& wasm) { | ||
| std::unordered_map<unsigned, Address> passiveOffsets; |
There was a problem hiding this comment.
unsigned can be Index as it is the index of a wasm module thing IIUC
| if (it != passiveOffsets.end()) { | ||
| segmentOffsets.push_back(it->second); | ||
| } else { | ||
| // This was a non-constant offset (perhaps TLS) |
There was a problem hiding this comment.
I don't understand what this does. What will happen with that 0?
There was a problem hiding this comment.
Basically if AsmConstWalker or EmJsWalker try to extract anything from such a segment they will silently get a bogus address. I added a condition to stringAtAddr, which seems to be the ultimate consumer of these segment offsets, to make it skip any segment with a 0 offset, which can never be valid.
There was a problem hiding this comment.
Hmm, why can't 0 be a valid offset? Doesn't that mean it starts at address 0 which is valid?
There was a problem hiding this comment.
0 can't be a valid segment offset because that would mean the linker tried to put some data at address 0, which is of course inaccessible from C.
|
@kripken This should be good to go now |
This will be necessary once we use passive segments for pthread code.