[lld] r362276 - [WebAssembly] Don't export __data_end and __heap_base by default.
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Fri May 31 15:52:00 PDT 2019
Author: sbc
Date: Fri May 31 15:51:59 2019
New Revision: 362276
URL: http://llvm.org/viewvc/llvm-project?rev=362276&view=rev
Log:
[WebAssembly] Don't export __data_end and __heap_base by default.
These can still be exported via --export if needed.
Differential Revision: https://reviews.llvm.org/D62744
Modified:
lld/trunk/test/wasm/alias.ll
lld/trunk/test/wasm/archive-export.ll
lld/trunk/test/wasm/call-indirect.ll
lld/trunk/test/wasm/comdats.ll
lld/trunk/test/wasm/cxx-mangling.ll
lld/trunk/test/wasm/data-layout.ll
lld/trunk/test/wasm/entry.ll
lld/trunk/test/wasm/export.ll
lld/trunk/test/wasm/local-symbols.ll
lld/trunk/test/wasm/locals-duplicate.test
lld/trunk/test/wasm/lto/export.ll
lld/trunk/test/wasm/stack-first.test
lld/trunk/test/wasm/undefined-weak-call.ll
lld/trunk/test/wasm/visibility-hidden.ll
lld/trunk/test/wasm/weak-alias-overide.ll
lld/trunk/test/wasm/weak-alias.ll
lld/trunk/test/wasm/weak-symbols.ll
lld/trunk/test/wasm/weak-undefined.ll
lld/trunk/wasm/Config.h
lld/trunk/wasm/Driver.cpp
lld/trunk/wasm/SymbolTable.cpp
lld/trunk/wasm/SymbolTable.h
lld/trunk/wasm/Writer.cpp
Modified: lld/trunk/test/wasm/alias.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/alias.ll?rev=362276&r1=362275&r2=362276&view=diff
==============================================================================
--- lld/trunk/test/wasm/alias.ll (original)
+++ lld/trunk/test/wasm/alias.ll Fri May 31 15:51:59 2019
@@ -41,29 +41,11 @@ entry:
; CHECK-NEXT: InitExpr:
; CHECK-NEXT: Opcode: I32_CONST
; CHECK-NEXT: Value: 66560
-; CHECK-NEXT: - Index: 1
-; CHECK-NEXT: Type: I32
-; CHECK-NEXT: Mutable: false
-; CHECK-NEXT: InitExpr:
-; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 66560
-; CHECK-NEXT: - Index: 2
-; CHECK-NEXT: Type: I32
-; CHECK-NEXT: Mutable: false
-; CHECK-NEXT: InitExpr:
-; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 1024
; CHECK-NEXT: - Type: EXPORT
; CHECK-NEXT: Exports:
; CHECK-NEXT: - Name: memory
; CHECK-NEXT: Kind: MEMORY
; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: __heap_base
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 1
-; CHECK-NEXT: - Name: __data_end
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 2
; CHECK-NEXT: - Name: _start
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 0
Modified: lld/trunk/test/wasm/archive-export.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/archive-export.ll?rev=362276&r1=362275&r2=362276&view=diff
==============================================================================
--- lld/trunk/test/wasm/archive-export.ll (original)
+++ lld/trunk/test/wasm/archive-export.ll Fri May 31 15:51:59 2019
@@ -14,12 +14,6 @@ CHECK: Exports:
CHECK-NEXT: - Name: memory
CHECK-NEXT: Kind: MEMORY
CHECK-NEXT: Index: 0
-CHECK-NEXT: - Name: __heap_base
-CHECK-NEXT: Kind: GLOBAL
-CHECK-NEXT: Index: 1
-CHECK-NEXT: - Name: __data_end
-CHECK-NEXT: Kind: GLOBAL
-CHECK-NEXT: Index: 2
CHECK-NEXT: - Name: foo
CHECK-NEXT: Kind: FUNCTION
CHECK-NEXT: Index: 1
@@ -38,12 +32,6 @@ NOEXPORT: Exports:
NOEXPORT-NEXT: - Name: memory
NOEXPORT-NEXT: Kind: MEMORY
NOEXPORT-NEXT: Index: 0
-NOEXPORT-NEXT: - Name: __heap_base
-NOEXPORT-NEXT: Kind: GLOBAL
-NOEXPORT-NEXT: Index: 1
-NOEXPORT-NEXT: - Name: __data_end
-NOEXPORT-NEXT: Kind: GLOBAL
-NOEXPORT-NEXT: Index: 2
NOEXPORT-NEXT: - Name: _start
NOEXPORT-NEXT: Kind: FUNCTION
NOEXPORT-NEXT: Index: 0
Modified: lld/trunk/test/wasm/call-indirect.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/call-indirect.ll?rev=362276&r1=362275&r2=362276&view=diff
==============================================================================
--- lld/trunk/test/wasm/call-indirect.ll (original)
+++ lld/trunk/test/wasm/call-indirect.ll Fri May 31 15:51:59 2019
@@ -81,30 +81,12 @@ define void @call_ptr(i64 (i64)* %arg) {
; CHECK-NEXT: Mutable: false
; CHECK-NEXT: InitExpr:
; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 66576
-; CHECK-NEXT: - Index: 2
-; CHECK-NEXT: Type: I32
-; CHECK-NEXT: Mutable: false
-; CHECK-NEXT: InitExpr:
-; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 1036
-; CHECK-NEXT: - Index: 3
-; CHECK-NEXT: Type: I32
-; CHECK-NEXT: Mutable: false
-; CHECK-NEXT: InitExpr:
-; CHECK-NEXT: Opcode: I32_CONST
; CHECK-NEXT: Value: 1032
; CHECK-NEXT: - Type: EXPORT
; CHECK-NEXT: Exports:
; CHECK-NEXT: - Name: memory
; CHECK-NEXT: Kind: MEMORY
; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: __heap_base
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 1
-; CHECK-NEXT: - Name: __data_end
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 2
; CHECK-NEXT: - Name: bar
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 0
@@ -119,7 +101,7 @@ define void @call_ptr(i64 (i64)* %arg) {
; CHECK-NEXT: Index: 3
; CHECK-NEXT: - Name: indirect_func
; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 3
+; CHECK-NEXT: Index: 1
; CHECK-NEXT: - Name: call_ptr
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 4
Modified: lld/trunk/test/wasm/comdats.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/comdats.ll?rev=362276&r1=362275&r2=362276&view=diff
==============================================================================
--- lld/trunk/test/wasm/comdats.ll (original)
+++ lld/trunk/test/wasm/comdats.ll Fri May 31 15:51:59 2019
@@ -27,30 +27,12 @@ entry:
; CHECK-NEXT: Mutable: false
; CHECK-NEXT: InitExpr:
; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 66576
-; CHECK-NEXT: - Index: 2
-; CHECK-NEXT: Type: I32
-; CHECK-NEXT: Mutable: false
-; CHECK-NEXT: InitExpr:
-; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 1027
-; CHECK-NEXT: - Index: 3
-; CHECK-NEXT: Type: I32
-; CHECK-NEXT: Mutable: false
-; CHECK-NEXT: InitExpr:
-; CHECK-NEXT: Opcode: I32_CONST
; CHECK-NEXT: Value: 1024
; CHECK-NEXT: - Type: EXPORT
; CHECK-NEXT: Exports:
; CHECK-NEXT: - Name: memory
; CHECK-NEXT: Kind: MEMORY
; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: __heap_base
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 1
-; CHECK-NEXT: - Name: __data_end
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 2
; CHECK-NEXT: - Name: _start
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 0
@@ -59,7 +41,7 @@ entry:
; CHECK-NEXT: Index: 1
; CHECK-NEXT: - Name: constantData
; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 3
+; CHECK-NEXT: Index: 1
; CHECK-NEXT: - Name: callInline1
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 2
Modified: lld/trunk/test/wasm/cxx-mangling.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/cxx-mangling.ll?rev=362276&r1=362275&r2=362276&view=diff
==============================================================================
--- lld/trunk/test/wasm/cxx-mangling.ll (original)
+++ lld/trunk/test/wasm/cxx-mangling.ll Fri May 31 15:51:59 2019
@@ -26,12 +26,6 @@ define void @_start() {
; CHECK-NEXT: - Name: memory
; CHECK-NEXT: Kind: MEMORY
; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: __heap_base
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 1
-; CHECK-NEXT: - Name: __data_end
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 2
; CHECK-NEXT: - Name: _Z3fooi
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 1
Modified: lld/trunk/test/wasm/data-layout.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/data-layout.ll?rev=362276&r1=362275&r2=362276&view=diff
==============================================================================
--- lld/trunk/test/wasm/data-layout.ll (original)
+++ lld/trunk/test/wasm/data-layout.ll Fri May 31 15:51:59 2019
@@ -13,7 +13,7 @@ target triple = "wasm32-unknown-unknown"
@local_struct = hidden global %struct.s zeroinitializer, align 4
@local_struct_internal_ptr = hidden local_unnamed_addr global i32* getelementptr inbounds (%struct.s, %struct.s* @local_struct, i32 0, i32 1), align 4
-; RUN: wasm-ld -no-gc-sections --allow-undefined --no-entry -o %t.wasm %t.o %t.hello.o
+; RUN: wasm-ld -no-gc-sections --export=__data_end --export=__heap_base --allow-undefined --no-entry -o %t.wasm %t.o %t.hello.o
; RUN: obj2yaml %t.wasm | FileCheck %s
; CHECK: - Type: MEMORY
@@ -32,9 +32,15 @@ target triple = "wasm32-unknown-unknown"
; CHECK-NEXT: Mutable: false
; CHECK-NEXT: InitExpr:
; CHECK-NEXT: Opcode: I32_CONST
+; CHECK-NEXT: Value: 1071
+; CHECK-NEXT: - Index: 2
+; CHECK-NEXT: Type: I32
+; CHECK-NEXT: Mutable: false
+; CHECK-NEXT: InitExpr:
+; CHECK-NEXT: Opcode: I32_CONST
; CHECK-NEXT: Value: 66608
-; CHECK: - Type: DATA
+; CHECK: - Type: DATA
; CHECK-NEXT: Segments:
; CHECK-NEXT: - SectionOffset: 7
; CHECK-NEXT: InitFlags: 0
Modified: lld/trunk/test/wasm/entry.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/entry.ll?rev=362276&r1=362275&r2=362276&view=diff
==============================================================================
--- lld/trunk/test/wasm/entry.ll (original)
+++ lld/trunk/test/wasm/entry.ll Fri May 31 15:51:59 2019
@@ -17,12 +17,6 @@ entry:
; CHECK-NEXT: - Name: memory
; CHECK-NEXT: Kind: MEMORY
; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: __heap_base
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 1
-; CHECK-NEXT: - Name: __data_end
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 2
; CHECK-NEXT: - Name: entry
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 0
@@ -41,10 +35,4 @@ entry:
; CHECK-CTOR-NEXT: - Name: __wasm_call_ctors
; CHECK-CTOR-NEXT: Kind: FUNCTION
; CHECK-CTOR-NEXT: Index: 0
-; CHECK-CTOR-NEXT: - Name: __heap_base
-; CHECK-CTOR-NEXT: Kind: GLOBAL
-; CHECK-CTOR-NEXT: Index: 1
-; CHECK-CTOR-NEXT: - Name: __data_end
-; CHECK-CTOR-NEXT: Kind: GLOBAL
-; CHECK-CTOR-NEXT: Index: 2
; CHECK-CTOR-NEXT: - Type:
Modified: lld/trunk/test/wasm/export.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/export.ll?rev=362276&r1=362275&r2=362276&view=diff
==============================================================================
--- lld/trunk/test/wasm/export.ll (original)
+++ lld/trunk/test/wasm/export.ll Fri May 31 15:51:59 2019
@@ -40,12 +40,6 @@ entry:
; CHECK-NEXT: - Name: memory
; CHECK-NEXT: Kind: MEMORY
; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: __heap_base
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 1
-; CHECK-NEXT: - Name: __data_end
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 2
; CHECK-NEXT: - Name: hidden_function
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 0
Modified: lld/trunk/test/wasm/local-symbols.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/local-symbols.ll?rev=362276&r1=362275&r2=362276&view=diff
==============================================================================
--- lld/trunk/test/wasm/local-symbols.ll (original)
+++ lld/trunk/test/wasm/local-symbols.ll Fri May 31 15:51:59 2019
@@ -57,36 +57,18 @@ entry:
; CHECK-NEXT: Mutable: false
; CHECK-NEXT: InitExpr:
; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 66576
-; CHECK-NEXT: - Index: 2
-; CHECK-NEXT: Type: I32
-; CHECK-NEXT: Mutable: false
-; CHECK-NEXT: InitExpr:
-; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 1032
-; CHECK-NEXT: - Index: 3
-; CHECK-NEXT: Type: I32
-; CHECK-NEXT: Mutable: false
-; CHECK-NEXT: InitExpr:
-; CHECK-NEXT: Opcode: I32_CONST
; CHECK-NEXT: Value: 1024
; CHECK-NEXT: - Type: EXPORT
; CHECK-NEXT: Exports:
; CHECK-NEXT: - Name: memory
; CHECK-NEXT: Kind: MEMORY
; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: __heap_base
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 1
-; CHECK-NEXT: - Name: __data_end
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 2
; CHECK-NEXT: - Name: _start
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 1
; CHECK-NEXT: - Name: foo
; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 3
+; CHECK-NEXT: Index: 1
; CHECK-NEXT: - Type: CODE
; CHECK-NEXT: Functions:
; CHECK-NEXT: - Index: 0
Modified: lld/trunk/test/wasm/locals-duplicate.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/locals-duplicate.test?rev=362276&r1=362275&r2=362276&view=diff
==============================================================================
--- lld/trunk/test/wasm/locals-duplicate.test (original)
+++ lld/trunk/test/wasm/locals-duplicate.test Fri May 31 15:51:59 2019
@@ -38,20 +38,8 @@
; CHECK-NEXT: Mutable: false
; CHECK-NEXT: InitExpr:
; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 66592
-; CHECK-NEXT: - Index: 2
-; CHECK-NEXT: Type: I32
-; CHECK-NEXT: Mutable: false
-; CHECK-NEXT: InitExpr:
-; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 1048
-; CHECK-NEXT: - Index: 3
-; CHECK-NEXT: Type: I32
-; CHECK-NEXT: Mutable: false
-; CHECK-NEXT: InitExpr:
-; CHECK-NEXT: Opcode: I32_CONST
; CHECK-NEXT: Value: 1028
-; CHECK-NEXT: - Index: 4
+; CHECK-NEXT: - Index: 2
; CHECK-NEXT: Type: I32
; CHECK-NEXT: Mutable: false
; CHECK-NEXT: InitExpr:
@@ -62,12 +50,6 @@
; CHECK-NEXT: - Name: memory
; CHECK-NEXT: Kind: MEMORY
; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: __heap_base
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 1
-; CHECK-NEXT: - Name: __data_end
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 2
; CHECK-NEXT: - Name: colliding_func2
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 1
@@ -79,7 +61,7 @@
; CHECK-NEXT: Index: 4
; CHECK-NEXT: - Name: colliding_global2
; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 3
+; CHECK-NEXT: Index: 1
; CHECK-NEXT: - Name: get_global3A
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 5
@@ -100,7 +82,7 @@
; CHECK-NEXT: Index: 12
; CHECK-NEXT: - Name: colliding_global1
; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 4
+; CHECK-NEXT: Index: 2
; CHECK-NEXT: - Name: get_global2B
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 13
Modified: lld/trunk/test/wasm/lto/export.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/lto/export.ll?rev=362276&r1=362275&r2=362276&view=diff
==============================================================================
--- lld/trunk/test/wasm/lto/export.ll (original)
+++ lld/trunk/test/wasm/lto/export.ll Fri May 31 15:51:59 2019
@@ -23,12 +23,6 @@ entry:
; CHECK-NEXT: - Name: memory
; CHECK-NEXT: Kind: MEMORY
; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: __heap_base
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 1
-; CHECK-NEXT: - Name: __data_end
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 2
; CHECK-NEXT: - Name: hidden_function
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 0
Modified: lld/trunk/test/wasm/stack-first.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/stack-first.test?rev=362276&r1=362275&r2=362276&view=diff
==============================================================================
--- lld/trunk/test/wasm/stack-first.test (original)
+++ lld/trunk/test/wasm/stack-first.test Fri May 31 15:51:59 2019
@@ -4,8 +4,7 @@
; global should be initialized to 512.
RUN: llc -filetype=obj %p/Inputs/start.ll -o %t.o
-
-RUN: wasm-ld -z stack-size=512 --stack-first --allow-undefined -o %t.wasm %t.o
+RUN: wasm-ld -z stack-size=512 --stack-first --export=__data_end --export=__heap_base -o %t.wasm %t.o
RUN: obj2yaml %t.wasm | FileCheck %s
CHECK: - Type: GLOBAL
@@ -33,10 +32,12 @@ CHECK-NEXT: Exports:
CHECK-NEXT: - Name: memory
CHECK-NEXT: Kind: MEMORY
CHECK-NEXT: Index: 0
-CHECK-NEXT: - Name: __heap_base
+CHECK-NEXT: - Name: __data_end
CHECK-NEXT: Kind: GLOBAL
CHECK-NEXT: Index: 1
-CHECK-NEXT: - Name: __data_end
+CHECK-NEXT: - Name: __heap_base
CHECK-NEXT: Kind: GLOBAL
CHECK-NEXT: Index: 2
-
+CHECK-NEXT: - Name: _start
+CHECK-NEXT: Kind: FUNCTION
+CHECK-NEXT: Index: 0
Modified: lld/trunk/test/wasm/undefined-weak-call.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/undefined-weak-call.ll?rev=362276&r1=362275&r2=362276&view=diff
==============================================================================
--- lld/trunk/test/wasm/undefined-weak-call.ll (original)
+++ lld/trunk/test/wasm/undefined-weak-call.ll Fri May 31 15:51:59 2019
@@ -61,29 +61,11 @@ define i32 @callWeakFuncs() {
; CHECK-NEXT: InitExpr:
; CHECK-NEXT: Opcode: I32_CONST
; CHECK-NEXT: Value: 66560
-; CHECK-NEXT: - Index: 1
-; CHECK-NEXT: Type: I32
-; CHECK-NEXT: Mutable: false
-; CHECK-NEXT: InitExpr:
-; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 66560
-; CHECK-NEXT: - Index: 2
-; CHECK-NEXT: Type: I32
-; CHECK-NEXT: Mutable: false
-; CHECK-NEXT: InitExpr:
-; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 1024
; CHECK-NEXT: - Type: EXPORT
; CHECK-NEXT: Exports:
; CHECK-NEXT: - Name: memory
; CHECK-NEXT: Kind: MEMORY
; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: __heap_base
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 1
-; CHECK-NEXT: - Name: __data_end
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 2
; CHECK-NEXT: - Name: callWeakFuncs
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 3
Modified: lld/trunk/test/wasm/visibility-hidden.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/visibility-hidden.ll?rev=362276&r1=362275&r2=362276&view=diff
==============================================================================
--- lld/trunk/test/wasm/visibility-hidden.ll (original)
+++ lld/trunk/test/wasm/visibility-hidden.ll Fri May 31 15:51:59 2019
@@ -43,12 +43,6 @@ entry:
; CHECK-NEXT: - Name: memory
; CHECK-NEXT: Kind: MEMORY
; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: __heap_base
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 1
-; CHECK-NEXT: - Name: __data_end
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 2
; CHECK-NEXT: - Name: objectDefault
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 1
@@ -66,12 +60,6 @@ entry:
; NO-DEFAULT-NEXT: - Name: memory
; NO-DEFAULT-NEXT: Kind: MEMORY
; NO-DEFAULT-NEXT: Index: 0
-; NO-DEFAULT-NEXT: - Name: __heap_base
-; NO-DEFAULT-NEXT: Kind: GLOBAL
-; NO-DEFAULT-NEXT: Index: 1
-; NO-DEFAULT-NEXT: - Name: __data_end
-; NO-DEFAULT-NEXT: Kind: GLOBAL
-; NO-DEFAULT-NEXT: Index: 2
; NO-DEFAULT-NEXT: - Name: _start
; NO-DEFAULT-NEXT: Kind: FUNCTION
; NO-DEFAULT-NEXT: Index: 2
Modified: lld/trunk/test/wasm/weak-alias-overide.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/weak-alias-overide.ll?rev=362276&r1=362275&r2=362276&view=diff
==============================================================================
--- lld/trunk/test/wasm/weak-alias-overide.ll (original)
+++ lld/trunk/test/wasm/weak-alias-overide.ll Fri May 31 15:51:59 2019
@@ -51,29 +51,11 @@ entry:
; CHECK-NEXT: InitExpr:
; CHECK-NEXT: Opcode: I32_CONST
; CHECK-NEXT: Value: 66560
-; CHECK-NEXT: - Index: 1
-; CHECK-NEXT: Type: I32
-; CHECK-NEXT: Mutable: false
-; CHECK-NEXT: InitExpr:
-; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 66560
-; CHECK-NEXT: - Index: 2
-; CHECK-NEXT: Type: I32
-; CHECK-NEXT: Mutable: false
-; CHECK-NEXT: InitExpr:
-; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 1024
; CHECK-NEXT: - Type: EXPORT
; CHECK-NEXT: Exports:
; CHECK-NEXT: - Name: memory
; CHECK-NEXT: Kind: MEMORY
; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: __heap_base
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 1
-; CHECK-NEXT: - Name: __data_end
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 2
; CHECK-NEXT: - Name: alias_fn
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 0
Modified: lld/trunk/test/wasm/weak-alias.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/weak-alias.ll?rev=362276&r1=362275&r2=362276&view=diff
==============================================================================
--- lld/trunk/test/wasm/weak-alias.ll (original)
+++ lld/trunk/test/wasm/weak-alias.ll Fri May 31 15:51:59 2019
@@ -48,29 +48,11 @@ entry:
; CHECK-NEXT: InitExpr:
; CHECK-NEXT: Opcode: I32_CONST
; CHECK-NEXT: Value: 66560
-; CHECK-NEXT: - Index: 1
-; CHECK-NEXT: Type: I32
-; CHECK-NEXT: Mutable: false
-; CHECK-NEXT: InitExpr:
-; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 66560
-; CHECK-NEXT: - Index: 2
-; CHECK-NEXT: Type: I32
-; CHECK-NEXT: Mutable: false
-; CHECK-NEXT: InitExpr:
-; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 1024
; CHECK-NEXT: - Type: EXPORT
; CHECK-NEXT: Exports:
; CHECK-NEXT: - Name: memory
; CHECK-NEXT: Kind: MEMORY
; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: __heap_base
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 1
-; CHECK-NEXT: - Name: __data_end
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 2
; CHECK-NEXT: - Name: _start
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 0
Modified: lld/trunk/test/wasm/weak-symbols.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/weak-symbols.ll?rev=362276&r1=362275&r2=362276&view=diff
==============================================================================
--- lld/trunk/test/wasm/weak-symbols.ll (original)
+++ lld/trunk/test/wasm/weak-symbols.ll Fri May 31 15:51:59 2019
@@ -53,30 +53,12 @@ entry:
; CHECK-NEXT: Mutable: false
; CHECK-NEXT: InitExpr:
; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 66576
-; CHECK-NEXT: - Index: 2
-; CHECK-NEXT: Type: I32
-; CHECK-NEXT: Mutable: false
-; CHECK-NEXT: InitExpr:
-; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 1028
-; CHECK-NEXT: - Index: 3
-; CHECK-NEXT: Type: I32
-; CHECK-NEXT: Mutable: false
-; CHECK-NEXT: InitExpr:
-; CHECK-NEXT: Opcode: I32_CONST
; CHECK-NEXT: Value: 1024
; CHECK-NEXT: - Type: EXPORT
; CHECK-NEXT: Exports:
; CHECK-NEXT: - Name: memory
; CHECK-NEXT: Kind: MEMORY
; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: __heap_base
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 1
-; CHECK-NEXT: - Name: __data_end
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 2
; CHECK-NEXT: - Name: _start
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 0
@@ -88,7 +70,7 @@ entry:
; CHECK-NEXT: Index: 2
; CHECK-NEXT: - Name: weakGlobal
; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 3
+; CHECK-NEXT: Index: 1
; CHECK-NEXT: - Name: exportWeak2
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 3
Modified: lld/trunk/test/wasm/weak-undefined.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/weak-undefined.ll?rev=362276&r1=362275&r2=362276&view=diff
==============================================================================
--- lld/trunk/test/wasm/weak-undefined.ll (original)
+++ lld/trunk/test/wasm/weak-undefined.ll Fri May 31 15:51:59 2019
@@ -59,29 +59,11 @@ entry:
; CHECK-NEXT: InitExpr:
; CHECK-NEXT: Opcode: I32_CONST
; CHECK-NEXT: Value: 66560
-; CHECK-NEXT: - Index: 1
-; CHECK-NEXT: Type: I32
-; CHECK-NEXT: Mutable: false
-; CHECK-NEXT: InitExpr:
-; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 66560
-; CHECK-NEXT: - Index: 2
-; CHECK-NEXT: Type: I32
-; CHECK-NEXT: Mutable: false
-; CHECK-NEXT: InitExpr:
-; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 1024
; CHECK-NEXT: - Type: EXPORT
; CHECK-NEXT: Exports:
; CHECK-NEXT: - Name: memory
; CHECK-NEXT: Kind: MEMORY
; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: __heap_base
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 1
-; CHECK-NEXT: - Name: __data_end
-; CHECK-NEXT: Kind: GLOBAL
-; CHECK-NEXT: Index: 2
; CHECK-NEXT: - Name: _start
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 2
Modified: lld/trunk/wasm/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Config.h?rev=362276&r1=362275&r2=362276&view=diff
==============================================================================
--- lld/trunk/wasm/Config.h (original)
+++ lld/trunk/wasm/Config.h Fri May 31 15:51:59 2019
@@ -59,6 +59,7 @@ struct Configuration {
llvm::StringRef ThinLTOCacheDir;
llvm::StringSet<> AllowUndefinedSymbols;
+ llvm::StringSet<> ExportedSymbols;
std::vector<llvm::StringRef> SearchPaths;
llvm::CachePruningPolicy ThinLTOCachePolicy;
llvm::Optional<std::vector<std::string>> Features;
Modified: lld/trunk/wasm/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Driver.cpp?rev=362276&r1=362275&r2=362276&view=diff
==============================================================================
--- lld/trunk/wasm/Driver.cpp (original)
+++ lld/trunk/wasm/Driver.cpp Fri May 31 15:51:59 2019
@@ -481,13 +481,8 @@ static void createSyntheticSymbols() {
// See: https://github.com/WebAssembly/mutable-global
WasmSym::StackPointer = Symtab->addSyntheticGlobal(
"__stack_pointer", WASM_SYMBOL_VISIBILITY_HIDDEN, StackPointer);
- WasmSym::HeapBase = Symtab->addSyntheticDataSymbol("__heap_base", 0);
- WasmSym::DataEnd = Symtab->addSyntheticDataSymbol("__data_end", 0);
-
- // These two synthetic symbols exist purely for the embedder so we always
- // want to export them.
- WasmSym::HeapBase->ForceExport = true;
- WasmSym::DataEnd->ForceExport = true;
+ WasmSym::DataEnd = Symtab->addOptionalDataSymbol("__data_end");
+ WasmSym::HeapBase = Symtab->addOptionalDataSymbol("__heap_base");
}
if (Config->Pic) {
@@ -670,6 +665,9 @@ void LinkerDriver::link(ArrayRef<const c
for (auto *Arg : Args.filtered(OPT_trace_symbol))
Symtab->trace(Arg->getValue());
+ for (auto *Arg : Args.filtered(OPT_export))
+ Config->ExportedSymbols.insert(Arg->getValue());
+
if (!Config->Relocatable)
createSyntheticSymbols();
@@ -688,6 +686,11 @@ void LinkerDriver::link(ArrayRef<const c
for (auto *Arg : Args.filtered(OPT_undefined))
handleUndefined(Arg->getValue());
+ // Handle the `--export <sym>` options
+ // This works like --undefined but also exports the symbol if its found
+ for (auto *Arg : Args.filtered(OPT_export))
+ handleUndefined(Arg->getValue());
+
Symbol *EntrySym = nullptr;
if (!Config->Relocatable && !Config->Entry.empty()) {
EntrySym = handleUndefined(Config->Entry);
@@ -701,11 +704,6 @@ void LinkerDriver::link(ArrayRef<const c
if (errorCount())
return;
- // Handle the `--export <sym>` options
- // This works like --undefined but also exports the symbol if its found
- for (auto *Arg : Args.filtered(OPT_export))
- handleUndefined(Arg->getValue());
-
// Create wrapped symbols for -wrap option.
std::vector<WrappedSymbol> Wrapped = addWrappedSymbols(Args);
Modified: lld/trunk/wasm/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/SymbolTable.cpp?rev=362276&r1=362275&r2=362276&view=diff
==============================================================================
--- lld/trunk/wasm/SymbolTable.cpp (original)
+++ lld/trunk/wasm/SymbolTable.cpp Fri May 31 15:51:59 2019
@@ -202,7 +202,10 @@ DefinedFunction *SymbolTable::addSynthet
DefinedData *SymbolTable::addOptionalDataSymbol(StringRef Name, uint32_t Value,
uint32_t Flags) {
Symbol *S = find(Name);
- if (!S || S->isDefined())
+ // Enable --export of optional symbols
+ if (!S && (Config->ExportAll || Config->ExportedSymbols.count(Name) != 0))
+ S = insertName(Name).first;
+ else if (!S || S->isDefined())
return nullptr;
LLVM_DEBUG(dbgs() << "addOptionalDataSymbol: " << Name << "\n");
auto *rtn = replaceSymbol<DefinedData>(S, Name, Flags);
Modified: lld/trunk/wasm/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/SymbolTable.h?rev=362276&r1=362275&r2=362276&view=diff
==============================================================================
--- lld/trunk/wasm/SymbolTable.h (original)
+++ lld/trunk/wasm/SymbolTable.h Fri May 31 15:51:59 2019
@@ -79,8 +79,8 @@ public:
InputGlobal *Global);
DefinedFunction *addSyntheticFunction(StringRef Name, uint32_t Flags,
InputFunction *Function);
- DefinedData *addOptionalDataSymbol(StringRef Name, uint32_t Value,
- uint32_t Flags);
+ DefinedData *addOptionalDataSymbol(StringRef Name, uint32_t Value = 0,
+ uint32_t Flags = 0);
void handleSymbolVariants();
void handleWeakUndefines();
Modified: lld/trunk/wasm/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Writer.cpp?rev=362276&r1=362275&r2=362276&view=diff
==============================================================================
--- lld/trunk/wasm/Writer.cpp (original)
+++ lld/trunk/wasm/Writer.cpp Fri May 31 15:51:59 2019
@@ -258,10 +258,9 @@ void Writer::layoutMemory() {
// Set `__heap_base` to directly follow the end of the stack or global data.
// The fact that this comes last means that a malloc/brk implementation
// can grow the heap at runtime.
- if (!Config->Relocatable) {
+ log("mem: heap base = " + Twine(MemoryPtr));
+ if (WasmSym::HeapBase)
WasmSym::HeapBase->setVirtualAddress(MemoryPtr);
- log("mem: heap base = " + Twine(MemoryPtr));
- }
if (Config->InitialMemory != 0) {
if (Config->InitialMemory != alignTo(Config->InitialMemory, WasmPageSize))
@@ -307,8 +306,8 @@ void Writer::addStartStopSymbols(const I
return;
uint32_t Start = Seg->OutputSeg->StartVA + Seg->OutputSegmentOffset;
uint32_t Stop = Start + Seg->getSize();
- Symtab->addOptionalDataSymbol(Saver.save("__start_" + S), Start, 0);
- Symtab->addOptionalDataSymbol(Saver.save("__stop_" + S), Stop, 0);
+ Symtab->addOptionalDataSymbol(Saver.save("__start_" + S), Start);
+ Symtab->addOptionalDataSymbol(Saver.save("__stop_" + S), Stop);
}
void Writer::addSections() {
More information about the llvm-commits
mailing list