diff --git a/lld/test/wasm/shared-memory.yaml b/lld/test/wasm/shared-memory.yaml --- a/lld/test/wasm/shared-memory.yaml +++ b/lld/test/wasm/shared-memory.yaml @@ -10,6 +10,8 @@ # RUN: not wasm-ld --no-entry --features=atomics %t1.o -o - 2>&1 | FileCheck %s --check-prefix ATOMICS-NO-SHARED +# RUN: wasm-ld --relocatable --features=atomics %t1.o -o - | obj2yaml | FileCheck %s --check-prefix ATOMICS-RELOCATABLE + # RUN: wasm-ld --no-entry --shared-memory --max-memory=131072 --features=atomics,bulk-memory %t1.o -o - | obj2yaml | FileCheck %s --check-prefix SHARED --- !WASM @@ -65,6 +67,11 @@ # ATOMICS-NO-SHARED: 'atomics' feature is used, so --shared-memory must be used{{$}} +# ATOMICS-RELOCATABLE: - Type: MEMORY +# ATOMICS-RELOCATABLE-NEXT: Memories: +# ATOMICS-RELOCATABLE-NEXT: Initial: 0x00000001 +# ATOMICS-RELOCATABLE-NEXT: - Type: + # SHARED: - Type: MEMORY # SHARED-NEXT: Memories: # SHARED-NEXT: - Flags: [ HAS_MAX, IS_SHARED ] diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp --- a/lld/wasm/Writer.cpp +++ b/lld/wasm/Writer.cpp @@ -421,7 +421,8 @@ for (const auto &key : used.keys()) allowed.insert(std::string(key)); - if (allowed.count("atomics") && !config->sharedMemory) { + if (allowed.count("atomics") && !config->sharedMemory && + !config->relocatable) { if (inferFeatures) error(Twine("'atomics' feature is used by ") + used["atomics"] + ", so --shared-memory must be used");