From 37a06f4dcf27c6bb5759656d6abc0d8b290f093f Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 20 Aug 2019 19:33:58 -0400 Subject: [PATCH] update embedded LLD to 9.0.0-rc2 upstream commit 67a4a12d61bfb10b2410b53c5a43ef9b4a03de7d --- deps/lld-prebuilt/MinGW/Options.inc | 3 + deps/lld/COFF/Driver.cpp | 4 +- deps/lld/COFF/Writer.cpp | 7 + deps/lld/ELF/SyntheticSections.cpp | 14 +- deps/lld/MinGW/Driver.cpp | 2 + deps/lld/MinGW/Options.td | 2 + deps/lld/docs/ReleaseNotes.rst | 9 + .../ReaderWriter/MachO/ArchHandler_x86_64.cpp | 1 + deps/lld/test/COFF/Inputs/mangled-symbol.s | 9 + deps/lld/test/COFF/autoimport-gnu-implib.s | 7 +- deps/lld/test/COFF/autoimport-x86.s | 9 +- deps/lld/test/COFF/thin-archive.s | 32 ++ deps/lld/test/ELF/arm-exidx-partial-discard.s | 37 ++ deps/lld/test/MinGW/driver.test | 4 + deps/lld/test/wasm/relocatable.ll | 360 +++++++++--------- deps/lld/wasm/Writer.cpp | 2 +- 16 files changed, 321 insertions(+), 181 deletions(-) create mode 100644 deps/lld/test/COFF/Inputs/mangled-symbol.s create mode 100644 deps/lld/test/COFF/thin-archive.s create mode 100644 deps/lld/test/ELF/arm-exidx-partial-discard.s diff --git a/deps/lld-prebuilt/MinGW/Options.inc b/deps/lld-prebuilt/MinGW/Options.inc index d32cd994c5..e6bfdb7f08 100644 --- a/deps/lld-prebuilt/MinGW/Options.inc +++ b/deps/lld-prebuilt/MinGW/Options.inc @@ -37,6 +37,9 @@ OPTION(prefix_2, "Bdynamic", Bdynamic, Flag, INVALID, INVALID, nullptr, 0, 0, OPTION(prefix_2, "Bstatic", Bstatic, Flag, INVALID, INVALID, nullptr, 0, 0, "Do not link against shared libraries", nullptr, nullptr) OPTION(prefix_2, "build-id", anonymous_1, Flag, INVALID, INVALID, nullptr, 0, 0, nullptr, nullptr, nullptr) +OPTION(prefix_2, "delayload=", delayload_eq, Joined, INVALID, delayload, nullptr, 0, 0, nullptr, nullptr, nullptr) +OPTION(prefix_2, "delayload", delayload, Separate, INVALID, INVALID, nullptr, 0, 0, + "DLL to load only on demand", nullptr, nullptr) OPTION(prefix_2, "disable-auto-image-base", anonymous_2, Flag, INVALID, INVALID, nullptr, 0, 0, nullptr, nullptr, nullptr) OPTION(prefix_2, "dynamicbase", dynamicbase, Flag, INVALID, INVALID, nullptr, 0, 0, "Enable ASLR", nullptr, nullptr) diff --git a/deps/lld/COFF/Driver.cpp b/deps/lld/COFF/Driver.cpp index d7af50b931..7214d12bde 100644 --- a/deps/lld/COFF/Driver.cpp +++ b/deps/lld/COFF/Driver.cpp @@ -184,8 +184,10 @@ void LinkerDriver::addBuffer(std::unique_ptr mb, if (wholeArchive) { std::unique_ptr file = CHECK(Archive::create(mbref), filename + ": failed to parse archive"); + Archive *archive = file.get(); + make>(std::move(file)); // take ownership - for (MemoryBufferRef m : getArchiveMembers(file.get())) + for (MemoryBufferRef m : getArchiveMembers(archive)) addArchiveBuffer(m, "", filename, 0); return; } diff --git a/deps/lld/COFF/Writer.cpp b/deps/lld/COFF/Writer.cpp index 3da8b98d3d..cc75db0f51 100644 --- a/deps/lld/COFF/Writer.cpp +++ b/deps/lld/COFF/Writer.cpp @@ -1095,6 +1095,13 @@ Optional Writer::createSymbol(Defined *def) { } } + // Symbols that are runtime pseudo relocations don't point to the actual + // symbol data itself (as they are imported), but points to the IAT entry + // instead. Avoid emitting them to the symbol table, as they can confuse + // debuggers. + if (def->isRuntimePseudoReloc) + return None; + StringRef name = def->getName(); if (name.size() > COFF::NameSize) { sym.Name.Offset.Zeroes = 0; diff --git a/deps/lld/ELF/SyntheticSections.cpp b/deps/lld/ELF/SyntheticSections.cpp index f6d0f190d8..35b9b8928c 100644 --- a/deps/lld/ELF/SyntheticSections.cpp +++ b/deps/lld/ELF/SyntheticSections.cpp @@ -3177,11 +3177,23 @@ static bool isDuplicateArmExidxSec(InputSection *prev, InputSection *cur) { // The .ARM.exidx table must be sorted in ascending order of the address of the // functions the table describes. Optionally duplicate adjacent table entries -// can be removed. At the end of the function the ExecutableSections must be +// can be removed. At the end of the function the executableSections must be // sorted in ascending order of address, Sentinel is set to the InputSection // with the highest address and any InputSections that have mergeable // .ARM.exidx table entries are removed from it. void ARMExidxSyntheticSection::finalizeContents() { + if (script->hasSectionsCommand) { + // The executableSections and exidxSections that we use to derive the + // final contents of this SyntheticSection are populated before the + // linker script assigns InputSections to OutputSections. The linker script + // SECTIONS command may have a /DISCARD/ entry that removes executable + // InputSections and their dependent .ARM.exidx section that we recorded + // earlier. + auto isDiscarded = [](const InputSection *isec) { return !isec->isLive(); }; + llvm::erase_if(executableSections, isDiscarded); + llvm::erase_if(exidxSections, isDiscarded); + } + // Sort the executable sections that may or may not have associated // .ARM.exidx sections by order of ascending address. This requires the // relative positions of InputSections to be known. diff --git a/deps/lld/MinGW/Driver.cpp b/deps/lld/MinGW/Driver.cpp index 24e18aacb3..be1b757e45 100644 --- a/deps/lld/MinGW/Driver.cpp +++ b/deps/lld/MinGW/Driver.cpp @@ -303,6 +303,8 @@ bool mingw::link(ArrayRef argsArr, raw_ostream &diag) { add("-include:" + StringRef(a->getValue())); for (auto *a : args.filtered(OPT_undefined)) add("-includeoptional:" + StringRef(a->getValue())); + for (auto *a : args.filtered(OPT_delayload)) + add("-delayload:" + StringRef(a->getValue())); std::vector searchPaths; for (auto *a : args.filtered(OPT_L)) { diff --git a/deps/lld/MinGW/Options.td b/deps/lld/MinGW/Options.td index 44de98dfc9..86400433d0 100644 --- a/deps/lld/MinGW/Options.td +++ b/deps/lld/MinGW/Options.td @@ -80,6 +80,8 @@ def require_defined_eq: J<"require-defined=">, Alias; def _HASH_HASH_HASH : Flag<["-"], "###">, HelpText<"Print (but do not run) the commands to run for this compilation">; def appcontainer: F<"appcontainer">, HelpText<"Set the appcontainer flag in the executable">; +def delayload: S<"delayload">, HelpText<"DLL to load only on demand">; +def delayload_eq: J<"delayload=">, Alias; def mllvm: S<"mllvm">; def pdb: S<"pdb">, HelpText<"Output PDB debug info file, chosen implicitly if the argument is empty">; def pdb_eq: J<"pdb=">, Alias; diff --git a/deps/lld/docs/ReleaseNotes.rst b/deps/lld/docs/ReleaseNotes.rst index bccef8165f..2d358bf8f2 100644 --- a/deps/lld/docs/ReleaseNotes.rst +++ b/deps/lld/docs/ReleaseNotes.rst @@ -28,6 +28,15 @@ ELF Improvements ``$ ld.lld --call-shared`` now prints ``unknown argument '--call-shared', did you mean '--call_shared'``. +* lld now supports replacing ``JAL`` with ``JALX`` instructions in case + of MIPS - microMIPS cross-mode jumps. + +* lld now creates LA25 thunks for MIPS R6 code. + +* Put MIPS-specific .reginfo, .MIPS.options, and .MIPS.abiflags sections + into corresponding PT_MIPS_REGINFO, PT_MIPS_OPTIONS, and PT_MIPS_ABIFLAGS + segments. + * ... COFF Improvements diff --git a/deps/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp b/deps/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp index f42ca3b2f7..316b5bbc6f 100644 --- a/deps/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp +++ b/deps/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp @@ -621,6 +621,7 @@ void ArchHandler_x86_64::applyFixupFinal( // Fall into llvm_unreachable(). break; } + llvm_unreachable("invalid x86_64 Reference Kind"); } void ArchHandler_x86_64::applyFixupRelocatable(const Reference &ref, diff --git a/deps/lld/test/COFF/Inputs/mangled-symbol.s b/deps/lld/test/COFF/Inputs/mangled-symbol.s new file mode 100644 index 0000000000..d393236768 --- /dev/null +++ b/deps/lld/test/COFF/Inputs/mangled-symbol.s @@ -0,0 +1,9 @@ + .text + + .def "?f@@YAHXZ" + .scl 2 + .type 32 + .endef + .global "?f@@YAHXZ" +"?f@@YAHXZ": + retq $0 diff --git a/deps/lld/test/COFF/autoimport-gnu-implib.s b/deps/lld/test/COFF/autoimport-gnu-implib.s index e6e0ed207c..d7d4ed626e 100644 --- a/deps/lld/test/COFF/autoimport-gnu-implib.s +++ b/deps/lld/test/COFF/autoimport-gnu-implib.s @@ -7,9 +7,10 @@ # RUN: llvm-ar rcs %t-implib.a %t-dabcdh.o %t-dabcds00000.o %t-dabcdt.o # RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t.obj -# RUN: lld-link -lldmingw -out:%t.exe -entry:main %t.obj %t-implib.a -verbose +# RUN: lld-link -lldmingw -debug:symtab -out:%t.exe -entry:main %t.obj %t-implib.a -verbose # RUN: llvm-readobj --coff-imports %t.exe | FileCheck -check-prefix=IMPORTS %s +# RUN: llvm-nm %t.exe | FileCheck -check-prefix=SYMBOLS %s # IMPORTS: Import { # IMPORTS-NEXT: Name: foo.dll @@ -18,6 +19,10 @@ # IMPORTS-NEXT: Symbol: data (0) # IMPORTS-NEXT: } +# Check that the automatically imported symbol "data" is not listed in +# the symbol table. +# SYMBOLS-NOT: {{ }}data + .global main .text main: diff --git a/deps/lld/test/COFF/autoimport-x86.s b/deps/lld/test/COFF/autoimport-x86.s index 400cec7117..9e0ae1ead1 100644 --- a/deps/lld/test/COFF/autoimport-x86.s +++ b/deps/lld/test/COFF/autoimport-x86.s @@ -5,11 +5,12 @@ # RUN: lld-link -out:%t-lib.dll -dll -entry:DllMainCRTStartup %t-lib.obj -lldmingw -implib:%t-lib.lib # RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t.obj -# RUN: lld-link -lldmingw -out:%t.exe -entry:main %t.obj %t-lib.lib -verbose +# RUN: lld-link -lldmingw -debug:symtab -out:%t.exe -entry:main %t.obj %t-lib.lib -verbose # RUN: llvm-readobj --coff-imports %t.exe | FileCheck -check-prefix=IMPORTS %s # RUN: llvm-objdump -d %t.exe | FileCheck -check-prefix=DISASM %s # RUN: llvm-objdump -s %t.exe | FileCheck -check-prefix=CONTENTS %s +# RUN: llvm-nm %t.exe | FileCheck -check-prefix=SYMBOLS %s # IMPORTS: Import { # IMPORTS-NEXT: Name: autoimport-x86.s.tmp-lib.dll @@ -20,7 +21,7 @@ # DISASM: Disassembly of section .text: # DISASM-EMPTY: -# DISASM: .text: +# DISASM: main: # Relative offset at 0x1002 pointing at the IAT at 0x2080. # DISASM: 140001000: 8b 05 7a 10 00 00 movl 4218(%rip), %eax # DISASM: 140001006: c3 retq @@ -41,6 +42,10 @@ # CONTENTS: 140003000 80200040 01000000 00200040 01000000 # CONTENTS: 140003010 24200040 01000000 +# Check that the automatically imported symbol "variable" is not listed in +# the symbol table. +# SYMBOLS-NOT: variable + .global main .text main: diff --git a/deps/lld/test/COFF/thin-archive.s b/deps/lld/test/COFF/thin-archive.s new file mode 100644 index 0000000000..f24911de40 --- /dev/null +++ b/deps/lld/test/COFF/thin-archive.s @@ -0,0 +1,32 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -filetype=obj -triple=x86_64-windows-msvc -o %t.main.obj %s + +# RUN: llvm-mc -filetype=obj -triple=x86_64-windows-msvc -o %t.lib.obj \ +# RUN: %S/Inputs/mangled-symbol.s +# RUN: lld-link /lib /out:%t.lib %t.lib.obj +# RUN: lld-link /lib /llvmlibthin /out:%t_thin.lib %t.lib.obj + +# RUN: lld-link /entry:main %t.main.obj %t.lib /out:%t.exe 2>&1 | \ +# RUN: FileCheck --allow-empty %s +# RUN: lld-link /entry:main %t.main.obj %t_thin.lib /out:%t.exe 2>&1 | \ +# RUN: FileCheck --allow-empty %s +# RUN: lld-link /entry:main %t.main.obj /wholearchive:%t_thin.lib /out:%t.exe 2>&1 | \ +# RUN: FileCheck --allow-empty %s + +# RUN: rm %t.lib.obj +# RUN: lld-link /entry:main %t.main.obj %t.lib /out:%t.exe 2>&1 | \ +# RUN: FileCheck --allow-empty %s + +# CHECK-NOT: error: could not get the buffer for the member defining + + .text + + .def main + .scl 2 + .type 32 + .endef + .global main +main: + call "?f@@YAHXZ" + retq $0 diff --git a/deps/lld/test/ELF/arm-exidx-partial-discard.s b/deps/lld/test/ELF/arm-exidx-partial-discard.s new file mode 100644 index 0000000000..770a811c1b --- /dev/null +++ b/deps/lld/test/ELF/arm-exidx-partial-discard.s @@ -0,0 +1,37 @@ +// REQUIRES: arm +// RUN: llvm-mc -filetype=obj -triple arm-gnu-linux-eabi -mcpu cortex-a7 -arm-add-build-attributes %s -o %t.o +// RUN: echo "SECTIONS { . = 0x10000; .text : { *(.text) } /DISCARD/ : { *(.exit.text) } }" > %t.script +// RUN: ld.lld -T %t.script %t.o -o %t.elf +// RUN: llvm-readobj -x .ARM.exidx --sections %t.elf | FileCheck %s + +// CHECK-NOT: .exit.text +/// Expect 2 entries both CANTUNWIND as the .ARM.exidx.exit.text +// should have been removed. +// CHECK: Hex dump of section '.ARM.exidx': +// CHECK-NEXT: 0x00010000 10000000 01000000 10000000 01000000 + +/// The /DISCARD/ is evaluated after sections have been assigned to the +/// .ARM.exidx synthetic section. We must account for the /DISCARD/ + .section .exit.text, "ax", %progbits + .globl foo + .type foo, %function +foo: + .fnstart + bx lr + .save {r7, lr} + .setfp r7, sp, #0 + .fnend + + .text + .globl _start + .type _start, %function +_start: + .fnstart + bx lr + .cantunwind + .fnend + + .section .text.__aeabi_unwind_cpp_pr0, "ax", %progbits + .global __aeabi_unwind_cpp_pr0 +__aeabi_unwind_cpp_pr0: + bx lr diff --git a/deps/lld/test/MinGW/driver.test b/deps/lld/test/MinGW/driver.test index cdd802e93f..b8bc2ddea8 100644 --- a/deps/lld/test/MinGW/driver.test +++ b/deps/lld/test/MinGW/driver.test @@ -200,3 +200,7 @@ APPCONTAINER: -appcontainer # RUN: ld.lld -m i386pep --help 2>&1 | FileCheck -check-prefix=HELP %s # HELP: USAGE: # HELP: --enable-auto-import + +RUN: ld.lld -### -m i386pep foo.o -delayload user32.dll --delayload shell32.dll | FileCheck -check-prefix DELAYLOAD %s +RUN: ld.lld -### -m i386pep foo.o -delayload=user32.dll --delayload=shell32.dll | FileCheck -check-prefix DELAYLOAD %s +DELAYLOAD: -delayload:user32.dll -delayload:shell32.dll diff --git a/deps/lld/test/wasm/relocatable.ll b/deps/lld/test/wasm/relocatable.ll index 67f8ac0d8b..097adca484 100644 --- a/deps/lld/test/wasm/relocatable.ll +++ b/deps/lld/test/wasm/relocatable.ll @@ -1,7 +1,12 @@ ; RUN: llc -filetype=obj %p/Inputs/hello.ll -o %t.hello.o ; RUN: llc -filetype=obj %s -o %t.o ; RUN: wasm-ld -r -o %t.wasm %t.hello.o %t.o -; RUN: obj2yaml %t.wasm | FileCheck %s +; RUN: obj2yaml %t.wasm | FileCheck %s --check-prefixes CHECK,NORMAL + +; RUN: llc -filetype=obj %p/Inputs/hello.ll -o %t.hello.bm.o -mattr=+bulk-memory +; RUN: llc -filetype=obj %s -o %t.bm.o -mattr=+bulk-memory +; RUN: wasm-ld -r -o %t.mt.wasm %t.hello.bm.o %t.bm.o --shared-memory --max-memory=131072 +; RUN: obj2yaml %t.mt.wasm | FileCheck %s --check-prefixes CHECK,SHARED target triple = "wasm32-unknown-unknown" @@ -70,13 +75,18 @@ entry: ; CHECK-NEXT: Maximum: 0x00000004 ; CHECK-NEXT: - Type: MEMORY ; CHECK-NEXT: Memories: -; CHECK-NEXT: - Initial: 0x00000001 +; NORMAL-NEXT: - Initial: 0x00000001 +; SHARED-NEXT: - Flags: [ HAS_MAX, IS_SHARED ] +; SHARED-NEXT: Initial: 0x00000001 +; SHARED-NEXT: Maximum: 0x00000002 ; CHECK-NEXT: - Type: ELEM ; CHECK-NEXT: Segments: ; CHECK-NEXT: - Offset: ; CHECK-NEXT: Opcode: I32_CONST ; CHECK-NEXT: Value: 1 ; CHECK-NEXT: Functions: [ 4, 1, 2 ] +; SHARED-NEXT: - Type: DATACOUNT +; SHARED-NEXT: Count: 6 ; CHECK-NEXT: - Type: CODE ; CHECK-NEXT: Relocations: ; CHECK-NEXT: - Type: R_WASM_MEMORY_ADDR_SLEB @@ -104,176 +114,176 @@ entry: ; CHECK-NEXT: - Index: 5 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 419C808080000B -; CHECK-NEXT: - Type: DATA -; CHECK-NEXT: Relocations: -; CHECK-NEXT: - Type: R_WASM_TABLE_INDEX_I32 -; CHECK-NEXT: Index: 3 -; CHECK-NEXT: Offset: 0x00000012 -; CHECK-NEXT: - Type: R_WASM_TABLE_INDEX_I32 -; CHECK-NEXT: Index: 4 -; CHECK-NEXT: Offset: 0x0000001B -; CHECK-NEXT: - Type: R_WASM_TABLE_INDEX_I32 -; CHECK-NEXT: Index: 5 -; CHECK-NEXT: Offset: 0x00000024 -; CHECK-NEXT: - Type: R_WASM_MEMORY_ADDR_I32 -; CHECK-NEXT: Index: 12 -; CHECK-NEXT: Offset: 0x0000002D -; CHECK-NEXT: Segments: -; CHECK-NEXT: - SectionOffset: 6 -; CHECK-NEXT: InitFlags: 0 -; CHECK-NEXT: Offset: -; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 0 -; CHECK-NEXT: Content: 68656C6C6F0A00 -; CHECK-NEXT: - SectionOffset: 18 -; CHECK-NEXT: InitFlags: 0 -; CHECK-NEXT: Offset: -; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 8 -; CHECK-NEXT: Content: '01000000' -; CHECK-NEXT: - SectionOffset: 27 -; CHECK-NEXT: InitFlags: 0 -; CHECK-NEXT: Offset: -; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 12 -; CHECK-NEXT: Content: '02000000' -; CHECK-NEXT: - SectionOffset: 36 -; CHECK-NEXT: InitFlags: 0 -; CHECK-NEXT: Offset: -; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 16 -; CHECK-NEXT: Content: '03000000' -; CHECK-NEXT: - SectionOffset: 45 -; CHECK-NEXT: InitFlags: 0 -; CHECK-NEXT: Offset: -; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 24 -; CHECK-NEXT: Content: '00000000' -; CHECK-NEXT: - SectionOffset: 54 -; CHECK-NEXT: InitFlags: 0 -; CHECK-NEXT: Offset: -; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 28 -; CHECK-NEXT: Content: '616263' -; CHECK-NEXT: - Type: CUSTOM -; CHECK-NEXT: Name: linking -; CHECK-NEXT: Version: 2 -; CHECK-NEXT: SymbolTable: -; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Name: hello -; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; CHECK-NEXT: Function: 3 -; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: Kind: DATA -; CHECK-NEXT: Name: hello_str -; CHECK-NEXT: Flags: [ ] -; CHECK-NEXT: Segment: 0 -; CHECK-NEXT: Size: 7 -; CHECK-NEXT: - Index: 2 -; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Name: puts -; CHECK-NEXT: Flags: [ UNDEFINED ] -; CHECK-NEXT: Function: 0 -; CHECK-NEXT: - Index: 3 -; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Name: my_func -; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; CHECK-NEXT: Function: 4 -; CHECK-NEXT: - Index: 4 -; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Name: foo_import -; CHECK-NEXT: Flags: [ UNDEFINED ] -; CHECK-NEXT: Function: 1 -; CHECK-NEXT: - Index: 5 -; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Name: bar_import -; CHECK-NEXT: Flags: [ BINDING_WEAK, UNDEFINED ] -; CHECK-NEXT: Function: 2 -; CHECK-NEXT: - Index: 6 -; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Name: func_comdat -; CHECK-NEXT: Flags: [ BINDING_WEAK ] -; CHECK-NEXT: Function: 5 -; CHECK-NEXT: - Index: 7 -; CHECK-NEXT: Kind: DATA -; CHECK-NEXT: Name: data_comdat -; CHECK-NEXT: Flags: [ BINDING_WEAK ] -; CHECK-NEXT: Segment: 5 -; CHECK-NEXT: Size: 3 -; CHECK-NEXT: - Index: 8 -; CHECK-NEXT: Kind: DATA -; CHECK-NEXT: Name: func_addr1 -; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; CHECK-NEXT: Segment: 1 -; CHECK-NEXT: Size: 4 -; CHECK-NEXT: - Index: 9 -; CHECK-NEXT: Kind: DATA -; CHECK-NEXT: Name: func_addr2 -; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; CHECK-NEXT: Segment: 2 -; CHECK-NEXT: Size: 4 -; CHECK-NEXT: - Index: 10 -; CHECK-NEXT: Kind: DATA -; CHECK-NEXT: Name: func_addr3 -; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; CHECK-NEXT: Segment: 3 -; CHECK-NEXT: Size: 4 -; CHECK-NEXT: - Index: 11 -; CHECK-NEXT: Kind: DATA -; CHECK-NEXT: Name: data_addr1 -; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; CHECK-NEXT: Segment: 4 -; CHECK-NEXT: Size: 4 -; CHECK-NEXT: - Index: 12 -; CHECK-NEXT: Kind: DATA -; CHECK-NEXT: Name: data_import -; CHECK-NEXT: Flags: [ UNDEFINED ] -; CHECK-NEXT: SegmentInfo: -; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: .rodata.hello_str -; CHECK-NEXT: Alignment: 0 -; CHECK-NEXT: Flags: [ ] -; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: Name: .data.func_addr1 -; CHECK-NEXT: Alignment: 2 -; CHECK-NEXT: Flags: [ ] -; CHECK-NEXT: - Index: 2 -; CHECK-NEXT: Name: .data.func_addr2 -; CHECK-NEXT: Alignment: 2 -; CHECK-NEXT: Flags: [ ] -; CHECK-NEXT: - Index: 3 -; CHECK-NEXT: Name: .data.func_addr3 -; CHECK-NEXT: Alignment: 2 -; CHECK-NEXT: Flags: [ ] -; CHECK-NEXT: - Index: 4 -; CHECK-NEXT: Name: .data.data_addr1 -; CHECK-NEXT: Alignment: 3 -; CHECK-NEXT: Flags: [ ] -; CHECK-NEXT: - Index: 5 -; CHECK-NEXT: Name: .rodata.data_comdat -; CHECK-NEXT: Alignment: 0 -; CHECK-NEXT: Flags: [ ] -; CHECK-NEXT: Comdats: -; CHECK-NEXT: - Name: func_comdat -; CHECK-NEXT: Entries: -; CHECK-NEXT: - Kind: FUNCTION -; CHECK-NEXT: Index: 5 -; CHECK-NEXT: - Kind: DATA -; CHECK-NEXT: Index: 5 -; CHECK-NEXT: - Type: CUSTOM -; CHECK-NEXT: Name: name -; CHECK-NEXT: FunctionNames: -; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: puts -; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: Name: foo_import -; CHECK-NEXT: - Index: 2 -; CHECK-NEXT: Name: bar_import -; CHECK-NEXT: - Index: 3 -; CHECK-NEXT: Name: hello -; CHECK-NEXT: - Index: 4 -; CHECK-NEXT: Name: my_func -; CHECK-NEXT: - Index: 5 -; CHECK-NEXT: Name: func_comdat -; CHECK-NEXT: ... +; NORMAL-NEXT: - Type: DATA +; NORMAL-NEXT: Relocations: +; NORMAL-NEXT: - Type: R_WASM_TABLE_INDEX_I32 +; NORMAL-NEXT: Index: 3 +; NORMAL-NEXT: Offset: 0x00000012 +; NORMAL-NEXT: - Type: R_WASM_TABLE_INDEX_I32 +; NORMAL-NEXT: Index: 4 +; NORMAL-NEXT: Offset: 0x0000001B +; NORMAL-NEXT: - Type: R_WASM_TABLE_INDEX_I32 +; NORMAL-NEXT: Index: 5 +; NORMAL-NEXT: Offset: 0x00000024 +; NORMAL-NEXT: - Type: R_WASM_MEMORY_ADDR_I32 +; NORMAL-NEXT: Index: 12 +; NORMAL-NEXT: Offset: 0x0000002D +; NORMAL-NEXT: Segments: +; NORMAL-NEXT: - SectionOffset: 6 +; NORMAL-NEXT: InitFlags: 0 +; NORMAL-NEXT: Offset: +; NORMAL-NEXT: Opcode: I32_CONST +; NORMAL-NEXT: Value: 0 +; NORMAL-NEXT: Content: 68656C6C6F0A00 +; NORMAL-NEXT: - SectionOffset: 18 +; NORMAL-NEXT: InitFlags: 0 +; NORMAL-NEXT: Offset: +; NORMAL-NEXT: Opcode: I32_CONST +; NORMAL-NEXT: Value: 8 +; NORMAL-NEXT: Content: '01000000' +; NORMAL-NEXT: - SectionOffset: 27 +; NORMAL-NEXT: InitFlags: 0 +; NORMAL-NEXT: Offset: +; NORMAL-NEXT: Opcode: I32_CONST +; NORMAL-NEXT: Value: 12 +; NORMAL-NEXT: Content: '02000000' +; NORMAL-NEXT: - SectionOffset: 36 +; NORMAL-NEXT: InitFlags: 0 +; NORMAL-NEXT: Offset: +; NORMAL-NEXT: Opcode: I32_CONST +; NORMAL-NEXT: Value: 16 +; NORMAL-NEXT: Content: '03000000' +; NORMAL-NEXT: - SectionOffset: 45 +; NORMAL-NEXT: InitFlags: 0 +; NORMAL-NEXT: Offset: +; NORMAL-NEXT: Opcode: I32_CONST +; NORMAL-NEXT: Value: 24 +; NORMAL-NEXT: Content: '00000000' +; NORMAL-NEXT: - SectionOffset: 54 +; NORMAL-NEXT: InitFlags: 0 +; NORMAL-NEXT: Offset: +; NORMAL-NEXT: Opcode: I32_CONST +; NORMAL-NEXT: Value: 28 +; NORMAL-NEXT: Content: '616263' +; NORMAL-NEXT: - Type: CUSTOM +; NORMAL-NEXT: Name: linking +; NORMAL-NEXT: Version: 2 +; NORMAL-NEXT: SymbolTable: +; NORMAL-NEXT: - Index: 0 +; NORMAL-NEXT: Kind: FUNCTION +; NORMAL-NEXT: Name: hello +; NORMAL-NEXT: Flags: [ VISIBILITY_HIDDEN ] +; NORMAL-NEXT: Function: 3 +; NORMAL-NEXT: - Index: 1 +; NORMAL-NEXT: Kind: DATA +; NORMAL-NEXT: Name: hello_str +; NORMAL-NEXT: Flags: [ ] +; NORMAL-NEXT: Segment: 0 +; NORMAL-NEXT: Size: 7 +; NORMAL-NEXT: - Index: 2 +; NORMAL-NEXT: Kind: FUNCTION +; NORMAL-NEXT: Name: puts +; NORMAL-NEXT: Flags: [ UNDEFINED ] +; NORMAL-NEXT: Function: 0 +; NORMAL-NEXT: - Index: 3 +; NORMAL-NEXT: Kind: FUNCTION +; NORMAL-NEXT: Name: my_func +; NORMAL-NEXT: Flags: [ VISIBILITY_HIDDEN ] +; NORMAL-NEXT: Function: 4 +; NORMAL-NEXT: - Index: 4 +; NORMAL-NEXT: Kind: FUNCTION +; NORMAL-NEXT: Name: foo_import +; NORMAL-NEXT: Flags: [ UNDEFINED ] +; NORMAL-NEXT: Function: 1 +; NORMAL-NEXT: - Index: 5 +; NORMAL-NEXT: Kind: FUNCTION +; NORMAL-NEXT: Name: bar_import +; NORMAL-NEXT: Flags: [ BINDING_WEAK, UNDEFINED ] +; NORMAL-NEXT: Function: 2 +; NORMAL-NEXT: - Index: 6 +; NORMAL-NEXT: Kind: FUNCTION +; NORMAL-NEXT: Name: func_comdat +; NORMAL-NEXT: Flags: [ BINDING_WEAK ] +; NORMAL-NEXT: Function: 5 +; NORMAL-NEXT: - Index: 7 +; NORMAL-NEXT: Kind: DATA +; NORMAL-NEXT: Name: data_comdat +; NORMAL-NEXT: Flags: [ BINDING_WEAK ] +; NORMAL-NEXT: Segment: 5 +; NORMAL-NEXT: Size: 3 +; NORMAL-NEXT: - Index: 8 +; NORMAL-NEXT: Kind: DATA +; NORMAL-NEXT: Name: func_addr1 +; NORMAL-NEXT: Flags: [ VISIBILITY_HIDDEN ] +; NORMAL-NEXT: Segment: 1 +; NORMAL-NEXT: Size: 4 +; NORMAL-NEXT: - Index: 9 +; NORMAL-NEXT: Kind: DATA +; NORMAL-NEXT: Name: func_addr2 +; NORMAL-NEXT: Flags: [ VISIBILITY_HIDDEN ] +; NORMAL-NEXT: Segment: 2 +; NORMAL-NEXT: Size: 4 +; NORMAL-NEXT: - Index: 10 +; NORMAL-NEXT: Kind: DATA +; NORMAL-NEXT: Name: func_addr3 +; NORMAL-NEXT: Flags: [ VISIBILITY_HIDDEN ] +; NORMAL-NEXT: Segment: 3 +; NORMAL-NEXT: Size: 4 +; NORMAL-NEXT: - Index: 11 +; NORMAL-NEXT: Kind: DATA +; NORMAL-NEXT: Name: data_addr1 +; NORMAL-NEXT: Flags: [ VISIBILITY_HIDDEN ] +; NORMAL-NEXT: Segment: 4 +; NORMAL-NEXT: Size: 4 +; NORMAL-NEXT: - Index: 12 +; NORMAL-NEXT: Kind: DATA +; NORMAL-NEXT: Name: data_import +; NORMAL-NEXT: Flags: [ UNDEFINED ] +; NORMAL-NEXT: SegmentInfo: +; NORMAL-NEXT: - Index: 0 +; NORMAL-NEXT: Name: .rodata.hello_str +; NORMAL-NEXT: Alignment: 0 +; NORMAL-NEXT: Flags: [ ] +; NORMAL-NEXT: - Index: 1 +; NORMAL-NEXT: Name: .data.func_addr1 +; NORMAL-NEXT: Alignment: 2 +; NORMAL-NEXT: Flags: [ ] +; NORMAL-NEXT: - Index: 2 +; NORMAL-NEXT: Name: .data.func_addr2 +; NORMAL-NEXT: Alignment: 2 +; NORMAL-NEXT: Flags: [ ] +; NORMAL-NEXT: - Index: 3 +; NORMAL-NEXT: Name: .data.func_addr3 +; NORMAL-NEXT: Alignment: 2 +; NORMAL-NEXT: Flags: [ ] +; NORMAL-NEXT: - Index: 4 +; NORMAL-NEXT: Name: .data.data_addr1 +; NORMAL-NEXT: Alignment: 3 +; NORMAL-NEXT: Flags: [ ] +; NORMAL-NEXT: - Index: 5 +; NORMAL-NEXT: Name: .rodata.data_comdat +; NORMAL-NEXT: Alignment: 0 +; NORMAL-NEXT: Flags: [ ] +; NORMAL-NEXT: Comdats: +; NORMAL-NEXT: - Name: func_comdat +; NORMAL-NEXT: Entries: +; NORMAL-NEXT: - Kind: FUNCTION +; NORMAL-NEXT: Index: 5 +; NORMAL-NEXT: - Kind: DATA +; NORMAL-NEXT: Index: 5 +; NORMAL-NEXT: - Type: CUSTOM +; NORMAL-NEXT: Name: name +; NORMAL-NEXT: FunctionNames: +; NORMAL-NEXT: - Index: 0 +; NORMAL-NEXT: Name: puts +; NORMAL-NEXT: - Index: 1 +; NORMAL-NEXT: Name: foo_import +; NORMAL-NEXT: - Index: 2 +; NORMAL-NEXT: Name: bar_import +; NORMAL-NEXT: - Index: 3 +; NORMAL-NEXT: Name: hello +; NORMAL-NEXT: - Index: 4 +; NORMAL-NEXT: Name: my_func +; NORMAL-NEXT: - Index: 5 +; NORMAL-NEXT: Name: func_comdat +; NORMAL-NEXT:... diff --git a/deps/lld/wasm/Writer.cpp b/deps/lld/wasm/Writer.cpp index 68e001ccc8..6338b6e5fa 100644 --- a/deps/lld/wasm/Writer.cpp +++ b/deps/lld/wasm/Writer.cpp @@ -898,7 +898,7 @@ void Writer::run() { createCallCtorsFunction(); } - if (config->sharedMemory && !config->shared) + if (!config->relocatable && config->sharedMemory && !config->shared) createInitTLSFunction(); if (errorCount())