| author | |
| committer | |
| log | 5768fcb0850335fa8b5f3dca23f1bbfca5d6efb2 |
| tree | ccf3f503ec9ff6b1855c017e3c836d594bd9448e |
| parent | 6bc19b437c4323f3b71ad38c5e8e9d0a54ad8d74 |
| signature | Commit is signed but in an unrecognized format. |
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 | 54 | OPTION(prefix_2, "Bsymbolic", Bsymbolic, Flag, INVALID, INVALID, nullptr, 0, 0, |
| 55 | 55 | "Bind defined symbols locally", nullptr, nullptr) |
| 56 | 56 | OPTION(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) | |
| 58 | 58 | OPTION(prefix_2, "build-id", build_id, Flag, INVALID, INVALID, nullptr, 0, 0, |
| 59 | 59 | "Alias for --build-id=fast", nullptr, nullptr) |
| 60 | 60 | OPTION(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 | 130 | .Cases("elf32btsmip", "elf32btsmipn32", {ELF32BEKind, EM_MIPS}) |
| 131 | 131 | .Cases("elf32ltsmip", "elf32ltsmipn32", {ELF32LEKind, EM_MIPS}) |
| 132 | 132 | .Case("elf32lriscv", {ELF32LEKind, EM_RISCV}) |
| 133 | .Case("elf32ppc", {ELF32BEKind, EM_PPC}) | |
| 133 | .Cases("elf32ppc", "elf32ppclinux", {ELF32BEKind, EM_PPC}) | |
| 134 | 134 | .Case("elf64btsmip", {ELF64BEKind, EM_MIPS}) |
| 135 | 135 | .Case("elf64ltsmip", {ELF64LEKind, EM_MIPS}) |
| 136 | 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 | 30 | def build_id: F<"build-id">, HelpText<"Alias for --build-id=fast">; |
| 31 | 31 | |
| 32 | 32 | def 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>]">; | |
| 34 | 34 | |
| 35 | 35 | defm check_sections: B<"check-sections", |
| 36 | 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 | 392 | .Case("elf32-x86-64", {ELF32LEKind, EM_X86_64}) |
| 393 | 393 | .Case("elf64-aarch64", {ELF64LEKind, EM_AARCH64}) |
| 394 | 394 | .Case("elf64-littleaarch64", {ELF64LEKind, EM_AARCH64}) |
| 395 | .Case("elf32-powerpc", {ELF32BEKind, EM_PPC}) | |
| 395 | 396 | .Case("elf64-powerpc", {ELF64BEKind, EM_PPC64}) |
| 396 | 397 | .Case("elf64-powerpcle", {ELF64LEKind, EM_PPC64}) |
| 397 | 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 | 400 | .Case("elf32-ntradbigmips", {ELF32BEKind, EM_MIPS}) |
| 400 | 401 | .Case("elf32-tradlittlemips", {ELF32LEKind, EM_MIPS}) |
| 401 | 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 | 5 | .. contents:: |
| 6 | 6 | :local: |
| 7 | 7 | |
| 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 | ||
| 13 | 8 | Introduction |
| 14 | 9 | ============ |
| 15 | 10 | |
| 16 | This document contains the release notes for the lld linker, release 8.0.0. | |
| 17 | Here we describe the status of lld, including major improvements | |
| 18 | from the previous release. All lld releases may be downloaded | |
| 19 | from the `LLVM releases web site <https://llvm.org/releases/>`_. | |
| 11 | lld is a high-performance linker that supports ELF (Unix), COFF (Windows), | |
| 12 | Mach-O (macOS), MinGW and WebAssembly. lld is command-line-compatible with | |
| 13 | GNU linkers and Microsoft link.exe and is significantly faster than the | |
| 14 | system default linkers. | |
| 15 | ||
| 16 | lld 8.0.0 has lots of feature improvements and bug fixes. | |
| 20 | 17 | |
| 21 | 18 | Non-comprehensive list of changes in this release |
| 22 | 19 | ================================================= |
| ... | ... | @@ -33,16 +30,36 @@ ELF Improvements |
| 33 | 30 | non-superpages to a superpage if they are aligned to the superpage |
| 34 | 31 | size. (`r342746 <https://reviews.llvm.org/rL342746>`_) |
| 35 | 32 | |
| 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 | 44 | * lld/Hexagon can now link Linux kernel and musl libc for Qualcomm |
| 37 | 45 | Hexagon ISA. |
| 38 | 46 | |
| 39 | 47 | * Initial MSP430 ISA support has landed. |
| 40 | 48 | |
| 41 | * The following flags have been added: ``-z interpose``, ``-z global`` | |
| 42 | ||
| 43 | 49 | * lld now uses the ``sigrie`` instruction as a trap instruction for |
| 44 | 50 | MIPS targets. |
| 45 | 51 | |
| 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 | ||
| 46 | 63 | COFF Improvements |
| 47 | 64 | ----------------- |
| 48 | 65 | |
| ... | ... | @@ -95,11 +112,6 @@ MinGW Improvements |
| 95 | 112 | Previously, the ``--build-id`` option did not actually generate a build id |
| 96 | 113 | unless ``--pdb`` was specified. |
| 97 | 114 | |
| 98 | MachO Improvements | |
| 99 | ------------------ | |
| 100 | ||
| 101 | * Item 1. | |
| 102 | ||
| 103 | 115 | WebAssembly Improvements |
| 104 | 116 | ------------------------ |
| 105 | 117 |
deps/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp+1| ... | ... | @@ -622,6 +622,7 @@ void ArchHandler_x86_64::applyFixupFinal( |
| 622 | 622 | // Fall into llvm_unreachable(). |
| 623 | 623 | break; |
| 624 | 624 | } |
| 625 | llvm_unreachable("invalid x86_64 Reference Kind"); | |
| 625 | 626 | } |
| 626 | 627 | |
| 627 | 628 | void ArchHandler_x86_64::applyFixupRelocatable(const Reference &ref, |
deps/lld/test/ELF/emulation-mips.s+3| ... | ... | @@ -7,6 +7,9 @@ |
| 7 | 7 | # RUN: echo 'OUTPUT_FORMAT(elf32-tradbigmips)' > %tmips.script |
| 8 | 8 | # RUN: ld.lld %tmips.script -e _start %tmips -o %t4mips |
| 9 | 9 | # 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 | 13 | # MIPS: ElfHeader { |
| 11 | 14 | # MIPS-NEXT: Ident { |
| 12 | 15 | # MIPS-NEXT: Magic: (7F 45 4C 46) |
deps/lld/test/ELF/emulation-ppc.s+37| ... | ... | @@ -103,5 +103,42 @@ |
| 103 | 103 | # PPC64LE-NEXT: StringTableSectionIndex: |
| 104 | 104 | # PPC64LE-NEXT: } |
| 105 | 105 | |
| 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 | 143 | .globl _start |
| 107 | 144 | _start: |
deps/lld/test/wasm/data-layout.ll+3-3| ... | ... | @@ -85,10 +85,10 @@ target triple = "wasm32-unknown-unknown" |
| 85 | 85 | ; RELOC: - Type: DATA |
| 86 | 86 | ; RELOC-NEXT: Relocations: |
| 87 | 87 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_I32 |
| 88 | ; RELOC-NEXT: Index: 6 | |
| 88 | ; RELOC-NEXT: Index: 3 | |
| 89 | 89 | ; RELOC-NEXT: Offset: 0x00000018 |
| 90 | 90 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_I32 |
| 91 | ; RELOC-NEXT: Index: 3 | |
| 91 | ; RELOC-NEXT: Index: 4 | |
| 92 | 92 | ; RELOC-NEXT: Offset: 0x0000002E |
| 93 | 93 | ; RELOC-NEXT: Addend: 4 |
| 94 | 94 | ; RELOC-NEXT: Segments: |
| ... | ... | @@ -148,7 +148,7 @@ target triple = "wasm32-unknown-unknown" |
| 148 | 148 | ; RELOC-NEXT: Flags: [ ] |
| 149 | 149 | ; RELOC-NEXT: Segment: 2 |
| 150 | 150 | ; RELOC-NEXT: Size: 4 |
| 151 | ; RELOC: - Index: 6 | |
| 151 | ; RELOC-NEXT: - Index: 3 | |
| 152 | 152 | ; RELOC-NEXT: Kind: DATA |
| 153 | 153 | ; RELOC-NEXT: Name: hello_str |
| 154 | 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 | ||
| 5 | target triple = "wasm32-unknown-unknown-wasm" | |
| 6 | ||
| 7 | define void @_start() { | |
| 8 | call void @foo(); | |
| 9 | ret void | |
| 10 | } | |
| 11 | ||
| 12 | declare void @foo() #0 | |
| 13 | ||
| 14 | attributes #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 | ||
| 5 | target triple = "wasm32-unknown-unknown" | |
| 6 | ||
| 7 | declare void @f0() #0 | |
| 8 | ||
| 9 | define void @_start() { | |
| 10 | call void @f0() | |
| 11 | ret void | |
| 12 | } | |
| 13 | ||
| 14 | attributes #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 | 163 | ; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ] |
| 164 | 164 | ; RELOC-NEXT: Function: 7 |
| 165 | 165 | ; 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 | 195 | ; RELOC-NEXT: Kind: FUNCTION |
| 167 | 196 | ; RELOC-NEXT: Name: .Lcall_dtors.101 |
| 168 | 197 | ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] |
| 169 | 198 | ; RELOC-NEXT: Function: 8 |
| 170 | ; RELOC-NEXT: - Index: 7 | |
| 199 | ; RELOC-NEXT: - Index: 13 | |
| 171 | 200 | ; RELOC-NEXT: Kind: FUNCTION |
| 172 | 201 | ; RELOC-NEXT: Name: .Lregister_call_dtors.101 |
| 173 | 202 | ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] |
| 174 | 203 | ; RELOC-NEXT: Function: 9 |
| 175 | ; RELOC-NEXT: - Index: 8 | |
| 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 | |
| 204 | ; RELOC-NEXT: - Index: 14 | |
| 180 | 205 | ; RELOC-NEXT: Kind: FUNCTION |
| 181 | 206 | ; RELOC-NEXT: Name: .Lcall_dtors.1001 |
| 182 | 207 | ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] |
| 183 | 208 | ; RELOC-NEXT: Function: 10 |
| 184 | ; RELOC-NEXT: - Index: 10 | |
| 209 | ; RELOC-NEXT: - Index: 15 | |
| 185 | 210 | ; RELOC-NEXT: Kind: FUNCTION |
| 186 | 211 | ; RELOC-NEXT: Name: .Lregister_call_dtors.1001 |
| 187 | 212 | ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] |
| 188 | 213 | ; RELOC-NEXT: Function: 11 |
| 189 | ; RELOC-NEXT: - Index: 11 | |
| 214 | ; RELOC-NEXT: - Index: 16 | |
| 190 | 215 | ; RELOC-NEXT: Kind: FUNCTION |
| 191 | 216 | ; RELOC-NEXT: Name: .Lcall_dtors.4000 |
| 192 | 217 | ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] |
| 193 | 218 | ; RELOC-NEXT: Function: 12 |
| 194 | ; RELOC-NEXT: - Index: 12 | |
| 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 | |
| 219 | ; RELOC-NEXT: - Index: 17 | |
| 200 | 220 | ; RELOC-NEXT: Kind: FUNCTION |
| 201 | 221 | ; RELOC-NEXT: Name: .Lregister_call_dtors.4000 |
| 202 | 222 | ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] |
| 203 | 223 | ; 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 | 224 | ; RELOC-NEXT: - Index: 18 |
| 225 | 225 | ; RELOC-NEXT: Kind: FUNCTION |
| 226 | 226 | ; RELOC-NEXT: Name: .Lcall_dtors.101 |
| ... | ... | @@ -251,36 +251,36 @@ entry: |
| 251 | 251 | ; RELOC-NEXT: Name: .Lregister_call_dtors.2002 |
| 252 | 252 | ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] |
| 253 | 253 | ; RELOC-NEXT: Function: 21 |
| 254 | ; RELOC-NEXT: InitFunctions: | |
| 254 | ; RELOC-NEXT: InitFunctions: | |
| 255 | 255 | ; RELOC-NEXT: - Priority: 101 |
| 256 | 256 | ; RELOC-NEXT: Symbol: 0 |
| 257 | 257 | ; RELOC-NEXT: - Priority: 101 |
| 258 | 258 | ; RELOC-NEXT: Symbol: 1 |
| 259 | 259 | ; RELOC-NEXT: - Priority: 101 |
| 260 | ; RELOC-NEXT: Symbol: 7 | |
| 260 | ; RELOC-NEXT: Symbol: 13 | |
| 261 | 261 | ; RELOC-NEXT: - Priority: 101 |
| 262 | ; RELOC-NEXT: Symbol: 15 | |
| 262 | ; RELOC-NEXT: Symbol: 9 | |
| 263 | 263 | ; RELOC-NEXT: - Priority: 101 |
| 264 | 264 | ; RELOC-NEXT: Symbol: 19 |
| 265 | 265 | ; RELOC-NEXT: - Priority: 202 |
| 266 | ; RELOC-NEXT: Symbol: 15 | |
| 266 | ; RELOC-NEXT: Symbol: 9 | |
| 267 | 267 | ; RELOC-NEXT: - Priority: 202 |
| 268 | 268 | ; RELOC-NEXT: Symbol: 21 |
| 269 | 269 | ; RELOC-NEXT: - Priority: 1001 |
| 270 | 270 | ; RELOC-NEXT: Symbol: 0 |
| 271 | 271 | ; RELOC-NEXT: - Priority: 1001 |
| 272 | ; RELOC-NEXT: Symbol: 10 | |
| 273 | ; RELOC-NEXT: - Priority: 2002 | |
| 274 | 272 | ; RELOC-NEXT: Symbol: 15 |
| 275 | 273 | ; RELOC-NEXT: - Priority: 2002 |
| 274 | ; RELOC-NEXT: Symbol: 9 | |
| 275 | ; RELOC-NEXT: - Priority: 2002 | |
| 276 | 276 | ; RELOC-NEXT: Symbol: 23 |
| 277 | 277 | ; RELOC-NEXT: - Priority: 4000 |
| 278 | ; RELOC-NEXT: Symbol: 14 | |
| 278 | ; RELOC-NEXT: Symbol: 8 | |
| 279 | 279 | ; RELOC-NEXT: - Priority: 4000 |
| 280 | ; RELOC-NEXT: Symbol: 13 | |
| 280 | ; RELOC-NEXT: Symbol: 17 | |
| 281 | 281 | ; RELOC-NEXT: - Type: CUSTOM |
| 282 | 282 | ; RELOC-NEXT: Name: name |
| 283 | ; RELOC-NEXT: FunctionNames: | |
| 283 | ; RELOC-NEXT: FunctionNames: | |
| 284 | 284 | ; RELOC-NEXT: - Index: 0 |
| 285 | 285 | ; RELOC-NEXT: Name: externDtor |
| 286 | 286 | ; RELOC-NEXT: - Index: 1 |
deps/lld/test/wasm/locals-duplicate.test+73-73| ... | ... | @@ -270,40 +270,40 @@ |
| 270 | 270 | ; RELOC-NEXT: - Type: CODE |
| 271 | 271 | ; RELOC-NEXT: Relocations: |
| 272 | 272 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_SLEB |
| 273 | ; RELOC-NEXT: Index: 4 | |
| 273 | ; RELOC-NEXT: Index: 18 | |
| 274 | 274 | ; RELOC-NEXT: Offset: 0x00000013 |
| 275 | 275 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_SLEB |
| 276 | ; RELOC-NEXT: Index: 6 | |
| 276 | ; RELOC-NEXT: Index: 3 | |
| 277 | 277 | ; RELOC-NEXT: Offset: 0x0000001C |
| 278 | 278 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_SLEB |
| 279 | ; RELOC-NEXT: Index: 8 | |
| 279 | ; RELOC-NEXT: Index: 19 | |
| 280 | 280 | ; RELOC-NEXT: Offset: 0x00000025 |
| 281 | 281 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB |
| 282 | ; RELOC-NEXT: Index: 0 | |
| 282 | ; RELOC-NEXT: Index: 16 | |
| 283 | 283 | ; RELOC-NEXT: Offset: 0x0000002E |
| 284 | 284 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB |
| 285 | ; RELOC-NEXT: Index: 1 | |
| 285 | ; RELOC-NEXT: Index: 0 | |
| 286 | 286 | ; RELOC-NEXT: Offset: 0x00000037 |
| 287 | 287 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB |
| 288 | ; RELOC-NEXT: Index: 2 | |
| 288 | ; RELOC-NEXT: Index: 17 | |
| 289 | 289 | ; RELOC-NEXT: Offset: 0x00000040 |
| 290 | 290 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_SLEB |
| 291 | ; RELOC-NEXT: Index: 16 | |
| 291 | ; RELOC-NEXT: Index: 10 | |
| 292 | 292 | ; RELOC-NEXT: Offset: 0x00000058 |
| 293 | 293 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_SLEB |
| 294 | ; RELOC-NEXT: Index: 18 | |
| 294 | ; RELOC-NEXT: Index: 22 | |
| 295 | 295 | ; RELOC-NEXT: Offset: 0x00000061 |
| 296 | 296 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_SLEB |
| 297 | ; RELOC-NEXT: Index: 20 | |
| 297 | ; RELOC-NEXT: Index: 23 | |
| 298 | 298 | ; RELOC-NEXT: Offset: 0x0000006A |
| 299 | 299 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB |
| 300 | ; RELOC-NEXT: Index: 12 | |
| 300 | ; RELOC-NEXT: Index: 8 | |
| 301 | 301 | ; RELOC-NEXT: Offset: 0x00000073 |
| 302 | 302 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB |
| 303 | ; RELOC-NEXT: Index: 13 | |
| 303 | ; RELOC-NEXT: Index: 20 | |
| 304 | 304 | ; RELOC-NEXT: Offset: 0x0000007C |
| 305 | 305 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB |
| 306 | ; RELOC-NEXT: Index: 14 | |
| 306 | ; RELOC-NEXT: Index: 21 | |
| 307 | 307 | ; RELOC-NEXT: Offset: 0x00000085 |
| 308 | 308 | ; RELOC-NEXT: Functions: |
| 309 | 309 | ; RELOC-NEXT: - Index: 0 |
| ... | ... | @@ -386,133 +386,133 @@ |
| 386 | 386 | ; RELOC-NEXT: SymbolTable: |
| 387 | 387 | ; RELOC-NEXT: - Index: 0 |
| 388 | 388 | ; 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 | 389 | ; RELOC-NEXT: Name: colliding_func2 |
| 395 | 390 | ; RELOC-NEXT: Flags: [ ] |
| 396 | 391 | ; RELOC-NEXT: Function: 1 |
| 397 | ; RELOC-NEXT: - Index: 2 | |
| 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 | |
| 392 | ; RELOC-NEXT: - Index: 1 | |
| 403 | 393 | ; RELOC-NEXT: Kind: FUNCTION |
| 404 | 394 | ; RELOC-NEXT: Name: get_global1A |
| 405 | 395 | ; RELOC-NEXT: Flags: [ ] |
| 406 | 396 | ; RELOC-NEXT: Function: 3 |
| 407 | ; RELOC-NEXT: - Index: 4 | |
| 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 | |
| 397 | ; RELOC-NEXT: - Index: 2 | |
| 414 | 398 | ; RELOC-NEXT: Kind: FUNCTION |
| 415 | 399 | ; RELOC-NEXT: Name: get_global2A |
| 416 | 400 | ; RELOC-NEXT: Flags: [ ] |
| 417 | 401 | ; RELOC-NEXT: Function: 4 |
| 418 | ; RELOC-NEXT: - Index: 6 | |
| 402 | ; RELOC-NEXT: - Index: 3 | |
| 419 | 403 | ; RELOC-NEXT: Kind: DATA |
| 420 | 404 | ; RELOC-NEXT: Name: colliding_global2 |
| 421 | 405 | ; RELOC-NEXT: Flags: [ ] |
| 422 | 406 | ; RELOC-NEXT: Segment: 1 |
| 423 | 407 | ; RELOC-NEXT: Size: 4 |
| 424 | ; RELOC-NEXT: - Index: 7 | |
| 408 | ; RELOC-NEXT: - Index: 4 | |
| 425 | 409 | ; RELOC-NEXT: Kind: FUNCTION |
| 426 | 410 | ; RELOC-NEXT: Name: get_global3A |
| 427 | 411 | ; RELOC-NEXT: Flags: [ ] |
| 428 | 412 | ; RELOC-NEXT: Function: 5 |
| 429 | ; RELOC-NEXT: - Index: 8 | |
| 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 | |
| 413 | ; RELOC-NEXT: - Index: 5 | |
| 436 | 414 | ; RELOC-NEXT: Kind: FUNCTION |
| 437 | 415 | ; RELOC-NEXT: Name: get_func1A |
| 438 | 416 | ; RELOC-NEXT: Flags: [ ] |
| 439 | 417 | ; RELOC-NEXT: Function: 6 |
| 440 | ; RELOC-NEXT: - Index: 10 | |
| 418 | ; RELOC-NEXT: - Index: 6 | |
| 441 | 419 | ; RELOC-NEXT: Kind: FUNCTION |
| 442 | 420 | ; RELOC-NEXT: Name: get_func2A |
| 443 | 421 | ; RELOC-NEXT: Flags: [ ] |
| 444 | 422 | ; RELOC-NEXT: Function: 7 |
| 445 | ; RELOC-NEXT: - Index: 11 | |
| 423 | ; RELOC-NEXT: - Index: 7 | |
| 446 | 424 | ; RELOC-NEXT: Kind: FUNCTION |
| 447 | 425 | ; RELOC-NEXT: Name: get_func3A |
| 448 | 426 | ; RELOC-NEXT: Flags: [ ] |
| 449 | 427 | ; RELOC-NEXT: Function: 8 |
| 450 | ; RELOC-NEXT: - Index: 12 | |
| 428 | ; RELOC-NEXT: - Index: 8 | |
| 451 | 429 | ; RELOC-NEXT: Kind: FUNCTION |
| 452 | 430 | ; RELOC-NEXT: Name: colliding_func1 |
| 453 | 431 | ; RELOC-NEXT: Flags: [ ] |
| 454 | 432 | ; RELOC-NEXT: Function: 9 |
| 455 | ; RELOC-NEXT: - Index: 13 | |
| 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 | |
| 433 | ; RELOC-NEXT: - Index: 9 | |
| 466 | 434 | ; RELOC-NEXT: Kind: FUNCTION |
| 467 | 435 | ; RELOC-NEXT: Name: get_global1B |
| 468 | 436 | ; RELOC-NEXT: Flags: [ ] |
| 469 | 437 | ; RELOC-NEXT: Function: 12 |
| 470 | ; RELOC-NEXT: - Index: 16 | |
| 438 | ; RELOC-NEXT: - Index: 10 | |
| 471 | 439 | ; RELOC-NEXT: Kind: DATA |
| 472 | 440 | ; RELOC-NEXT: Name: colliding_global1 |
| 473 | 441 | ; RELOC-NEXT: Flags: [ ] |
| 474 | 442 | ; RELOC-NEXT: Segment: 0 |
| 475 | 443 | ; RELOC-NEXT: Offset: 4 |
| 476 | 444 | ; RELOC-NEXT: Size: 4 |
| 477 | ; RELOC-NEXT: - Index: 17 | |
| 445 | ; RELOC-NEXT: - Index: 11 | |
| 478 | 446 | ; RELOC-NEXT: Kind: FUNCTION |
| 479 | 447 | ; RELOC-NEXT: Name: get_global2B |
| 480 | 448 | ; RELOC-NEXT: Flags: [ ] |
| 481 | 449 | ; RELOC-NEXT: Function: 13 |
| 482 | ; RELOC-NEXT: - Index: 18 | |
| 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 | |
| 450 | ; RELOC-NEXT: - Index: 12 | |
| 490 | 451 | ; RELOC-NEXT: Kind: FUNCTION |
| 491 | 452 | ; RELOC-NEXT: Name: get_global3B |
| 492 | 453 | ; RELOC-NEXT: Flags: [ ] |
| 493 | 454 | ; RELOC-NEXT: Function: 14 |
| 494 | ; RELOC-NEXT: - Index: 20 | |
| 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 | |
| 455 | ; RELOC-NEXT: - Index: 13 | |
| 502 | 456 | ; RELOC-NEXT: Kind: FUNCTION |
| 503 | 457 | ; RELOC-NEXT: Name: get_func1B |
| 504 | 458 | ; RELOC-NEXT: Flags: [ ] |
| 505 | 459 | ; RELOC-NEXT: Function: 15 |
| 506 | ; RELOC-NEXT: - Index: 22 | |
| 460 | ; RELOC-NEXT: - Index: 14 | |
| 507 | 461 | ; RELOC-NEXT: Kind: FUNCTION |
| 508 | 462 | ; RELOC-NEXT: Name: get_func2B |
| 509 | 463 | ; RELOC-NEXT: Flags: [ ] |
| 510 | 464 | ; RELOC-NEXT: Function: 16 |
| 511 | ; RELOC-NEXT: - Index: 23 | |
| 465 | ; RELOC-NEXT: - Index: 15 | |
| 512 | 466 | ; RELOC-NEXT: Kind: FUNCTION |
| 513 | 467 | ; RELOC-NEXT: Name: get_func3B |
| 514 | 468 | ; RELOC-NEXT: Flags: [ ] |
| 515 | 469 | ; 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 | 516 | ; RELOC-NEXT: SegmentInfo: |
| 517 | 517 | ; RELOC-NEXT: - Index: 0 |
| 518 | 518 | ; 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 | ||
| 5 | target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" | |
| 6 | target triple = "wasm32-unknown-unknown" | |
| 7 | ||
| 8 | @missing_data = external global i32 | |
| 9 | declare i32 @missing_func() local_unnamed_addr | |
| 10 | ||
| 11 | define i32 @foo() { | |
| 12 | entry: | |
| 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 | 187 | ; RELOC-NEXT: - Type: CODE |
| 188 | 188 | ; RELOC-NEXT: Relocations: |
| 189 | 189 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB |
| 190 | ; RELOC-NEXT: Index: 4 | |
| 190 | ; RELOC-NEXT: Index: 1 | |
| 191 | 191 | ; RELOC-NEXT: Offset: 0x00000004 |
| 192 | 192 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB |
| 193 | ; RELOC-NEXT: Index: 1 | |
| 193 | ; RELOC-NEXT: Index: 2 | |
| 194 | 194 | ; RELOC-NEXT: Offset: 0x00000013 |
| 195 | 195 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB |
| 196 | ; RELOC-NEXT: Index: 4 | |
| 196 | ; RELOC-NEXT: Index: 1 | |
| 197 | 197 | ; RELOC-NEXT: Offset: 0x0000001C |
| 198 | 198 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_GLOBAL_INDEX_LEB |
| 199 | 199 | ; RELOC-NEXT: Index: 6 |
| ... | ... | @@ -202,10 +202,10 @@ entry: |
| 202 | 202 | ; RELOC-NEXT: Index: 6 |
| 203 | 203 | ; RELOC-NEXT: Offset: 0x00000032 |
| 204 | 204 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB |
| 205 | ; RELOC-NEXT: Index: 4 | |
| 205 | ; RELOC-NEXT: Index: 1 | |
| 206 | 206 | ; RELOC-NEXT: Offset: 0x0000003A |
| 207 | 207 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB |
| 208 | ; RELOC-NEXT: Index: 4 | |
| 208 | ; RELOC-NEXT: Index: 1 | |
| 209 | 209 | ; RELOC-NEXT: Offset: 0x00000043 |
| 210 | 210 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_GLOBAL_INDEX_LEB |
| 211 | 211 | ; RELOC-NEXT: Index: 6 |
| ... | ... | @@ -217,10 +217,10 @@ entry: |
| 217 | 217 | ; RELOC-NEXT: Index: 6 |
| 218 | 218 | ; RELOC-NEXT: Offset: 0x00000068 |
| 219 | 219 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB |
| 220 | ; RELOC-NEXT: Index: 1 | |
| 220 | ; RELOC-NEXT: Index: 2 | |
| 221 | 221 | ; RELOC-NEXT: Offset: 0x00000070 |
| 222 | 222 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB |
| 223 | ; RELOC-NEXT: Index: 1 | |
| 223 | ; RELOC-NEXT: Index: 2 | |
| 224 | 224 | ; RELOC-NEXT: Offset: 0x00000079 |
| 225 | 225 | ; RELOC-NEXT: - Type: R_WEBASSEMBLY_GLOBAL_INDEX_LEB |
| 226 | 226 | ; RELOC-NEXT: Index: 6 |
| ... | ... | @@ -259,24 +259,24 @@ entry: |
| 259 | 259 | ; RELOC-NEXT: Function: 0 |
| 260 | 260 | ; RELOC-NEXT: - Index: 1 |
| 261 | 261 | ; 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 | 267 | ; RELOC-NEXT: Name: direct_fn |
| 263 | 268 | ; RELOC-NEXT: Flags: [ ] |
| 264 | 269 | ; RELOC-NEXT: Function: 1 |
| 265 | ; RELOC-NEXT: - Index: 2 | |
| 270 | ; RELOC-NEXT: - Index: 3 | |
| 266 | 271 | ; RELOC-NEXT: Kind: FUNCTION |
| 267 | 272 | ; RELOC-NEXT: Name: call_direct |
| 268 | 273 | ; RELOC-NEXT: Flags: [ ] |
| 269 | 274 | ; RELOC-NEXT: Function: 2 |
| 270 | ; RELOC-NEXT: - Index: 3 | |
| 275 | ; RELOC-NEXT: - Index: 4 | |
| 271 | 276 | ; RELOC-NEXT: Kind: FUNCTION |
| 272 | 277 | ; RELOC-NEXT: Name: call_alias |
| 273 | 278 | ; RELOC-NEXT: Flags: [ ] |
| 274 | 279 | ; 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 | 280 | ; RELOC-NEXT: - Index: 5 |
| 281 | 281 | ; RELOC-NEXT: Kind: FUNCTION |
| 282 | 282 | ; RELOC-NEXT: Name: call_alias_ptr |
deps/lld/wasm/Driver.cpp+3-1| ... | ... | @@ -434,7 +434,9 @@ static Symbol *handleUndefined(StringRef Name) { |
| 434 | 434 | static UndefinedGlobal * |
| 435 | 435 | createUndefinedGlobal(StringRef Name, llvm::wasm::WasmGlobalType *Type) { |
| 436 | 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 | 440 | Config->AllowUndefinedSymbols.insert(Sym->getName()); |
| 439 | 441 | Sym->IsUsedInRegularObj = true; |
| 440 | 442 | return Sym; |
deps/lld/wasm/InputChunks.cpp+3-3| ... | ... | @@ -23,7 +23,7 @@ using namespace llvm::support::endian; |
| 23 | 23 | using namespace lld; |
| 24 | 24 | using namespace lld::wasm; |
| 25 | 25 | |
| 26 | static StringRef ReloctTypeToString(uint8_t RelocType) { | |
| 26 | static StringRef reloctTypeToString(uint8_t RelocType) { | |
| 27 | 27 | switch (RelocType) { |
| 28 | 28 | #define WASM_RELOC(NAME, REL) \ |
| 29 | 29 | case REL: \ |
| ... | ... | @@ -77,7 +77,7 @@ void InputChunk::verifyRelocTargets() const { |
| 77 | 77 | warn("expected LEB at relocation site be 5-byte padded"); |
| 78 | 78 | uint32_t ExpectedValue = File->calcExpectedValue(Rel); |
| 79 | 79 | if (ExpectedValue != ExistingValue) |
| 80 | warn("unexpected existing value for " + ReloctTypeToString(Rel.Type) + | |
| 80 | warn("unexpected existing value for " + reloctTypeToString(Rel.Type) + | |
| 81 | 81 | ": existing=" + Twine(ExistingValue) + |
| 82 | 82 | " expected=" + Twine(ExpectedValue)); |
| 83 | 83 | } |
| ... | ... | @@ -103,7 +103,7 @@ void InputChunk::writeTo(uint8_t *Buf) const { |
| 103 | 103 | for (const WasmRelocation &Rel : Relocations) { |
| 104 | 104 | uint8_t *Loc = Buf + Rel.Offset + Off; |
| 105 | 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 | 107 | << " addend=" << Rel.Addend << " index=" << Rel.Index |
| 108 | 108 | << " value=" << Value << " offset=" << Rel.Offset |
| 109 | 109 | << "\n"); |
deps/lld/wasm/InputFiles.cpp+8-3| ... | ... | @@ -377,11 +377,15 @@ Symbol *ObjFile::createUndefined(const WasmSymbol &Sym) { |
| 377 | 377 | |
| 378 | 378 | switch (Sym.Info.Kind) { |
| 379 | 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 | 383 | case WASM_SYMBOL_TYPE_DATA: |
| 382 | 384 | return Symtab->addUndefinedData(Name, Flags, this); |
| 383 | 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 | 389 | case WASM_SYMBOL_TYPE_SECTION: |
| 386 | 390 | llvm_unreachable("section symbols cannot be undefined"); |
| 387 | 391 | } |
| ... | ... | @@ -445,7 +449,8 @@ static Symbol *createBitcodeSymbol(const lto::InputFile::Symbol &ObjSym, |
| 445 | 449 | |
| 446 | 450 | if (ObjSym.isUndefined()) { |
| 447 | 451 | if (ObjSym.isExecutable()) |
| 448 | return Symtab->addUndefinedFunction(Name, Flags, &F, nullptr); | |
| 452 | return Symtab->addUndefinedFunction(Name, Name, DefaultModule, Flags, &F, | |
| 453 | nullptr); | |
| 449 | 454 | return Symtab->addUndefinedData(Name, Flags, &F); |
| 450 | 455 | } |
| 451 | 456 |
deps/lld/wasm/LTO.cpp+3-2| ... | ... | @@ -79,8 +79,9 @@ BitcodeCompiler::~BitcodeCompiler() = default; |
| 79 | 79 | |
| 80 | 80 | static void undefine(Symbol *S) { |
| 81 | 81 | if (auto F = dyn_cast<DefinedFunction>(S)) |
| 82 | replaceSymbol<UndefinedFunction>(F, F->getName(), 0, F->getFile(), | |
| 83 | F->Signature); | |
| 82 | replaceSymbol<UndefinedFunction>(F, F->getName(), F->getName(), | |
| 83 | DefaultModule, 0, | |
| 84 | F->getFile(), F->Signature); | |
| 84 | 85 | else if (isa<DefinedData>(S)) |
| 85 | 86 | replaceSymbol<UndefinedData>(S, S->getName(), 0, S->getFile()); |
| 86 | 87 | else |
deps/lld/wasm/LTO.h+1| ... | ... | @@ -23,6 +23,7 @@ |
| 23 | 23 | |
| 24 | 24 | #include "lld/Common/LLVM.h" |
| 25 | 25 | #include "llvm/ADT/SmallString.h" |
| 26 | #include "Writer.h" | |
| 26 | 27 | #include <memory> |
| 27 | 28 | #include <vector> |
| 28 | 29 |
deps/lld/wasm/MarkLive.cpp+1-1| ... | ... | @@ -85,7 +85,7 @@ void lld::wasm::markLive() { |
| 85 | 85 | // equal to null pointer, only reachable via direct call). |
| 86 | 86 | if (Reloc.Type == R_WEBASSEMBLY_TABLE_INDEX_SLEB || |
| 87 | 87 | Reloc.Type == R_WEBASSEMBLY_TABLE_INDEX_I32) { |
| 88 | FunctionSymbol *FuncSym = cast<FunctionSymbol>(Sym); | |
| 88 | auto *FuncSym = cast<FunctionSymbol>(Sym); | |
| 89 | 89 | if (FuncSym->hasTableIndex() && FuncSym->getTableIndex() == 0) |
| 90 | 90 | continue; |
| 91 | 91 | } |
deps/lld/wasm/SymbolTable.cpp+9-5| ... | ... | @@ -314,8 +314,9 @@ Symbol *SymbolTable::addDefinedEvent(StringRef Name, uint32_t Flags, |
| 314 | 314 | return S; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | Symbol *SymbolTable::addUndefinedFunction(StringRef Name, uint32_t Flags, | |
| 318 | InputFile *File, | |
| 317 | Symbol *SymbolTable::addUndefinedFunction(StringRef Name, StringRef ImportName, | |
| 318 | StringRef ImportModule, | |
| 319 | uint32_t Flags, InputFile *File, | |
| 319 | 320 | const WasmSignature *Sig) { |
| 320 | 321 | LLVM_DEBUG(dbgs() << "addUndefinedFunction: " << Name << |
| 321 | 322 | " [" << (Sig ? toString(*Sig) : "none") << "]\n"); |
| ... | ... | @@ -325,7 +326,8 @@ Symbol *SymbolTable::addUndefinedFunction(StringRef Name, uint32_t Flags, |
| 325 | 326 | std::tie(S, WasInserted) = insert(Name, File); |
| 326 | 327 | |
| 327 | 328 | if (WasInserted) |
| 328 | replaceSymbol<UndefinedFunction>(S, Name, Flags, File, Sig); | |
| 329 | replaceSymbol<UndefinedFunction>(S, Name, ImportName, ImportModule, Flags, | |
| 330 | File, Sig); | |
| 329 | 331 | else if (auto *Lazy = dyn_cast<LazySymbol>(S)) |
| 330 | 332 | Lazy->fetch(); |
| 331 | 333 | else |
| ... | ... | @@ -351,7 +353,8 @@ Symbol *SymbolTable::addUndefinedData(StringRef Name, uint32_t Flags, |
| 351 | 353 | return S; |
| 352 | 354 | } |
| 353 | 355 | |
| 354 | Symbol *SymbolTable::addUndefinedGlobal(StringRef Name, uint32_t Flags, | |
| 356 | Symbol *SymbolTable::addUndefinedGlobal(StringRef Name, StringRef ImportName, | |
| 357 | StringRef ImportModule, uint32_t Flags, | |
| 355 | 358 | InputFile *File, |
| 356 | 359 | const WasmGlobalType *Type) { |
| 357 | 360 | LLVM_DEBUG(dbgs() << "addUndefinedGlobal: " << Name << "\n"); |
| ... | ... | @@ -361,7 +364,8 @@ Symbol *SymbolTable::addUndefinedGlobal(StringRef Name, uint32_t Flags, |
| 361 | 364 | std::tie(S, WasInserted) = insert(Name, File); |
| 362 | 365 | |
| 363 | 366 | if (WasInserted) |
| 364 | replaceSymbol<UndefinedGlobal>(S, Name, Flags, File, Type); | |
| 367 | replaceSymbol<UndefinedGlobal>(S, Name, ImportName, ImportModule, Flags, | |
| 368 | File, Type); | |
| 365 | 369 | else if (auto *Lazy = dyn_cast<LazySymbol>(S)) |
| 366 | 370 | Lazy->fetch(); |
| 367 | 371 | else if (S->isDefined()) |
deps/lld/wasm/SymbolTable.h+6-4| ... | ... | @@ -59,11 +59,13 @@ public: |
| 59 | 59 | Symbol *addDefinedEvent(StringRef Name, uint32_t Flags, InputFile *File, |
| 60 | 60 | InputEvent *E); |
| 61 | 61 | |
| 62 | Symbol *addUndefinedFunction(StringRef Name, uint32_t Flags, InputFile *File, | |
| 63 | const WasmSignature *Signature); | |
| 62 | Symbol *addUndefinedFunction(StringRef Name, StringRef ImportName, | |
| 63 | StringRef ImportModule, uint32_t Flags, | |
| 64 | InputFile *File, const WasmSignature *Signature); | |
| 64 | 65 | Symbol *addUndefinedData(StringRef Name, uint32_t Flags, InputFile *File); |
| 65 | Symbol *addUndefinedGlobal(StringRef Name, uint32_t Flags, InputFile *File, | |
| 66 | const WasmGlobalType *Type); | |
| 66 | Symbol *addUndefinedGlobal(StringRef Name, StringRef ImportName, | |
| 67 | StringRef ImportModule, uint32_t Flags, | |
| 68 | InputFile *File, const WasmGlobalType *Type); | |
| 67 | 69 | |
| 68 | 70 | void addLazy(ArchiveFile *F, const llvm::object::Archive::Symbol *Sym); |
| 69 | 71 |
deps/lld/wasm/Symbols.h+15-4| ... | ... | @@ -149,13 +149,19 @@ public: |
| 149 | 149 | |
| 150 | 150 | class UndefinedFunction : public FunctionSymbol { |
| 151 | 151 | public: |
| 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 | 155 | const WasmSignature *Type = nullptr) |
| 154 | : FunctionSymbol(Name, UndefinedFunctionKind, Flags, File, Type) {} | |
| 156 | : FunctionSymbol(Name, UndefinedFunctionKind, Flags, File, Type), | |
| 157 | ImportName(ImportName), ImportModule(ImportModule) {} | |
| 155 | 158 | |
| 156 | 159 | static bool classof(const Symbol *S) { |
| 157 | 160 | return S->kind() == UndefinedFunctionKind; |
| 158 | 161 | } |
| 162 | ||
| 163 | StringRef ImportName; | |
| 164 | StringRef ImportModule; | |
| 159 | 165 | }; |
| 160 | 166 | |
| 161 | 167 | class SectionSymbol : public Symbol { |
| ... | ... | @@ -261,13 +267,18 @@ public: |
| 261 | 267 | |
| 262 | 268 | class UndefinedGlobal : public GlobalSymbol { |
| 263 | 269 | public: |
| 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 | 272 | const WasmGlobalType *Type = nullptr) |
| 266 | : GlobalSymbol(Name, UndefinedGlobalKind, Flags, File, Type) {} | |
| 273 | : GlobalSymbol(Name, UndefinedGlobalKind, Flags, File, Type), | |
| 274 | ImportName(ImportName), ImportModule(ImportModule) {} | |
| 267 | 275 | |
| 268 | 276 | static bool classof(const Symbol *S) { |
| 269 | 277 | return S->kind() == UndefinedGlobalKind; |
| 270 | 278 | } |
| 279 | ||
| 280 | StringRef ImportName; | |
| 281 | StringRef ImportModule; | |
| 271 | 282 | }; |
| 272 | 283 | |
| 273 | 284 | // 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 | 39 | using namespace lld; |
| 40 | 40 | using namespace lld::wasm; |
| 41 | 41 | |
| 42 | static constexpr int kStackAlignment = 16; | |
| 43 | static constexpr const char *kFunctionTableName = "__indirect_function_table"; | |
| 42 | static constexpr int StackAlignment = 16; | |
| 43 | static constexpr const char *FunctionTableName = "__indirect_function_table"; | |
| 44 | const char *lld::wasm::DefaultModule = "env"; | |
| 44 | 45 | |
| 45 | 46 | namespace { |
| 46 | 47 | |
| ... | ... | @@ -155,7 +156,7 @@ void Writer::createImportSection() { |
| 155 | 156 | |
| 156 | 157 | if (Config->ImportMemory) { |
| 157 | 158 | WasmImport Import; |
| 158 | Import.Module = "env"; | |
| 159 | Import.Module = DefaultModule; | |
| 159 | 160 | Import.Field = "memory"; |
| 160 | 161 | Import.Kind = WASM_EXTERNAL_MEMORY; |
| 161 | 162 | Import.Memory.Flags = 0; |
| ... | ... | @@ -172,8 +173,8 @@ void Writer::createImportSection() { |
| 172 | 173 | if (Config->ImportTable) { |
| 173 | 174 | uint32_t TableSize = TableBase + IndirectFunctions.size(); |
| 174 | 175 | WasmImport Import; |
| 175 | Import.Module = "env"; | |
| 176 | Import.Field = kFunctionTableName; | |
| 176 | Import.Module = DefaultModule; | |
| 177 | Import.Field = FunctionTableName; | |
| 177 | 178 | Import.Kind = WASM_EXTERNAL_TABLE; |
| 178 | 179 | Import.Table.ElemType = WASM_TYPE_FUNCREF; |
| 179 | 180 | Import.Table.Limits = {0, TableSize, 0}; |
| ... | ... | @@ -182,8 +183,17 @@ void Writer::createImportSection() { |
| 182 | 183 | |
| 183 | 184 | for (const Symbol *Sym : ImportedSymbols) { |
| 184 | 185 | WasmImport Import; |
| 185 | Import.Module = "env"; | |
| 186 | Import.Field = Sym->getName(); | |
| 186 | if (auto *F = dyn_cast<UndefinedFunction>(Sym)) { | |
| 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 | 197 | if (auto *FunctionSym = dyn_cast<FunctionSymbol>(Sym)) { |
| 188 | 198 | Import.Kind = WASM_EXTERNAL_FUNCTION; |
| 189 | 199 | Import.SigIndex = lookupType(*FunctionSym->Signature); |
| ... | ... | @@ -441,6 +451,13 @@ static uint32_t getWasmFlags(const Symbol *Sym) { |
| 441 | 451 | Flags |= WASM_SYMBOL_VISIBILITY_HIDDEN; |
| 442 | 452 | if (Sym->isUndefined()) |
| 443 | 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 | 461 | return Flags; |
| 445 | 462 | } |
| 446 | 463 | |
| ... | ... | @@ -506,15 +523,18 @@ void Writer::createLinkingSection() { |
| 506 | 523 | |
| 507 | 524 | if (auto *F = dyn_cast<FunctionSymbol>(Sym)) { |
| 508 | 525 | writeUleb128(Sub.OS, F->getFunctionIndex(), "index"); |
| 509 | if (Sym->isDefined()) | |
| 526 | if (Sym->isDefined() || | |
| 527 | (Flags & WASM_SYMBOL_EXPLICIT_NAME) != 0) | |
| 510 | 528 | writeStr(Sub.OS, Sym->getName(), "sym name"); |
| 511 | 529 | } else if (auto *G = dyn_cast<GlobalSymbol>(Sym)) { |
| 512 | 530 | writeUleb128(Sub.OS, G->getGlobalIndex(), "index"); |
| 513 | if (Sym->isDefined()) | |
| 531 | if (Sym->isDefined() || | |
| 532 | (Flags & WASM_SYMBOL_EXPLICIT_NAME) != 0) | |
| 514 | 533 | writeStr(Sub.OS, Sym->getName(), "sym name"); |
| 515 | 534 | } else if (auto *E = dyn_cast<EventSymbol>(Sym)) { |
| 516 | 535 | writeUleb128(Sub.OS, E->getEventIndex(), "index"); |
| 517 | if (Sym->isDefined()) | |
| 536 | if (Sym->isDefined() || | |
| 537 | (Flags & WASM_SYMBOL_EXPLICIT_NAME) != 0) | |
| 518 | 538 | writeStr(Sub.OS, Sym->getName(), "sym name"); |
| 519 | 539 | } else if (isa<DataSymbol>(Sym)) { |
| 520 | 540 | writeStr(Sub.OS, Sym->getName(), "sym name"); |
| ... | ... | @@ -663,9 +683,9 @@ void Writer::layoutMemory() { |
| 663 | 683 | auto PlaceStack = [&]() { |
| 664 | 684 | if (Config->Relocatable || Config->Shared) |
| 665 | 685 | return; |
| 666 | MemoryPtr = alignTo(MemoryPtr, kStackAlignment); | |
| 667 | if (Config->ZStackSize != alignTo(Config->ZStackSize, kStackAlignment)) | |
| 668 | error("stack size must be " + Twine(kStackAlignment) + "-byte aligned"); | |
| 686 | MemoryPtr = alignTo(MemoryPtr, StackAlignment); | |
| 687 | if (Config->ZStackSize != alignTo(Config->ZStackSize, StackAlignment)) | |
| 688 | error("stack size must be " + Twine(StackAlignment) + "-byte aligned"); | |
| 669 | 689 | log("mem: stack size = " + Twine(Config->ZStackSize)); |
| 670 | 690 | log("mem: stack base = " + Twine(MemoryPtr)); |
| 671 | 691 | MemoryPtr += Config->ZStackSize; |
| ... | ... | @@ -814,7 +834,7 @@ void Writer::calculateExports() { |
| 814 | 834 | Exports.push_back(WasmExport{"memory", WASM_EXTERNAL_MEMORY, 0}); |
| 815 | 835 | |
| 816 | 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}); | |
| 818 | 838 | |
| 819 | 839 | unsigned FakeGlobalIndex = NumImportedGlobals + InputGlobals.size(); |
| 820 | 840 | |
| ... | ... | @@ -858,40 +878,42 @@ void Writer::assignSymtab() { |
| 858 | 878 | StringMap<uint32_t> SectionSymbolIndices; |
| 859 | 879 | |
| 860 | 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 | } | |
| 877 | 881 | |
| 878 | SectionSymbolIndices[Name] = SymbolIndex; | |
| 879 | CustomSectionSymbols[Name] = cast<SectionSymbol>(Sym); | |
| 882 | auto AddSymbol = [&](Symbol *Sym) { | |
| 883 | if (auto *S = dyn_cast<SectionSymbol>(Sym)) { | |
| 884 | StringRef Name = S->getName(); | |
| 885 | if (CustomSectionMapping.count(Name) == 0) | |
| 886 | return; | |
| 880 | 887 | |
| 881 | Sym->markLive(); | |
| 888 | auto SSI = SectionSymbolIndices.find(Name); | |
| 889 | if (SSI != SectionSymbolIndices.end()) { | |
| 890 | Sym->setOutputSymbolIndex(SSI->second); | |
| 891 | return; | |
| 882 | 892 | } |
| 883 | 893 | |
| 884 | // (Since this is relocatable output, GC is not performed so symbols must | |
| 885 | // be live.) | |
| 886 | assert(Sym->isLive()); | |
| 887 | Sym->setOutputSymbolIndex(SymbolIndex++); | |
| 888 | SymtabEntries.emplace_back(Sym); | |
| 894 | SectionSymbolIndices[Name] = SymbolIndex; | |
| 895 | CustomSectionSymbols[Name] = cast<SectionSymbol>(Sym); | |
| 896 | ||
| 897 | Sym->markLive(); | |
| 889 | 898 | } |
| 890 | } | |
| 891 | 899 | |
| 892 | // For the moment, relocatable output doesn't contain any synthetic functions, | |
| 893 | // so no need to look through the Symtab for symbols not referenced by | |
| 894 | // Symtab->ObjectFiles. | |
| 900 | // (Since this is relocatable output, GC is not performed so symbols must | |
| 901 | // be live.) | |
| 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 | } |
| 896 | 918 | |
| 897 | 919 | uint32_t Writer::lookupType(const WasmSignature &Sig) { |
deps/lld/wasm/Writer.h+2| ... | ... | @@ -15,6 +15,8 @@ namespace wasm { |
| 15 | 15 | |
| 16 | 16 | void writeResult(); |
| 17 | 17 | |
| 18 | extern const char *DefaultModule; | |
| 19 | ||
| 18 | 20 | } // namespace wasm |
| 19 | 21 | } // namespace lld |
| 20 | 22 |