[PATCH] D102937: [lld][WebAssembly] Fix for PIC output + TLS + non-shared-memory

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 21 11:00:57 PDT 2021


sbc100 created this revision.
Herald added subscribers: wingo, ecnelises, sunfish, jgravelle-google, dschuff.
sbc100 requested review of this revision.
Herald added subscribers: llvm-commits, aheejin.
Herald added a project: LLVM.

Prior to this change build with `-shared/-pie` and using TLS (but
without -shared-memory) would hit this assert:

  "Currenly only a single data segment is supported in PIC mode"

This is because we were not including TLS data when merging data
segments.  However, when we build without shared-memory (i.e.  without
threads) we effectively lower away TLS into a normal active data
segment.. so we were ending up with two active data segments: the merged
data, and the lowered TLS data.

To fix this problem we can instead avoid combining data segments at
all when running in shared memory mode (because in this case all
segment initialization is passive).  And then in non-shared memory
mode we know that TLS has been lowered and therefore we can can
and should combine all segments.

So with this new behavior we have two different modes:

1. With shared memory / mutli-threaded: Never combine data segments since it is not necessary.  (All data segments as passive already).

2. Wihout shared memory / single-threaded: Combine *all* data segments since we treat TLS as normal data.  (We end up with a single active data segment).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102937

Files:
  lld/test/wasm/data-segments.ll
  lld/test/wasm/relocation-bad-tls.s
  lld/test/wasm/tls-no-shared.s
  lld/test/wasm/tls-non-shared-memory.s
  lld/wasm/OutputSections.cpp
  lld/wasm/Relocations.cpp
  lld/wasm/Writer.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102937.347082.patch
Type: text/x-patch
Size: 9053 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210521/14ceb4ad/attachment.bin>


More information about the llvm-commits mailing list