This is an archive of the discontinued LLVM Phabricator instance.

[lld][WebAssembly] Disallow exporting of TLS symbols
ClosedPublic

Authored by sbc100 on May 6 2021, 8:31 PM.

Details

Summary

Cross module TLS is currently not supported by our ABI. This
change makes explicitly exporting a TLS symbol into an error
and prevents implicit exporting (via --export-all).

See https://github.com/emscripten-core/emscripten/issues/14120

Diff Detail

Event Timeline

sbc100 created this revision.May 6 2021, 8:31 PM
sbc100 requested review of this revision.May 6 2021, 8:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 6 2021, 8:31 PM
dschuff accepted this revision.May 7 2021, 9:37 AM
dschuff added inline comments.
lld/test/wasm/tls-export.s
10

What is it that actually designates the symbol as TLS? Is it just the section name?
edit: ok yeah i just read the rest of the code. That's surprising; I guess in the object file (and eventually in dylibs) there's a flag in the symbol table, right? or is it still just based on the section name? is ELF like this too, or do they have a section or symbol flag?

17

Hm, you know, If we're going to be writing a lot of these asm tests with post-MVP features, maybe we actually do want to have an assembler directive for it at some point.

lld/wasm/InputChunks.h
121

I guess there doesn't need to be a .trodata because if it's read-only it can always be shared across threads....

lld/wasm/OutputSegment.h
35

I guess this is asymmetric with input chunks because BSS doesn't end up in any kind of segment or descriptor in the output file (it's just implicitly-zeroed space)?

This revision is now accepted and ready to land.May 7 2021, 9:37 AM
sbc100 added inline comments.May 9 2021, 8:29 PM
lld/test/wasm/tls-export.s
10

Currently in wasm its solely based on magic section names. I believe this is true for ELF too, which I did/do find surprising. I could also be wrong.

Symbols themselves are not ever TLS, but they can point into TLS sections. That is my understanding.

17

Indeed, that does seem like something we will need. (either that or some kind command line flag but I don't know if such flags for mc are a thing).

lld/wasm/InputChunks.h
121

Yes as far as I know that is not a thing.

lld/wasm/OutputSegment.h
35

We merge tdata and tbss when we create the output segments. I think the idea is that we want them
to share a single base address (__tls_base + offset should work for anything in any TLS section) avoiding
the need for a separate __tls_bss_base).

static StringRef getOutputDataSegmentName(StringRef name) {                      
  // We only support one thread-local segment, so we must merge the segments        
  // despite --no-merge-data-segments.                                           
  // We also need to merge .tbss into .tdata so they share the same offsets.                                      
  if (name.startswith(".tdata") || name.startswith(".tbss"))                     
    return ".tdata";

thanks, still LGTM

This revision was automatically updated to reflect the committed changes.