1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

[WebAssembly] Weak symbols should be defined in SF_Global

Summary:
This manifested itself in lld since it meant that weak
symbols were not appearing in archive symbol tables.

Subscribers: jfb, dschuff, jgravelle-google, aheejin

Differential Revision: https://reviews.llvm.org/D38111

llvm-svn: 313838
This commit is contained in:
Sam Clegg 2017-09-20 23:39:44 +00:00
parent 430e5141ba
commit fd7b58837b
2 changed files with 15 additions and 2 deletions

View File

@ -769,7 +769,7 @@ uint32_t WasmObjectFile::getSymbolFlags(DataRefImpl Symb) const {
DEBUG(dbgs() << "getSymbolFlags: ptr=" << &Sym << " " << Sym << "\n");
if (Sym.isWeak())
Result |= SymbolRef::SF_Weak;
else if (Sym.isGlobal())
if (!Sym.isLocal())
Result |= SymbolRef::SF_Global;
switch (Sym.Type) {

View File

@ -1,4 +1,6 @@
; RUN: llc -mtriple wasm32-unknown-unknown-wasm -filetype=obj %s -o - | obj2yaml | FileCheck %s
; RUN: llc -mtriple wasm32-unknown-unknown-wasm -filetype=obj %s -o %t.o
; RUN: obj2yaml %t.o | FileCheck %s
; RUN: llvm-objdump -t %t.o | FileCheck --check-prefix=CHECK-SYMS %s
; 'foo_alias()' is weak alias of function 'foo()'
; 'bar_alias' is weak alias of global variable 'bar'
@ -107,3 +109,14 @@ entry:
; CHECK-NEXT: - Index: 1
; CHECK-NEXT: Name: .data.bar_alias_address
; CHECK-NEXT: ...
; CHECK-SYMS: SYMBOL TABLE:
; CHECK-SYMS-NEXT: 00000000 g F name foo_alias
; CHECK-SYMS-NEXT: 00000001 g F name call_alias
; CHECK-SYMS-NEXT: 00000002 g F name foo
; CHECK-SYMS-NEXT: 00000002 gw F EXPORT foo_alias
; CHECK-SYMS-NEXT: 00000000 gw EXPORT bar_alias
; CHECK-SYMS-NEXT: 00000001 g F EXPORT call_alias
; CHECK-SYMS-NEXT: 00000002 g F EXPORT foo
; CHECK-SYMS-NEXT: 00000000 g EXPORT bar
; CHECK-SYMS-NEXT: 00000008 g EXPORT bar_alias_address