authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-02-28 12:53:08-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-02-28 12:53:08-05:00
log5768fcb0850335fa8b5f3dca23f1bbfca5d6efb2
treeccf3f503ec9ff6b1855c017e3c836d594bd9448e
parent6bc19b437c4323f3b71ad38c5e8e9d0a54ad8d74
signaturelock-open Commit is signed but in an unrecognized format.

update embedded LLD to 8.0.0rc3


26 files changed, 406 insertions(+), 218 deletions(-)

deps/lld-prebuilt/ELF/Options.inc+1-1
...@@ -54,7 +54,7 @@ OPTION(prefix_2, "Bsymbolic-functions", Bsymbolic_functions, Flag, INVALID, INVA...@@ -54,7 +54,7 @@ OPTION(prefix_2, "Bsymbolic-functions", Bsymbolic_functions, Flag, INVALID, INVA
54OPTION(prefix_2, "Bsymbolic", Bsymbolic, Flag, INVALID, INVALID, nullptr, 0, 0,54OPTION(prefix_2, "Bsymbolic", Bsymbolic, Flag, INVALID, INVALID, nullptr, 0, 0,
55 "Bind defined symbols locally", nullptr, nullptr)55 "Bind defined symbols locally", nullptr, nullptr)
56OPTION(prefix_2, "build-id=", build_id_eq, Joined, INVALID, INVALID, nullptr, 0, 0,56OPTION(prefix_2, "build-id=", build_id_eq, Joined, INVALID, INVALID, nullptr, 0, 0,
57 "Generate build ID note", "[fast,md5,sha,uuid,0x<hexstring>]", nullptr)57 "Generate build ID note", "[fast,md5,sha1,uuid,0x<hexstring>]", nullptr)
58OPTION(prefix_2, "build-id", build_id, Flag, INVALID, INVALID, nullptr, 0, 0,58OPTION(prefix_2, "build-id", build_id, Flag, INVALID, INVALID, nullptr, 0, 0,
59 "Alias for --build-id=fast", nullptr, nullptr)59 "Alias for --build-id=fast", nullptr, nullptr)
60OPTION(prefix_1, "b", anonymous_16, Separate, INVALID, format, nullptr, 0, 0,60OPTION(prefix_1, "b", anonymous_16, Separate, INVALID, format, nullptr, 0, 0,
deps/lld/ELF/Driver.cpp+1-1
...@@ -130,7 +130,7 @@ static std::tuple<ELFKind, uint16_t, uint8_t> parseEmulation(StringRef Emul) {...@@ -130,7 +130,7 @@ static std::tuple<ELFKind, uint16_t, uint8_t> parseEmulation(StringRef Emul) {
130 .Cases("elf32btsmip", "elf32btsmipn32", {ELF32BEKind, EM_MIPS})130 .Cases("elf32btsmip", "elf32btsmipn32", {ELF32BEKind, EM_MIPS})
131 .Cases("elf32ltsmip", "elf32ltsmipn32", {ELF32LEKind, EM_MIPS})131 .Cases("elf32ltsmip", "elf32ltsmipn32", {ELF32LEKind, EM_MIPS})
132 .Case("elf32lriscv", {ELF32LEKind, EM_RISCV})132 .Case("elf32lriscv", {ELF32LEKind, EM_RISCV})
133 .Case("elf32ppc", {ELF32BEKind, EM_PPC})133 .Cases("elf32ppc", "elf32ppclinux", {ELF32BEKind, EM_PPC})
134 .Case("elf64btsmip", {ELF64BEKind, EM_MIPS})134 .Case("elf64btsmip", {ELF64BEKind, EM_MIPS})
135 .Case("elf64ltsmip", {ELF64LEKind, EM_MIPS})135 .Case("elf64ltsmip", {ELF64LEKind, EM_MIPS})
136 .Case("elf64lriscv", {ELF64LEKind, EM_RISCV})136 .Case("elf64lriscv", {ELF64LEKind, EM_RISCV})
deps/lld/ELF/Options.td+1-1
...@@ -30,7 +30,7 @@ def Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries">;...@@ -30,7 +30,7 @@ def Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries">;
30def build_id: F<"build-id">, HelpText<"Alias for --build-id=fast">;30def build_id: F<"build-id">, HelpText<"Alias for --build-id=fast">;
3131
32def build_id_eq: J<"build-id=">, HelpText<"Generate build ID note">,32def build_id_eq: J<"build-id=">, HelpText<"Generate build ID note">,
33 MetaVarName<"[fast,md5,sha,uuid,0x<hexstring>]">;33 MetaVarName<"[fast,md5,sha1,uuid,0x<hexstring>]">;
3434
35defm check_sections: B<"check-sections",35defm check_sections: B<"check-sections",
36 "Check section addresses for overlaps (default)",36 "Check section addresses for overlaps (default)",
deps/lld/ELF/ScriptParser.cpp+2-1
...@@ -392,10 +392,11 @@ static std::pair<ELFKind, uint16_t> parseBfdName(StringRef S) {...@@ -392,10 +392,11 @@ static std::pair<ELFKind, uint16_t> parseBfdName(StringRef S) {
392 .Case("elf32-x86-64", {ELF32LEKind, EM_X86_64})392 .Case("elf32-x86-64", {ELF32LEKind, EM_X86_64})
393 .Case("elf64-aarch64", {ELF64LEKind, EM_AARCH64})393 .Case("elf64-aarch64", {ELF64LEKind, EM_AARCH64})
394 .Case("elf64-littleaarch64", {ELF64LEKind, EM_AARCH64})394 .Case("elf64-littleaarch64", {ELF64LEKind, EM_AARCH64})
395 .Case("elf32-powerpc", {ELF32BEKind, EM_PPC})
395 .Case("elf64-powerpc", {ELF64BEKind, EM_PPC64})396 .Case("elf64-powerpc", {ELF64BEKind, EM_PPC64})
396 .Case("elf64-powerpcle", {ELF64LEKind, EM_PPC64})397 .Case("elf64-powerpcle", {ELF64LEKind, EM_PPC64})
397 .Case("elf64-x86-64", {ELF64LEKind, EM_X86_64})398 .Case("elf64-x86-64", {ELF64LEKind, EM_X86_64})
398 .Case("elf32-tradbigmips", {ELF32BEKind, EM_MIPS})399 .Cases("elf32-tradbigmips", "elf32-bigmips", {ELF32BEKind, EM_MIPS})
399 .Case("elf32-ntradbigmips", {ELF32BEKind, EM_MIPS})400 .Case("elf32-ntradbigmips", {ELF32BEKind, EM_MIPS})
400 .Case("elf32-tradlittlemips", {ELF32LEKind, EM_MIPS})401 .Case("elf32-tradlittlemips", {ELF32LEKind, EM_MIPS})
401 .Case("elf32-ntradlittlemips", {ELF32LEKind, EM_MIPS})402 .Case("elf32-ntradlittlemips", {ELF32LEKind, EM_MIPS})
deps/lld/docs/ReleaseNotes.rst+28-16
...@@ -5,18 +5,15 @@ lld 8.0.0 Release Notes...@@ -5,18 +5,15 @@ lld 8.0.0 Release Notes
5.. contents::5.. contents::
6 :local:6 :local:
77
8.. warning::
9 These are in-progress notes for the upcoming LLVM 8.0.0 release.
10 Release notes for previous releases can be found on
11 `the Download Page <https://releases.llvm.org/download.html>`_.
12
13Introduction8Introduction
14============9============
1510
16This document contains the release notes for the lld linker, release 8.0.0.11lld is a high-performance linker that supports ELF (Unix), COFF (Windows),
17Here we describe the status of lld, including major improvements12Mach-O (macOS), MinGW and WebAssembly. lld is command-line-compatible with
18from the previous release. All lld releases may be downloaded13GNU linkers and Microsoft link.exe and is significantly faster than the
19from the `LLVM releases web site <https://llvm.org/releases/>`_.14system default linkers.
15
16lld 8.0.0 has lots of feature improvements and bug fixes.
2017
21Non-comprehensive list of changes in this release18Non-comprehensive list of changes in this release
22=================================================19=================================================
...@@ -33,16 +30,36 @@ ELF Improvements...@@ -33,16 +30,36 @@ ELF Improvements
33 non-superpages to a superpage if they are aligned to the superpage30 non-superpages to a superpage if they are aligned to the superpage
34 size. (`r342746 <https://reviews.llvm.org/rL342746>`_)31 size. (`r342746 <https://reviews.llvm.org/rL342746>`_)
3532
33* lld now attempts to place a ``.note`` segment in the first page of a
34 generated file, so that you can find some important information
35 (``.note.gnu.build-id`` in particular) in a core file even if a core
36 file is truncated by ulimit.
37 (`r349524 <https://reviews.llvm.org/rL349524>`_)
38
39* lld now reports an error if ``_GLOBAL_OFFSET_TABLE_`` symbol is
40 defined by an input object file, as the symbol is supposed to be
41 synthesized by the linker.
42 (`r347854 <https://reviews.llvm.org/rL347854>`_)
43
36* lld/Hexagon can now link Linux kernel and musl libc for Qualcomm44* lld/Hexagon can now link Linux kernel and musl libc for Qualcomm
37 Hexagon ISA.45 Hexagon ISA.
3846
39* Initial MSP430 ISA support has landed.47* Initial MSP430 ISA support has landed.
4048
41* The following flags have been added: ``-z interpose``, ``-z global``
42
43* lld now uses the ``sigrie`` instruction as a trap instruction for49* lld now uses the ``sigrie`` instruction as a trap instruction for
44 MIPS targets.50 MIPS targets.
4551
52* lld now creates a TLS segment for AArch64 with a slightly larger
53 alignment requirement, so that the loader makes a few bytes room
54 before each TLS segment at runtime. The aim of this change is to
55 make room to accomodate nonstandard Android TLS slots while keeping
56 the compatibility with the standard AArch64 ABI.
57 (`r350681 <https://reviews.llvm.org/rL350681>`_)
58
59* The following flags have been added: ``--call-graph-profile``,
60 ``--no-call-graph-profile``, ``--warn-ifunc-textrel``,
61 ``-z interpose``, ``-z global``, ``-z nodefaultlib``
62
46COFF Improvements63COFF Improvements
47-----------------64-----------------
4865
...@@ -95,11 +112,6 @@ MinGW Improvements...@@ -95,11 +112,6 @@ MinGW Improvements
95 Previously, the ``--build-id`` option did not actually generate a build id112 Previously, the ``--build-id`` option did not actually generate a build id
96 unless ``--pdb`` was specified.113 unless ``--pdb`` was specified.
97114
98MachO Improvements
99------------------
100
101* Item 1.
102
103WebAssembly Improvements115WebAssembly Improvements
104------------------------116------------------------
105117
deps/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp+1
...@@ -622,6 +622,7 @@ void ArchHandler_x86_64::applyFixupFinal(...@@ -622,6 +622,7 @@ void ArchHandler_x86_64::applyFixupFinal(
622 // Fall into llvm_unreachable().622 // Fall into llvm_unreachable().
623 break;623 break;
624 }624 }
625 llvm_unreachable("invalid x86_64 Reference Kind");
625}626}
626627
627void ArchHandler_x86_64::applyFixupRelocatable(const Reference &ref,628void ArchHandler_x86_64::applyFixupRelocatable(const Reference &ref,
deps/lld/test/ELF/emulation-mips.s+3
...@@ -7,6 +7,9 @@...@@ -7,6 +7,9 @@
7# RUN: echo 'OUTPUT_FORMAT(elf32-tradbigmips)' > %tmips.script7# RUN: echo 'OUTPUT_FORMAT(elf32-tradbigmips)' > %tmips.script
8# RUN: ld.lld %tmips.script -e _start %tmips -o %t4mips8# RUN: ld.lld %tmips.script -e _start %tmips -o %t4mips
9# RUN: llvm-readobj -file-headers %t4mips | FileCheck --check-prefix=MIPS %s9# RUN: llvm-readobj -file-headers %t4mips | FileCheck --check-prefix=MIPS %s
10# RUN: echo 'OUTPUT_FORMAT(elf32-bigmips)' > %tmips2.script
11# RUN: ld.lld %tmips2.script -e _start %tmips -o %t5mips
12# RUN: llvm-readobj -file-headers %t5mips | FileCheck --check-prefix=MIPS %s
10# MIPS: ElfHeader {13# MIPS: ElfHeader {
11# MIPS-NEXT: Ident {14# MIPS-NEXT: Ident {
12# MIPS-NEXT: Magic: (7F 45 4C 46)15# MIPS-NEXT: Magic: (7F 45 4C 46)
deps/lld/test/ELF/emulation-ppc.s+37
...@@ -103,5 +103,42 @@...@@ -103,5 +103,42 @@
103# PPC64LE-NEXT: StringTableSectionIndex:103# PPC64LE-NEXT: StringTableSectionIndex:
104# PPC64LE-NEXT: }104# PPC64LE-NEXT: }
105105
106# RUN: llvm-mc -filetype=obj -triple=powerpc-unknown-linux %s -o %tppc32
107# RUN: ld.lld -m elf32ppc %tppc32 -o %t2ppc32
108# RUN: llvm-readobj -file-headers %t2ppc32 | FileCheck --check-prefix=PPC32 %s
109# RUN: ld.lld %tppc32 -o %t3ppc32
110# RUN: llvm-readobj -file-headers %t3ppc32 | FileCheck --check-prefix=PPC32 %s
111# RUN: echo 'OUTPUT_FORMAT(elf32-powerpc)' > %tppc32.script
112# RUN: ld.lld %tppc32.script %tppc32 -o %t4ppc32
113# RUN: llvm-readobj -file-headers %t4ppc32 | FileCheck --check-prefix=PPC32 %s
114# RUN: ld.lld -m elf32ppclinux %tppc32 -o %t5ppc32
115# RUN: llvm-readobj -file-headers %t5ppc32 | FileCheck --check-prefix=PPC32 %s
116
117# PPC32: ElfHeader {
118# PPC32-NEXT: Ident {
119# PPC32-NEXT: Magic: (7F 45 4C 46)
120# PPC32-NEXT: Class: 32-bit (0x1)
121# PPC32-NEXT: DataEncoding: BigEndian (0x2)
122# PPC32-NEXT: FileVersion: 1
123# PPC32-NEXT: OS/ABI: SystemV (0x0)
124# PPC32-NEXT: ABIVersion: 0
125# PPC32-NEXT: Unused: (00 00 00 00 00 00 00)
126# PPC32-NEXT: }
127# PPC32-NEXT: Type: Executable (0x2)
128# PPC32-NEXT: Machine: EM_PPC (0x14)
129# PPC32-NEXT: Version: 1
130# PPC32-NEXT: Entry:
131# PPC32-NEXT: ProgramHeaderOffset: 0x34
132# PPC32-NEXT: SectionHeaderOffset:
133# PPC32-NEXT: Flags [ (0x0)
134# PPC32-NEXT: ]
135# PPC32-NEXT: HeaderSize: 52
136# PPC32-NEXT: ProgramHeaderEntrySize: 32
137# PPC32-NEXT: ProgramHeaderCount:
138# PPC32-NEXT: SectionHeaderEntrySize: 40
139# PPC32-NEXT: SectionHeaderCount:
140# PPC32-NEXT: StringTableSectionIndex:
141# PPC32-NEXT: }
142
106.globl _start143.globl _start
107_start:144_start:
deps/lld/test/wasm/data-layout.ll+3-3
...@@ -85,10 +85,10 @@ target triple = "wasm32-unknown-unknown"...@@ -85,10 +85,10 @@ target triple = "wasm32-unknown-unknown"
85; RELOC: - Type: DATA85; RELOC: - Type: DATA
86; RELOC-NEXT: Relocations:86; RELOC-NEXT: Relocations:
87; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_I3287; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_I32
88; RELOC-NEXT: Index: 688; RELOC-NEXT: Index: 3
89; RELOC-NEXT: Offset: 0x0000001889; RELOC-NEXT: Offset: 0x00000018
90; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_I3290; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_I32
91; RELOC-NEXT: Index: 391; RELOC-NEXT: Index: 4
92; RELOC-NEXT: Offset: 0x0000002E92; RELOC-NEXT: Offset: 0x0000002E
93; RELOC-NEXT: Addend: 493; RELOC-NEXT: Addend: 4
94; RELOC-NEXT: Segments:94; RELOC-NEXT: Segments:
...@@ -148,7 +148,7 @@ target triple = "wasm32-unknown-unknown"...@@ -148,7 +148,7 @@ target triple = "wasm32-unknown-unknown"
148; RELOC-NEXT: Flags: [ ]148; RELOC-NEXT: Flags: [ ]
149; RELOC-NEXT: Segment: 2149; RELOC-NEXT: Segment: 2
150; RELOC-NEXT: Size: 4150; RELOC-NEXT: Size: 4
151; RELOC: - Index: 6151; RELOC-NEXT: - Index: 3
152; RELOC-NEXT: Kind: DATA152; RELOC-NEXT: Kind: DATA
153; RELOC-NEXT: Name: hello_str153; RELOC-NEXT: Name: hello_str
154; RELOC-NEXT: Flags: [ ]154; RELOC-NEXT: Flags: [ ]
deps/lld/test/wasm/import-module.ll created+21
...@@ -0,0 +1,21 @@
1; RUN: llc -filetype=obj %s -o %t.o
2; RUN: wasm-ld --allow-undefined -o %t.wasm %t.o
3; RUN: obj2yaml %t.wasm | FileCheck %s
4
5target triple = "wasm32-unknown-unknown-wasm"
6
7define void @_start() {
8 call void @foo();
9 ret void
10}
11
12declare void @foo() #0
13
14attributes #0 = { "wasm-import-module"="bar" }
15
16; CHECK: - Type: IMPORT
17; CHECK-NEXT: Imports:
18; CHECK-NEXT: - Module: bar
19; CHECK-NEXT: Field: foo
20; CHECK-NEXT: Kind: FUNCTION
21; CHECK-NEXT: SigIndex: 0
deps/lld/test/wasm/import-names.ll created+27
...@@ -0,0 +1,27 @@
1; RUN: llc -filetype=obj %s -o %t.o
2; RUN: wasm-ld --allow-undefined -o %t.wasm %t.o
3; RUN: obj2yaml %t.wasm | FileCheck %s
4
5target triple = "wasm32-unknown-unknown"
6
7declare void @f0() #0
8
9define void @_start() {
10 call void @f0()
11 ret void
12}
13
14attributes #0 = { "wasm-import-module"="somewhere" "wasm-import-name"="something" }
15
16; CHECK: - Type: IMPORT
17; CHECK-NEXT: Imports:
18; CHECK-NEXT: - Module: somewhere
19; CHECK-NEXT: Field: something
20; CHECK-NEXT: Kind: FUNCTION
21; CHECK-NEXT: SigIndex: 0
22
23; CHECK: - Type: CUSTOM
24; CHECK-NEXT: Name: name
25; CHECK-NEXT: FunctionNames:
26; CHECK-NEXT: - Index: 0
27; CHECK-NEXT: Name: f0
deps/lld/test/wasm/init-fini.ll+43-43
...@@ -163,64 +163,64 @@ entry:...@@ -163,64 +163,64 @@ entry:
163; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ]163; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ]
164; RELOC-NEXT: Function: 7164; RELOC-NEXT: Function: 7
165; RELOC-NEXT: - Index: 6165; RELOC-NEXT: - Index: 6
166; RELOC-NEXT: Kind: DATA
167; RELOC-NEXT: Name: __dso_handle
168; RELOC-NEXT: Flags: [ BINDING_WEAK, VISIBILITY_HIDDEN, UNDEFINED ]
169; RELOC-NEXT: - Index: 7
170; RELOC-NEXT: Kind: FUNCTION
171; RELOC-NEXT: Name: externDtor
172; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN, UNDEFINED ]
173; RELOC-NEXT: Function: 0
174; RELOC-NEXT: - Index: 8
175; RELOC-NEXT: Kind: FUNCTION
176; RELOC-NEXT: Name: externCtor
177; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN, UNDEFINED ]
178; RELOC-NEXT: Function: 1
179; RELOC-NEXT: - Index: 9
180; RELOC-NEXT: Kind: FUNCTION
181; RELOC-NEXT: Name: myctor
182; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ]
183; RELOC-NEXT: Function: 14
184; RELOC-NEXT: - Index: 10
185; RELOC-NEXT: Kind: FUNCTION
186; RELOC-NEXT: Name: mydtor
187; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ]
188; RELOC-NEXT: Function: 15
189; RELOC-NEXT: - Index: 11
190; RELOC-NEXT: Kind: GLOBAL
191; RELOC-NEXT: Name: __stack_pointer
192; RELOC-NEXT: Flags: [ UNDEFINED ]
193; RELOC-NEXT: Global: 0
194; RELOC-NEXT: - Index: 12
166; RELOC-NEXT: Kind: FUNCTION195; RELOC-NEXT: Kind: FUNCTION
167; RELOC-NEXT: Name: .Lcall_dtors.101196; RELOC-NEXT: Name: .Lcall_dtors.101
168; RELOC-NEXT: Flags: [ BINDING_LOCAL ]197; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
169; RELOC-NEXT: Function: 8198; RELOC-NEXT: Function: 8
170; RELOC-NEXT: - Index: 7199; RELOC-NEXT: - Index: 13
171; RELOC-NEXT: Kind: FUNCTION200; RELOC-NEXT: Kind: FUNCTION
172; RELOC-NEXT: Name: .Lregister_call_dtors.101201; RELOC-NEXT: Name: .Lregister_call_dtors.101
173; RELOC-NEXT: Flags: [ BINDING_LOCAL ]202; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
174; RELOC-NEXT: Function: 9203; RELOC-NEXT: Function: 9
175; RELOC-NEXT: - Index: 8204; RELOC-NEXT: - Index: 14
176; RELOC-NEXT: Kind: DATA
177; RELOC-NEXT: Name: __dso_handle
178; RELOC-NEXT: Flags: [ BINDING_WEAK, VISIBILITY_HIDDEN, UNDEFINED ]
179; RELOC-NEXT: - Index: 9
180; RELOC-NEXT: Kind: FUNCTION205; RELOC-NEXT: Kind: FUNCTION
181; RELOC-NEXT: Name: .Lcall_dtors.1001206; RELOC-NEXT: Name: .Lcall_dtors.1001
182; RELOC-NEXT: Flags: [ BINDING_LOCAL ]207; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
183; RELOC-NEXT: Function: 10208; RELOC-NEXT: Function: 10
184; RELOC-NEXT: - Index: 10209; RELOC-NEXT: - Index: 15
185; RELOC-NEXT: Kind: FUNCTION210; RELOC-NEXT: Kind: FUNCTION
186; RELOC-NEXT: Name: .Lregister_call_dtors.1001211; RELOC-NEXT: Name: .Lregister_call_dtors.1001
187; RELOC-NEXT: Flags: [ BINDING_LOCAL ]212; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
188; RELOC-NEXT: Function: 11213; RELOC-NEXT: Function: 11
189; RELOC-NEXT: - Index: 11214; RELOC-NEXT: - Index: 16
190; RELOC-NEXT: Kind: FUNCTION215; RELOC-NEXT: Kind: FUNCTION
191; RELOC-NEXT: Name: .Lcall_dtors.4000216; RELOC-NEXT: Name: .Lcall_dtors.4000
192; RELOC-NEXT: Flags: [ BINDING_LOCAL ]217; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
193; RELOC-NEXT: Function: 12218; RELOC-NEXT: Function: 12
194; RELOC-NEXT: - Index: 12219; RELOC-NEXT: - Index: 17
195; RELOC-NEXT: Kind: FUNCTION
196; RELOC-NEXT: Name: externDtor
197; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN, UNDEFINED ]
198; RELOC-NEXT: Function: 0
199; RELOC-NEXT: - Index: 13
200; RELOC-NEXT: Kind: FUNCTION220; RELOC-NEXT: Kind: FUNCTION
201; RELOC-NEXT: Name: .Lregister_call_dtors.4000221; RELOC-NEXT: Name: .Lregister_call_dtors.4000
202; RELOC-NEXT: Flags: [ BINDING_LOCAL ]222; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
203; RELOC-NEXT: Function: 13223; RELOC-NEXT: Function: 13
204; RELOC-NEXT: - Index: 14
205; RELOC-NEXT: Kind: FUNCTION
206; RELOC-NEXT: Name: externCtor
207; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN, UNDEFINED ]
208; RELOC-NEXT: Function: 1
209; RELOC-NEXT: - Index: 15
210; RELOC-NEXT: Kind: FUNCTION
211; RELOC-NEXT: Name: myctor
212; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ]
213; RELOC-NEXT: Function: 14
214; RELOC-NEXT: - Index: 16
215; RELOC-NEXT: Kind: FUNCTION
216; RELOC-NEXT: Name: mydtor
217; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ]
218; RELOC-NEXT: Function: 15
219; RELOC-NEXT: - Index: 17
220; RELOC-NEXT: Kind: GLOBAL
221; RELOC-NEXT: Name: __stack_pointer
222; RELOC-NEXT: Flags: [ UNDEFINED ]
223; RELOC-NEXT: Global: 0
224; RELOC-NEXT: - Index: 18224; RELOC-NEXT: - Index: 18
225; RELOC-NEXT: Kind: FUNCTION225; RELOC-NEXT: Kind: FUNCTION
226; RELOC-NEXT: Name: .Lcall_dtors.101226; RELOC-NEXT: Name: .Lcall_dtors.101
...@@ -251,36 +251,36 @@ entry:...@@ -251,36 +251,36 @@ entry:
251; RELOC-NEXT: Name: .Lregister_call_dtors.2002251; RELOC-NEXT: Name: .Lregister_call_dtors.2002
252; RELOC-NEXT: Flags: [ BINDING_LOCAL ]252; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
253; RELOC-NEXT: Function: 21253; RELOC-NEXT: Function: 21
254; RELOC-NEXT: InitFunctions:254; RELOC-NEXT: InitFunctions:
255; RELOC-NEXT: - Priority: 101255; RELOC-NEXT: - Priority: 101
256; RELOC-NEXT: Symbol: 0256; RELOC-NEXT: Symbol: 0
257; RELOC-NEXT: - Priority: 101257; RELOC-NEXT: - Priority: 101
258; RELOC-NEXT: Symbol: 1258; RELOC-NEXT: Symbol: 1
259; RELOC-NEXT: - Priority: 101259; RELOC-NEXT: - Priority: 101
260; RELOC-NEXT: Symbol: 7260; RELOC-NEXT: Symbol: 13
261; RELOC-NEXT: - Priority: 101261; RELOC-NEXT: - Priority: 101
262; RELOC-NEXT: Symbol: 15262; RELOC-NEXT: Symbol: 9
263; RELOC-NEXT: - Priority: 101263; RELOC-NEXT: - Priority: 101
264; RELOC-NEXT: Symbol: 19264; RELOC-NEXT: Symbol: 19
265; RELOC-NEXT: - Priority: 202265; RELOC-NEXT: - Priority: 202
266; RELOC-NEXT: Symbol: 15266; RELOC-NEXT: Symbol: 9
267; RELOC-NEXT: - Priority: 202267; RELOC-NEXT: - Priority: 202
268; RELOC-NEXT: Symbol: 21268; RELOC-NEXT: Symbol: 21
269; RELOC-NEXT: - Priority: 1001269; RELOC-NEXT: - Priority: 1001
270; RELOC-NEXT: Symbol: 0270; RELOC-NEXT: Symbol: 0
271; RELOC-NEXT: - Priority: 1001271; RELOC-NEXT: - Priority: 1001
272; RELOC-NEXT: Symbol: 10
273; RELOC-NEXT: - Priority: 2002
274; RELOC-NEXT: Symbol: 15272; RELOC-NEXT: Symbol: 15
275; RELOC-NEXT: - Priority: 2002273; RELOC-NEXT: - Priority: 2002
274; RELOC-NEXT: Symbol: 9
275; RELOC-NEXT: - Priority: 2002
276; RELOC-NEXT: Symbol: 23276; RELOC-NEXT: Symbol: 23
277; RELOC-NEXT: - Priority: 4000277; RELOC-NEXT: - Priority: 4000
278; RELOC-NEXT: Symbol: 14278; RELOC-NEXT: Symbol: 8
279; RELOC-NEXT: - Priority: 4000279; RELOC-NEXT: - Priority: 4000
280; RELOC-NEXT: Symbol: 13280; RELOC-NEXT: Symbol: 17
281; RELOC-NEXT: - Type: CUSTOM281; RELOC-NEXT: - Type: CUSTOM
282; RELOC-NEXT: Name: name282; RELOC-NEXT: Name: name
283; RELOC-NEXT: FunctionNames:283; RELOC-NEXT: FunctionNames:
284; RELOC-NEXT: - Index: 0284; RELOC-NEXT: - Index: 0
285; RELOC-NEXT: Name: externDtor285; RELOC-NEXT: Name: externDtor
286; RELOC-NEXT: - Index: 1286; RELOC-NEXT: - Index: 1
deps/lld/test/wasm/locals-duplicate.test+73-73
...@@ -270,40 +270,40 @@...@@ -270,40 +270,40 @@
270; RELOC-NEXT: - Type: CODE270; RELOC-NEXT: - Type: CODE
271; RELOC-NEXT: Relocations:271; RELOC-NEXT: Relocations:
272; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_SLEB272; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_SLEB
273; RELOC-NEXT: Index: 4273; RELOC-NEXT: Index: 18
274; RELOC-NEXT: Offset: 0x00000013274; RELOC-NEXT: Offset: 0x00000013
275; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_SLEB275; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_SLEB
276; RELOC-NEXT: Index: 6276; RELOC-NEXT: Index: 3
277; RELOC-NEXT: Offset: 0x0000001C277; RELOC-NEXT: Offset: 0x0000001C
278; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_SLEB278; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_SLEB
279; RELOC-NEXT: Index: 8279; RELOC-NEXT: Index: 19
280; RELOC-NEXT: Offset: 0x00000025280; RELOC-NEXT: Offset: 0x00000025
281; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB281; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB
282; RELOC-NEXT: Index: 0282; RELOC-NEXT: Index: 16
283; RELOC-NEXT: Offset: 0x0000002E283; RELOC-NEXT: Offset: 0x0000002E
284; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB284; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB
285; RELOC-NEXT: Index: 1285; RELOC-NEXT: Index: 0
286; RELOC-NEXT: Offset: 0x00000037286; RELOC-NEXT: Offset: 0x00000037
287; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB287; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB
288; RELOC-NEXT: Index: 2288; RELOC-NEXT: Index: 17
289; RELOC-NEXT: Offset: 0x00000040289; RELOC-NEXT: Offset: 0x00000040
290; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_SLEB290; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_SLEB
291; RELOC-NEXT: Index: 16291; RELOC-NEXT: Index: 10
292; RELOC-NEXT: Offset: 0x00000058292; RELOC-NEXT: Offset: 0x00000058
293; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_SLEB293; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_SLEB
294; RELOC-NEXT: Index: 18294; RELOC-NEXT: Index: 22
295; RELOC-NEXT: Offset: 0x00000061295; RELOC-NEXT: Offset: 0x00000061
296; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_SLEB296; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_SLEB
297; RELOC-NEXT: Index: 20297; RELOC-NEXT: Index: 23
298; RELOC-NEXT: Offset: 0x0000006A298; RELOC-NEXT: Offset: 0x0000006A
299; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB299; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB
300; RELOC-NEXT: Index: 12300; RELOC-NEXT: Index: 8
301; RELOC-NEXT: Offset: 0x00000073301; RELOC-NEXT: Offset: 0x00000073
302; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB302; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB
303; RELOC-NEXT: Index: 13303; RELOC-NEXT: Index: 20
304; RELOC-NEXT: Offset: 0x0000007C304; RELOC-NEXT: Offset: 0x0000007C
305; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB305; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB
306; RELOC-NEXT: Index: 14306; RELOC-NEXT: Index: 21
307; RELOC-NEXT: Offset: 0x00000085307; RELOC-NEXT: Offset: 0x00000085
308; RELOC-NEXT: Functions:308; RELOC-NEXT: Functions:
309; RELOC-NEXT: - Index: 0309; RELOC-NEXT: - Index: 0
...@@ -386,133 +386,133 @@...@@ -386,133 +386,133 @@
386; RELOC-NEXT: SymbolTable:386; RELOC-NEXT: SymbolTable:
387; RELOC-NEXT: - Index: 0387; RELOC-NEXT: - Index: 0
388; RELOC-NEXT: Kind: FUNCTION388; RELOC-NEXT: Kind: FUNCTION
389; RELOC-NEXT: Name: colliding_func1
390; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
391; RELOC-NEXT: Function: 0
392; RELOC-NEXT: - Index: 1
393; RELOC-NEXT: Kind: FUNCTION
394; RELOC-NEXT: Name: colliding_func2389; RELOC-NEXT: Name: colliding_func2
395; RELOC-NEXT: Flags: [ ]390; RELOC-NEXT: Flags: [ ]
396; RELOC-NEXT: Function: 1391; RELOC-NEXT: Function: 1
397; RELOC-NEXT: - Index: 2392; RELOC-NEXT: - Index: 1
398; RELOC-NEXT: Kind: FUNCTION
399; RELOC-NEXT: Name: colliding_func3
400; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
401; RELOC-NEXT: Function: 2
402; RELOC-NEXT: - Index: 3
403; RELOC-NEXT: Kind: FUNCTION393; RELOC-NEXT: Kind: FUNCTION
404; RELOC-NEXT: Name: get_global1A394; RELOC-NEXT: Name: get_global1A
405; RELOC-NEXT: Flags: [ ]395; RELOC-NEXT: Flags: [ ]
406; RELOC-NEXT: Function: 3396; RELOC-NEXT: Function: 3
407; RELOC-NEXT: - Index: 4397; RELOC-NEXT: - Index: 2
408; RELOC-NEXT: Kind: DATA
409; RELOC-NEXT: Name: colliding_global1
410; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
411; RELOC-NEXT: Segment: 0
412; RELOC-NEXT: Size: 4
413; RELOC-NEXT: - Index: 5
414; RELOC-NEXT: Kind: FUNCTION398; RELOC-NEXT: Kind: FUNCTION
415; RELOC-NEXT: Name: get_global2A399; RELOC-NEXT: Name: get_global2A
416; RELOC-NEXT: Flags: [ ]400; RELOC-NEXT: Flags: [ ]
417; RELOC-NEXT: Function: 4401; RELOC-NEXT: Function: 4
418; RELOC-NEXT: - Index: 6402; RELOC-NEXT: - Index: 3
419; RELOC-NEXT: Kind: DATA403; RELOC-NEXT: Kind: DATA
420; RELOC-NEXT: Name: colliding_global2404; RELOC-NEXT: Name: colliding_global2
421; RELOC-NEXT: Flags: [ ]405; RELOC-NEXT: Flags: [ ]
422; RELOC-NEXT: Segment: 1406; RELOC-NEXT: Segment: 1
423; RELOC-NEXT: Size: 4407; RELOC-NEXT: Size: 4
424; RELOC-NEXT: - Index: 7408; RELOC-NEXT: - Index: 4
425; RELOC-NEXT: Kind: FUNCTION409; RELOC-NEXT: Kind: FUNCTION
426; RELOC-NEXT: Name: get_global3A410; RELOC-NEXT: Name: get_global3A
427; RELOC-NEXT: Flags: [ ]411; RELOC-NEXT: Flags: [ ]
428; RELOC-NEXT: Function: 5412; RELOC-NEXT: Function: 5
429; RELOC-NEXT: - Index: 8413; RELOC-NEXT: - Index: 5
430; RELOC-NEXT: Kind: DATA
431; RELOC-NEXT: Name: colliding_global3
432; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
433; RELOC-NEXT: Segment: 2
434; RELOC-NEXT: Size: 4
435; RELOC-NEXT: - Index: 9
436; RELOC-NEXT: Kind: FUNCTION414; RELOC-NEXT: Kind: FUNCTION
437; RELOC-NEXT: Name: get_func1A415; RELOC-NEXT: Name: get_func1A
438; RELOC-NEXT: Flags: [ ]416; RELOC-NEXT: Flags: [ ]
439; RELOC-NEXT: Function: 6417; RELOC-NEXT: Function: 6
440; RELOC-NEXT: - Index: 10418; RELOC-NEXT: - Index: 6
441; RELOC-NEXT: Kind: FUNCTION419; RELOC-NEXT: Kind: FUNCTION
442; RELOC-NEXT: Name: get_func2A420; RELOC-NEXT: Name: get_func2A
443; RELOC-NEXT: Flags: [ ]421; RELOC-NEXT: Flags: [ ]
444; RELOC-NEXT: Function: 7422; RELOC-NEXT: Function: 7
445; RELOC-NEXT: - Index: 11423; RELOC-NEXT: - Index: 7
446; RELOC-NEXT: Kind: FUNCTION424; RELOC-NEXT: Kind: FUNCTION
447; RELOC-NEXT: Name: get_func3A425; RELOC-NEXT: Name: get_func3A
448; RELOC-NEXT: Flags: [ ]426; RELOC-NEXT: Flags: [ ]
449; RELOC-NEXT: Function: 8427; RELOC-NEXT: Function: 8
450; RELOC-NEXT: - Index: 12428; RELOC-NEXT: - Index: 8
451; RELOC-NEXT: Kind: FUNCTION429; RELOC-NEXT: Kind: FUNCTION
452; RELOC-NEXT: Name: colliding_func1430; RELOC-NEXT: Name: colliding_func1
453; RELOC-NEXT: Flags: [ ]431; RELOC-NEXT: Flags: [ ]
454; RELOC-NEXT: Function: 9432; RELOC-NEXT: Function: 9
455; RELOC-NEXT: - Index: 13433; RELOC-NEXT: - Index: 9
456; RELOC-NEXT: Kind: FUNCTION
457; RELOC-NEXT: Name: colliding_func2
458; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
459; RELOC-NEXT: Function: 10
460; RELOC-NEXT: - Index: 14
461; RELOC-NEXT: Kind: FUNCTION
462; RELOC-NEXT: Name: colliding_func3
463; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
464; RELOC-NEXT: Function: 11
465; RELOC-NEXT: - Index: 15
466; RELOC-NEXT: Kind: FUNCTION434; RELOC-NEXT: Kind: FUNCTION
467; RELOC-NEXT: Name: get_global1B435; RELOC-NEXT: Name: get_global1B
468; RELOC-NEXT: Flags: [ ]436; RELOC-NEXT: Flags: [ ]
469; RELOC-NEXT: Function: 12437; RELOC-NEXT: Function: 12
470; RELOC-NEXT: - Index: 16438; RELOC-NEXT: - Index: 10
471; RELOC-NEXT: Kind: DATA439; RELOC-NEXT: Kind: DATA
472; RELOC-NEXT: Name: colliding_global1440; RELOC-NEXT: Name: colliding_global1
473; RELOC-NEXT: Flags: [ ]441; RELOC-NEXT: Flags: [ ]
474; RELOC-NEXT: Segment: 0442; RELOC-NEXT: Segment: 0
475; RELOC-NEXT: Offset: 4443; RELOC-NEXT: Offset: 4
476; RELOC-NEXT: Size: 4444; RELOC-NEXT: Size: 4
477; RELOC-NEXT: - Index: 17445; RELOC-NEXT: - Index: 11
478; RELOC-NEXT: Kind: FUNCTION446; RELOC-NEXT: Kind: FUNCTION
479; RELOC-NEXT: Name: get_global2B447; RELOC-NEXT: Name: get_global2B
480; RELOC-NEXT: Flags: [ ]448; RELOC-NEXT: Flags: [ ]
481; RELOC-NEXT: Function: 13449; RELOC-NEXT: Function: 13
482; RELOC-NEXT: - Index: 18450; RELOC-NEXT: - Index: 12
483; RELOC-NEXT: Kind: DATA
484; RELOC-NEXT: Name: colliding_global2
485; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
486; RELOC-NEXT: Segment: 1
487; RELOC-NEXT: Offset: 4
488; RELOC-NEXT: Size: 4
489; RELOC-NEXT: - Index: 19
490; RELOC-NEXT: Kind: FUNCTION451; RELOC-NEXT: Kind: FUNCTION
491; RELOC-NEXT: Name: get_global3B452; RELOC-NEXT: Name: get_global3B
492; RELOC-NEXT: Flags: [ ]453; RELOC-NEXT: Flags: [ ]
493; RELOC-NEXT: Function: 14454; RELOC-NEXT: Function: 14
494; RELOC-NEXT: - Index: 20455; RELOC-NEXT: - Index: 13
495; RELOC-NEXT: Kind: DATA
496; RELOC-NEXT: Name: colliding_global3
497; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
498; RELOC-NEXT: Segment: 2
499; RELOC-NEXT: Offset: 4
500; RELOC-NEXT: Size: 4
501; RELOC-NEXT: - Index: 21
502; RELOC-NEXT: Kind: FUNCTION456; RELOC-NEXT: Kind: FUNCTION
503; RELOC-NEXT: Name: get_func1B457; RELOC-NEXT: Name: get_func1B
504; RELOC-NEXT: Flags: [ ]458; RELOC-NEXT: Flags: [ ]
505; RELOC-NEXT: Function: 15459; RELOC-NEXT: Function: 15
506; RELOC-NEXT: - Index: 22460; RELOC-NEXT: - Index: 14
507; RELOC-NEXT: Kind: FUNCTION461; RELOC-NEXT: Kind: FUNCTION
508; RELOC-NEXT: Name: get_func2B462; RELOC-NEXT: Name: get_func2B
509; RELOC-NEXT: Flags: [ ]463; RELOC-NEXT: Flags: [ ]
510; RELOC-NEXT: Function: 16464; RELOC-NEXT: Function: 16
511; RELOC-NEXT: - Index: 23465; RELOC-NEXT: - Index: 15
512; RELOC-NEXT: Kind: FUNCTION466; RELOC-NEXT: Kind: FUNCTION
513; RELOC-NEXT: Name: get_func3B467; RELOC-NEXT: Name: get_func3B
514; RELOC-NEXT: Flags: [ ]468; RELOC-NEXT: Flags: [ ]
515; RELOC-NEXT: Function: 17469; RELOC-NEXT: Function: 17
470; RELOC-NEXT: - Index: 16
471; RELOC-NEXT: Kind: FUNCTION
472; RELOC-NEXT: Name: colliding_func1
473; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
474; RELOC-NEXT: Function: 0
475; RELOC-NEXT: - Index: 17
476; RELOC-NEXT: Kind: FUNCTION
477; RELOC-NEXT: Name: colliding_func3
478; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
479; RELOC-NEXT: Function: 2
480; RELOC-NEXT: - Index: 18
481; RELOC-NEXT: Kind: DATA
482; RELOC-NEXT: Name: colliding_global1
483; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
484; RELOC-NEXT: Segment: 0
485; RELOC-NEXT: Size: 4
486; RELOC-NEXT: - Index: 19
487; RELOC-NEXT: Kind: DATA
488; RELOC-NEXT: Name: colliding_global3
489; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
490; RELOC-NEXT: Segment: 2
491; RELOC-NEXT: Size: 4
492; RELOC-NEXT: - Index: 20
493; RELOC-NEXT: Kind: FUNCTION
494; RELOC-NEXT: Name: colliding_func2
495; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
496; RELOC-NEXT: Function: 10
497; RELOC-NEXT: - Index: 21
498; RELOC-NEXT: Kind: FUNCTION
499; RELOC-NEXT: Name: colliding_func3
500; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
501; RELOC-NEXT: Function: 11
502; RELOC-NEXT: - Index: 22
503; RELOC-NEXT: Kind: DATA
504; RELOC-NEXT: Name: colliding_global2
505; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
506; RELOC-NEXT: Segment: 1
507; RELOC-NEXT: Offset: 4
508; RELOC-NEXT: Size: 4
509; RELOC-NEXT: - Index: 23
510; RELOC-NEXT: Kind: DATA
511; RELOC-NEXT: Name: colliding_global3
512; RELOC-NEXT: Flags: [ BINDING_LOCAL ]
513; RELOC-NEXT: Segment: 2
514; RELOC-NEXT: Offset: 4
515; RELOC-NEXT: Size: 4
516; RELOC-NEXT: SegmentInfo:516; RELOC-NEXT: SegmentInfo:
517; RELOC-NEXT: - Index: 0517; RELOC-NEXT: - Index: 0
518; RELOC-NEXT: Name: .bss.colliding_global1518; RELOC-NEXT: Name: .bss.colliding_global1
deps/lld/test/wasm/lto/relocatable-undefined.ll created+36
...@@ -0,0 +1,36 @@
1; RUN: llvm-as %s -o %t.o
2; RUN: wasm-ld -r -o %t.wasm %t.o
3; RUN: obj2yaml %t.wasm | FileCheck %s
4
5target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
6target triple = "wasm32-unknown-unknown"
7
8@missing_data = external global i32
9declare i32 @missing_func() local_unnamed_addr
10
11define i32 @foo() {
12entry:
13 %0 = call i32 @missing_func()
14 %1 = load i32, i32* @missing_data, align 4
15 ret i32 %1
16}
17
18
19; CHECK: - Type: CUSTOM
20; CHECK-NEXT: Name: linking
21; CHECK-NEXT: Version: 2
22; CHECK-NEXT: SymbolTable:
23; CHECK-NEXT: - Index: 0
24; CHECK-NEXT: Kind: FUNCTION
25; CHECK-NEXT: Name: missing_func
26; CHECK-NEXT: Flags: [ UNDEFINED ]
27; CHECK-NEXT: Function: 0
28; CHECK-NEXT: - Index: 1
29; CHECK-NEXT: Kind: FUNCTION
30; CHECK-NEXT: Name: foo
31; CHECK-NEXT: Flags: [ ]
32; CHECK-NEXT: Function: 1
33; CHECK-NEXT: - Index: 2
34; CHECK-NEXT: Kind: DATA
35; CHECK-NEXT: Name: missing_data
36; CHECK-NEXT: Flags: [ UNDEFINED ]
deps/lld/test/wasm/weak-alias.ll+14-14
...@@ -187,13 +187,13 @@ entry:...@@ -187,13 +187,13 @@ entry:
187; RELOC-NEXT: - Type: CODE187; RELOC-NEXT: - Type: CODE
188; RELOC-NEXT: Relocations:188; RELOC-NEXT: Relocations:
189; RELOC-NEXT: - Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB189; RELOC-NEXT: - Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB
190; RELOC-NEXT: Index: 4190; RELOC-NEXT: Index: 1
191; RELOC-NEXT: Offset: 0x00000004191; RELOC-NEXT: Offset: 0x00000004
192; RELOC-NEXT: - Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB192; RELOC-NEXT: - Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB
193; RELOC-NEXT: Index: 1193; RELOC-NEXT: Index: 2
194; RELOC-NEXT: Offset: 0x00000013194; RELOC-NEXT: Offset: 0x00000013
195; RELOC-NEXT: - Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB195; RELOC-NEXT: - Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB
196; RELOC-NEXT: Index: 4196; RELOC-NEXT: Index: 1
197; RELOC-NEXT: Offset: 0x0000001C197; RELOC-NEXT: Offset: 0x0000001C
198; RELOC-NEXT: - Type: R_WEBASSEMBLY_GLOBAL_INDEX_LEB198; RELOC-NEXT: - Type: R_WEBASSEMBLY_GLOBAL_INDEX_LEB
199; RELOC-NEXT: Index: 6199; RELOC-NEXT: Index: 6
...@@ -202,10 +202,10 @@ entry:...@@ -202,10 +202,10 @@ entry:
202; RELOC-NEXT: Index: 6202; RELOC-NEXT: Index: 6
203; RELOC-NEXT: Offset: 0x00000032203; RELOC-NEXT: Offset: 0x00000032
204; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB204; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB
205; RELOC-NEXT: Index: 4205; RELOC-NEXT: Index: 1
206; RELOC-NEXT: Offset: 0x0000003A206; RELOC-NEXT: Offset: 0x0000003A
207; RELOC-NEXT: - Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB207; RELOC-NEXT: - Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB
208; RELOC-NEXT: Index: 4208; RELOC-NEXT: Index: 1
209; RELOC-NEXT: Offset: 0x00000043209; RELOC-NEXT: Offset: 0x00000043
210; RELOC-NEXT: - Type: R_WEBASSEMBLY_GLOBAL_INDEX_LEB210; RELOC-NEXT: - Type: R_WEBASSEMBLY_GLOBAL_INDEX_LEB
211; RELOC-NEXT: Index: 6211; RELOC-NEXT: Index: 6
...@@ -217,10 +217,10 @@ entry:...@@ -217,10 +217,10 @@ entry:
217; RELOC-NEXT: Index: 6217; RELOC-NEXT: Index: 6
218; RELOC-NEXT: Offset: 0x00000068218; RELOC-NEXT: Offset: 0x00000068
219; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB219; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB
220; RELOC-NEXT: Index: 1220; RELOC-NEXT: Index: 2
221; RELOC-NEXT: Offset: 0x00000070221; RELOC-NEXT: Offset: 0x00000070
222; RELOC-NEXT: - Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB222; RELOC-NEXT: - Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB
223; RELOC-NEXT: Index: 1223; RELOC-NEXT: Index: 2
224; RELOC-NEXT: Offset: 0x00000079224; RELOC-NEXT: Offset: 0x00000079
225; RELOC-NEXT: - Type: R_WEBASSEMBLY_GLOBAL_INDEX_LEB225; RELOC-NEXT: - Type: R_WEBASSEMBLY_GLOBAL_INDEX_LEB
226; RELOC-NEXT: Index: 6226; RELOC-NEXT: Index: 6
...@@ -259,24 +259,24 @@ entry:...@@ -259,24 +259,24 @@ entry:
259; RELOC-NEXT: Function: 0259; RELOC-NEXT: Function: 0
260; RELOC-NEXT: - Index: 1260; RELOC-NEXT: - Index: 1
261; RELOC-NEXT: Kind: FUNCTION261; RELOC-NEXT: Kind: FUNCTION
262; RELOC-NEXT: Name: alias_fn
263; RELOC-NEXT: Flags: [ BINDING_WEAK ]
264; RELOC-NEXT: Function: 1
265; RELOC-NEXT: - Index: 2
266; RELOC-NEXT: Kind: FUNCTION
262; RELOC-NEXT: Name: direct_fn267; RELOC-NEXT: Name: direct_fn
263; RELOC-NEXT: Flags: [ ]268; RELOC-NEXT: Flags: [ ]
264; RELOC-NEXT: Function: 1269; RELOC-NEXT: Function: 1
265; RELOC-NEXT: - Index: 2270; RELOC-NEXT: - Index: 3
266; RELOC-NEXT: Kind: FUNCTION271; RELOC-NEXT: Kind: FUNCTION
267; RELOC-NEXT: Name: call_direct272; RELOC-NEXT: Name: call_direct
268; RELOC-NEXT: Flags: [ ]273; RELOC-NEXT: Flags: [ ]
269; RELOC-NEXT: Function: 2274; RELOC-NEXT: Function: 2
270; RELOC-NEXT: - Index: 3275; RELOC-NEXT: - Index: 4
271; RELOC-NEXT: Kind: FUNCTION276; RELOC-NEXT: Kind: FUNCTION
272; RELOC-NEXT: Name: call_alias277; RELOC-NEXT: Name: call_alias
273; RELOC-NEXT: Flags: [ ]278; RELOC-NEXT: Flags: [ ]
274; RELOC-NEXT: Function: 3279; RELOC-NEXT: Function: 3
275; RELOC-NEXT: - Index: 4
276; RELOC-NEXT: Kind: FUNCTION
277; RELOC-NEXT: Name: alias_fn
278; RELOC-NEXT: Flags: [ BINDING_WEAK ]
279; RELOC-NEXT: Function: 1
280; RELOC-NEXT: - Index: 5280; RELOC-NEXT: - Index: 5
281; RELOC-NEXT: Kind: FUNCTION281; RELOC-NEXT: Kind: FUNCTION
282; RELOC-NEXT: Name: call_alias_ptr282; RELOC-NEXT: Name: call_alias_ptr
deps/lld/wasm/Driver.cpp+3-1
...@@ -434,7 +434,9 @@ static Symbol *handleUndefined(StringRef Name) {...@@ -434,7 +434,9 @@ static Symbol *handleUndefined(StringRef Name) {
434static UndefinedGlobal *434static UndefinedGlobal *
435createUndefinedGlobal(StringRef Name, llvm::wasm::WasmGlobalType *Type) {435createUndefinedGlobal(StringRef Name, llvm::wasm::WasmGlobalType *Type) {
436 auto *Sym =436 auto *Sym =
437 cast<UndefinedGlobal>(Symtab->addUndefinedGlobal(Name, 0, nullptr, Type));437 cast<UndefinedGlobal>(Symtab->addUndefinedGlobal(Name, Name,
438 DefaultModule, 0,
439 nullptr, Type));
438 Config->AllowUndefinedSymbols.insert(Sym->getName());440 Config->AllowUndefinedSymbols.insert(Sym->getName());
439 Sym->IsUsedInRegularObj = true;441 Sym->IsUsedInRegularObj = true;
440 return Sym;442 return Sym;
deps/lld/wasm/InputChunks.cpp+3-3
...@@ -23,7 +23,7 @@ using namespace llvm::support::endian;...@@ -23,7 +23,7 @@ using namespace llvm::support::endian;
23using namespace lld;23using namespace lld;
24using namespace lld::wasm;24using namespace lld::wasm;
2525
26static StringRef ReloctTypeToString(uint8_t RelocType) {26static StringRef reloctTypeToString(uint8_t RelocType) {
27 switch (RelocType) {27 switch (RelocType) {
28#define WASM_RELOC(NAME, REL) \28#define WASM_RELOC(NAME, REL) \
29 case REL: \29 case REL: \
...@@ -77,7 +77,7 @@ void InputChunk::verifyRelocTargets() const {...@@ -77,7 +77,7 @@ void InputChunk::verifyRelocTargets() const {
77 warn("expected LEB at relocation site be 5-byte padded");77 warn("expected LEB at relocation site be 5-byte padded");
78 uint32_t ExpectedValue = File->calcExpectedValue(Rel);78 uint32_t ExpectedValue = File->calcExpectedValue(Rel);
79 if (ExpectedValue != ExistingValue)79 if (ExpectedValue != ExistingValue)
80 warn("unexpected existing value for " + ReloctTypeToString(Rel.Type) +80 warn("unexpected existing value for " + reloctTypeToString(Rel.Type) +
81 ": existing=" + Twine(ExistingValue) +81 ": existing=" + Twine(ExistingValue) +
82 " expected=" + Twine(ExpectedValue));82 " expected=" + Twine(ExpectedValue));
83 }83 }
...@@ -103,7 +103,7 @@ void InputChunk::writeTo(uint8_t *Buf) const {...@@ -103,7 +103,7 @@ void InputChunk::writeTo(uint8_t *Buf) const {
103 for (const WasmRelocation &Rel : Relocations) {103 for (const WasmRelocation &Rel : Relocations) {
104 uint8_t *Loc = Buf + Rel.Offset + Off;104 uint8_t *Loc = Buf + Rel.Offset + Off;
105 uint32_t Value = File->calcNewValue(Rel);105 uint32_t Value = File->calcNewValue(Rel);
106 LLVM_DEBUG(dbgs() << "apply reloc: type=" << ReloctTypeToString(Rel.Type)106 LLVM_DEBUG(dbgs() << "apply reloc: type=" << reloctTypeToString(Rel.Type)
107 << " addend=" << Rel.Addend << " index=" << Rel.Index107 << " addend=" << Rel.Addend << " index=" << Rel.Index
108 << " value=" << Value << " offset=" << Rel.Offset108 << " value=" << Value << " offset=" << Rel.Offset
109 << "\n");109 << "\n");
deps/lld/wasm/InputFiles.cpp+8-3
...@@ -377,11 +377,15 @@ Symbol *ObjFile::createUndefined(const WasmSymbol &Sym) {...@@ -377,11 +377,15 @@ Symbol *ObjFile::createUndefined(const WasmSymbol &Sym) {
377377
378 switch (Sym.Info.Kind) {378 switch (Sym.Info.Kind) {
379 case WASM_SYMBOL_TYPE_FUNCTION:379 case WASM_SYMBOL_TYPE_FUNCTION:
380 return Symtab->addUndefinedFunction(Name, Flags, this, Sym.Signature);380 return Symtab->addUndefinedFunction(Name, Sym.Info.ImportName,
381 Sym.Info.ImportModule, Flags, this,
382 Sym.Signature);
381 case WASM_SYMBOL_TYPE_DATA:383 case WASM_SYMBOL_TYPE_DATA:
382 return Symtab->addUndefinedData(Name, Flags, this);384 return Symtab->addUndefinedData(Name, Flags, this);
383 case WASM_SYMBOL_TYPE_GLOBAL:385 case WASM_SYMBOL_TYPE_GLOBAL:
384 return Symtab->addUndefinedGlobal(Name, Flags, this, Sym.GlobalType);386 return Symtab->addUndefinedGlobal(Name, Sym.Info.ImportName,
387 Sym.Info.ImportModule, Flags, this,
388 Sym.GlobalType);
385 case WASM_SYMBOL_TYPE_SECTION:389 case WASM_SYMBOL_TYPE_SECTION:
386 llvm_unreachable("section symbols cannot be undefined");390 llvm_unreachable("section symbols cannot be undefined");
387 }391 }
...@@ -445,7 +449,8 @@ static Symbol *createBitcodeSymbol(const lto::InputFile::Symbol &ObjSym,...@@ -445,7 +449,8 @@ static Symbol *createBitcodeSymbol(const lto::InputFile::Symbol &ObjSym,
445449
446 if (ObjSym.isUndefined()) {450 if (ObjSym.isUndefined()) {
447 if (ObjSym.isExecutable())451 if (ObjSym.isExecutable())
448 return Symtab->addUndefinedFunction(Name, Flags, &F, nullptr);452 return Symtab->addUndefinedFunction(Name, Name, DefaultModule, Flags, &F,
453 nullptr);
449 return Symtab->addUndefinedData(Name, Flags, &F);454 return Symtab->addUndefinedData(Name, Flags, &F);
450 }455 }
451456
deps/lld/wasm/LTO.cpp+3-2
...@@ -79,8 +79,9 @@ BitcodeCompiler::~BitcodeCompiler() = default;...@@ -79,8 +79,9 @@ BitcodeCompiler::~BitcodeCompiler() = default;
7979
80static void undefine(Symbol *S) {80static void undefine(Symbol *S) {
81 if (auto F = dyn_cast<DefinedFunction>(S))81 if (auto F = dyn_cast<DefinedFunction>(S))
82 replaceSymbol<UndefinedFunction>(F, F->getName(), 0, F->getFile(),82 replaceSymbol<UndefinedFunction>(F, F->getName(), F->getName(),
83 F->Signature);83 DefaultModule, 0,
84 F->getFile(), F->Signature);
84 else if (isa<DefinedData>(S))85 else if (isa<DefinedData>(S))
85 replaceSymbol<UndefinedData>(S, S->getName(), 0, S->getFile());86 replaceSymbol<UndefinedData>(S, S->getName(), 0, S->getFile());
86 else87 else
deps/lld/wasm/LTO.h+1
...@@ -23,6 +23,7 @@...@@ -23,6 +23,7 @@
2323
24#include "lld/Common/LLVM.h"24#include "lld/Common/LLVM.h"
25#include "llvm/ADT/SmallString.h"25#include "llvm/ADT/SmallString.h"
26#include "Writer.h"
26#include <memory>27#include <memory>
27#include <vector>28#include <vector>
2829
deps/lld/wasm/MarkLive.cpp+1-1
...@@ -85,7 +85,7 @@ void lld::wasm::markLive() {...@@ -85,7 +85,7 @@ void lld::wasm::markLive() {
85 // equal to null pointer, only reachable via direct call).85 // equal to null pointer, only reachable via direct call).
86 if (Reloc.Type == R_WEBASSEMBLY_TABLE_INDEX_SLEB ||86 if (Reloc.Type == R_WEBASSEMBLY_TABLE_INDEX_SLEB ||
87 Reloc.Type == R_WEBASSEMBLY_TABLE_INDEX_I32) {87 Reloc.Type == R_WEBASSEMBLY_TABLE_INDEX_I32) {
88 FunctionSymbol *FuncSym = cast<FunctionSymbol>(Sym);88 auto *FuncSym = cast<FunctionSymbol>(Sym);
89 if (FuncSym->hasTableIndex() && FuncSym->getTableIndex() == 0)89 if (FuncSym->hasTableIndex() && FuncSym->getTableIndex() == 0)
90 continue;90 continue;
91 }91 }
deps/lld/wasm/SymbolTable.cpp+9-5
...@@ -314,8 +314,9 @@ Symbol *SymbolTable::addDefinedEvent(StringRef Name, uint32_t Flags,...@@ -314,8 +314,9 @@ Symbol *SymbolTable::addDefinedEvent(StringRef Name, uint32_t Flags,
314 return S;314 return S;
315}315}
316316
317Symbol *SymbolTable::addUndefinedFunction(StringRef Name, uint32_t Flags,317Symbol *SymbolTable::addUndefinedFunction(StringRef Name, StringRef ImportName,
318 InputFile *File,318 StringRef ImportModule,
319 uint32_t Flags, InputFile *File,
319 const WasmSignature *Sig) {320 const WasmSignature *Sig) {
320 LLVM_DEBUG(dbgs() << "addUndefinedFunction: " << Name <<321 LLVM_DEBUG(dbgs() << "addUndefinedFunction: " << Name <<
321 " [" << (Sig ? toString(*Sig) : "none") << "]\n");322 " [" << (Sig ? toString(*Sig) : "none") << "]\n");
...@@ -325,7 +326,8 @@ Symbol *SymbolTable::addUndefinedFunction(StringRef Name, uint32_t Flags,...@@ -325,7 +326,8 @@ Symbol *SymbolTable::addUndefinedFunction(StringRef Name, uint32_t Flags,
325 std::tie(S, WasInserted) = insert(Name, File);326 std::tie(S, WasInserted) = insert(Name, File);
326327
327 if (WasInserted)328 if (WasInserted)
328 replaceSymbol<UndefinedFunction>(S, Name, Flags, File, Sig);329 replaceSymbol<UndefinedFunction>(S, Name, ImportName, ImportModule, Flags,
330 File, Sig);
329 else if (auto *Lazy = dyn_cast<LazySymbol>(S))331 else if (auto *Lazy = dyn_cast<LazySymbol>(S))
330 Lazy->fetch();332 Lazy->fetch();
331 else333 else
...@@ -351,7 +353,8 @@ Symbol *SymbolTable::addUndefinedData(StringRef Name, uint32_t Flags,...@@ -351,7 +353,8 @@ Symbol *SymbolTable::addUndefinedData(StringRef Name, uint32_t Flags,
351 return S;353 return S;
352}354}
353355
354Symbol *SymbolTable::addUndefinedGlobal(StringRef Name, uint32_t Flags,356Symbol *SymbolTable::addUndefinedGlobal(StringRef Name, StringRef ImportName,
357 StringRef ImportModule, uint32_t Flags,
355 InputFile *File,358 InputFile *File,
356 const WasmGlobalType *Type) {359 const WasmGlobalType *Type) {
357 LLVM_DEBUG(dbgs() << "addUndefinedGlobal: " << Name << "\n");360 LLVM_DEBUG(dbgs() << "addUndefinedGlobal: " << Name << "\n");
...@@ -361,7 +364,8 @@ Symbol *SymbolTable::addUndefinedGlobal(StringRef Name, uint32_t Flags,...@@ -361,7 +364,8 @@ Symbol *SymbolTable::addUndefinedGlobal(StringRef Name, uint32_t Flags,
361 std::tie(S, WasInserted) = insert(Name, File);364 std::tie(S, WasInserted) = insert(Name, File);
362365
363 if (WasInserted)366 if (WasInserted)
364 replaceSymbol<UndefinedGlobal>(S, Name, Flags, File, Type);367 replaceSymbol<UndefinedGlobal>(S, Name, ImportName, ImportModule, Flags,
368 File, Type);
365 else if (auto *Lazy = dyn_cast<LazySymbol>(S))369 else if (auto *Lazy = dyn_cast<LazySymbol>(S))
366 Lazy->fetch();370 Lazy->fetch();
367 else if (S->isDefined())371 else if (S->isDefined())
deps/lld/wasm/SymbolTable.h+6-4
...@@ -59,11 +59,13 @@ public:...@@ -59,11 +59,13 @@ public:
59 Symbol *addDefinedEvent(StringRef Name, uint32_t Flags, InputFile *File,59 Symbol *addDefinedEvent(StringRef Name, uint32_t Flags, InputFile *File,
60 InputEvent *E);60 InputEvent *E);
6161
62 Symbol *addUndefinedFunction(StringRef Name, uint32_t Flags, InputFile *File,62 Symbol *addUndefinedFunction(StringRef Name, StringRef ImportName,
63 const WasmSignature *Signature);63 StringRef ImportModule, uint32_t Flags,
64 InputFile *File, const WasmSignature *Signature);
64 Symbol *addUndefinedData(StringRef Name, uint32_t Flags, InputFile *File);65 Symbol *addUndefinedData(StringRef Name, uint32_t Flags, InputFile *File);
65 Symbol *addUndefinedGlobal(StringRef Name, uint32_t Flags, InputFile *File,66 Symbol *addUndefinedGlobal(StringRef Name, StringRef ImportName,
66 const WasmGlobalType *Type);67 StringRef ImportModule, uint32_t Flags,
68 InputFile *File, const WasmGlobalType *Type);
6769
68 void addLazy(ArchiveFile *F, const llvm::object::Archive::Symbol *Sym);70 void addLazy(ArchiveFile *F, const llvm::object::Archive::Symbol *Sym);
6971
deps/lld/wasm/Symbols.h+15-4
...@@ -149,13 +149,19 @@ public:...@@ -149,13 +149,19 @@ public:
149149
150class UndefinedFunction : public FunctionSymbol {150class UndefinedFunction : public FunctionSymbol {
151public:151public:
152 UndefinedFunction(StringRef Name, uint32_t Flags, InputFile *File = nullptr,152 UndefinedFunction(StringRef Name, StringRef ImportName,
153 StringRef ImportModule, uint32_t Flags,
154 InputFile *File = nullptr,
153 const WasmSignature *Type = nullptr)155 const WasmSignature *Type = nullptr)
154 : FunctionSymbol(Name, UndefinedFunctionKind, Flags, File, Type) {}156 : FunctionSymbol(Name, UndefinedFunctionKind, Flags, File, Type),
157 ImportName(ImportName), ImportModule(ImportModule) {}
155158
156 static bool classof(const Symbol *S) {159 static bool classof(const Symbol *S) {
157 return S->kind() == UndefinedFunctionKind;160 return S->kind() == UndefinedFunctionKind;
158 }161 }
162
163 StringRef ImportName;
164 StringRef ImportModule;
159};165};
160166
161class SectionSymbol : public Symbol {167class SectionSymbol : public Symbol {
...@@ -261,13 +267,18 @@ public:...@@ -261,13 +267,18 @@ public:
261267
262class UndefinedGlobal : public GlobalSymbol {268class UndefinedGlobal : public GlobalSymbol {
263public:269public:
264 UndefinedGlobal(StringRef Name, uint32_t Flags, InputFile *File = nullptr,270 UndefinedGlobal(StringRef Name, StringRef ImportName, StringRef ImportModule,
271 uint32_t Flags, InputFile *File = nullptr,
265 const WasmGlobalType *Type = nullptr)272 const WasmGlobalType *Type = nullptr)
266 : GlobalSymbol(Name, UndefinedGlobalKind, Flags, File, Type) {}273 : GlobalSymbol(Name, UndefinedGlobalKind, Flags, File, Type),
274 ImportName(ImportName), ImportModule(ImportModule) {}
267275
268 static bool classof(const Symbol *S) {276 static bool classof(const Symbol *S) {
269 return S->kind() == UndefinedGlobalKind;277 return S->kind() == UndefinedGlobalKind;
270 }278 }
279
280 StringRef ImportName;
281 StringRef ImportModule;
271};282};
272283
273// Wasm events are features that suspend the current execution and transfer the284// Wasm events are features that suspend the current execution and transfer the
deps/lld/wasm/Writer.cpp+64-42
...@@ -39,8 +39,9 @@ using namespace llvm::wasm;...@@ -39,8 +39,9 @@ using namespace llvm::wasm;
39using namespace lld;39using namespace lld;
40using namespace lld::wasm;40using namespace lld::wasm;
4141
42static constexpr int kStackAlignment = 16;42static constexpr int StackAlignment = 16;
43static constexpr const char *kFunctionTableName = "__indirect_function_table";43static constexpr const char *FunctionTableName = "__indirect_function_table";
44const char *lld::wasm::DefaultModule = "env";
4445
45namespace {46namespace {
4647
...@@ -155,7 +156,7 @@ void Writer::createImportSection() {...@@ -155,7 +156,7 @@ void Writer::createImportSection() {
155156
156 if (Config->ImportMemory) {157 if (Config->ImportMemory) {
157 WasmImport Import;158 WasmImport Import;
158 Import.Module = "env";159 Import.Module = DefaultModule;
159 Import.Field = "memory";160 Import.Field = "memory";
160 Import.Kind = WASM_EXTERNAL_MEMORY;161 Import.Kind = WASM_EXTERNAL_MEMORY;
161 Import.Memory.Flags = 0;162 Import.Memory.Flags = 0;
...@@ -172,8 +173,8 @@ void Writer::createImportSection() {...@@ -172,8 +173,8 @@ void Writer::createImportSection() {
172 if (Config->ImportTable) {173 if (Config->ImportTable) {
173 uint32_t TableSize = TableBase + IndirectFunctions.size();174 uint32_t TableSize = TableBase + IndirectFunctions.size();
174 WasmImport Import;175 WasmImport Import;
175 Import.Module = "env";176 Import.Module = DefaultModule;
176 Import.Field = kFunctionTableName;177 Import.Field = FunctionTableName;
177 Import.Kind = WASM_EXTERNAL_TABLE;178 Import.Kind = WASM_EXTERNAL_TABLE;
178 Import.Table.ElemType = WASM_TYPE_FUNCREF;179 Import.Table.ElemType = WASM_TYPE_FUNCREF;
179 Import.Table.Limits = {0, TableSize, 0};180 Import.Table.Limits = {0, TableSize, 0};
...@@ -182,8 +183,17 @@ void Writer::createImportSection() {...@@ -182,8 +183,17 @@ void Writer::createImportSection() {
182183
183 for (const Symbol *Sym : ImportedSymbols) {184 for (const Symbol *Sym : ImportedSymbols) {
184 WasmImport Import;185 WasmImport Import;
185 Import.Module = "env";186 if (auto *F = dyn_cast<UndefinedFunction>(Sym)) {
186 Import.Field = Sym->getName();187 Import.Field = F->ImportName;
188 Import.Module = F->ImportModule;
189 } else if (auto *G = dyn_cast<UndefinedGlobal>(Sym)) {
190 Import.Field = G->ImportName;
191 Import.Module = G->ImportModule;
192 } else {
193 Import.Field = Sym->getName();
194 Import.Module = DefaultModule;
195 }
196
187 if (auto *FunctionSym = dyn_cast<FunctionSymbol>(Sym)) {197 if (auto *FunctionSym = dyn_cast<FunctionSymbol>(Sym)) {
188 Import.Kind = WASM_EXTERNAL_FUNCTION;198 Import.Kind = WASM_EXTERNAL_FUNCTION;
189 Import.SigIndex = lookupType(*FunctionSym->Signature);199 Import.SigIndex = lookupType(*FunctionSym->Signature);
...@@ -441,6 +451,13 @@ static uint32_t getWasmFlags(const Symbol *Sym) {...@@ -441,6 +451,13 @@ static uint32_t getWasmFlags(const Symbol *Sym) {
441 Flags |= WASM_SYMBOL_VISIBILITY_HIDDEN;451 Flags |= WASM_SYMBOL_VISIBILITY_HIDDEN;
442 if (Sym->isUndefined())452 if (Sym->isUndefined())
443 Flags |= WASM_SYMBOL_UNDEFINED;453 Flags |= WASM_SYMBOL_UNDEFINED;
454 if (auto *F = dyn_cast<UndefinedFunction>(Sym)) {
455 if (F->getName() != F->ImportName)
456 Flags |= WASM_SYMBOL_EXPLICIT_NAME;
457 } else if (auto *G = dyn_cast<UndefinedGlobal>(Sym)) {
458 if (G->getName() != G->ImportName)
459 Flags |= WASM_SYMBOL_EXPLICIT_NAME;
460 }
444 return Flags;461 return Flags;
445}462}
446463
...@@ -506,15 +523,18 @@ void Writer::createLinkingSection() {...@@ -506,15 +523,18 @@ void Writer::createLinkingSection() {
506523
507 if (auto *F = dyn_cast<FunctionSymbol>(Sym)) {524 if (auto *F = dyn_cast<FunctionSymbol>(Sym)) {
508 writeUleb128(Sub.OS, F->getFunctionIndex(), "index");525 writeUleb128(Sub.OS, F->getFunctionIndex(), "index");
509 if (Sym->isDefined())526 if (Sym->isDefined() ||
527 (Flags & WASM_SYMBOL_EXPLICIT_NAME) != 0)
510 writeStr(Sub.OS, Sym->getName(), "sym name");528 writeStr(Sub.OS, Sym->getName(), "sym name");
511 } else if (auto *G = dyn_cast<GlobalSymbol>(Sym)) {529 } else if (auto *G = dyn_cast<GlobalSymbol>(Sym)) {
512 writeUleb128(Sub.OS, G->getGlobalIndex(), "index");530 writeUleb128(Sub.OS, G->getGlobalIndex(), "index");
513 if (Sym->isDefined())531 if (Sym->isDefined() ||
532 (Flags & WASM_SYMBOL_EXPLICIT_NAME) != 0)
514 writeStr(Sub.OS, Sym->getName(), "sym name");533 writeStr(Sub.OS, Sym->getName(), "sym name");
515 } else if (auto *E = dyn_cast<EventSymbol>(Sym)) {534 } else if (auto *E = dyn_cast<EventSymbol>(Sym)) {
516 writeUleb128(Sub.OS, E->getEventIndex(), "index");535 writeUleb128(Sub.OS, E->getEventIndex(), "index");
517 if (Sym->isDefined())536 if (Sym->isDefined() ||
537 (Flags & WASM_SYMBOL_EXPLICIT_NAME) != 0)
518 writeStr(Sub.OS, Sym->getName(), "sym name");538 writeStr(Sub.OS, Sym->getName(), "sym name");
519 } else if (isa<DataSymbol>(Sym)) {539 } else if (isa<DataSymbol>(Sym)) {
520 writeStr(Sub.OS, Sym->getName(), "sym name");540 writeStr(Sub.OS, Sym->getName(), "sym name");
...@@ -663,9 +683,9 @@ void Writer::layoutMemory() {...@@ -663,9 +683,9 @@ void Writer::layoutMemory() {
663 auto PlaceStack = [&]() {683 auto PlaceStack = [&]() {
664 if (Config->Relocatable || Config->Shared)684 if (Config->Relocatable || Config->Shared)
665 return;685 return;
666 MemoryPtr = alignTo(MemoryPtr, kStackAlignment);686 MemoryPtr = alignTo(MemoryPtr, StackAlignment);
667 if (Config->ZStackSize != alignTo(Config->ZStackSize, kStackAlignment))687 if (Config->ZStackSize != alignTo(Config->ZStackSize, StackAlignment))
668 error("stack size must be " + Twine(kStackAlignment) + "-byte aligned");688 error("stack size must be " + Twine(StackAlignment) + "-byte aligned");
669 log("mem: stack size = " + Twine(Config->ZStackSize));689 log("mem: stack size = " + Twine(Config->ZStackSize));
670 log("mem: stack base = " + Twine(MemoryPtr));690 log("mem: stack base = " + Twine(MemoryPtr));
671 MemoryPtr += Config->ZStackSize;691 MemoryPtr += Config->ZStackSize;
...@@ -814,7 +834,7 @@ void Writer::calculateExports() {...@@ -814,7 +834,7 @@ void Writer::calculateExports() {
814 Exports.push_back(WasmExport{"memory", WASM_EXTERNAL_MEMORY, 0});834 Exports.push_back(WasmExport{"memory", WASM_EXTERNAL_MEMORY, 0});
815835
816 if (!Config->Relocatable && Config->ExportTable)836 if (!Config->Relocatable && Config->ExportTable)
817 Exports.push_back(WasmExport{kFunctionTableName, WASM_EXTERNAL_TABLE, 0});837 Exports.push_back(WasmExport{FunctionTableName, WASM_EXTERNAL_TABLE, 0});
818838
819 unsigned FakeGlobalIndex = NumImportedGlobals + InputGlobals.size();839 unsigned FakeGlobalIndex = NumImportedGlobals + InputGlobals.size();
820840
...@@ -858,40 +878,42 @@ void Writer::assignSymtab() {...@@ -858,40 +878,42 @@ void Writer::assignSymtab() {
858 StringMap<uint32_t> SectionSymbolIndices;878 StringMap<uint32_t> SectionSymbolIndices;
859879
860 unsigned SymbolIndex = SymtabEntries.size();880 unsigned SymbolIndex = SymtabEntries.size();
861 for (ObjFile *File : Symtab->ObjectFiles) {
862 LLVM_DEBUG(dbgs() << "Symtab entries: " << File->getName() << "\n");
863 for (Symbol *Sym : File->getSymbols()) {
864 if (Sym->getFile() != File)
865 continue;
866
867 if (auto *S = dyn_cast<SectionSymbol>(Sym)) {
868 StringRef Name = S->getName();
869 if (CustomSectionMapping.count(Name) == 0)
870 continue;
871
872 auto SSI = SectionSymbolIndices.find(Name);
873 if (SSI != SectionSymbolIndices.end()) {
874 Sym->setOutputSymbolIndex(SSI->second);
875 continue;
876 }
877881
878 SectionSymbolIndices[Name] = SymbolIndex;882 auto AddSymbol = [&](Symbol *Sym) {
879 CustomSectionSymbols[Name] = cast<SectionSymbol>(Sym);883 if (auto *S = dyn_cast<SectionSymbol>(Sym)) {
884 StringRef Name = S->getName();
885 if (CustomSectionMapping.count(Name) == 0)
886 return;
880887
881 Sym->markLive();888 auto SSI = SectionSymbolIndices.find(Name);
889 if (SSI != SectionSymbolIndices.end()) {
890 Sym->setOutputSymbolIndex(SSI->second);
891 return;
882 }892 }
883893
884 // (Since this is relocatable output, GC is not performed so symbols must894 SectionSymbolIndices[Name] = SymbolIndex;
885 // be live.)895 CustomSectionSymbols[Name] = cast<SectionSymbol>(Sym);
886 assert(Sym->isLive());896
887 Sym->setOutputSymbolIndex(SymbolIndex++);897 Sym->markLive();
888 SymtabEntries.emplace_back(Sym);
889 }898 }
890 }
891899
892 // For the moment, relocatable output doesn't contain any synthetic functions,900 // (Since this is relocatable output, GC is not performed so symbols must
893 // so no need to look through the Symtab for symbols not referenced by901 // be live.)
894 // Symtab->ObjectFiles.902 assert(Sym->isLive());
903 Sym->setOutputSymbolIndex(SymbolIndex++);
904 SymtabEntries.emplace_back(Sym);
905 };
906
907 for (Symbol *Sym : Symtab->getSymbols())
908 if (!Sym->isLazy())
909 AddSymbol(Sym);
910
911 for (ObjFile *File : Symtab->ObjectFiles) {
912 LLVM_DEBUG(dbgs() << "Local symtab entries: " << File->getName() << "\n");
913 for (Symbol *Sym : File->getSymbols())
914 if (Sym->isLocal())
915 AddSymbol(Sym);
916 }
895}917}
896918
897uint32_t Writer::lookupType(const WasmSignature &Sig) {919uint32_t Writer::lookupType(const WasmSignature &Sig) {
deps/lld/wasm/Writer.h+2
...@@ -15,6 +15,8 @@ namespace wasm {...@@ -15,6 +15,8 @@ namespace wasm {
1515
16void writeResult();16void writeResult();
1717
18extern const char *DefaultModule;
19
18} // namespace wasm20} // namespace wasm
19} // namespace lld21} // namespace lld
2022