aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-04-16 16:03:39 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-04-16 16:03:39 +0000
commitd2d3ebb81992e107edf95c1c136d7a342d9b1418 (patch)
treebb1af8fff2b1400cf240e3b2532a1e5d22a121da /test
parent16787c9ce0b96aaa669d7fab3a495916b35ce758 (diff)
downloadsrc-d2d3ebb81992e107edf95c1c136d7a342d9b1418.tar.gz
src-d2d3ebb81992e107edf95c1c136d7a342d9b1418.zip
Vendor import of lld trunk r300422:vendor/lld/lld-trunk-r300422
Notes
Notes: svn path=/vendor/lld/dist/; revision=317025 svn path=/vendor/lld/lld-trunk-r300422/; revision=317026; tag=vendor/lld/lld-trunk-r300422
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt35
-rw-r--r--test/COFF/Inputs/bar.ll6
-rw-r--r--test/COFF/Inputs/msvclto.s3
-rw-r--r--test/COFF/Inputs/thinlto-mangled-qux.ll28
-rw-r--r--test/COFF/def-name.test28
-rw-r--r--test/COFF/driver-windows.test3
-rw-r--r--test/COFF/error-limit.test29
-rw-r--r--test/COFF/export32.test10
-rw-r--r--test/COFF/hello32.test5
-rw-r--r--test/COFF/include-lto.ll24
-rw-r--r--test/COFF/invalid-debug-type.test5
-rw-r--r--test/COFF/lldmap.test9
-rw-r--r--test/COFF/lto-comdat.ll69
-rw-r--r--test/COFF/lto-debug-pass-arguments.ll16
-rw-r--r--test/COFF/lto-parallel.ll8
-rw-r--r--test/COFF/msvclto-archive.ll39
-rw-r--r--test/COFF/msvclto.ll18
-rw-r--r--test/COFF/nopdb.test14
-rw-r--r--test/COFF/pdb-none.test13
-rw-r--r--test/COFF/pdb.test222
-rw-r--r--test/COFF/rsds.test25
-rw-r--r--test/COFF/savetemps.ll28
-rw-r--r--test/COFF/thinlto-archives.ll22
-rw-r--r--test/COFF/thinlto-mangled.ll16
-rw-r--r--test/COFF/thinlto.ll18
-rw-r--r--test/COFF/weak-external.test5
-rw-r--r--test/COFF/weak-external3.test10
-rw-r--r--test/ELF/Inputs/i386-got32x-baseless.elfbin0 -> 628 bytes
-rw-r--r--test/ELF/Inputs/i386-reloc-16-error.s3
-rw-r--r--test/ELF/Inputs/i386-reloc-16.s3
-rw-r--r--test/ELF/Inputs/i386-reloc-8-error.s3
-rw-r--r--test/ELF/Inputs/i386-reloc-8.s3
-rw-r--r--test/ELF/Inputs/icf-absolute.s3
-rw-r--r--test/ELF/Inputs/map-file2.s8
-rw-r--r--test/ELF/Inputs/map-file3.s2
-rw-r--r--test/ELF/Inputs/map-file4.s3
-rw-r--r--test/ELF/Inputs/relocatable-non-alloc.s6
-rw-r--r--test/ELF/Inputs/relocation-copy-align-common.s7
-rw-r--r--test/ELF/Inputs/resolution-end.s1
-rw-r--r--test/ELF/Inputs/x86-64-reloc-16-error.s3
-rw-r--r--test/ELF/Inputs/x86-64-reloc-16.s3
-rw-r--r--test/ELF/Inputs/x86-64-reloc-8-error.s3
-rw-r--r--test/ELF/Inputs/x86-64-reloc-8.s3
-rw-r--r--test/ELF/Inputs/ztext-text-notext.s10
-rw-r--r--test/ELF/aarch64-fpic-abs16.s4
-rw-r--r--test/ELF/aarch64-fpic-add_abs_lo12_nc.s4
-rw-r--r--test/ELF/aarch64-fpic-adr_prel_lo21.s4
-rw-r--r--test/ELF/aarch64-fpic-adr_prel_pg_hi21.s4
-rw-r--r--test/ELF/aarch64-fpic-ldst32_abs_lo12_nc.s4
-rw-r--r--test/ELF/aarch64-fpic-ldst64_abs_lo12_nc.s4
-rw-r--r--test/ELF/aarch64-fpic-ldst8_abs_lo12_nc.s4
-rw-r--r--test/ELF/aarch64-fpic-prel16.s4
-rw-r--r--test/ELF/aarch64-fpic-prel32.s4
-rw-r--r--test/ELF/aarch64-fpic-prel64.s4
-rw-r--r--test/ELF/abs-conflict.s4
-rw-r--r--test/ELF/arm-gnu-ifunc-plt.s28
-rw-r--r--test/ELF/arm-gnu-ifunc.s25
-rw-r--r--test/ELF/arm-icf-exidx.s31
-rw-r--r--test/ELF/arm-plt-reloc.s46
-rw-r--r--test/ELF/arm-target1.s8
-rw-r--r--test/ELF/arm-thumb-interwork-shared.s22
-rw-r--r--test/ELF/arm-thumb-interwork-thunk.s185
-rw-r--r--test/ELF/arm-thumb-plt-reloc.s17
-rw-r--r--test/ELF/arm-tls-gd-nonpreemptible.s72
-rw-r--r--test/ELF/as-needed-no-reloc.s2
-rw-r--r--test/ELF/basic-aarch64.s2
-rw-r--r--test/ELF/basic-mips.s2
-rw-r--r--test/ELF/basic-ppc.s2
-rw-r--r--test/ELF/basic.s7
-rw-r--r--test/ELF/basic32.s2
-rw-r--r--test/ELF/basic64be.s2
-rw-r--r--test/ELF/bss-start-common.s15
-rw-r--r--test/ELF/build-id.s6
-rw-r--r--test/ELF/compatible-section-types.s20
-rw-r--r--test/ELF/compressed-debug-input.s2
-rw-r--r--test/ELF/conflict.s32
-rw-r--r--test/ELF/copy-errors.s10
-rw-r--r--test/ELF/copy-in-shared.s5
-rw-r--r--test/ELF/copy-rel-pie-error.s9
-rw-r--r--test/ELF/default-fill.s38
-rw-r--r--test/ELF/driver.test9
-rw-r--r--test/ELF/dt_flags.s6
-rw-r--r--test/ELF/dynamic-list.s63
-rw-r--r--test/ELF/dynamic-reloc-in-ro.s6
-rw-r--r--test/ELF/early-exit-for-bad-paths.s35
-rw-r--r--test/ELF/edata-etext.s6
-rw-r--r--test/ELF/eh-frame-dyn-rel.s12
-rw-r--r--test/ELF/ehdr_start.s22
-rw-r--r--test/ELF/emit-relocs-merge.s20
-rw-r--r--test/ELF/emit-relocs-shared.s16
-rw-r--r--test/ELF/emit-relocs.s99
-rw-r--r--test/ELF/emulation.s6
-rw-r--r--test/ELF/end-abs.s11
-rw-r--r--test/ELF/gc-debuginfo-tls.s18
-rw-r--r--test/ELF/gc-merge-local-sym.s2
-rw-r--r--test/ELF/gc-sections-merge-addend.s2
-rw-r--r--test/ELF/gc-sections-merge-implicit-addend.s2
-rw-r--r--test/ELF/gc-sections-merge.s4
-rw-r--r--test/ELF/gc-sections-metadata-startstop.s33
-rw-r--r--test/ELF/gc-sections-metadata.s38
-rw-r--r--test/ELF/gc-sections-metadata2.s19
-rw-r--r--test/ELF/gnu-hash-table.s2
-rw-r--r--test/ELF/gnustack.s40
-rw-r--r--test/ELF/got32-i386.s23
-rw-r--r--test/ELF/got32x-i386.s47
-rw-r--r--test/ELF/hidden-vis-shared.s18
-rw-r--r--test/ELF/i386-pc16.test6
-rw-r--r--test/ELF/i386-pc8-pc16-addend.s17
-rw-r--r--test/ELF/i386-pc8.s15
-rw-r--r--test/ELF/i386-reloc-16.s14
-rw-r--r--test/ELF/i386-reloc-8.s14
-rw-r--r--test/ELF/i386-reloc8-reloc16-addend.s17
-rw-r--r--test/ELF/icf-absolute.s20
-rw-r--r--test/ELF/icf8.s14
-rw-r--r--test/ELF/icf9.s20
-rw-r--r--test/ELF/incompatible-section-types.s10
-rw-r--r--test/ELF/init-fini-progbits.s19
-rw-r--r--test/ELF/invalid-cie-length.s7
-rw-r--r--test/ELF/invalid-cie-length2.s7
-rw-r--r--test/ELF/invalid-cie-length3.s8
-rw-r--r--test/ELF/invalid-cie-length4.s9
-rw-r--r--test/ELF/invalid-fde-rel.s8
-rw-r--r--test/ELF/invalid-linkerscript.test2
-rw-r--r--test/ELF/invalid/broken-relaxation-x64.test (renamed from test/ELF/invalid/broken-relaxation-x64.s)0
-rw-r--r--test/ELF/invalid/dynamic-section-size.s2
-rw-r--r--test/ELF/invalid/invalid-relocation-x64.test (renamed from test/ELF/invalid/invalid-relocation-x64.s)4
-rw-r--r--test/ELF/invalid/mips-invalid-options-descriptor.s2
-rw-r--r--test/ELF/libsearch.s3
-rw-r--r--test/ELF/linkerscript/Inputs/lazy-symbols.s2
-rw-r--r--test/ELF/linkerscript/absolute.s17
-rw-r--r--test/ELF/linkerscript/addr-zero.s18
-rw-r--r--test/ELF/linkerscript/align.s87
-rw-r--r--test/ELF/linkerscript/alternate-sections.s40
-rw-r--r--test/ELF/linkerscript/assert.s4
-rw-r--r--test/ELF/linkerscript/at-addr.s39
-rw-r--r--test/ELF/linkerscript/at.s37
-rw-r--r--test/ELF/linkerscript/constructor.s13
-rw-r--r--test/ELF/linkerscript/discard-print-gc.s19
-rw-r--r--test/ELF/linkerscript/discard-section-metadata.s32
-rw-r--r--test/ELF/linkerscript/edata-etext.s9
-rw-r--r--test/ELF/linkerscript/eh-frame-reloc-out-of-range.s27
-rw-r--r--test/ELF/linkerscript/eh-frame.s19
-rw-r--r--test/ELF/linkerscript/ehdr_start.s3
-rw-r--r--test/ELF/linkerscript/emit-reloc.s17
-rw-r--r--test/ELF/linkerscript/emit-relocs-discard.s14
-rw-r--r--test/ELF/linkerscript/emit-relocs-ehframe-discard.s11
-rw-r--r--test/ELF/linkerscript/empty-load.s3
-rw-r--r--test/ELF/linkerscript/excludefile.s9
-rw-r--r--test/ELF/linkerscript/expr-invalid-sec.s6
-rw-r--r--test/ELF/linkerscript/expr-sections.s22
-rw-r--r--test/ELF/linkerscript/fill-exec-sections.s40
-rw-r--r--test/ELF/linkerscript/fill.s5
-rw-r--r--test/ELF/linkerscript/huge-temporary-file.s12
-rw-r--r--test/ELF/linkerscript/lazy-symbols.s13
-rw-r--r--test/ELF/linkerscript/locationcounter.s189
-rw-r--r--test/ELF/linkerscript/locationcountererr.s6
-rw-r--r--test/ELF/linkerscript/locationcountererr2.s9
-rw-r--r--test/ELF/linkerscript/memory.s114
-rw-r--r--test/ELF/linkerscript/merge-sections-syms.s49
-rw-r--r--test/ELF/linkerscript/merge-sections.s50
-rw-r--r--test/ELF/linkerscript/no-space.s6
-rw-r--r--test/ELF/linkerscript/non-absolute.s30
-rw-r--r--test/ELF/linkerscript/non-absolute2.s12
-rw-r--r--test/ELF/linkerscript/non-alloc.s6
-rw-r--r--test/ELF/linkerscript/numbers.s26
-rw-r--r--test/ELF/linkerscript/obj-symbol-value.s19
-rw-r--r--test/ELF/linkerscript/operators.s93
-rw-r--r--test/ELF/linkerscript/orphan-first-cmd.s4
-rw-r--r--test/ELF/linkerscript/out-of-order.s10
-rw-r--r--test/ELF/linkerscript/output-too-large.s8
-rw-r--r--test/ELF/linkerscript/outputarch.s8
-rw-r--r--test/ELF/linkerscript/outsections-addr.s22
-rw-r--r--test/ELF/linkerscript/page-size.s4
-rw-r--r--test/ELF/linkerscript/pt_gnu_eh_frame.s13
-rw-r--r--test/ELF/linkerscript/section-align.s62
-rw-r--r--test/ELF/linkerscript/sections-gc.s19
-rw-r--r--test/ELF/linkerscript/sections-gc2.s31
-rw-r--r--test/ELF/linkerscript/sections-padding.s11
-rw-r--r--test/ELF/linkerscript/sections-sort.s5
-rw-r--r--test/ELF/linkerscript/sections.s24
-rw-r--r--test/ELF/linkerscript/symbol-assignexpr.s4
-rw-r--r--test/ELF/linkerscript/symbol-only.s2
-rw-r--r--test/ELF/linkerscript/symbol-reserved.s16
-rw-r--r--test/ELF/linkerscript/symbols-non-alloc.s16
-rw-r--r--test/ELF/lto/Inputs/cache.ll10
-rw-r--r--test/ELF/lto/archive-no-index.ll39
-rw-r--r--test/ELF/lto/cache.ll21
-rw-r--r--test/ELF/lto/codemodel.ll20
-rw-r--r--test/ELF/lto/combined-lto-object-name.ll4
-rw-r--r--test/ELF/lto/duplicated.ll6
-rw-r--r--test/ELF/lto/opt-remarks.ll68
-rw-r--r--test/ELF/lto/parallel-internalize.ll3
-rw-r--r--test/ELF/lto/parallel.ll3
-rw-r--r--test/ELF/lto/thinlto.ll13
-rw-r--r--test/ELF/map-file.s62
-rw-r--r--test/ELF/merge-reloc.s8
-rw-r--r--test/ELF/merge-string-align.s4
-rw-r--r--test/ELF/merge-string.s28
-rw-r--r--test/ELF/merge.s2
-rw-r--r--test/ELF/mips-elf-flags-err.s9
-rw-r--r--test/ELF/mips-elf-flags.s4
-rw-r--r--test/ELF/mips-got-string.s28
-rw-r--r--test/ELF/mips-got16-relocatable.s40
-rw-r--r--test/ELF/mips-gp-ext.s4
-rw-r--r--test/ELF/mips-gprel-sec.s37
-rw-r--r--test/ELF/mips-npic-call-pic-os.s138
-rw-r--r--test/ELF/mips-npic-call-pic.s169
-rw-r--r--test/ELF/mips-options.s2
-rw-r--r--test/ELF/mips-reginfo.s2
-rw-r--r--test/ELF/mips-sto-pic-flag.s4
-rw-r--r--test/ELF/mips-tls-64.s3
-rw-r--r--test/ELF/mips-tls-hilo.s3
-rw-r--r--test/ELF/mips-tls.s3
-rw-r--r--test/ELF/no-dynamic-linker.s12
-rw-r--r--test/ELF/no-merge.s22
-rw-r--r--test/ELF/no-soname.s31
-rw-r--r--test/ELF/note-contiguous.s24
-rw-r--r--test/ELF/note-loadaddr.c35
-rw-r--r--test/ELF/note-multiple.s43
-rw-r--r--test/ELF/plt-i686.s12
-rw-r--r--test/ELF/pre_init_fini_array_missing.s13
-rw-r--r--test/ELF/relocatable-bss.s2
-rw-r--r--test/ELF/relocatable-common.s12
-rw-r--r--test/ELF/relocatable-eh-frame-hdr.s11
-rw-r--r--test/ELF/relocatable-eh-frame.s19
-rw-r--r--test/ELF/relocatable-ehframe.s4
-rw-r--r--test/ELF/relocatable-non-alloc.s10
-rw-r--r--test/ELF/relocatable-section-symbol.s49
-rw-r--r--test/ELF/relocatable-symbol-name.s28
-rw-r--r--test/ELF/relocatable.s2
-rw-r--r--test/ELF/relocation-copy-align-common.s40
-rw-r--r--test/ELF/relocation-group.test43
-rw-r--r--test/ELF/relocation-nocopy.s19
-rw-r--r--test/ELF/relocation-none-aarch64.test24
-rw-r--r--test/ELF/relocation-relative-absolute.s4
-rw-r--r--test/ELF/relro-omagic.s2
-rw-r--r--test/ELF/reproduce.s8
-rw-r--r--test/ELF/resolution-end.s13
-rw-r--r--test/ELF/retain-symbols-file.s44
-rw-r--r--test/ELF/retain-und.s18
-rw-r--r--test/ELF/section-name.s4
-rw-r--r--test/ELF/splitstacks.s2
-rw-r--r--test/ELF/startstop-gccollect.s16
-rw-r--r--test/ELF/static-with-export-dynamic.s32
-rw-r--r--test/ELF/sysroot.s3
-rw-r--r--test/ELF/tls-mismatch.s5
-rw-r--r--test/ELF/tls-static.s3
-rw-r--r--test/ELF/trace-symbols.s2
-rw-r--r--test/ELF/ttext-tdata-tbss.s11
-rw-r--r--test/ELF/undef-shared.s9
-rw-r--r--test/ELF/undef-with-plt-addr.s3
-rw-r--r--test/ELF/undef.s36
-rw-r--r--test/ELF/unknown-reloc.s14
-rw-r--r--test/ELF/unresolved-symbols.s10
-rw-r--r--test/ELF/verneed-local.s3
-rw-r--r--test/ELF/version-script-copy-rel.s24
-rw-r--r--test/ELF/version-script-extern-exact.s18
-rw-r--r--test/ELF/version-script-extern-wildcards-anon.s12
-rw-r--r--test/ELF/version-script-glob.s27
-rw-r--r--test/ELF/version-script.s3
-rw-r--r--test/ELF/warn-unresolved-symbols-hidden.s14
-rw-r--r--test/ELF/warn-unresolved-symbols.s51
-rw-r--r--test/ELF/x86-64-dyn-rel-error.s2
-rw-r--r--test/ELF/x86-64-dyn-rel-error2.s6
-rw-r--r--test/ELF/x86-64-reloc-16.s14
-rw-r--r--test/ELF/x86-64-reloc-32-fpic.s5
-rw-r--r--test/ELF/x86-64-reloc-8.s14
-rw-r--r--test/ELF/x86-64-reloc-pc32-fpic.s5
-rw-r--r--test/ELF/zdefs.s3
-rw-r--r--test/ELF/zstack-size.s37
-rw-r--r--test/ELF/ztext-text-notext.s36
-rw-r--r--test/lit.cfg16
-rw-r--r--test/lit.site.cfg.in4
273 files changed, 4064 insertions, 1230 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 678880b7ff38..cef2e2c68ae1 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -3,13 +3,18 @@ set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}")
set(LLVM_BUILD_MODE "%(build_mode)s")
set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_config)s")
set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/%(build_config)s")
-set(CLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
-set(CLANG_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/..")
-if(BUILD_SHARED_LIBS)
- set(ENABLE_SHARED 1)
-else()
- set(ENABLE_SHARED 0)
-endif(BUILD_SHARED_LIBS)
+
+if(LLD_BUILT_STANDALONE)
+ # Set HAVE_LIBZ according to recorded LLVM_ENABLE_ZLIB value. This
+ # value is forced to 0 if zlib was not found, so it is fine to use it
+ # instead of HAVE_LIBZ (not recorded).
+ if(LLVM_ENABLE_ZLIB)
+ set(HAVE_LIBZ 1)
+ endif()
+endif()
+
+llvm_canonicalize_cmake_booleans(
+ HAVE_LIBZ)
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
@@ -19,13 +24,17 @@ configure_lit_site_cfg(
${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
)
-set(LLD_TEST_DEPS
- FileCheck not llvm-ar llvm-as llvm-dis llvm-dwarfdump llvm-nm
- llc lld llvm-config llvm-objdump llvm-readobj yaml2obj obj2yaml
- llvm-mc llvm-lib llvm-pdbdump opt
- )
+set(LLD_TEST_DEPS lld)
+if (NOT LLD_BUILT_STANDALONE)
+ list(APPEND LLD_TEST_DEPS
+ FileCheck count not llvm-ar llvm-as llvm-dis llvm-dwarfdump llvm-nm
+ llc llvm-config llvm-objdump llvm-readobj yaml2obj obj2yaml
+ llvm-mc llvm-lib llvm-pdbdump opt
+ )
+endif()
+
if (LLVM_INCLUDE_TESTS)
- set(LLD_TEST_DEPS ${LLD_TEST_DEPS} LLDUnitTests)
+ list(APPEND LLD_TEST_DEPS LLDUnitTests)
endif()
set(LLD_TEST_PARAMS
diff --git a/test/COFF/Inputs/bar.ll b/test/COFF/Inputs/bar.ll
new file mode 100644
index 000000000000..4aed5d22a9e0
--- /dev/null
+++ b/test/COFF/Inputs/bar.ll
@@ -0,0 +1,6 @@
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc"
+
+define void @bar() {
+ ret void
+}
diff --git a/test/COFF/Inputs/msvclto.s b/test/COFF/Inputs/msvclto.s
new file mode 100644
index 000000000000..a69f870a1b60
--- /dev/null
+++ b/test/COFF/Inputs/msvclto.s
@@ -0,0 +1,3 @@
+.globl foo
+foo:
+ret
diff --git a/test/COFF/Inputs/thinlto-mangled-qux.ll b/test/COFF/Inputs/thinlto-mangled-qux.ll
new file mode 100644
index 000000000000..4c9cc8e9e742
--- /dev/null
+++ b/test/COFF/Inputs/thinlto-mangled-qux.ll
@@ -0,0 +1,28 @@
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc19.0.24215"
+
+%class.baz = type { %class.bar }
+%class.bar = type { i32 (...)** }
+
+$"\01?x@bar@@UEBA_NXZ" = comdat any
+
+$"\01??_7baz@@6B@" = comdat any
+
+$"\01??_Gbaz@@UEAAPEAXI@Z" = comdat any
+
+@"\01??_7baz@@6B@" = linkonce_odr unnamed_addr constant { [2 x i8*] } { [2 x i8*] [i8* bitcast (i8* (%class.baz*, i32)* @"\01??_Gbaz@@UEAAPEAXI@Z" to i8*), i8* bitcast (i1 (%class.bar*)* @"\01?x@bar@@UEBA_NXZ" to i8*)] }, comdat, !type !0, !type !1
+
+define void @"\01?qux@@YAXXZ"() local_unnamed_addr {
+ ret void
+}
+
+define linkonce_odr i8* @"\01??_Gbaz@@UEAAPEAXI@Z"(%class.baz* %this, i32 %should_call_delete) unnamed_addr comdat {
+ ret i8* null
+}
+
+define linkonce_odr zeroext i1 @"\01?x@bar@@UEBA_NXZ"(%class.bar* %this) unnamed_addr comdat {
+ ret i1 false
+}
+
+!0 = !{i64 0, !"?AVbar@@"}
+!1 = !{i64 0, !"?AVbaz@@"}
diff --git a/test/COFF/def-name.test b/test/COFF/def-name.test
new file mode 100644
index 000000000000..c48424a1bff0
--- /dev/null
+++ b/test/COFF/def-name.test
@@ -0,0 +1,28 @@
+# REQUIRES: winres
+
+# RUN: rm -rf %t
+# RUN: mkdir -p %t
+# RUN: cd %t
+# RUN: yaml2obj < %p/Inputs/ret42.yaml > in.obj
+
+# RUN: lld-link /entry:main in.obj
+# RUN: lld-link /entry:main /dll in.obj
+
+# RUN: echo -e "NAME foo\n" > fooexe.def
+# RUN: echo -e "LIBRARY foo\n" > foodll.def
+# RUN: lld-link /entry:main /def:fooexe.def in.obj
+# RUN: lld-link /entry:main /def:foodll.def /dll in.obj
+
+# RUN: lld-link /entry:main /out:bar.exe /def:fooexe.def in.obj
+# RUN: lld-link /entry:main /out:bar.dll /def:foodll.def /dll in.obj
+
+# RUN: llvm-readobj in.exe | FileCheck %s
+# RUN: llvm-readobj in.dll | FileCheck %s
+
+# RUN: llvm-readobj foo.exe | FileCheck %s
+# RUN: llvm-readobj foo.dll | FileCheck %s
+
+# RUN: llvm-readobj bar.exe | FileCheck %s
+# RUN: llvm-readobj bar.dll | FileCheck %s
+
+CHECK: File:
diff --git a/test/COFF/driver-windows.test b/test/COFF/driver-windows.test
new file mode 100644
index 000000000000..1b93a53bddb3
--- /dev/null
+++ b/test/COFF/driver-windows.test
@@ -0,0 +1,3 @@
+# REQUIRES: system-windows
+# RUN: not LLD-LINK 2>&1 | FileCheck %s
+CHECK: no input files
diff --git a/test/COFF/error-limit.test b/test/COFF/error-limit.test
new file mode 100644
index 000000000000..3eebd12aaabe
--- /dev/null
+++ b/test/COFF/error-limit.test
@@ -0,0 +1,29 @@
+RUN: not lld-link 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 \
+RUN: 21 22 2>&1 | FileCheck -check-prefix=DEFAULT %s
+
+DEFAULT: could not open 01
+DEFAULT: could not open 20
+DEFAULT-NEXT: too many errors emitted, stopping now (use /ERRORLIMIT:0 to see all errors)
+DEFAULT-NOT: could not open 21
+
+RUN: not lld-link /ERRORLIMIT:5 01 02 03 04 05 06 07 08 09 10 2>&1 \
+RUN: | FileCheck -check-prefix=LIMIT5 %s
+
+LIMIT5: could not open 01
+LIMIT5: could not open 05
+LIMIT5-NEXT: too many errors emitted, stopping now (use /ERRORLIMIT:0 to see all errors)
+LIMIT5-NOT: could not open 06
+
+RUN: not lld-link /ERRORLIMIT:0 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 \
+RUN: 16 17 18 19 20 21 22 2>&1 | FileCheck -check-prefix=UNLIMITED %s
+
+UNLIMITED: could not open 01
+UNLIMITED: could not open 20
+UNLIMITED: could not open 21
+UNLIMITED: could not open 22
+UNLIMITED-NOT: too many errors emitted, stopping now (use /ERRORLIMIT:0 to see all errors)
+
+RUN: not lld-link /ERRORLIMIT:XYZ 01 02 03 04 05 06 07 08 09 10 11 12 13 14 \
+RUN: 15 16 17 18 19 20 21 22 2>&1 | FileCheck -check-prefix=WRONG %s
+
+WRONG: /ERRORLIMIT: number expected, but got XYZ
diff --git a/test/COFF/export32.test b/test/COFF/export32.test
index 79f5daf62dbf..83de18b11624 100644
--- a/test/COFF/export32.test
+++ b/test/COFF/export32.test
@@ -73,6 +73,16 @@
# CHECK6: duplicate /export option: _exportfn2
# CHECK6-NOT: duplicate /export option: _exportfn1
+# RUN: lld-link /out:%t.dll /dll %t.obj /export:foo=mangled
+# RUN: llvm-objdump -p %t.dll | FileCheck -check-prefix=CHECK7 %s
+
+# CHECK7: Export Table:
+# CHECK7: DLL name: export32.test.tmp.dll
+# CHECK7: Ordinal RVA Name
+# CHECK7-NEXT: 0 0
+# CHECK7-NEXT: 1 0
+# CHECK7-NEXT: 2 0x1010 foo
+
--- !COFF
header:
Machine: IMAGE_FILE_MACHINE_I386
diff --git a/test/COFF/hello32.test b/test/COFF/hello32.test
index 4307d4bf89a9..b7bc887d46eb 100644
--- a/test/COFF/hello32.test
+++ b/test/COFF/hello32.test
@@ -1,6 +1,6 @@
# RUN: yaml2obj < %p/Inputs/hello32.yaml > %t.obj
# RUN: lld-link %t.obj %p/Inputs/std32.lib /subsystem:console \
-# RUN: /entry:main@0 /out:%t.exe
+# RUN: /entry:main@0 /out:%t.exe /appcontainer
# RUN: llvm-readobj -file-headers %t.exe | FileCheck -check-prefix=HEADER %s
# RUN: llvm-readobj -coff-imports %t.exe | FileCheck -check-prefix=IMPORTS %s
# RUN: llvm-readobj -coff-basereloc %t.exe | FileCheck -check-prefix=BASEREL %s
@@ -41,7 +41,8 @@ HEADER-NEXT: MinorSubsystemVersion: 0
HEADER-NEXT: SizeOfImage: 16896
HEADER-NEXT: SizeOfHeaders: 512
HEADER-NEXT: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI (0x3)
-HEADER-NEXT: Characteristics [ (0x8140)
+HEADER-NEXT: Characteristics [ (0x9140)
+HEADER-NEXT: IMAGE_DLL_CHARACTERISTICS_APPCONTAINER (0x1000)
HEADER-NEXT: IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE (0x40)
HEADER-NEXT: IMAGE_DLL_CHARACTERISTICS_NX_COMPAT (0x100)
HEADER-NEXT: IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE (0x8000)
diff --git a/test/COFF/include-lto.ll b/test/COFF/include-lto.ll
new file mode 100644
index 000000000000..ab9f85f5719e
--- /dev/null
+++ b/test/COFF/include-lto.ll
@@ -0,0 +1,24 @@
+; RUN: llvm-as -o %t.obj %s
+; RUN: lld-link /dll /out:%t.dll %t.obj
+; RUN: llvm-objdump -d %t.dll | FileCheck %s
+
+; Checks that code for foo is emitted, as required by the /INCLUDE directive.
+; CHECK: xorl %eax, %eax
+; CHECK-NEXT: retq
+
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc"
+
+define void @_DllMainCRTStartup() {
+ ret void
+}
+
+define i32 @foo() {
+ ret i32 0
+}
+
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 6, !"Linker Options", !1}
+!1 = !{!2}
+!2 = !{!"/INCLUDE:foo"}
diff --git a/test/COFF/invalid-debug-type.test b/test/COFF/invalid-debug-type.test
new file mode 100644
index 000000000000..e48b3fdd2e06
--- /dev/null
+++ b/test/COFF/invalid-debug-type.test
@@ -0,0 +1,5 @@
+# RUN: yaml2obj < %p/Inputs/pdb1.yaml > %t1.obj
+# RUN: yaml2obj < %p/Inputs/pdb2.yaml > %t2.obj
+# RUN: lld-link /debug /debugtype:invalid /pdb:%t.pdb /dll /out:%t.dll /entry:main /nodefaultlib \
+# RUN: /debugpdb %t1.obj %t2.obj
+
diff --git a/test/COFF/lldmap.test b/test/COFF/lldmap.test
index eb61f0e5a6c2..69080fd639ab 100644
--- a/test/COFF/lldmap.test
+++ b/test/COFF/lldmap.test
@@ -4,7 +4,8 @@
# RUN: lld-link /out:%T/bar.exe /entry:main /lldmap %t.obj
# RUN: FileCheck %s < %T/bar.map
-# CHECK: .obj:
-# CHECK-NEXT: 140001000 .text$mn
-# CHECK-NEXT: 140001000 .data
-# CHECK-NEXT: 140001000 main
+# CHECK: Address Size Align Out In File Symbol
+# CHECK-NEXT: 00001000 00000006 4096 .text
+# CHECK-NEXT: 00001000 00000006 16 .text$mn
+# CHECK-NEXT: 00001000 00000006 16 {{.*}}lldmap.test.tmp.obj
+# CHECK-NEXT: 00001000 00000006 0 main
diff --git a/test/COFF/lto-comdat.ll b/test/COFF/lto-comdat.ll
index aaa7a16c4afb..b255f69d1ab5 100644
--- a/test/COFF/lto-comdat.ll
+++ b/test/COFF/lto-comdat.ll
@@ -10,6 +10,8 @@
; RUN: rm -f %T/comdat.lib
; RUN: llvm-ar cru %T/comdat.lib %T/comdat1.obj %T/comdat2.obj
+; Check that, when we use an LTO main with LTO objects, we optimize away all
+; of f1, f2, and comdat.
; RUN: lld-link /out:%T/comdat-main.exe /entry:main /subsystem:console %T/comdat-main.lto.obj %T/comdat1.lto.obj %T/comdat2.lto.obj
; RUN: llvm-readobj -file-headers %T/comdat-main.exe | FileCheck -check-prefix=HEADERS-11 %s
; RUN: llvm-objdump -d %T/comdat-main.exe | FileCheck -check-prefix=TEXT-11 %s
@@ -17,6 +19,9 @@
; RUN: llvm-readobj -file-headers %T/comdat-main.exe | FileCheck -check-prefix=HEADERS-11 %s
; RUN: llvm-objdump -d %T/comdat-main.exe | FileCheck -check-prefix=TEXT-11 %s
+; Check that, when we use a non-LTO main with LTO objects, we pick the comdat
+; implementation in LTO, elide calls to it from inside LTO, and retain the
+; call to comdat from main.
; RUN: lld-link /out:%T/comdat-main.exe /entry:main /subsystem:console %T/comdat-main.obj %T/comdat1.lto.obj %T/comdat2.lto.obj
; RUN: llvm-readobj -file-headers %T/comdat-main.exe | FileCheck -check-prefix=HEADERS-01 %s
; RUN: llvm-objdump -d %T/comdat-main.exe | FileCheck -check-prefix=TEXT-01 %s
@@ -24,6 +29,9 @@
; RUN: llvm-readobj -file-headers %T/comdat-main.exe | FileCheck -check-prefix=HEADERS-01 %s
; RUN: llvm-objdump -d %T/comdat-main.exe | FileCheck -check-prefix=TEXT-01 %s
+; Check that, when we use an LTO main with non-LTO objects, we pick the comdat
+; implementation in LTO, elide the call to it from inside LTO, and keep the
+; calls to comdat from the non-LTO objects.
; RUN: lld-link /out:%T/comdat-main.exe /entry:main /subsystem:console %T/comdat-main.lto.obj %T/comdat1.obj %T/comdat2.obj
; RUN: llvm-readobj -file-headers %T/comdat-main.exe | FileCheck -check-prefix=HEADERS-10 %s
; RUN: llvm-objdump -d %T/comdat-main.exe | FileCheck -check-prefix=TEXT-10 %s
@@ -46,70 +54,39 @@
; TEXT-01-NEXT: callq 13
; TEXT-01-NEXT: xorl %eax, %eax
; TEXT-01-NEXT: addq $40, %rsp
-; TEXT-01-NEXT: retq
-; TEXT-01-NEXT: int3
-; TEXT-01-NEXT: int3
-; TEXT-01-NEXT: int3
-; TEXT-01-NEXT: int3
-; TEXT-01-NEXT: int3
-; TEXT-01-NEXT: int3
-; TEXT-01-NEXT: retq
-; TEXT-01-NEXT: int3
-; TEXT-01-NEXT: int3
-; TEXT-01-NEXT: int3
-; TEXT-01-NEXT: int3
-; TEXT-01-NEXT: int3
-; TEXT-01-NEXT: int3
-; TEXT-01-NEXT: int3
-; TEXT-01-NEXT: int3
-; TEXT-01-NEXT: int3
-; TEXT-01-NEXT: int3
-; TEXT-01-NEXT: int3
-; TEXT-01-NEXT: int3
-; TEXT-01-NEXT: int3
-; TEXT-01-NEXT: int3
-; TEXT-01-NEXT: int3
-; TEXT-01-NEXT: retq
-; TEXT-01-NEXT: nopw %cs:(%rax,%rax)
-; TEXT-01-NEXT: retq
+; TEXT-01: retq
+; TEXT-01-NOT: callq
+; TEXT-01: retq
+; TEXT-01-NOT: callq
+; TEXT-01: retq
+; TEXT-01-NOT: callq
+; TEXT-01: retq
+; TEXT-01-NOT: {{.}}
-; HEADERS-10: AddressOfEntryPoint: 0x2030
+; HEADERS-10: AddressOfEntryPoint: 0x2020
; TEXT-10: Disassembly of section .text:
; TEXT-10-NEXT: .text:
; TEXT-10-NEXT: subq $40, %rsp
-; TEXT-10-NEXT: callq 7
+; TEXT-10-NEXT: callq 55
; TEXT-10-NEXT: nop
; TEXT-10-NEXT: addq $40, %rsp
; TEXT-10-NEXT: retq
; TEXT-10-NEXT: int3
-; TEXT-10-NEXT: retq
-; TEXT-10-NEXT: int3
-; TEXT-10-NEXT: int3
-; TEXT-10-NEXT: int3
-; TEXT-10-NEXT: int3
-; TEXT-10-NEXT: int3
-; TEXT-10-NEXT: int3
-; TEXT-10-NEXT: int3
-; TEXT-10-NEXT: int3
-; TEXT-10-NEXT: int3
-; TEXT-10-NEXT: int3
-; TEXT-10-NEXT: int3
-; TEXT-10-NEXT: int3
-; TEXT-10-NEXT: int3
-; TEXT-10-NEXT: int3
-; TEXT-10-NEXT: int3
; TEXT-10-NEXT: subq $40, %rsp
-; TEXT-10-NEXT: callq -25
+; TEXT-10-NEXT: callq 39
; TEXT-10-NEXT: nop
; TEXT-10-NEXT: addq $40, %rsp
; TEXT-10-NEXT: retq
; TEXT-10-NEXT: int3
; TEXT-10-NEXT: subq $40, %rsp
-; TEXT-10-NEXT: callq -57
+; TEXT-10-NEXT: callq -41
; TEXT-10-NEXT: callq -30
; TEXT-10-NEXT: xorl %eax, %eax
; TEXT-10-NEXT: addq $40, %rsp
; TEXT-10-NEXT: retq
+; TEXT-10-NOT: callq
+; TEXT-10: retq
+; TEXT-10-NOT: {{.}}
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc"
diff --git a/test/COFF/lto-debug-pass-arguments.ll b/test/COFF/lto-debug-pass-arguments.ll
new file mode 100644
index 000000000000..4381590ff130
--- /dev/null
+++ b/test/COFF/lto-debug-pass-arguments.ll
@@ -0,0 +1,16 @@
+; REQUIRES: x86
+; RUN: llvm-as %s -o %t.obj
+; RUN: lld-link /dll /out:%t.dll %t.obj /mllvm:-debug-pass=Arguments 2>&1 | FileCheck %s
+
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc"
+
+define void @dummy() {
+ ret void
+}
+
+define void @_DllMainCRTStartup() {
+ ret void
+}
+
+; CHECK: Pass Arguments:
diff --git a/test/COFF/lto-parallel.ll b/test/COFF/lto-parallel.ll
index 2303797019a5..449e3a01a853 100644
--- a/test/COFF/lto-parallel.ll
+++ b/test/COFF/lto-parallel.ll
@@ -1,18 +1,18 @@
; RUN: llvm-as -o %t.obj %s
-; RUN: lld-link /out:%t.exe /entry:foo /include:bar /opt:lldltojobs=2 /subsystem:console /lldmap:%t.map %t.obj
+; RUN: lld-link /out:%t.exe /entry:foo /include:bar /opt:lldltopartitions=2 /subsystem:console /lldmap:%t.map %t.obj
; RUN: FileCheck %s < %t.map
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc"
-; CHECK: <lto object>:
-; CHECK: foo
+; CHECK: lto.tmp
+; CHECK-NEXT: foo
define void @foo() {
call void @bar()
ret void
}
-; CHECK: <lto object>:
+; CHECK: lto.tmp
; CHECK: bar
define void @bar() {
call void @foo()
diff --git a/test/COFF/msvclto-archive.ll b/test/COFF/msvclto-archive.ll
new file mode 100644
index 000000000000..047b19e76ddf
--- /dev/null
+++ b/test/COFF/msvclto-archive.ll
@@ -0,0 +1,39 @@
+;; Make sure we re-create archive files to strip bitcode files.
+
+;; Do not create empty archives because the MSVC linker
+;; doesn't support them.
+; RUN: llvm-as -o %t.obj %s
+; RUN: rm -f %t-main1.a
+; RUN: llvm-ar cru %t-main1.a %t.obj
+; RUN: mkdir -p %t.dir
+; RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o %t.dir/bitcode.obj %p/Inputs/msvclto.s
+; RUN: lld-link %t-main1.a %t.dir/bitcode.obj /msvclto /out:%t.exe /opt:lldlto=1 /opt:icf \
+; RUN: /entry:main /verbose > %t.log || true
+; RUN: FileCheck -check-prefix=BC %s < %t.log
+; BC-NOT: Creating a temporary archive for
+
+; RUN: rm -f %t-main2.a
+; RUN: llvm-ar cru %t-main2.a %t.dir/bitcode.obj
+; RUN: lld-link %t.obj %t-main2.a /msvclto /out:%t.exe /opt:lldlto=1 /opt:icf \
+; RUN: /entry:main /verbose > %t.log || true
+; RUN: FileCheck -check-prefix=OBJ %s < %t.log
+; OBJ-NOT: Creating a temporary archive
+
+;; Make sure that we always rebuild thin archives because
+;; the MSVC linker doesn't support thin archives.
+; RUN: rm -f %t-main3.a
+; RUN: llvm-ar cruT %t-main3.a %t.dir/bitcode.obj
+; RUN: lld-link %t.obj %t-main3.a /msvclto /out:%t.exe /opt:lldlto=1 /opt:icf \
+; RUN: /entry:main /verbose > %t.log || true
+; RUN: FileCheck -check-prefix=THIN %s < %t.log
+; THIN: Creating a temporary archive
+
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc"
+
+declare void @foo()
+
+define i32 @main() {
+ call void @foo()
+ ret i32 0
+}
diff --git a/test/COFF/msvclto.ll b/test/COFF/msvclto.ll
new file mode 100644
index 000000000000..e8a6b5c49ce9
--- /dev/null
+++ b/test/COFF/msvclto.ll
@@ -0,0 +1,18 @@
+; RUN: llvm-as -o %t.obj %s
+; RUN: mkdir -p %t.dir
+; RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o %t.dir/bitcode.obj %p/Inputs/msvclto.s
+; RUN: lld-link %t.obj %t.dir/bitcode.obj /msvclto /out:%t.exe /opt:lldlto=1 /opt:icf \
+; RUN: /entry:main /verbose > %t.log || true
+; RUN: FileCheck %s < %t.log
+
+; CHECK: /opt:icf /entry:main /verbose
+
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc"
+
+declare void @foo()
+
+define i32 @main() {
+ call void @foo()
+ ret i32 0
+}
diff --git a/test/COFF/nopdb.test b/test/COFF/nopdb.test
new file mode 100644
index 000000000000..29797bbf9310
--- /dev/null
+++ b/test/COFF/nopdb.test
@@ -0,0 +1,14 @@
+# Check that /debug creates %t.pdb.
+# RUN: rm -f %t.pdb
+# RUN: lld-link /debug /entry:main /out:%t.exe %p/Inputs/ret42.obj
+# RUN: ls %t.pdb
+
+# Check that /debug /nopdb does not create %t.pdb.
+# RUN: rm -f %t.pdb
+# RUN: lld-link /debug /nopdb /entry:main /out:%t.exe %p/Inputs/ret42.obj
+# RUN: not ls %t.pdb
+
+# Check that /debug /nopdb /pdb:%t.pdb does not create %t.pdb.
+# RUN: rm -f %t.pdb
+# RUN: lld-link /debug /nopdb /pdb:%t.pdb /entry:main /out:%t.exe %p/Inputs/ret42.obj
+# RUN: not ls %t.pdb
diff --git a/test/COFF/pdb-none.test b/test/COFF/pdb-none.test
new file mode 100644
index 000000000000..480ff2a4ace3
--- /dev/null
+++ b/test/COFF/pdb-none.test
@@ -0,0 +1,13 @@
+# RUN: yaml2obj < %p/Inputs/pdb1.yaml > %t1.obj
+# RUN: yaml2obj < %p/Inputs/pdb2.yaml > %t2.obj
+# RUN: lld-link /debug /debugtype:pdata /pdb:%t.pdb /dll /out:%t.dll /entry:main /nodefaultlib \
+# RUN: /debugpdb %t1.obj %t2.obj
+
+# RUN: llvm-pdbdump pdb2yaml -pdb-stream %t.pdb | FileCheck %s
+
+# CHECK: PdbStream:
+# CHECK-NEXT: Age: 0
+# CHECK-NEXT: Guid: '{00000000-0000-0000-0000-000000000000}'
+# CHECK-NEXT: Signature: 0
+# CHECK-NEXT: Version: VC70
+
diff --git a/test/COFF/pdb.test b/test/COFF/pdb.test
index 5939b825f9a2..aa14d290c737 100644
--- a/test/COFF/pdb.test
+++ b/test/COFF/pdb.test
@@ -6,32 +6,28 @@
# RUN: llvm-pdbdump pdb2yaml -stream-metadata -stream-directory -pdb-stream \
# RUN: -dbi-stream -ipi-stream -tpi-stream %t.pdb | FileCheck %s
+# RUN: llvm-pdbdump raw -modules -section-map -section-headers -section-contribs \
+# RUN: -tpi-records %t.pdb | FileCheck -check-prefix RAW %s
+
# CHECK: MSF:
# CHECK-NEXT: SuperBlock:
# CHECK-NEXT: BlockSize: 4096
# CHECK-NEXT: FreeBlockMap: 1
-# CHECK-NEXT: NumBlocks: 10
-# CHECK-NEXT: NumDirectoryBytes: 48
+# CHECK-NEXT: NumBlocks:
+# CHECK-NEXT: NumDirectoryBytes:
# CHECK-NEXT: Unknown1: 0
-# CHECK-NEXT: BlockMapAddr: 3
-# CHECK-NEXT: NumDirectoryBlocks: 1
-# CHECK-NEXT: DirectoryBlocks: [ 9 ]
-# CHECK-NEXT: NumStreams: 6
-# CHECK-NEXT: FileSize: 40960
-# CHECK-NEXT: StreamSizes: [ 0, 48, 736, 390, 56, 160 ]
+# CHECK-NEXT: BlockMapAddr:
+# CHECK-NEXT: NumDirectoryBlocks:
+# CHECK-NEXT: DirectoryBlocks:
+# CHECK-NEXT: NumStreams:
+# CHECK-NEXT: FileSize:
+# CHECK-NEXT: StreamSizes:
# CHECK-NEXT: StreamMap:
-# CHECK-NEXT: - Stream: [ ]
-# CHECK-NEXT: - Stream: [ 5 ]
-# CHECK-NEXT: - Stream: [ 7 ]
-# CHECK-NEXT: - Stream: [ 6 ]
-# CHECK-NEXT: - Stream: [ 8 ]
-# CHECK-NEXT: - Stream: [ 4 ]
-# CHECK-NEXT: PdbStream:
+# CHECK: PdbStream:
# CHECK-NEXT: Age: 1
# CHECK-NEXT: Guid:
# CHECK-NEXT: Signature: 0
# CHECK-NEXT: Version: VC70
-# CHECK-NEXT: NamedStreams:
# CHECK-NEXT: DbiStream:
# CHECK-NEXT: VerHeader: V110
# CHECK-NEXT: Age: 1
@@ -67,6 +63,9 @@
# CHECK-NEXT: Options: [ None ]
# CHECK-NEXT: ParameterCount: 0
# CHECK-NEXT: ArgumentList: 4099
+# CHECK-NEXT: IpiStream:
+# CHECK-NEXT: Version: VC80
+# CHECK-NEXT: Records:
# CHECK-NEXT: - Kind: LF_FUNC_ID
# CHECK-NEXT: FuncId:
# CHECK-NEXT: ParentScope: 0
@@ -90,11 +89,11 @@
# CHECK-NEXT: Id: 0
# CHECK-NEXT: String: '-Z7 -c -MT -IC:\vs14\VC\INCLUDE -IC:\vs14\VC\ATLMFC\INCLUDE -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10150.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\shared"'
# CHECK-NEXT: - Kind: LF_SUBSTR_LIST
-# CHECK-NEXT: ArgList:
-# CHECK-NEXT: ArgIndices: [ 4105 ]
+# CHECK-NEXT: StringList:
+# CHECK-NEXT: StringIndices: [ 4100 ]
# CHECK-NEXT: - Kind: LF_STRING_ID
# CHECK-NEXT: StringId:
-# CHECK-NEXT: Id: 4106
+# CHECK-NEXT: Id: 4101
# CHECK-NEXT: String: ' -I"C:\Program Files (x86)\Windows Kits\8.1\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\winrt" -TC -X'
# CHECK-NEXT: - Kind: LF_STRING_ID
# CHECK-NEXT: StringId:
@@ -106,58 +105,18 @@
# CHECK-NEXT: String: 'D:\b\vc140.pdb'
# CHECK-NEXT: - Kind: LF_BUILDINFO
# CHECK-NEXT: BuildInfo:
-# CHECK-NEXT: ArgIndices: [ 4103, 4104, 4108, 4109, 4107 ]
+# CHECK-NEXT: ArgIndices: [ 4098, 4099, 4103, 4104, 4102 ]
# CHECK-NEXT: - Kind: LF_STRING_ID
# CHECK-NEXT: StringId:
# CHECK-NEXT: Id: 0
# CHECK-NEXT: String: ret42-sub.c
# CHECK-NEXT: - Kind: LF_BUILDINFO
# CHECK-NEXT: BuildInfo:
-# CHECK-NEXT: ArgIndices: [ 4103, 4104, 4111, 4109, 4107 ]
-# CHECK-NEXT: IpiStream:
-# CHECK-NEXT: Version: VC80
-# CHECK-NEXT: Records:
+# CHECK-NEXT: ArgIndices: [ 4098, 4099, 4106, 4104, 4102 ]
-# RAW: FileHeaders {
-# RAW-NEXT: BlockSize: 4096
-# RAW-NEXT: FreeBlockMap: 1
-# RAW-NEXT: NumBlocks: 10
-# RAW-NEXT: NumDirectoryBytes: 48
-# RAW-NEXT: Unknown1: 0
-# RAW-NEXT: BlockMapAddr: 3
-# RAW-NEXT: NumDirectoryBlocks: 1
-# RAW-NEXT: DirectoryBlocks: [9]
-# RAW-NEXT: NumStreams: 6
-# RAW-NEXT: }
-# RAW-NEXT: Streams [
-# RAW-NEXT: Stream 0: [Old MSF Directory] (0 bytes)
-# RAW-NEXT: Stream 1: [PDB Stream] (48 bytes)
-# RAW-NEXT: Stream 2: [TPI Stream] (736 bytes)
-# RAW-NEXT: Stream 3: [DBI Stream] (390 bytes)
-# RAW-NEXT: Stream 4: [IPI Stream] (56 bytes)
-# RAW-NEXT: Stream 5: [Section Header Data] (160 bytes)
-# RAW-NEXT: ]
-# RAW-NEXT: Msf Free Pages: []
-# RAW-NEXT: Orphaned Pages: []
-# RAW-NEXT: Multiply Used Pages: []
-# RAW-NEXT: Use After Free Pages: []
-# RAW-NEXT: StreamBlocks [
-# RAW-NEXT: Stream 0: []
-# RAW-NEXT: Stream 1: [5]
-# RAW-NEXT: Stream 2: [7]
-# RAW-NEXT: Stream 3: [6]
-# RAW-NEXT: Stream 4: [8]
-# RAW-NEXT: Stream 5: [4]
-# RAW-NEXT: ]
-# RAW-NEXT: PDB Stream {
-# RAW-NEXT: Version: 20000404
-# RAW-NEXT: Signature: 0x0
-# RAW-NEXT: Age: 1
-# RAW-NEXT: Guid: {7EBCCC79-C488-0267-C898-06D7E94A8A10}
-# RAW-NEXT: }
-# RAW-NEXT: Type Info Stream (TPI) {
+# RAW: Type Info Stream (TPI) {
# RAW-NEXT: TPI Version: 20040203
-# RAW-NEXT: Record count: 17
+# RAW-NEXT: Record count: 5
# RAW-NEXT: Records [
# RAW-NEXT: {
# RAW-NEXT: ArgList (0x1000) {
@@ -212,126 +171,9 @@
# RAW-NEXT: ArgListType: (<no type>) (0x1003)
# RAW-NEXT: }
# RAW-NEXT: }
-# RAW-NEXT: {
-# RAW-NEXT: FuncId (0x1005) {
-# RAW-NEXT: TypeLeafKind: LF_FUNC_ID (0x1601)
-# RAW-NEXT: ParentScope: 0x0
-# RAW-NEXT: FunctionType: int (<no type>) (0x1004)
-# RAW-NEXT: Name: main
-# RAW-NEXT: }
-# RAW-NEXT: }
-# RAW-NEXT: {
-# RAW-NEXT: FuncId (0x1006) {
-# RAW-NEXT: TypeLeafKind: LF_FUNC_ID (0x1601)
-# RAW-NEXT: ParentScope: 0x0
-# RAW-NEXT: FunctionType: int () (0x1001)
-# RAW-NEXT: Name: foo
-# RAW-NEXT: }
-# RAW-NEXT: }
-# RAW-NEXT: {
-# RAW-NEXT: StringId (0x1007) {
-# RAW-NEXT: TypeLeafKind: LF_STRING_ID (0x1605)
-# RAW-NEXT: Id: 0x0
-# RAW-NEXT: StringData: D:\b
-# RAW-NEXT: }
-# RAW-NEXT: }
-# RAW-NEXT: {
-# RAW-NEXT: StringId (0x1008) {
-# RAW-NEXT: TypeLeafKind: LF_STRING_ID (0x1605)
-# RAW-NEXT: Id: 0x0
-# RAW-NEXT: StringData: C:\vs14\VC\BIN\amd64\cl.exe
-# RAW-NEXT: }
-# RAW-NEXT: }
-# RAW-NEXT: {
-# RAW-NEXT: StringId (0x1009) {
-# RAW-NEXT: TypeLeafKind: LF_STRING_ID (0x1605)
-# RAW-NEXT: Id: 0x0
-# RAW-NEXT: StringData: -Z7 -c -MT -IC:\vs14\VC\INCLUDE -IC:\vs14\VC\ATLMFC\INCLUDE -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10150.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\shared"
-# RAW-NEXT: }
-# RAW-NEXT: }
-# RAW-NEXT: {
-# RAW-NEXT: StringList (0x100A) {
-# RAW-NEXT: TypeLeafKind: LF_SUBSTR_LIST (0x1604)
-# RAW-NEXT: NumArgs: 1
-# RAW-NEXT: Arguments [
-# RAW-NEXT: ArgType: -Z7 -c -MT -IC:\vs14\VC\INCLUDE -IC:\vs14\VC\ATLMFC\INCLUDE -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10150.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\shared" (0x1009)
-# RAW-NEXT: ]
-# RAW-NEXT: }
-# RAW-NEXT: }
-# RAW-NEXT: {
-# RAW-NEXT: StringId (0x100B) {
-# RAW-NEXT: TypeLeafKind: LF_STRING_ID (0x1605)
-# RAW-NEXT: Id: (-Z7 -c -MT -IC:\vs14\VC\INCLUDE -IC:\vs14\VC\ATLMFC\INCLUDE -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10150.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\shared") (0x100A)
-# RAW-NEXT: StringData: -I"C:\Program Files (x86)\Windows Kits\8.1\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\winrt" -TC -X
-# RAW-NEXT: }
-# RAW-NEXT: }
-# RAW-NEXT: {
-# RAW-NEXT: StringId (0x100C) {
-# RAW-NEXT: TypeLeafKind: LF_STRING_ID (0x1605)
-# RAW-NEXT: Id: 0x0
-# RAW-NEXT: StringData: ret42-main.c
-# RAW-NEXT: }
-# RAW-NEXT: }
-# RAW-NEXT: {
-# RAW-NEXT: StringId (0x100D) {
-# RAW-NEXT: TypeLeafKind: LF_STRING_ID (0x1605)
-# RAW-NEXT: Id: 0x0
-# RAW-NEXT: StringData: D:\b\vc140.pdb
-# RAW-NEXT: }
-# RAW-NEXT: }
-# RAW-NEXT: {
-# RAW-NEXT: BuildInfo (0x100E) {
-# RAW-NEXT: TypeLeafKind: LF_BUILDINFO (0x1603)
-# RAW-NEXT: NumArgs: 5
-# RAW-NEXT: Arguments [
-# RAW-NEXT: ArgType: D:\b (0x1007)
-# RAW-NEXT: ArgType: C:\vs14\VC\BIN\amd64\cl.exe (0x1008)
-# RAW-NEXT: ArgType: ret42-main.c (0x100C)
-# RAW-NEXT: ArgType: D:\b\vc140.pdb (0x100D)
-# RAW-NEXT: ArgType: -I"C:\Program Files (x86)\Windows Kits\8.1\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\winrt" -TC -X (0x100B)
-# RAW-NEXT: ]
-# RAW-NEXT: }
-# RAW-NEXT: }
-# RAW-NEXT: {
-# RAW-NEXT: StringId (0x100F) {
-# RAW-NEXT: TypeLeafKind: LF_STRING_ID (0x1605)
-# RAW-NEXT: Id: 0x0
-# RAW-NEXT: StringData: ret42-sub.c
-# RAW-NEXT: }
-# RAW-NEXT: }
-# RAW-NEXT: {
-# RAW-NEXT: BuildInfo (0x1010) {
-# RAW-NEXT: TypeLeafKind: LF_BUILDINFO (0x1603)
-# RAW-NEXT: NumArgs: 5
-# RAW-NEXT: Arguments [
-# RAW-NEXT: ArgType: D:\b (0x1007)
-# RAW-NEXT: ArgType: C:\vs14\VC\BIN\amd64\cl.exe (0x1008)
-# RAW-NEXT: ArgType: ret42-sub.c (0x100F)
-# RAW-NEXT: ArgType: D:\b\vc140.pdb (0x100D)
-# RAW-NEXT: ArgType: -I"C:\Program Files (x86)\Windows Kits\8.1\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\winrt" -TC -X (0x100B)
-# RAW-NEXT: ]
-# RAW-NEXT: }
-# RAW-NEXT: }
-# RAW-NEXT: Hash {
-# RAW-NEXT: Number of Hash Buckets: 4096
-# RAW-NEXT: Hash Key Size: 4
-# RAW-NEXT: Values: []
-# RAW-NEXT: Type Index Offsets: []
-# RAW-NEXT: Hash Adjustments: []
-# RAW-NEXT: }
-# RAW-NEXT: ]
-# RAW-NEXT: }
-# RAW-NEXT: Type Info Stream (IPI) {
-# RAW-NEXT: IPI Version: 20040203
-# RAW-NEXT: Record count: 0
-# RAW-NEXT: Records [
-# RAW-NEXT: Hash {
-# RAW-NEXT: Number of Hash Buckets: 4096
-# RAW-NEXT: Hash Key Size: 4
-# RAW-NEXT: Values: []
-# RAW-NEXT: Type Index Offsets: []
-# RAW-NEXT: Hash Adjustments: []
-# RAW-NEXT: }
+# RAW-NEXT: TypeIndexOffsets [
+# RAW-NEXT: Index: 0x1000, Offset: 0
+# RAW-NEXT: ]
# RAW-NEXT: ]
# RAW-NEXT: }
# RAW-NEXT: DBI Stream {
@@ -349,18 +191,16 @@
# RAW-NEXT: Modules [
# RAW-NEXT: {
# RAW-NEXT: Name: * Linker *
-# RAW-NEXT: Debug Stream Index: 65535
+# RAW-NEXT: Debug Stream Index: 9
# RAW-NEXT: Object File Name:
# RAW-NEXT: Num Files: 0
# RAW-NEXT: Source File Name Idx: 0
# RAW-NEXT: Pdb File Name Idx: 0
# RAW-NEXT: Line Info Byte Size: 0
# RAW-NEXT: C13 Line Info Byte Size: 0
-# RAW-NEXT: Symbol Byte Size: 0
+# RAW-NEXT: Symbol Byte Size: 4
# RAW-NEXT: Type Server Index: 0
# RAW-NEXT: Has EC Info: No
-# RAW-NEXT: 0 Contributing Source Files [
-# RAW-NEXT: ]
# RAW-NEXT: }
# RAW-NEXT: ]
# RAW-NEXT: }
@@ -488,7 +328,7 @@
# RAW-NEXT: SecName: 65535
# RAW-NEXT: ClassName: 65535
# RAW-NEXT: Offset: 0
-# RAW-NEXT: SecByteLength: 101
+# RAW-NEXT: SecByteLength:
# RAW-NEXT: }
# RAW-NEXT: Entry {
# RAW-NEXT: Flags [ (0x208)
@@ -504,8 +344,6 @@
# RAW-NEXT: SecByteLength: 4294967295
# RAW-NEXT: }
# RAW-NEXT: ]
-# RAW-NEXT: Globals Stream not present
-# RAW-NEXT: Publics Stream not present
# RAW-NEXT: Section Headers [
# RAW-NEXT: {
# RAW-NEXT: Name: .pdata
@@ -555,7 +393,7 @@
# RAW-NEXT: }
# RAW-NEXT: {
# RAW-NEXT: Name: .rdata
-# RAW-NEXT: Virtual Size: 101
+# RAW-NEXT: Virtual Size:
# RAW-NEXT: Virtual Address: 16384
# RAW-NEXT: Size of Raw Data: 512
# RAW-NEXT: File Pointer to Raw Data: 2560
@@ -569,5 +407,3 @@
# RAW-NEXT: ]
# RAW-NEXT: }
# RAW-NEXT: ]
-# RAW-NEXT: New FPO [
-# RAW-NEXT: ]
diff --git a/test/COFF/rsds.test b/test/COFF/rsds.test
index 37ec48b5068e..82b0f220b6c1 100644
--- a/test/COFF/rsds.test
+++ b/test/COFF/rsds.test
@@ -4,7 +4,7 @@
# RUN: llvm-readobj -coff-debug-directory %t.dll | FileCheck %s
# RUN: lld-link /debug /pdb:%t.pdb /dll /out:%t.dll /entry:DllMain %t.obj
-# RUN: llvm-readobj -coff-debug-directory %t.dll | FileCheck %s -check-prefix CHECK-PDB
+# RUN: llvm-readobj -coff-debug-directory %t.dll | FileCheck %s
# CHECK: DebugDirectory [
# CHECK: DebugEntry {
@@ -13,37 +13,18 @@
# CHECK: MajorVersion: 0x0
# CHECK: MinorVersion: 0x0
# CHECK: Type: CodeView (0x2)
-# CHECK: SizeOfData: 0x19
+# CHECK: SizeOfData:
# CHECK: AddressOfRawData:
# CHECK: PointerToRawData:
# CHECK: PDBInfo {
# CHECK: PDBSignature: 0x53445352
# CHECK: PDBGUID:
# CHECK: PDBAge: 1
-# CHECK: PDBFileName: {{$}}
+# CHECK: PDBFileName: {{.*}}.pdb
# CHECK: }
# CHECK: }
# CHECK: ]
-# CHECK-PDB: DebugDirectory [
-# CHECK-PDB: DebugEntry {
-# CHECK-PDB: Characteristics: 0x0
-# CHECK-PDB: TimeDateStamp: 1970-01-01 00:00:00 (0x0)
-# CHECK-PDB: MajorVersion: 0x0
-# CHECK-PDB: MinorVersion: 0x0
-# CHECK-PDB: Type: CodeView (0x2)
-# CHECK-PDB: SizeOfData:
-# CHECK-PDB: AddressOfRawData:
-# CHECK-PDB: PointerToRawData:
-# CHECK-PDB: PDBInfo {
-# CHECK-PDB: PDBSignature: 0x53445352
-# CHECK-PDB: PDBGUID:
-# CHECK-PDB: PDBAge: 1
-# CHECK-PDB: PDBFileName: {{.*}}.pdb
-# CHECK-PDB: }
-# CHECK-PDB: }
-# CHECK-PDB: ]
-
--- !COFF
header:
Machine: IMAGE_FILE_MACHINE_I386
diff --git a/test/COFF/savetemps.ll b/test/COFF/savetemps.ll
new file mode 100644
index 000000000000..4e59812441a9
--- /dev/null
+++ b/test/COFF/savetemps.ll
@@ -0,0 +1,28 @@
+; RUN: rm -fr %T/savetemps
+; RUN: mkdir %T/savetemps
+; RUN: llvm-as -o %T/savetemps/savetemps.obj %s
+; RUN: lld-link /out:%T/savetemps/savetemps.exe /entry:main \
+; RUN: /subsystem:console %T/savetemps/savetemps.obj
+; RUN: not llvm-dis -o - %T/savetemps/savetemps.exe.0.0.preopt.bc
+; RUN: not llvm-dis -o - %T/savetemps/savetemps.exe.0.2.internalize.bc
+; RUN: not llvm-dis -o - %T/savetemps/savetemps.exe.0.4.opt.bc
+; RUN: not llvm-dis -o - %T/savetemps/savetemps.exe.0.5.precodegen.bc
+; RUN: not llvm-objdump -s %T/savetemps/savetemps.exe.lto.obj
+; RUN: lld-link /lldsavetemps /out:%T/savetemps/savetemps.exe /entry:main \
+; RUN: /subsystem:console %T/savetemps/savetemps.obj
+; RUN: llvm-dis -o - %T/savetemps/savetemps.exe.0.0.preopt.bc | FileCheck %s
+; RUN: llvm-dis -o - %T/savetemps/savetemps.exe.0.2.internalize.bc | FileCheck %s
+; RUN: llvm-dis -o - %T/savetemps/savetemps.exe.0.4.opt.bc | FileCheck %s
+; RUN: llvm-dis -o - %T/savetemps/savetemps.exe.0.5.precodegen.bc | FileCheck %s
+; RUN: llvm-objdump -s %T/savetemps/savetemps.exe.lto.obj | \
+; RUN: FileCheck --check-prefix=CHECK-OBJDUMP %s
+
+; CHECK: define i32 @main()
+; CHECK-OBJDUMP: file format COFF
+
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc"
+
+define i32 @main() {
+ ret i32 0
+}
diff --git a/test/COFF/thinlto-archives.ll b/test/COFF/thinlto-archives.ll
new file mode 100644
index 000000000000..7a5e36aa1fb9
--- /dev/null
+++ b/test/COFF/thinlto-archives.ll
@@ -0,0 +1,22 @@
+; RUN: rm -fr %T/thinlto-archives
+; RUN: mkdir %T/thinlto-archives %T/thinlto-archives/a %T/thinlto-archives/b
+; RUN: opt -thinlto-bc -o %T/thinlto-archives/main.obj %s
+; RUN: opt -thinlto-bc -o %T/thinlto-archives/a/bar.obj %S/Inputs/lto-dep.ll
+; RUN: opt -thinlto-bc -o %T/thinlto-archives/b/bar.obj %S/Inputs/bar.ll
+; RUN: llvm-ar crs %T/thinlto-archives/a.lib %T/thinlto-archives/a/bar.obj
+; RUN: llvm-ar crs %T/thinlto-archives/b.lib %T/thinlto-archives/b/bar.obj
+; RUN: lld-link /out:%T/thinlto-archives/main.exe -entry:main \
+; RUN: -subsystem:console %T/thinlto-archives/main.obj \
+; RUN: %T/thinlto-archives/a.lib %T/thinlto-archives/b.lib
+
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc"
+
+declare void @bar()
+declare void @foo()
+
+define i32 @main() {
+ call void @foo()
+ call void @bar()
+ ret i32 0
+}
diff --git a/test/COFF/thinlto-mangled.ll b/test/COFF/thinlto-mangled.ll
new file mode 100644
index 000000000000..efcd9c3d2d0a
--- /dev/null
+++ b/test/COFF/thinlto-mangled.ll
@@ -0,0 +1,16 @@
+; RUN: opt -thinlto-bc %s -o %t.obj
+; RUN: opt -thinlto-bc %S/Inputs/thinlto-mangled-qux.ll -o %T/thinlto-mangled-qux.obj
+; RUN: lld-link -out:%t.exe -entry:main %t.obj %T/thinlto-mangled-qux.obj
+
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc19.0.24215"
+
+%"class.bar" = type { i32 (...)**, i8*, i8*, i8*, i32 }
+
+define i32 @main() {
+ ret i32 0
+}
+
+define available_externally zeroext i1 @"\01?x@bar@@UEBA_NXZ"(%"class.bar"* %this) unnamed_addr align 2 {
+ ret i1 false
+}
diff --git a/test/COFF/thinlto.ll b/test/COFF/thinlto.ll
new file mode 100644
index 000000000000..11b689d6327e
--- /dev/null
+++ b/test/COFF/thinlto.ll
@@ -0,0 +1,18 @@
+; RUN: rm -fr %T/thinlto
+; RUN: mkdir %T/thinlto
+; RUN: opt -thinlto-bc -o %T/thinlto/main.obj %s
+; RUN: opt -thinlto-bc -o %T/thinlto/foo.obj %S/Inputs/lto-dep.ll
+; RUN: lld-link /lldsavetemps /out:%T/thinlto/main.exe /entry:main /subsystem:console %T/thinlto/main.obj %T/thinlto/foo.obj
+; RUN: llvm-nm %T/thinlto/main.exe.lto.obj | FileCheck %s
+
+; CHECK-NOT: U foo
+
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc"
+
+define i32 @main() {
+ call void @foo()
+ ret i32 0
+}
+
+declare void @foo()
diff --git a/test/COFF/weak-external.test b/test/COFF/weak-external.test
index e422b2e62761..7bdadd9b1c94 100644
--- a/test/COFF/weak-external.test
+++ b/test/COFF/weak-external.test
@@ -4,9 +4,8 @@
# RUN: lld-link /out:%t2.exe /entry:g /subsystem:console /lldmap:%t2.map %t.obj %t.lto.obj
# RUN: FileCheck %s < %t2.map
-# CHECK: <lto object>:
-# CHECK-NOT: :
-# CHECK: {{ g$}}
+# CHECK: lto.tmp
+# CHECK-NEXT: 0 g
--- !COFF
header:
diff --git a/test/COFF/weak-external3.test b/test/COFF/weak-external3.test
index 05ff859993a3..a06ce48a61a6 100644
--- a/test/COFF/weak-external3.test
+++ b/test/COFF/weak-external3.test
@@ -5,13 +5,11 @@
# RUN: lld-link /out:%t2.exe /entry:f /subsystem:console /lldmap:%t2.map %t.obj %t.lto.obj
# RUN: FileCheck --check-prefix=CHECK2 %s < %t2.map
-# CHECK1: <lto object>:
-# CHECK1-NOT: :
-# CHECK1: {{ g$}}
+# CHECK1: lto.tmp
+# CHECK1-NEXT: 0 g
-# CHECK2: weak-external3{{.*}}:
-# CHECK2-NOT: :
-# CHECK2: {{ f$}}
+# CHECK2: weak-external3.test.tmp.obj
+# CHECK2-NEXT: 0 f
--- !COFF
header:
diff --git a/test/ELF/Inputs/i386-got32x-baseless.elf b/test/ELF/Inputs/i386-got32x-baseless.elf
new file mode 100644
index 000000000000..824d757f3b8c
--- /dev/null
+++ b/test/ELF/Inputs/i386-got32x-baseless.elf
Binary files differ
diff --git a/test/ELF/Inputs/i386-reloc-16-error.s b/test/ELF/Inputs/i386-reloc-16-error.s
new file mode 100644
index 000000000000..8deed64dbef8
--- /dev/null
+++ b/test/ELF/Inputs/i386-reloc-16-error.s
@@ -0,0 +1,3 @@
+.globl foo
+.hidden foo
+foo = 65536
diff --git a/test/ELF/Inputs/i386-reloc-16.s b/test/ELF/Inputs/i386-reloc-16.s
new file mode 100644
index 000000000000..ac4601b5c580
--- /dev/null
+++ b/test/ELF/Inputs/i386-reloc-16.s
@@ -0,0 +1,3 @@
+.globl foo
+.hidden foo
+foo = 0xffff
diff --git a/test/ELF/Inputs/i386-reloc-8-error.s b/test/ELF/Inputs/i386-reloc-8-error.s
new file mode 100644
index 000000000000..b6a7626456dc
--- /dev/null
+++ b/test/ELF/Inputs/i386-reloc-8-error.s
@@ -0,0 +1,3 @@
+.globl foo
+.hidden foo
+foo = 256
diff --git a/test/ELF/Inputs/i386-reloc-8.s b/test/ELF/Inputs/i386-reloc-8.s
new file mode 100644
index 000000000000..ce488f6e1d57
--- /dev/null
+++ b/test/ELF/Inputs/i386-reloc-8.s
@@ -0,0 +1,3 @@
+.globl foo
+.hidden foo
+foo = 0xff
diff --git a/test/ELF/Inputs/icf-absolute.s b/test/ELF/Inputs/icf-absolute.s
new file mode 100644
index 000000000000..4c2da9db6c15
--- /dev/null
+++ b/test/ELF/Inputs/icf-absolute.s
@@ -0,0 +1,3 @@
+.globl a1, a2
+a1 = 1
+a2 = 1
diff --git a/test/ELF/Inputs/map-file2.s b/test/ELF/Inputs/map-file2.s
new file mode 100644
index 000000000000..d46b06f7345a
--- /dev/null
+++ b/test/ELF/Inputs/map-file2.s
@@ -0,0 +1,8 @@
+foo:
+nop
+.global bar
+bar:
+nop
+.section .text.zed,"ax",@progbits
+.global zed
+zed:
diff --git a/test/ELF/Inputs/map-file3.s b/test/ELF/Inputs/map-file3.s
new file mode 100644
index 000000000000..3e869c02a917
--- /dev/null
+++ b/test/ELF/Inputs/map-file3.s
@@ -0,0 +1,2 @@
+.global bah
+bah:
diff --git a/test/ELF/Inputs/map-file4.s b/test/ELF/Inputs/map-file4.s
new file mode 100644
index 000000000000..c95ce37e5242
--- /dev/null
+++ b/test/ELF/Inputs/map-file4.s
@@ -0,0 +1,3 @@
+.global baz
+baz:
+ retq
diff --git a/test/ELF/Inputs/relocatable-non-alloc.s b/test/ELF/Inputs/relocatable-non-alloc.s
new file mode 100644
index 000000000000..26a9d87db754
--- /dev/null
+++ b/test/ELF/Inputs/relocatable-non-alloc.s
@@ -0,0 +1,6 @@
+.section .text.foo,"axG",@progbits,foo,comdat,unique,0
+foo:
+ nop
+
+.section .debug_info
+.long .text.foo
diff --git a/test/ELF/Inputs/relocation-copy-align-common.s b/test/ELF/Inputs/relocation-copy-align-common.s
new file mode 100644
index 000000000000..b2fc8fd2bf61
--- /dev/null
+++ b/test/ELF/Inputs/relocation-copy-align-common.s
@@ -0,0 +1,7 @@
+.data
+.global foo
+.type foo, @object
+.align 8
+.size foo, 8
+foo:
+.quad 0
diff --git a/test/ELF/Inputs/resolution-end.s b/test/ELF/Inputs/resolution-end.s
index 41567c81ef53..6dcc0b760037 100644
--- a/test/ELF/Inputs/resolution-end.s
+++ b/test/ELF/Inputs/resolution-end.s
@@ -1,2 +1,3 @@
.data
.quad _end
+ .quad end
diff --git a/test/ELF/Inputs/x86-64-reloc-16-error.s b/test/ELF/Inputs/x86-64-reloc-16-error.s
new file mode 100644
index 000000000000..8deed64dbef8
--- /dev/null
+++ b/test/ELF/Inputs/x86-64-reloc-16-error.s
@@ -0,0 +1,3 @@
+.globl foo
+.hidden foo
+foo = 65536
diff --git a/test/ELF/Inputs/x86-64-reloc-16.s b/test/ELF/Inputs/x86-64-reloc-16.s
new file mode 100644
index 000000000000..c5b2f5536047
--- /dev/null
+++ b/test/ELF/Inputs/x86-64-reloc-16.s
@@ -0,0 +1,3 @@
+.globl foo
+.hidden foo
+foo = 0x42
diff --git a/test/ELF/Inputs/x86-64-reloc-8-error.s b/test/ELF/Inputs/x86-64-reloc-8-error.s
new file mode 100644
index 000000000000..b6a7626456dc
--- /dev/null
+++ b/test/ELF/Inputs/x86-64-reloc-8-error.s
@@ -0,0 +1,3 @@
+.globl foo
+.hidden foo
+foo = 256
diff --git a/test/ELF/Inputs/x86-64-reloc-8.s b/test/ELF/Inputs/x86-64-reloc-8.s
new file mode 100644
index 000000000000..c5b2f5536047
--- /dev/null
+++ b/test/ELF/Inputs/x86-64-reloc-8.s
@@ -0,0 +1,3 @@
+.globl foo
+.hidden foo
+foo = 0x42
diff --git a/test/ELF/Inputs/ztext-text-notext.s b/test/ELF/Inputs/ztext-text-notext.s
new file mode 100644
index 000000000000..f66b3ee1e29b
--- /dev/null
+++ b/test/ELF/Inputs/ztext-text-notext.s
@@ -0,0 +1,10 @@
+ .global bar
+ .type bar, @object
+ .size bar, 8
+bar:
+ .quad 0
+
+ .global zed
+ .type zed, @function
+zed:
+ nop
diff --git a/test/ELF/aarch64-fpic-abs16.s b/test/ELF/aarch64-fpic-abs16.s
index 539242a8d217..2b14b11c75db 100644
--- a/test/ELF/aarch64-fpic-abs16.s
+++ b/test/ELF/aarch64-fpic-abs16.s
@@ -1,7 +1,9 @@
// REQUIRES: aarch64
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
-// CHECK: {{.*}}:(.data+0x0): relocation R_AARCH64_ABS16 cannot be used against shared object; recompile with -fPIC.
+// CHECK: relocation R_AARCH64_ABS16 cannot be used against shared object; recompile with -fPIC
+// CHECK-NEXT: >>> defined in {{.*}}.o
+// CHECK-NEXT: >>> referenced by {{.*}}.o:(.data+0x0)
.data
.hword foo
diff --git a/test/ELF/aarch64-fpic-add_abs_lo12_nc.s b/test/ELF/aarch64-fpic-add_abs_lo12_nc.s
index 0ebd0fdde3a5..9e13fd18af46 100644
--- a/test/ELF/aarch64-fpic-add_abs_lo12_nc.s
+++ b/test/ELF/aarch64-fpic-add_abs_lo12_nc.s
@@ -1,7 +1,9 @@
// REQUIRES: aarch64
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
-// CHECK: {{.*}}.o:(.text+0x0): can't create dynamic relocation R_AARCH64_ADD_ABS_LO12_NC against symbol 'dat' defined in {{.*}}.o
+// CHECK: can't create dynamic relocation R_AARCH64_ADD_ABS_LO12_NC against symbol: dat
+// CHECK: >>> defined in {{.*}}.o
+// CHECK: >>> referenced by {{.*}}.o:(.text+0x0)
add x0, x0, :lo12:dat
.data
diff --git a/test/ELF/aarch64-fpic-adr_prel_lo21.s b/test/ELF/aarch64-fpic-adr_prel_lo21.s
index d01749600e71..c1e6bc6359bd 100644
--- a/test/ELF/aarch64-fpic-adr_prel_lo21.s
+++ b/test/ELF/aarch64-fpic-adr_prel_lo21.s
@@ -1,7 +1,9 @@
// REQUIRES: aarch64
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
-// CHECK: {{.*}}.o:(.text+0x0): can't create dynamic relocation R_AARCH64_ADR_PREL_LO21 against symbol 'dat' defined in {{.*}}.o
+// CHECK: can't create dynamic relocation R_AARCH64_ADR_PREL_LO21 against symbol: dat
+// CHECK: >>> defined in {{.*}}.o
+// CHECK: >>> referenced by {{.*}}.o:(.text+0x0)
adr x0, dat
.data
diff --git a/test/ELF/aarch64-fpic-adr_prel_pg_hi21.s b/test/ELF/aarch64-fpic-adr_prel_pg_hi21.s
index 3da4b2ece517..e27867b85242 100644
--- a/test/ELF/aarch64-fpic-adr_prel_pg_hi21.s
+++ b/test/ELF/aarch64-fpic-adr_prel_pg_hi21.s
@@ -1,7 +1,9 @@
// REQUIRES: aarch64
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
-// CHECK: {{.*}}.o:(.text+0x0): can't create dynamic relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol 'dat' defined in {{.*}}.o
+// CHECK: can't create dynamic relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol: dat
+// CHECK: >>> defined in {{.*}}.o
+// CHECK: >>> referenced by {{.*}}.o:(.text+0x0)
adrp x0, dat
.data
diff --git a/test/ELF/aarch64-fpic-ldst32_abs_lo12_nc.s b/test/ELF/aarch64-fpic-ldst32_abs_lo12_nc.s
index 8df582186b23..02b75a5bfcde 100644
--- a/test/ELF/aarch64-fpic-ldst32_abs_lo12_nc.s
+++ b/test/ELF/aarch64-fpic-ldst32_abs_lo12_nc.s
@@ -1,7 +1,9 @@
// REQUIRES: aarch64
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
-// CHECK: {{.*}}.o:(.text+0x0): can't create dynamic relocation R_AARCH64_LDST32_ABS_LO12_NC against symbol 'dat' defined in {{.*}}.o
+// CHECK: can't create dynamic relocation R_AARCH64_LDST32_ABS_LO12_NC against symbol: dat
+// CHECK: >>> defined in {{.*}}.o
+// CHECK: >>> referenced by {{.*}}.o:(.text+0x0)
ldr s4, [x0, :lo12:dat]
.data
diff --git a/test/ELF/aarch64-fpic-ldst64_abs_lo12_nc.s b/test/ELF/aarch64-fpic-ldst64_abs_lo12_nc.s
index fe80e654277f..45e4f2032c19 100644
--- a/test/ELF/aarch64-fpic-ldst64_abs_lo12_nc.s
+++ b/test/ELF/aarch64-fpic-ldst64_abs_lo12_nc.s
@@ -1,7 +1,9 @@
// REQUIRES: aarch64
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
-// CHECK: {{.*}}.o:(.text+0x0): can't create dynamic relocation R_AARCH64_LDST64_ABS_LO12_NC against symbol 'dat' defined in {{.*}}.o
+// CHECK: can't create dynamic relocation R_AARCH64_LDST64_ABS_LO12_NC against symbol: dat
+// CHECK: >>> defined in {{.*}}.o
+// CHECK: >>> referenced by {{.*}}.o:(.text+0x0)
ldr x0, [x0, :lo12:dat]
.data
diff --git a/test/ELF/aarch64-fpic-ldst8_abs_lo12_nc.s b/test/ELF/aarch64-fpic-ldst8_abs_lo12_nc.s
index 8442062bed97..16e7df1bc4a1 100644
--- a/test/ELF/aarch64-fpic-ldst8_abs_lo12_nc.s
+++ b/test/ELF/aarch64-fpic-ldst8_abs_lo12_nc.s
@@ -1,7 +1,9 @@
// REQUIRES: aarch64
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
-// CHECK: {{.*}}.o:(.text+0x0): can't create dynamic relocation R_AARCH64_LDST8_ABS_LO12_NC against symbol 'dat' defined in {{.*}}.o
+// CHECK: can't create dynamic relocation R_AARCH64_LDST8_ABS_LO12_NC against symbol: dat
+// CHECK: >>> defined in {{.*}}.o
+// CHECK: >>> referenced by {{.*}}.o:(.text+0x0)
ldrsb x0, [x1, :lo12:dat]
.data
diff --git a/test/ELF/aarch64-fpic-prel16.s b/test/ELF/aarch64-fpic-prel16.s
index 3cb76cabd06b..1faef9f866e0 100644
--- a/test/ELF/aarch64-fpic-prel16.s
+++ b/test/ELF/aarch64-fpic-prel16.s
@@ -1,7 +1,9 @@
// REQUIRES: aarch64
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
-// CHECK: {{.*}}:(.data+0x0): relocation R_AARCH64_PREL16 cannot be used against shared object; recompile with -fPIC.
+// CHECK: R_AARCH64_PREL16 cannot be used against shared object; recompile with -fPIC
+// CHECK: >>> defined in {{.*}}
+// CHECK: >>> referenced by {{.*}}:(.data+0x0)
.data
.hword foo - .
diff --git a/test/ELF/aarch64-fpic-prel32.s b/test/ELF/aarch64-fpic-prel32.s
index 1c701e93cf84..b797dca2f2c4 100644
--- a/test/ELF/aarch64-fpic-prel32.s
+++ b/test/ELF/aarch64-fpic-prel32.s
@@ -1,7 +1,9 @@
// REQUIRES: aarch64
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
-// CHECK: {{.*}}:(.data+0x0): relocation R_AARCH64_PREL32 cannot be used against shared object; recompile with -fPIC.
+// CHECK: relocation R_AARCH64_PREL32 cannot be used against shared object; recompile with -fPIC
+// CHECK: >>> defined in {{.*}}
+// CHECK: >>> referenced by {{.*}}:(.data+0x0)
.data
.word foo - .
diff --git a/test/ELF/aarch64-fpic-prel64.s b/test/ELF/aarch64-fpic-prel64.s
index 0f5f08a88eb3..4c67837eac78 100644
--- a/test/ELF/aarch64-fpic-prel64.s
+++ b/test/ELF/aarch64-fpic-prel64.s
@@ -1,7 +1,9 @@
// REQUIRES: aarch64
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
-// CHECK: {{.*}}:(.data+0x0): relocation R_AARCH64_PREL64 cannot be used against shared object; recompile with -fPIC.
+// CHECK: relocation R_AARCH64_PREL64 cannot be used against shared object; recompile with -fPIC
+// CHECK: >>> defined in {{.*}}
+// CHECK: >>> referenced by {{.*}}:(.data+0x0)
.data
.xword foo - .
diff --git a/test/ELF/abs-conflict.s b/test/ELF/abs-conflict.s
index 7837a6bae50a..17a530200033 100644
--- a/test/ELF/abs-conflict.s
+++ b/test/ELF/abs-conflict.s
@@ -13,4 +13,6 @@ foo = 0x123
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %t2.s -o %t2.o
// RUN: not ld.lld %t.o %t2.o -o %t.so -shared 2>&1 | FileCheck --check-prefix=DUP %s
-// DUP: duplicate symbol 'foo'
+// DUP: duplicate symbol: foo
+// DUP-NEXT: >>> defined in {{.*}}.o
+// DUP-NEXT: >>> defined in (internal)
diff --git a/test/ELF/arm-gnu-ifunc-plt.s b/test/ELF/arm-gnu-ifunc-plt.s
index cd1e8b740b3e..2561a4d34bed 100644
--- a/test/ELF/arm-gnu-ifunc-plt.s
+++ b/test/ELF/arm-gnu-ifunc-plt.s
@@ -41,33 +41,41 @@
// DISASM: 11018: 05 00 00 eb bl #20
// DISASM-NEXT: 1101c: 08 00 00 eb bl #32
// DISASM-NEXT: Disassembly of section .plt:
-// DISASM-NEXT: .plt:
+// DISASM-NEXT: $a:
// DISASM-NEXT: 11020: 04 e0 2d e5 str lr, [sp, #-4]!
// DISASM-NEXT: 11024: 04 e0 9f e5 ldr lr, [pc, #4]
// DISASM-NEXT: 11028: 0e e0 8f e0 add lr, pc, lr
// DISASM-NEXT: 1102c: 08 f0 be e5 ldr pc, [lr, #8]!
-// DISASM-NEXT: 11030: d0 0f 00 00
+// DISASM: $d:
+// DISASM-NEXT: 11030: d0 0f 00 00 .word 0x00000fd0
+// DISASM: $a:
// DISASM-NEXT: 11034: 04 c0 9f e5 ldr r12, [pc, #4]
// DISASM-NEXT: 11038: 0f c0 8c e0 add r12, r12, pc
// DISASM-NEXT: 1103c: 00 f0 9c e5 ldr pc, [r12]
-// DISASM-NEXT: 11040: cc 0f 00 00
+// DISASM: $d:
+// DISASM-NEXT: 11040: cc 0f 00 00 .word 0x00000fcc
+// DISASM: $a:
// DISASM-NEXT: 11044: 04 c0 9f e5 ldr r12, [pc, #4]
// DISASM-NEXT: 11048: 0f c0 8c e0 add r12, r12, pc
// DISASM-NEXT: 1104c: 00 f0 9c e5 ldr pc, [r12]
-// DISASM-NEXT: 11050: c0 0f 00 00
+// DISASM: $d:
+// DISASM-NEXT: 11050: c0 0f 00 00 .word 0x00000fc0
// Alignment to 16 byte boundary not strictly necessary on ARM, but harmless
-// DISASM-NEXT: 11054: 00 00 00 00 andeq r0, r0, r0
-// DISASM-NEXT: 11058: 00 00 00 00 andeq r0, r0, r0
-// DISASM-NEXT: 1105c: 00 00 00 00 andeq r0, r0, r0
+// DISASM-NEXT: 11054: 00 00 00 00 .word 0x00000000
+// DISASM-NEXT: 11058: 00 00 00 00 .word 0x00000000
+// DISASM-NEXT: 1105c: 00 00 00 00 .word 0x00000000
+// DISASM: $a:
// DISASM-NEXT: 11060: 04 c0 9f e5 ldr r12, [pc, #4]
// DISASM-NEXT: 11064: 0f c0 8c e0 add r12, r12, pc
// DISASM-NEXT: 11068: 00 f0 9c e5 ldr pc, [r12]
-// DISASM-NEXT: 1106c: 14 20 00 00
+// DISASM: $d:
+// DISASM-NEXT: 1106c: 14 20 00 00 .word 0x00002014
+// DISASM: $a:
// DISASM-NEXT: 11070: 04 c0 9f e5 ldr r12, [pc, #4]
// DISASM-NEXT: 11074: 0f c0 8c e0 add r12, r12, pc
// DISASM-NEXT: 11078: 00 f0 9c e5 ldr pc, [r12]
-// DISASM-NEXT: 1107c: 08 20 00 00
-
+// DISASM: $d:
+// DISASM-NEXT: 1107c: 08 20 00 00 .word 0x00002008
.syntax unified
.text
diff --git a/test/ELF/arm-gnu-ifunc.s b/test/ELF/arm-gnu-ifunc.s
index 214a8824787c..23c540310b3c 100644
--- a/test/ELF/arm-gnu-ifunc.s
+++ b/test/ELF/arm-gnu-ifunc.s
@@ -60,7 +60,7 @@ _start:
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK: Symbol {
-// CHECK: Name: __rel_iplt_end (6)
+// CHECK: Name: __rel_iplt_end
// CHECK-NEXT: Value: 0x10104
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local
@@ -124,14 +124,17 @@ _start:
// DISASM-NEXT: 11018: 04 01 00 e3 movw r0, #260
// DISASM-NEXT: 1101c: 01 00 40 e3 movt r0, #1
// DISASM-NEXT: Disassembly of section .plt:
-// DISASM-NEXT: .plt:
-// DISASM-NEXT: 11020: 04 c0 9f e5 ldr r12, [pc, #4]
-// DISASM-NEXT: 11024: 0f c0 8c e0 add r12, r12, pc
+// DISASM: $a:
+// DISASM-NEXT: 11020: 04 c0 9f e5 ldr r12, [pc, #4]
+// DISASM-NEXT: 11024: 0f c0 8c e0 add r12, r12, pc
// 11024 + 8 + fd4 = 0x12000
-// DISASM-NEXT: 11028: 00 f0 9c e5 ldr pc, [r12]
-// DISASM-NEXT: 1102c: d4 0f 00 00
-// DISASM-NEXT: 11030: 04 c0 9f e5 ldr r12, [pc, #4]
-// DISASM-NEXT: 11034: 0f c0 8c e0 add r12, r12, pc
-// 11034 + 8 + fc8 = 0x12004
-// DISASM-NEXT: 11038: 00 f0 9c e5 ldr pc, [r12]
-// DISASM-NEXT: 1103c: c8 0f 00 00
+// DISASM-NEXT: 11028: 00 f0 9c e5 ldr pc, [r12]
+// DISASM: $d:
+// DISASM-NEXT: 1102c: d4 0f 00 00 .word 0x00000fd4
+// DISASM: $a:
+// DISASM-NEXT: 11030: 04 c0 9f e5 ldr r12, [pc, #4]
+// DISASM-NEXT: 11034: 0f c0 8c e0 add r12, r12, pc
+// 11034 + 8 + fc8 = 0x12004
+// DISASM-NEXT: 11038: 00 f0 9c e5 ldr pc, [r12]
+// DISASM: $d:
+// DISASM-NEXT: 1103c: c8 0f 00 00 .word 0x00000fc8
diff --git a/test/ELF/arm-icf-exidx.s b/test/ELF/arm-icf-exidx.s
new file mode 100644
index 000000000000..cb801b7f2420
--- /dev/null
+++ b/test/ELF/arm-icf-exidx.s
@@ -0,0 +1,31 @@
+// REQUIRES: arm
+// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
+// RUN: ld.lld %t -o %t2 --icf=all
+// RUN: llvm-objdump -s -d -triple=armv7a-none-linux-gnueabi %t2 | FileCheck %s
+
+ .syntax unified
+ .section .text.f,"axG",%progbits,f,comdat
+f:
+ .fnstart
+ bx lr
+ .fnend
+
+ .section .text.g,"axG",%progbits,g,comdat
+g:
+ .fnstart
+ bx lr
+ .fnend
+
+ .section .text.h
+ .global __aeabi_unwind_cpp_pr0
+__aeabi_unwind_cpp_pr0:
+ bx lr
+
+// CHECK: Disassembly of section .text:
+// CHECK-NEXT: f:
+// CHECK-NEXT: 11000: 1e ff 2f e1 bx lr
+// CHECK: __aeabi_unwind_cpp_pr0:
+// CHECK-NEXT: 11004: 1e ff 2f e1 bx lr
+
+// CHECK: Contents of section .ARM.exidx:
+// CHECK-NEXT: 100d4 2c0f0000 b0b0b080 280f0000 01000000
diff --git a/test/ELF/arm-plt-reloc.s b/test/ELF/arm-plt-reloc.s
index 9d4ecbd6774f..1588f745f22c 100644
--- a/test/ELF/arm-plt-reloc.s
+++ b/test/ELF/arm-plt-reloc.s
@@ -46,29 +46,37 @@ _start:
// DSO-NEXT: 1010: 0b 00 00 eb bl #44
// S(0x1054) - P(0x1014) + A(-8) = 0x38 = 56
// DSO-NEXT: 1014: 0e 00 00 0a beq #56
+
// DSO: Disassembly of section .plt:
-// DSO-NEXT:.plt:
-// DSO-NEXT: 1020: 04 e0 2d e5 str lr, [sp, #-4]!
-// DSO-NEXT: 1024: 04 e0 9f e5 ldr lr, [pc, #4]
-// DSO-NEXT: 1028: 0e e0 8f e0 add lr, pc, lr
-// DSO-NEXT: 102c: 08 f0 be e5 ldr pc, [lr, #8]!
+// DSO-NEXT: $a:
+// DSO-NEXT: 1020: 04 e0 2d e5 str lr, [sp, #-4]!
+// DSO-NEXT: 1024: 04 e0 9f e5 ldr lr, [pc, #4]
+// DSO-NEXT: 1028: 0e e0 8f e0 add lr, pc, lr
+// DSO-NEXT: 102c: 08 f0 be e5 ldr pc, [lr, #8]!
// 0x1028 + 8 + 0fd0 = 0x2000
-// DSO-NEXT: 1030: d0 0f 00 00
-// DSO-NEXT: 1034: 04 c0 9f e5 ldr r12, [pc, #4]
-// DSO-NEXT: 1038: 0f c0 8c e0 add r12, r12, pc
-// DSO-NEXT: 103c: 00 f0 9c e5 ldr pc, [r12]
-// 0x1038 + 8 + 0fcc = 0x200c
-// DSO-NEXT: 1040: cc 0f 00 00
-// DSO-NEXT: 1044: 04 c0 9f e5 ldr r12, [pc, #4]
-// DSO-NEXT: 1048: 0f c0 8c e0 add r12, r12, pc
-// DSO-NEXT: 104c: 00 f0 9c e5 ldr pc, [r12]
+// DSO: $d:
+// DSO-NEXT: 1030: d0 0f 00 00 .word 0x00000fd0
+// DSO: $a:
+// DSO-NEXT: 1034: 04 c0 9f e5 ldr r12, [pc, #4]
+// DSO-NEXT: 1038: 0f c0 8c e0 add r12, r12, pc
+// DSO-NEXT: 103c: 00 f0 9c e5 ldr pc, [r12]
+// 0x1038 + 8 + 0fcc = 0x200c
+// DSO: $d:
+// DSO-NEXT: 1040: cc 0f 00 00 .word 0x00000fcc
+// DSO: $a:
+// DSO-NEXT: 1044: 04 c0 9f e5 ldr r12, [pc, #4]
+// DSO-NEXT: 1048: 0f c0 8c e0 add r12, r12, pc
+// DSO-NEXT: 104c: 00 f0 9c e5 ldr pc, [r12]
// 0x1048 + 8 + 0fc0 = 0x2010
-// DSO-NEXT: 1050: c0 0f 00 00
-// DSO-NEXT: 1054: 04 c0 9f e5 ldr r12, [pc, #4]
-// DSO-NEXT: 1058: 0f c0 8c e0 add r12, r12, pc
-// DSO-NEXT: 105c: 00 f0 9c e5 ldr pc, [r12]
+// DSO: $d:
+// DSO-NEXT: 1050: c0 0f 00 00 .word 0x00000fc0
+// DSO: $a:
+// DSO-NEXT: 1054: 04 c0 9f e5 ldr r12, [pc, #4]
+// DSO-NEXT: 1058: 0f c0 8c e0 add r12, r12, pc
+// DSO-NEXT: 105c: 00 f0 9c e5 ldr pc, [r12]
// 0x1058 + 8 + 0fb4 = 0x2014
-// DSO-NEXT: 1060: b4 0f 00 00
+// DSO: $d:
+// DSO-NEXT: 1060: b4 0f 00 00 .word 0x00000fb4
// DSOREL: Name: .got.plt
// DSOREL-NEXT: Type: SHT_PROGBITS
diff --git a/test/ELF/arm-target1.s b/test/ELF/arm-target1.s
index b62d6d663a85..e77fa57bbf16 100644
--- a/test/ELF/arm-target1.s
+++ b/test/ELF/arm-target1.s
@@ -22,11 +22,15 @@
.text
.word patatino(target1)
patatino:
-
+ .word 32
+// Force generation of $d.0 as section is not all data
+ nop
// RELATIVE: Disassembly of section .text:
// RELATIVE: $d.0:
// RELATIVE: 1000: 04 00 00 00 .word 0x00000004
// RELATIVE: SYMBOL TABLE:
// RELATIVE: 00001004 .text 00000000 patatino
-// ABS: {{.*}}.o:(.text+0x0): can't create dynamic relocation R_ARM_TARGET1 against symbol 'patatino' defined in {{.*}}.o
+// ABS: can't create dynamic relocation R_ARM_TARGET1 against symbol: patatino
+// ABS: >>> defined in {{.*}}.o
+// ABS: >>> referenced by {{.*}}.o:(.text+0x0)
diff --git a/test/ELF/arm-thumb-interwork-shared.s b/test/ELF/arm-thumb-interwork-shared.s
index 460931876dcc..8362ae26aed4 100644
--- a/test/ELF/arm-thumb-interwork-shared.s
+++ b/test/ELF/arm-thumb-interwork-shared.s
@@ -16,29 +16,37 @@ sym1:
// CHECK: Disassembly of section .text:
// CHECK-NEXT: sym1:
-// CHECK: 1000: 00 f0 02 b8 b.w #4
-// CHECK-NEXT: 1004: 00 f0 06 b8 b.w #12
+// CHECK-NEXT: 1000: 00 f0 02 b8 b.w #4 <__ThumbV7PILongThunk_elsewhere>
+// CHECK-NEXT: 1004: 00 f0 06 b8 b.w #12 <__ThumbV7PILongThunk_weakref>
+// CHECK: __ThumbV7PILongThunk_elsewhere:
// CHECK-NEXT: 1008: 40 f2 20 0c movw r12, #32
// CHECK-NEXT: 100c: c0 f2 00 0c movt r12, #0
// CHECK-NEXT: 1010: fc 44 add r12, pc
// CHECK-NEXT: 1012: 60 47 bx r12
+
+// CHECK: __ThumbV7PILongThunk_weakref:
// CHECK-NEXT: 1014: 40 f2 24 0c movw r12, #36
// CHECK-NEXT: 1018: c0 f2 00 0c movt r12, #0
// CHECK-NEXT: 101c: fc 44 add r12, pc
// CHECK-NEXT: 101e: 60 47 bx r12
// PLT: Disassembly of section .plt:
-// PLT-NEXT: .plt:
-// PLT: 1020: 04 e0 2d e5 str lr, [sp, #-4]!
+// PLT: $a:
+// PLT-NEXT: 1020: 04 e0 2d e5 str lr, [sp, #-4]!
// PLT-NEXT: 1024: 04 e0 9f e5 ldr lr, [pc, #4]
// PLT-NEXT: 1028: 0e e0 8f e0 add lr, pc, lr
// PLT-NEXT: 102c: 08 f0 be e5 ldr pc, [lr, #8]!
-// PLT-NEXT: 1030: d0 0f 00 00
+// PLT: $d:
+// PLT-NEXT: 1030: d0 0f 00 00 .word 0x00000fd0
+// PLT: $a:
// PLT-NEXT: 1034: 04 c0 9f e5 ldr r12, [pc, #4]
// PLT-NEXT: 1038: 0f c0 8c e0 add r12, r12, pc
// PLT-NEXT: 103c: 00 f0 9c e5 ldr pc, [r12]
-// PLT-NEXT: 1040: cc 0f 00 00
+// PLT: $d:
+// PLT-NEXT: 1040: cc 0f 00 00 .word 0x00000fcc
+// PLT: $a:
// PLT-NEXT: 1044: 04 c0 9f e5 ldr r12, [pc, #4]
// PLT-NEXT: 1048: 0f c0 8c e0 add r12, r12, pc
// PLT-NEXT: 104c: 00 f0 9c e5 ldr pc, [r12]
-// PLT-NEXT: 1050: c0 0f 00 00
+// PLT: $d:
+// PLT-NEXT: 1050: c0 0f 00 00 .word 0x00000fc0
diff --git a/test/ELF/arm-thumb-interwork-thunk.s b/test/ELF/arm-thumb-interwork-thunk.s
index 3fd36b910cd1..04755c4603cc 100644
--- a/test/ELF/arm-thumb-interwork-thunk.s
+++ b/test/ELF/arm-thumb-interwork-thunk.s
@@ -78,62 +78,65 @@ arm_caller:
beq arm_callee2
bne arm_callee3
bx lr
-// CHECK-ABS-ARM: Disassembly of section .arm_caller:
-// CHECK-ABS-ARM-NEXT: arm_caller:
-// CHECK-ABS-ARM-NEXT: 1300: 3e ff ff fa blx #-776 <thumb_callee1>
-// CHECK-ABS-ARM-NEXT: 1304: 3d ff ff fa blx #-780 <thumb_callee1>
-// CHECK-ABS-ARM-NEXT: 1308: 06 00 00 ea b #24 <arm_caller+0x28>
-// CHECK-ABS-ARM-NEXT: 130c: 05 00 00 ea b #20 <arm_caller+0x28>
-// CHECK-ABS-ARM-NEXT: 1310: 07 00 00 ea b #28 <arm_caller+0x34>
-// CHECK-ABS-ARM-NEXT: 1314: 09 00 00 ea b #36 <arm_caller+0x40>
-// CHECK-ABS-ARM-NEXT: 1318: 78 ff ff ea b #-544 <arm_callee1>
-// CHECK-ABS-ARM-NEXT: 131c: b7 00 00 0a beq #732 <arm_callee2>
-// CHECK-ABS-ARM-NEXT: 1320: b7 00 00 1a bne #732 <arm_callee3>
-// CHECK-ABS-ARM-NEXT: 1324: 1e ff 2f e1 bx lr
+// CHECK-ARM-ABS-ARM: Disassembly of section .arm_caller:
+// CHECK-ARM-ABS-ARM-NEXT: arm_caller:
+// CHECK-ARM-ABS-ARM-NEXT: 1300: 3e ff ff fa blx #-776 <thumb_callee1>
+// CHECK-ARM-ABS-ARM-NEXT: 1304: 3d ff ff fa blx #-780 <thumb_callee1>
+// CHECK-ARM-ABS-ARM-NEXT: 1308: 06 00 00 ea b #24 <__ARMv7ABSLongThunk_thumb_callee1>
+// CHECK-ARM-ABS-ARM-NEXT: 130c: 05 00 00 ea b #20 <__ARMv7ABSLongThunk_thumb_callee1>
+// CHECK-ARM-ABS-ARM-NEXT: 1310: 07 00 00 ea b #28 <__ARMv7ABSLongThunk_thumb_callee2>
+// CHECK-ARM-ABS-ARM-NEXT: 1314: 09 00 00 ea b #36 <__ARMv7ABSLongThunk_thumb_callee3>
+// CHECK-ARM-ABS-ARM-NEXT: 1318: 78 ff ff ea b #-544 <arm_callee1>
+// CHECK-ARM-ABS-ARM-NEXT: 131c: b7 00 00 0a beq #732 <arm_callee2>
+// CHECK-ARM-ABS-ARM-NEXT: 1320: b7 00 00 1a bne #732 <arm_callee3>
+// CHECK-ARM-ABS-ARM-NEXT: 1324: 1e ff 2f e1 bx lr
+// CHECK-ARM-ABS-ARM: __ARMv7ABSLongThunk_thumb_callee1:
// 0x1001 = thumb_callee1
-// CHECK-ABS-ARM-NEXT: 1328: 01 c0 01 e3 movw r12, #4097
-// CHECK-ABS-ARM-NEXT: 132c: 00 c0 40 e3 movt r12, #0
-// CHECK-ABS-ARM-NEXT: 1330: 1c ff 2f e1 bx r12
+// CHECK-ARM-ABS-ARM-NEXT: 1328: 01 c0 01 e3 movw r12, #4097
+// CHECK-ARM-ABS-ARM-NEXT: 132c: 00 c0 40 e3 movt r12, #0
+// CHECK-ARM-ABS-ARM-NEXT: 1330: 1c ff 2f e1 bx r12
// 0x1501 = thumb_callee2
-// CHECK-ABS-ARM-NEXT: 1334: 01 c5 01 e3 movw r12, #5377
-// CHECK-ABS-ARM-NEXT: 1338: 00 c0 40 e3 movt r12, #0
-// CHECK-ABS-ARM-NEXT: 133c: 1c ff 2f e1 bx r12
+// CHECK-ARM-ABS-ARM: __ARMv7ABSLongThunk_thumb_callee2:
+// CHECK-ARM-ABS-ARM-NEXT: 1334: 01 c5 01 e3 movw r12, #5377
+// CHECK-ARM-ABS-ARM-NEXT: 1338: 00 c0 40 e3 movt r12, #0
+// CHECK-ARM-ABS-ARM-NEXT: 133c: 1c ff 2f e1 bx r12
// 0x1503 = thumb_callee3
-// CHECK-ABS-ARM-NEXT: 1340: 03 c5 01 e3 movw r12, #5379
-// CHECK-ABS-ARM-NEXT: 1344: 00 c0 40 e3 movt r12, #0
-// CHECK-ABS-ARM-NEXT: 1348: 1c ff 2f e1 bx r12
+// CHECK-ARM-ABS-ARM: __ARMv7ABSLongThunk_thumb_callee3:
+// CHECK-ARM-ABS-ARM-NEXT: 1340: 03 c5 01 e3 movw r12, #5379
+// CHECK-ARM-ABS-ARM-NEXT: 1344: 00 c0 40 e3 movt r12, #0
+// CHECK-ARM-ABS-ARM-NEXT: 1348: 1c ff 2f e1 bx r12
// CHECK-PI-ARM: Disassembly of section .arm_caller:
// CHECK-PI-ARM-NEXT: arm_caller:
-// CHECK-PI-ARM-NEXT: 1300: 3e ff ff fa blx #-776 <thumb_callee1>
-// CHECK-PI-ARM-NEXT: 1304: 3d ff ff fa blx #-780 <thumb_callee1>
-// 0x1308 + 8 + 0x18 = 0x1328
-// CHECK-PI-ARM-NEXT: 1308: 06 00 00 ea b #24 <arm_caller+0x28>
-// 0x130c + 8 + 0x14 = 0x1328
-// CHECK-PI-ARM-NEXT: 130c: 05 00 00 ea b #20 <arm_caller+0x28>
-// 0x1310 + 8 + 0x20 = 0x1338
-// CHECK-PI-ARM-NEXT: 1310: 08 00 00 ea b #32 <arm_caller+0x38>
-// 0x1314 + 8 + 0x2c = 0x1348
-// CHECK-PI-ARM-NEXT: 1314: 0b 00 00 ea b #44 <arm_caller+0x48>
-// CHECK-PI-ARM-NEXT: 1318: 78 ff ff ea b #-544 <arm_callee1>
-// CHECK-PI-ARM-NEXT: 131c: b7 00 00 0a beq #732 <arm_callee2>
-// CHECK-PI-ARM-NEXT: 1320: b7 00 00 1a bne #732 <arm_callee3>
-// CHECK-PI-ARM-NEXT: 1324: 1e ff 2f e1 bx lr
+// CHECK-PI-ARM-NEXT: 1300: 3e ff ff fa blx #-776 <thumb_callee1>
+// CHECK-PI-ARM-NEXT: 1304: 3d ff ff fa blx #-780 <thumb_callee1>
+// CHECK-PI-ARM-NEXT: 1308: 06 00 00 ea b #24 <__ARMV7PILongThunk_thumb_callee1>
+// CHECK-PI-ARM-NEXT: 130c: 05 00 00 ea b #20 <__ARMV7PILongThunk_thumb_callee1>
+// CHECK-PI-ARM-NEXT: 1310: 08 00 00 ea b #32 <__ARMV7PILongThunk_thumb_callee2>
+// CHECK-PI-ARM-NEXT: 1314: 0b 00 00 ea b #44 <__ARMV7PILongThunk_thumb_callee3>
+// CHECK-PI-ARM-NEXT: 1318: 78 ff ff ea b #-544 <arm_callee1>
+// CHECK-PI-ARM-NEXT: 131c: b7 00 00 0a beq #732 <arm_callee2>
+// CHECK-PI-ARM-NEXT: 1320: b7 00 00 1a bne #732 <arm_callee3>
+// CHECK-PI-ARM-NEXT: 1324: 1e ff 2f e1 bx lr
+// CHECK-PI-ARM: __ARMV7PILongThunk_thumb_callee1:
// 0x1330 + 8 - 0x337 = 0x1001 = thumb_callee1
-// CHECK-PI-ARM-NEXT: 1328: c9 cc 0f e3 movw r12, #64713
-// CHECK-PI-ARM-NEXT: 132c: ff cf 4f e3 movt r12, #65535
-// CHECK-PI-ARM-NEXT: 1330: 0f c0 8c e0 add r12, r12, pc
-// CHECK-PI-ARM-NEXT: 1334: 1c ff 2f e1 bx r12
+// CHECK-PI-ARM-NEXT: 1328: c9 cc 0f e3 movw r12, #64713
+// CHECK-PI-ARM-NEXT: 132c: ff cf 4f e3 movt r12, #65535
+// CHECK-PI-ARM-NEXT: 1330: 0f c0 8c e0 add r12, r12, pc
+// CHECK-PI-ARM-NEXT: 1334: 1c ff 2f e1 bx r12
+// CHECK-PI-ARM: __ARMV7PILongThunk_thumb_callee2:
+
+// CHECK-PI-ARM-NEXT: 1338: b9 c1 00 e3 movw r12, #441
+// CHECK-PI-ARM-NEXT: 133c: 00 c0 40 e3 movt r12, #0
+// CHECK-PI-ARM-NEXT: 1340: 0f c0 8c e0 add r12, r12, pc
+// CHECK-PI-ARM-NEXT: 1344: 1c ff 2f e1 bx r12
+// CHECK-PI-ARM: __ARMV7PILongThunk_thumb_callee3:
// 0x1340 + 8 + 0x1b9 = 0x1501
-// CHECK-PI-ARM-NEXT: 1338: b9 c1 00 e3 movw r12, #441
-// CHECK-PI-ARM-NEXT: 133c: 00 c0 40 e3 movt r12, #0
-// CHECK-PI-ARM-NEXT: 1340: 0f c0 8c e0 add r12, r12, pc
-// CHECK-PI-ARM-NEXT: 1344: 1c ff 2f e1 bx r12
+// CHECK-PI-ARM-NEXT: 1348: ab c1 00 e3 movw r12, #427
+// CHECK-PI-ARM-NEXT: 134c: 00 c0 40 e3 movt r12, #0
+// CHECK-PI-ARM-NEXT: 1350: 0f c0 8c e0 add r12, r12, pc
+// CHECK-PI-ARM-NEXT: 1354: 1c ff 2f e1 bx r12
// 1350 + 8 + 0x1ab = 0x1503
-// CHECK-PI-ARM-NEXT: 1348: ab c1 00 e3 movw r12, #427
-// CHECK-PI-ARM-NEXT: 134c: 00 c0 40 e3 movt r12, #0
-// CHECK-PI-ARM-NEXT: 1350: 0f c0 8c e0 add r12, r12, pc
-// CHECK-PI-ARM-NEXT: 1354: 1c ff 2f e1 bx r12
// All PLT entries are ARM, no need for interworking thunks
// CHECK-PI-ARM-PLT: Disassembly of section .arm_caller:
@@ -182,60 +185,58 @@ thumb_caller:
bne.w arm_callee3
// CHECK-ABS-THUMB: Disassembly of section .thumb_caller:
// CHECK-ABS-THUMB-NEXT: thumb_caller:
-// 0x1400 + 4 - 0x304 = 0x1100 = arm_callee1
-// CHECK-ABS-THUMB-NEXT: 1400: ff f7 7e ee blx #-772
-// 0x1404 + 4 - 0x308 = 0x1100 = arm_callee1
-// CHECK-ABS-THUMB-NEXT: 1404: ff f7 7c ee blx #-776
-// 0x1408 + 4 + 0x14 = 0x520
-// CHECK-ABS-THUMB-NEXT: 1408: 00 f0 0a b8 b.w #20
-// 0x140c + 4 + 0x1a = 0x52a
-// CHECK-ABS-THUMB-NEXT: 140c: 00 f0 0d b8 b.w #26
-// 0x1410 + 4 + 0x20 = 0x534
-// CHECK-ABS-THUMB-NEXT: 1410: 00 f0 10 b8 b.w #32
-// 0x1414 + 4 + 8 = 0x520
-// CHECK-ABS-THUMB-NEXT: 1414: 00 f0 04 80 beq.w #8
-// 0x1418 + 4 + 0xe = 0x52a
-// CHECK-ABS-THUMB-NEXT: 1418: 00 f0 07 80 beq.w #14
-// 0x141c + 4 + 0x14 = 0x534
-// CHECK-ABS-THUMB-NEXT: 141c: 40 f0 0a 80 bne.w #20
+// CHECK-ABS-THUMB-NEXT: 1400: ff f7 7e ee blx #-772
+// CHECK-ABS-THUMB-NEXT: 1404: ff f7 7c ee blx #-776
+// CHECK-ABS-THUMB-NEXT: 1408: 00 f0 0a b8 b.w #20 <__Thumbv7ABSLongThunk_arm_callee1>
+// CHECK-ABS-THUMB-NEXT: 140c: 00 f0 0d b8 b.w #26 <__Thumbv7ABSLongThunk_arm_callee2>
+// CHECK-ABS-THUMB-NEXT: 1410: 00 f0 10 b8 b.w #32 <__Thumbv7ABSLongThunk_arm_callee3>
+// CHECK-ABS-THUMB-NEXT: 1414: 00 f0 04 80 beq.w #8 <__Thumbv7ABSLongThunk_arm_callee1>
+// CHECK-ABS-THUMB-NEXT: 1418: 00 f0 07 80 beq.w #14 <__Thumbv7ABSLongThunk_arm_callee2>
+// CHECK-ABS-THUMB-NEXT: 141c: 40 f0 0a 80 bne.w #20 <__Thumbv7ABSLongThunk_arm_callee3>
+// CHECK-ABS-THUMB: __Thumbv7ABSLongThunk_arm_callee1:
// 0x1100 = arm_callee1
-// CHECK-ABS-THUMB-NEXT: 1420: 41 f2 00 1c movw r12, #4352
-// CHECK-ABS-THUMB-NEXT: 1424: c0 f2 00 0c movt r12, #0
-// CHECK-ABS-THUMB-NEXT: 1428: 60 47 bx r12
+// CHECK-ABS-THUMB-NEXT: 1420: 41 f2 00 1c movw r12, #4352
+// CHECK-ABS-THUMB-NEXT: 1424: c0 f2 00 0c movt r12, #0
+// CHECK-ABS-THUMB-NEXT: 1428: 60 47 bx r12
+// CHECK-ABS-THUMB: __Thumbv7ABSLongThunk_arm_callee2:
// 0x1600 = arm_callee2
-// CHECK-ABS-THUMB-NEXT: 142a: 41 f2 00 6c movw r12, #5632
-// CHECK-ABS-THUMB-NEXT: 142e: c0 f2 00 0c movt r12, #0
-// CHECK-ABS-THUMB-NEXT: 1432: 60 47 bx r12
+// CHECK-ABS-THUMB-NEXT: 142a: 41 f2 00 6c movw r12, #5632
+// CHECK-ABS-THUMB-NEXT: 142e: c0 f2 00 0c movt r12, #0
+// CHECK-ABS-THUMB-NEXT: 1432: 60 47 bx r12
// 0x1604 = arm_callee3
-// CHECK-ABS-THUMB-NEXT: 1434: 41 f2 04 6c movw r12, #5636
-// CHECK-ABS-THUMB-NEXT: 1438: c0 f2 00 0c movt r12, #0
-// CHECK-ABS-THUMB-NEXT: 143c: 60 47 bx r12
+// CHECK-ABS-THUMB: __Thumbv7ABSLongThunk_arm_callee3:
+// CHECK-ABS-THUMB-NEXT: 1434: 41 f2 04 6c movw r12, #5636
+// CHECK-ABS-THUMB-NEXT: 1438: c0 f2 00 0c movt r12, #0
+// CHECK-ABS-THUMB-NEXT: 143c: 60 47 bx r12
// CHECK-PI-THUMB: Disassembly of section .thumb_caller:
// CHECK-PI-THUMB-NEXT: thumb_caller:
-// CHECK-PI-THUMB-NEXT: 1400: ff f7 7e ee blx #-772
-// CHECK-PI-THUMB-NEXT: 1404: ff f7 7c ee blx #-776
-// CHECK-PI-THUMB-NEXT: 1408: 00 f0 0a b8 b.w #20
-// CHECK-PI-THUMB-NEXT: 140c: 00 f0 0e b8 b.w #28
-// CHECK-PI-THUMB-NEXT: 1410: 00 f0 12 b8 b.w #36
-// CHECK-PI-THUMB-NEXT: 1414: 00 f0 04 80 beq.w #8
-// CHECK-PI-THUMB-NEXT: 1418: 00 f0 08 80 beq.w #16
-// CHECK-PI-THUMB-NEXT: 141c: 40 f0 0c 80 bne.w #24
+// CHECK-PI-THUMB-NEXT: 1400: ff f7 7e ee blx #-772
+// CHECK-PI-THUMB-NEXT: 1404: ff f7 7c ee blx #-776
+// CHECK-PI-THUMB-NEXT: 1408: 00 f0 0a b8 b.w #20 <__ThumbV7PILongThunk_arm_callee1>
+// CHECK-PI-THUMB-NEXT: 140c: 00 f0 0e b8 b.w #28 <__ThumbV7PILongThunk_arm_callee2>
+// CHECK-PI-THUMB-NEXT: 1410: 00 f0 12 b8 b.w #36 <__ThumbV7PILongThunk_arm_callee3>
+// CHECK-PI-THUMB-NEXT: 1414: 00 f0 04 80 beq.w #8 <__ThumbV7PILongThunk_arm_callee1>
+// CHECK-PI-THUMB-NEXT: 1418: 00 f0 08 80 beq.w #16 <__ThumbV7PILongThunk_arm_callee2>
+// CHECK-PI-THUMB-NEXT: 141c: 40 f0 0c 80 bne.w #24 <__ThumbV7PILongThunk_arm_callee3>
+// CHECK-PI-THUMB: __ThumbV7PILongThunk_arm_callee1:
// 0x1428 + 4 - 0x32c = 0x1100 = arm_callee1
-// CHECK-PI-THUMB-NEXT: 1420: 4f f6 d4 4c movw r12, #64724
-// CHECK-PI-THUMB-NEXT: 1424: cf f6 ff 7c movt r12, #65535
-// CHECK-PI-THUMB-NEXT: 1428: fc 44 add r12, pc
-// CHECK-PI-THUMB-NEXT: 142a: 60 47 bx r12
+// CHECK-PI-THUMB-NEXT: 1420: 4f f6 d4 4c movw r12, #64724
+// CHECK-PI-THUMB-NEXT: 1424: cf f6 ff 7c movt r12, #65535
+// CHECK-PI-THUMB-NEXT: 1428: fc 44 add r12, pc
+// CHECK-PI-THUMB-NEXT: 142a: 60 47 bx r12
+// CHECK-PI-THUMB: __ThumbV7PILongThunk_arm_callee2:
// 0x1434 + 4 + 0x1c8 = 0x1600 = arm_callee2
-// CHECK-PI-THUMB-NEXT: 142c: 40 f2 c8 1c movw r12, #456
-// CHECK-PI-THUMB-NEXT: 1430: c0 f2 00 0c movt r12, #0
-// CHECK-PI-THUMB-NEXT: 1434: fc 44 add r12, pc
-// CHECK-PI-THUMB-NEXT: 1436: 60 47 bx r12
+// CHECK-PI-THUMB-NEXT: 142c: 40 f2 c8 1c movw r12, #456
+// CHECK-PI-THUMB-NEXT: 1430: c0 f2 00 0c movt r12, #0
+// CHECK-PI-THUMB-NEXT: 1434: fc 44 add r12, pc
+// CHECK-PI-THUMB-NEXT: 1436: 60 47 bx r12
+// CHECK-PI-THUMB: __ThumbV7PILongThunk_arm_callee3:
// 0x1440 + 4 + 0x1c0 = 0x1604 = arm_callee3
-// CHECK-PI-THUMB-NEXT: 1438: 40 f2 c0 1c movw r12, #448
-// CHECK-PI-THUMB-NEXT: 143c: c0 f2 00 0c movt r12, #0
-// CHECK-PI-THUMB-NEXT: 1440: fc 44 add r12, pc
-// CHECK-PI-THUMB-NEXT: 1442: 60 47 bx r12
+// CHECK-PI-THUMB-NEXT: 1438: 40 f2 c0 1c movw r12, #448
+// CHECK-PI-THUMB-NEXT: 143c: c0 f2 00 0c movt r12, #0
+// CHECK-PI-THUMB-NEXT: 1440: fc 44 add r12, pc
+// CHECK-PI-THUMB-NEXT: 1442: 60 47 bx r12
// CHECK-PI-THUMB-PLT: Disassembly of section .arm_caller:
// CHECK-PI-THUMB-PLT-NEXT: thumb_caller:
diff --git a/test/ELF/arm-thumb-plt-reloc.s b/test/ELF/arm-thumb-plt-reloc.s
index 36c64b1ec306..95a6e9e7af79 100644
--- a/test/ELF/arm-thumb-plt-reloc.s
+++ b/test/ELF/arm-thumb-plt-reloc.s
@@ -58,27 +58,34 @@ _start:
// 0x1010 + 0x40 + 4 = 0x1054 = PLT func3
// DSOTHUMB-NEXT: 1010: 00 f0 20 e8 blx #64
// DSOARM: Disassembly of section .plt:
-// DSOARM: .plt:
+// DSOARM-NEXT: $a:
// DSOARM-NEXT: 1020: 04 e0 2d e5 str lr, [sp, #-4]!
// DSOARM-NEXT: 1024: 04 e0 9f e5 ldr lr, [pc, #4]
// DSOARM-NEXT: 1028: 0e e0 8f e0 add lr, pc, lr
// DSOARM-NEXT: 102c: 08 f0 be e5 ldr pc, [lr, #8]!
-// DSOARM-NEXT: 1030: d0 0f 00 00
+// DSOARM: $d:
+// DSOARM-NEXT: 1030: d0 0f 00 00 .word 0x00000fd0
// 0x1028 + 8 + 0fd0 = 0x2000
+// DSOARM: $a:
// DSOARM-NEXT: 1034: 04 c0 9f e5 ldr r12, [pc, #4]
// DSOARM-NEXT: 1038: 0f c0 8c e0 add r12, r12, pc
// DSOARM-NEXT: 103c: 00 f0 9c e5 ldr pc, [r12]
-// DSOARM-NEXT: 1040: cc 0f 00 00
+// DSOARM: $d:
+// DSOARM-NEXT: 1040: cc 0f 00 00 .word 0x00000fcc
// 0x1038 + 8 + 0fcc = 0x200c
+// DSOARM: $a:
// DSOARM-NEXT: 1044: 04 c0 9f e5 ldr r12, [pc, #4]
// DSOARM-NEXT: 1048: 0f c0 8c e0 add r12, r12, pc
// DSOARM-NEXT: 104c: 00 f0 9c e5 ldr pc, [r12]
-// DSOARM-NEXT: 1050: c0 0f 00 00
+// DSOARM: $d:
+// DSOARM-NEXT: 1050: c0 0f 00 00 .word 0x00000fc0
// 0x1048 + 8 + 0fc0 = 0x2010
+// DSOARM: $a:
// DSOARM-NEXT: 1054: 04 c0 9f e5 ldr r12, [pc, #4]
// DSOARM-NEXT: 1058: 0f c0 8c e0 add r12, r12, pc
// DSOARM-NEXT: 105c: 00 f0 9c e5 ldr pc, [r12]
-// DSOARM-NEXT: 1060: b4 0f 00 00
+// DSOARM: $d:
+// DSOARM-NEXT: 1060: b4 0f 00 00 .word 0x00000fb4
// 0x1058 + 8 + 0fb4 = 0x2014
// DSOREL: Name: .got.plt
diff --git a/test/ELF/arm-tls-gd-nonpreemptible.s b/test/ELF/arm-tls-gd-nonpreemptible.s
new file mode 100644
index 000000000000..650c00800269
--- /dev/null
+++ b/test/ELF/arm-tls-gd-nonpreemptible.s
@@ -0,0 +1,72 @@
+// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
+// RUN: ld.lld %t -o %t2
+// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=armv7a-linux-gnueabi
+// RUN: llvm-objdump -s %t2 | FileCheck %s
+// RUN: ld.lld %t --shared -o %t3.so
+// RUN: llvm-objdump -s %t3.so | FileCheck -check-prefix=CHECK-SHARED %s
+// REQUIRES: arm
+
+// For an executable, we write the module index 1 and the offset into the TLS
+// directly into the GOT. For a shared library we can only write the offset
+// into the TLS directly if the symbol is non-preemptible
+
+ .text
+ .syntax unified
+ .globl __tls_get_addr
+ .type __tls_get_addr,%function
+__tls_get_addr:
+ bx lr
+
+ .globl _start
+ .p2align 2
+ .type _start,%function
+func:
+.L0:
+ nop
+.L1:
+ nop
+.L2:
+ nop
+.L3:
+ nop
+ .p2align 2
+// Generate R_ARM_TLS_GD32 relocations
+// These can be resolved at static link time for executables as 1 is always the
+// module index and the offset into tls is known at static link time
+.Lt0: .word x1(TLSGD) + (. - .L0 - 8)
+.Lt1: .word x2(TLSGD) + (. - .L1 - 8)
+.Lt2: .word x3(TLSGD) + (. - .L2 - 8)
+.Lt3: .word x4(TLSGD) + (. - .L3 - 8)
+ .hidden x1
+ .globl x1
+ .hidden x2
+ .globl x2
+ .globl x3
+ .globl x4
+
+ .section .tdata,"awT",%progbits
+ .p2align 2
+.TLSSTART:
+ .type x1, %object
+x1:
+ .word 10
+ .type x2, %object
+x2:
+ .word 20
+
+ .section .tbss,"awT",%nobits
+ .p2align 2
+ .type x3, %object
+x3:
+ .space 4
+ .type x4, %object
+x4:
+ .space 4
+
+// CHECK: Contents of section .got:
+// CHECK-NEXT: 12008 01000000 00000000 01000000 04000000
+// CHECK-NEXT: 12018 01000000 08000000 01000000 0c000000
+
+// CHECK-SHARED: Contents of section .got:
+// CHECK-SHARED-NEXT: 2050 00000000 00000000 00000000 04000000
+// CHECK-SHARED-NEXT: 2060 00000000 00000000 00000000 00000000
diff --git a/test/ELF/as-needed-no-reloc.s b/test/ELF/as-needed-no-reloc.s
index 9cbe25cf1767..68f03d782c24 100644
--- a/test/ELF/as-needed-no-reloc.s
+++ b/test/ELF/as-needed-no-reloc.s
@@ -16,7 +16,7 @@
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: Undefined
-# CHECK: NEEDED SharedLibrary (as-needed-no-reloc{{.*}}2.so)
+# CHECK: NEEDED SharedLibrary ({{.*}}as-needed-no-reloc{{.*}}2.so)
.globl _start
_start:
diff --git a/test/ELF/basic-aarch64.s b/test/ELF/basic-aarch64.s
index b68a2f9942a7..144fe6aee41b 100644
--- a/test/ELF/basic-aarch64.s
+++ b/test/ELF/basic-aarch64.s
@@ -81,7 +81,7 @@ _start:
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
# CHECK-NEXT: AddressAlignment: 1
-# CHECK-NEXT: EntrySize: 1
+# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: }
# CHECK-NEXT: Section {
# CHECK-NEXT: Index: 3
diff --git a/test/ELF/basic-mips.s b/test/ELF/basic-mips.s
index b143697ce0f8..4c7a66cf0050 100644
--- a/test/ELF/basic-mips.s
+++ b/test/ELF/basic-mips.s
@@ -164,7 +164,7 @@ __start:
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
# CHECK-NEXT: AddressAlignment: 1
-# CHECK-NEXT: EntrySize: 1
+# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: }
# CHECK-NEXT: Section {
# CHECK-NEXT: Index: 8
diff --git a/test/ELF/basic-ppc.s b/test/ELF/basic-ppc.s
index aae81fe2ac0e..4a36af99ed72 100644
--- a/test/ELF/basic-ppc.s
+++ b/test/ELF/basic-ppc.s
@@ -163,7 +163,7 @@
// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
// CHECK-NEXT: AddressAlignment: 1
-// CHECK-NEXT: EntrySize: 1
+// CHECK-NEXT: EntrySize: 0
// CHECK-NEXT: SectionData (
// CHECK-NEXT: 0000: 4C4C4420 312E3000 |LLD 1.0.|
// CHECK-NEXT: )
diff --git a/test/ELF/basic.s b/test/ELF/basic.s
index 93ef03f9cd81..c62a516c1bf6 100644
--- a/test/ELF/basic.s
+++ b/test/ELF/basic.s
@@ -83,7 +83,7 @@ _start:
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
# CHECK-NEXT: AddressAlignment: 1
-# CHECK-NEXT: EntrySize: 1
+# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: }
# CHECK-NEXT: Section {
# CHECK-NEXT: Index: 3
@@ -238,8 +238,9 @@ _start:
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: not ld.lld %t %t -o %t2 2>&1 | FileCheck --check-prefix=DUP %s
-# DUP: {{.*}}:(.text+0x0): duplicate symbol '_start'
-# DUP: {{.*}}:(.text+0x0): previous definition was here
+# DUP: duplicate symbol: _start
+# DUP-NEXT: >>> defined at {{.*}}:(.text+0x0)
+# DUP-NEXT: >>> defined at {{.*}}:(.text+0x0)
# RUN: not ld.lld %t -o %t -m wrong_emul_fbsd 2>&1 | FileCheck --check-prefix=UNKNOWN_EMUL %s
# UNKNOWN_EMUL: unknown emulation: wrong_emul_fbsd
diff --git a/test/ELF/basic32.s b/test/ELF/basic32.s
index e68ed73e637d..cbf67eec8b7d 100644
--- a/test/ELF/basic32.s
+++ b/test/ELF/basic32.s
@@ -80,7 +80,7 @@ _start:
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
# CHECK-NEXT: AddressAlignment: 1
-# CHECK-NEXT: EntrySize: 1
+# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: }
# CHECK-NEXT: Section {
# CHECK-NEXT: Index: 3
diff --git a/test/ELF/basic64be.s b/test/ELF/basic64be.s
index d16f4a074175..c39669bfd547 100644
--- a/test/ELF/basic64be.s
+++ b/test/ELF/basic64be.s
@@ -175,7 +175,7 @@ _start:
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
# CHECK-NEXT: AddressAlignment: 1
-# CHECK-NEXT: EntrySize: 1
+# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: SectionData (
# CHECK-NEXT: 0000: 4C4C4420 312E3000 |LLD 1.0.|
# CHECK-NEXT: )
diff --git a/test/ELF/bss-start-common.s b/test/ELF/bss-start-common.s
new file mode 100644
index 000000000000..cedf6a8668d4
--- /dev/null
+++ b/test/ELF/bss-start-common.s
@@ -0,0 +1,15 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: ld.lld %t -o %t2
+# RUN: llvm-objdump -t -section-headers %t2 | FileCheck %s
+
+# CHECK: Sections:
+# CHECK: Idx Name Size Address Type
+# CHECK: 2 .bss 00000004 0000000000201000 BSS
+# CHECK: SYMBOL TABLE:
+# CHECK: 0000000000201000 .bss 00000000 __bss_start
+
+.global __bss_start
+.text
+_start:
+.comm sym1,4,4
diff --git a/test/ELF/build-id.s b/test/ELF/build-id.s
index 51758d9eb24a..ffd8d7744f70 100644
--- a/test/ELF/build-id.s
+++ b/test/ELF/build-id.s
@@ -44,15 +44,15 @@ _start:
# DEFAULT: Contents of section .note.test:
# DEFAULT: Contents of section .note.gnu.build-id:
# DEFAULT-NEXT: 04000000 08000000 03000000 474e5500 ............GNU.
-# DEFAULT-NEXT: d08dafb4 e6294b62
+# DEFAULT-NEXT: fd36edb1 f6ff02af
# MD5: Contents of section .note.gnu.build-id:
# MD5-NEXT: 04000000 10000000 03000000 474e5500 ............GNU.
-# MD5-NEXT: 37
+# MD5-NEXT: fc
# SHA1: Contents of section .note.gnu.build-id:
# SHA1-NEXT: 04000000 14000000 03000000 474e5500 ............GNU.
-# SHA1-NEXT: 7a4f4eaf 69ceb948 4a7d6e51 2225e87c
+# SHA1-NEXT: 55b1eedb 03b588e1 09987d1d e9a79be7
# UUID: Contents of section .note.gnu.build-id:
# UUID-NEXT: 04000000 10000000 03000000 474e5500 ............GNU.
diff --git a/test/ELF/compatible-section-types.s b/test/ELF/compatible-section-types.s
new file mode 100644
index 000000000000..a5dadb867dc0
--- /dev/null
+++ b/test/ELF/compatible-section-types.s
@@ -0,0 +1,20 @@
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: ld.lld -shared %t.o -o %t
+// RUN: llvm-objdump -section-headers %t | FileCheck %s
+
+// CHECK: .foo {{0*}}28
+
+.section .foo, "aw", @progbits, unique, 1
+.quad 0
+
+.section .foo, "aw", @init_array, unique, 2
+.quad 0
+
+.section .foo, "aw", @preinit_array, unique, 3
+.quad 0
+
+.section .foo, "aw", @fini_array, unique, 4
+.quad 0
+
+.section .foo, "aw", @note, unique, 5
+.quad 0
diff --git a/test/ELF/compressed-debug-input.s b/test/ELF/compressed-debug-input.s
index 5104a102ba30..fbd5b02a07f0 100644
--- a/test/ELF/compressed-debug-input.s
+++ b/test/ELF/compressed-debug-input.s
@@ -59,7 +59,7 @@
# DATA-NEXT: Link: 0
# DATA-NEXT: Info: 0
# DATA-NEXT: AddressAlignment: 1
-# DATA-NEXT: EntrySize: 1
+# DATA-NEXT: EntrySize: 0
# DATA-NEXT: SectionData (
# DATA-NEXT: 0000: 73686F72 7420756E 7369676E 65642069 |short unsigned i|
# DATA-NEXT: 0010: 6E740075 6E736967 6E656420 696E7400 |nt.unsigned int.|
diff --git a/test/ELF/conflict.s b/test/ELF/conflict.s
index b9bb50515c5c..4318759cbc11 100644
--- a/test/ELF/conflict.s
+++ b/test/ELF/conflict.s
@@ -3,18 +3,22 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
# RUN: not ld.lld %t1.o %t1.o -o %t2 2>&1 | FileCheck -check-prefix=DEMANGLE %s
-# DEMANGLE: {{.*}}:(.text+0x0): duplicate symbol 'mul(double, double)'
-# DEMANGLE-NEXT: {{.*}}:(.text+0x0): previous definition was here
-# DEMANGLE-NEXT: {{.*}}:(.text+0x0): duplicate symbol 'foo'
-# DEMANGLE-NEXT: {{.*}}:(.text+0x0): previous definition was here
+# DEMANGLE: duplicate symbol: mul(double, double)
+# DEMANGLE-NEXT: >>> defined at {{.*}}:(.text+0x0)
+# DEMANGLE-NEXT: >>> defined at {{.*}}:(.text+0x0)
+# DEMANGLE: duplicate symbol: foo
+# DEMANGLE-NEXT: >>> defined at {{.*}}:(.text+0x0)
+# DEMANGLE-NEXT: >>> defined at {{.*}}:(.text+0x0)
# RUN: not ld.lld %t1.o %t1.o -o %t2 --no-demangle 2>&1 | \
# RUN: FileCheck -check-prefix=NO_DEMANGLE %s
-# NO_DEMANGLE: {{.*}}:(.text+0x0): duplicate symbol '_Z3muldd'
-# NO_DEMANGLE-NEXT: {{.*}}:(.text+0x0): previous definition was here
-# NO_DEMANGLE-NEXT: {{.*}}:(.text+0x0): duplicate symbol 'foo'
-# NO_DEMANGLE-NEXT: {{.*}}:(.text+0x0): previous definition was here
+# NO_DEMANGLE: duplicate symbol: _Z3muldd
+# NO_DEMANGLE-NEXT: >>> defined at {{.*}}:(.text+0x0)
+# NO_DEMANGLE-NEXT: >>> defined at {{.*}}:(.text+0x0)
+# NO_DEMANGLE: duplicate symbol: foo
+# NO_DEMANGLE-NEXT: >>> defined at {{.*}}:(.text+0x0)
+# NO_DEMANGLE-NEXT: >>> defined at {{.*}}:(.text+0x0)
# RUN: not ld.lld %t1.o %t1.o -o %t2 --demangle --no-demangle 2>&1 | \
# RUN: FileCheck -check-prefix=NO_DEMANGLE %s
@@ -25,14 +29,18 @@
# RUN: llvm-ar rcs %t3.a %t2.o
# RUN: not ld.lld %t1.o %t3.a -u baz -o %t2 2>&1 | FileCheck -check-prefix=ARCHIVE %s
-# ARCHIVE: {{.*}}3.a({{.*}}2.o):(.text+0x0): duplicate symbol 'foo'
-# ARCHIVE-NEXT: {{.*}}1.o:(.text+0x0): previous definition was here
+# ARCHIVE: duplicate symbol: foo
+# ARCHIVE-NEXT: >>> defined at {{.*}}:(.text+0x0)
+# ARCHIVE-NEXT: >>> defined at {{.*}}:(.text+0x0) in archive {{.*}}.a
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/conflict-debug.s -o %t-dbg.o
# RUN: not ld.lld %t-dbg.o %t-dbg.o -o %t-dbg 2>&1 | FileCheck -check-prefix=DBGINFO %s
-# DBGINFO: conflict-debug.s:4: duplicate symbol 'zed'
-# DBGINFO-NEXT: conflict-debug.s:4: previous definition was here
+# DBGINFO: duplicate symbol: zed
+# DBGINFO-NEXT: >>> defined at conflict-debug.s:4
+# DBGINFO-NEXT: >>> {{.*}}:(.text+0x0)
+# DBGINFO-NEXT: >>> defined at conflict-debug.s:4
+# DBGINFO-NEXT: >>> {{.*}}:(.text+0x0)
.globl _Z3muldd, foo
_Z3muldd:
diff --git a/test/ELF/copy-errors.s b/test/ELF/copy-errors.s
index b0d56c9c6c64..d0d6abdf68da 100644
--- a/test/ELF/copy-errors.s
+++ b/test/ELF/copy-errors.s
@@ -4,12 +4,12 @@
// RUN: ld.lld %t2.o -o %t2.so -shared
// RUN: not ld.lld %t.o %t2.so -o %t 2>&1 | FileCheck %s
+// CHECK: cannot preempt symbol: bar
+// CHECK: >>> defined in {{.*}}.so
+// CHECK: >>> referenced by {{.*}}.o:(.text+0x1)
+// CHECK: symbol 'zed' defined in {{.*}}.so has no type
+
.global _start
_start:
-
-
call bar
-// CHECK: {{.*}}.o:(.text+0x1): cannot preempt symbol 'bar' defined in {{.*}}.so
-
call zed
-// CHECK: symbol 'zed' defined in {{.*}}.so is missing type
diff --git a/test/ELF/copy-in-shared.s b/test/ELF/copy-in-shared.s
index b8e57ce9e703..1d77eaf3a141 100644
--- a/test/ELF/copy-in-shared.s
+++ b/test/ELF/copy-in-shared.s
@@ -4,7 +4,8 @@
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t2.o
// RUN: not ld.lld %t2.o %t1.so -o %t2.so -shared 2>&1 | FileCheck %s
+// CHECK: can't create dynamic relocation R_X86_64_64 against symbol: foo
+// CHECK: >>> defined in {{.*}}.so
+// CHECK: >>> referenced by {{.*}}.o:(.text+0x0)
.quad foo
-
-// CHECK: {{.*}}.o:(.text+0x0): can't create dynamic relocation R_X86_64_64 against symbol 'foo' defined in {{.*}}.so
diff --git a/test/ELF/copy-rel-pie-error.s b/test/ELF/copy-rel-pie-error.s
index 7cb6700ef9f3..6f7677e25e3a 100644
--- a/test/ELF/copy-rel-pie-error.s
+++ b/test/ELF/copy-rel-pie-error.s
@@ -3,8 +3,13 @@
// RUN: ld.lld %t2.o -o %t2.so -shared
// RUN: not ld.lld %t.o %t2.so -o %t.exe -pie 2>&1 | FileCheck %s
-// CHECK: {{.*}}.o:(.text+0x0): can't create dynamic relocation R_X86_64_64 against symbol 'bar' defined in {{.*}}.so
-// CHECK: {{.*}}.o:(.text+0x8): can't create dynamic relocation R_X86_64_64 against symbol 'foo' defined in {{.*}}.so
+// CHECK: can't create dynamic relocation R_X86_64_64 against symbol: bar
+// CHECK: >>> defined in {{.*}}.so
+// CHECK: >>> referenced by {{.*}}.o:(.text+0x0)
+
+// CHECK: can't create dynamic relocation R_X86_64_64 against symbol: foo
+// CHECK: >>> defined in {{.*}}.so
+// CHECK: >>> referenced by {{.*}}.o:(.text+0x8)
.global _start
_start:
diff --git a/test/ELF/default-fill.s b/test/ELF/default-fill.s
new file mode 100644
index 000000000000..4ea949567dcc
--- /dev/null
+++ b/test/ELF/default-fill.s
@@ -0,0 +1,38 @@
+# REQUIRES: x86
+# Verify that the fill between sections has a default of interrupt instructions
+# (0xcc on x86/x86_64) for executable sections and zero for other sections.
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
+# RUN: ld.lld %t1.o -o %t1.elf
+# RUN: llvm-objdump -s %t1.elf > %t1.sections
+# RUN: FileCheck %s --input-file %t1.sections --check-prefix=TEXT
+# RUN: FileCheck %s --input-file %t1.sections --check-prefix=DATA
+
+# RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %s -o %t2.o
+# RUN: ld.lld %t2.o -o %t2.elf
+# RUN: llvm-objdump -s %t2.elf > %t2.sections
+# RUN: FileCheck %s --input-file %t2.sections --check-prefix=TEXT
+# RUN: FileCheck %s --input-file %t2.sections --check-prefix=DATA
+
+# TEXT: Contents of section .text:
+# TEXT-NEXT: 11cccccc cccccccc cccccccc cccccccc
+# TEXT-NEXT: 22
+# DATA: Contents of section .data:
+# DATA-NEXT: 33000000 00000000 00000000 00000000
+# DATA-NEXT: 44
+
+.section .text.1,"ax",@progbits
+.align 16
+.byte 0x11
+
+.section .text.2,"ax",@progbits
+.align 16
+.byte 0x22
+
+.section .data.1,"a",@progbits
+.align 16
+.byte 0x33
+
+.section .data.2,"a",@progbits
+.align 16
+.byte 0x44
diff --git a/test/ELF/driver.test b/test/ELF/driver.test
index 80d19cb4d6a8..d876218130c3 100644
--- a/test/ELF/driver.test
+++ b/test/ELF/driver.test
@@ -11,13 +11,14 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: not ld.lld %t -o /no/such/file 2>&1 | FileCheck -check-prefix=MISSING %s
-# MISSING: failed to open /no/such/file
+# MISSING: cannot open output file /no/such/file
# RUN: ld.lld --help 2>&1 | FileCheck -check-prefix=HELP %s
# HELP: USAGE:
+# HELP: : supported targets:{{.*}} elf
# RUN: ld.lld --version 2>&1 | FileCheck -check-prefix=VERSION %s
-# VERSION: LLD
+# VERSION: LLD {{.*}} (compatible with GNU linkers)
# RUN: not ld.lld -v 2>&1 | FileCheck -check-prefix=VERSION %s
@@ -48,11 +49,11 @@
## "--output=foo" is equivalent to "-o foo".
# RUN: not ld.lld %t --output=/no/such/file 2>&1 | FileCheck -check-prefix=ERR7 %s
-# ERR7: failed to open /no/such/file
+# ERR7: cannot open output file /no/such/file
## "-output=foo" is equivalent to "-o utput=foo".
# RUN: not ld.lld %t -output=/no/such/file 2>&1 | FileCheck -check-prefix=ERR8 %s
-# ERR8: failed to open utput=/no/such/file
+# ERR8: cannot open output file utput=/no/such/file
.globl _start
_start:
diff --git a/test/ELF/dt_flags.s b/test/ELF/dt_flags.s
index a1d8d77433a5..431f83df7ab3 100644
--- a/test/ELF/dt_flags.s
+++ b/test/ELF/dt_flags.s
@@ -2,19 +2,19 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: ld.lld -shared %t -o %t.so
-# RUN: ld.lld -z now -z nodelete -z origin -Bsymbolic %t %t.so -o %t1
+# RUN: ld.lld -z now -z nodelete -z nodlopen -z origin -Bsymbolic %t %t.so -o %t1
# RUN: ld.lld %t %t.so -o %t2
# RUN: llvm-readobj -dynamic-table %t1 | FileCheck -check-prefix=FLAGS %s
# RUN: llvm-readobj -dynamic-table %t2 | FileCheck %s
# FLAGS: DynamicSection [
# FLAGS: 0x000000000000001E FLAGS ORIGIN SYMBOLIC BIND_NOW
-# FLAGS: 0x000000006FFFFFFB FLAGS_1 NOW NODELETE ORIGIN
+# FLAGS: 0x000000006FFFFFFB FLAGS_1 NOW NODELETE NOOPEN ORIGIN
# FLAGS: ]
# CHECK: DynamicSection [
# CHECK-NOT: 0x000000000000001E FLAGS ORIGIN SYMBOLIC BIND_NOW
-# CHECK-NOT: 0x000000006FFFFFFB FLAGS_1 NOW NODELETE ORIGIN
+# CHECK-NOT: 0x000000006FFFFFFB FLAGS_1 NOW NODELETE NOOPEN ORIGIN
# CHECK: ]
.globl _start
diff --git a/test/ELF/dynamic-list.s b/test/ELF/dynamic-list.s
index e2472e716b3f..7cd587380e59 100644
--- a/test/ELF/dynamic-list.s
+++ b/test/ELF/dynamic-list.s
@@ -51,6 +51,10 @@
# RUN: echo "{ foo1; foo2; foo31; };" > %t.list
# RUN: ld.lld --dynamic-list %t.list %t %t2.so -o %t.exe
# RUN: llvm-readobj -dyn-symbols %t.exe | FileCheck -check-prefix=CHECK2 %s
+# RUN: echo "{ foo1; foo2; };" > %t1.list
+# RUN: echo "{ foo31; };" > %t2.list
+# RUN: ld.lld --dynamic-list %t1.list --dynamic-list %t2.list %t %t2.so -o %t.exe
+# RUN: llvm-readobj -dyn-symbols %t.exe | FileCheck -check-prefix=CHECK2 %s
# CHECK2: DynamicSymbols [
# CHECK2-NEXT: Symbol {
@@ -91,6 +95,65 @@
# CHECK2-NEXT: }
# CHECK2-NEXT: ]
+
+## --export-dynamic overrides --dynamic-list, i.e. --export-dynamic with an
+## incomplete dynamic-list still exports everything.
+# RUN: echo "{ foo2; };" > %t.list
+# RUN: ld.lld --dynamic-list %t.list --export-dynamic %t %t2.so -o %t.exe
+# RUN: llvm-readobj -dyn-symbols %t.exe | FileCheck -check-prefix=CHECK3 %s
+
+## The same with --export-dynamic-symbol.
+# RUN: ld.lld --export-dynamic-symbol=foo2 --export-dynamic %t %t2.so -o %t.exe
+# RUN: llvm-readobj -dyn-symbols %t.exe | FileCheck -check-prefix=CHECK3 %s
+
+# CHECK3: DynamicSymbols [
+# CHECK3-NEXT: Symbol {
+# CHECK3-NEXT: Name: @
+# CHECK3-NEXT: Value: 0x0
+# CHECK3-NEXT: Size: 0
+# CHECK3-NEXT: Binding: Local
+# CHECK3-NEXT: Type: None
+# CHECK3-NEXT: Other: 0
+# CHECK3-NEXT: Section: Undefined
+# CHECK3-NEXT: }
+# CHECK3-NEXT: Symbol {
+# CHECK3-NEXT: Name: _start@
+# CHECK3-NEXT: Value: 0x201003
+# CHECK3-NEXT: Size: 0
+# CHECK3-NEXT: Binding: Global (0x1)
+# CHECK3-NEXT: Type: None (0x0)
+# CHECK3-NEXT: Other: 0
+# CHECK3-NEXT: Section: .text (0x4)
+# CHECK3-NEXT: }
+# CHECK3-NEXT: Symbol {
+# CHECK3-NEXT: Name: foo1@
+# CHECK3-NEXT: Value: 0x201000
+# CHECK3-NEXT: Size: 0
+# CHECK3-NEXT: Binding: Global (0x1)
+# CHECK3-NEXT: Type: None (0x0)
+# CHECK3-NEXT: Other: 0
+# CHECK3-NEXT: Section: .text (0x4)
+# CHECK3-NEXT: }
+# CHECK3-NEXT: Symbol {
+# CHECK3-NEXT: Name: foo2@
+# CHECK3-NEXT: Value: 0x201001
+# CHECK3-NEXT: Size: 0
+# CHECK3-NEXT: Binding: Global (0x1)
+# CHECK3-NEXT: Type: None (0x0)
+# CHECK3-NEXT: Other: 0
+# CHECK3-NEXT: Section: .text (0x4)
+# CHECK3-NEXT: }
+# CHECK3-NEXT: Symbol {
+# CHECK3-NEXT: Name: foo31@
+# CHECK3-NEXT: Value: 0x201002
+# CHECK3-NEXT: Size: 0
+# CHECK3-NEXT: Binding: Global (0x1)
+# CHECK3-NEXT: Type: None (0x0)
+# CHECK3-NEXT: Other: 0
+# CHECK3-NEXT: Section: .text (0x4)
+# CHECK3-NEXT: }
+# CHECK3-NEXT: ]
+
.globl foo1
foo1:
ret
diff --git a/test/ELF/dynamic-reloc-in-ro.s b/test/ELF/dynamic-reloc-in-ro.s
index 682dbdd8984e..23b068ff839f 100644
--- a/test/ELF/dynamic-reloc-in-ro.s
+++ b/test/ELF/dynamic-reloc-in-ro.s
@@ -2,7 +2,9 @@
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
// RUN: not ld.lld %t.o -o %t.so -shared 2>&1 | FileCheck %s
+// CHECK: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment
+// CHECK: >>> defined in {{.*}}.o
+// CHECK: >>> referenced by {{.*}}.o:(.text+0x0)
+
foo:
.quad foo
-
-// CHECK: {{.*}}.o:(.text+0x0): can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment defined in {{.*}}.o
diff --git a/test/ELF/early-exit-for-bad-paths.s b/test/ELF/early-exit-for-bad-paths.s
new file mode 100644
index 000000000000..03462f51da03
--- /dev/null
+++ b/test/ELF/early-exit-for-bad-paths.s
@@ -0,0 +1,35 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+
+# RUN: not ld.lld %t.o -o does_not_exist/output 2>&1 | \
+# RUN: FileCheck %s -check-prefixes=NO-DIR-OUTPUT,CHECK
+# RUN: not ld.lld %t.o -o %s/dir_is_a_file 2>&1 | \
+# RUN: FileCheck %s -check-prefixes=DIR-IS-OUTPUT,CHECK
+
+# RUN: echo "OUTPUT(\"does_not_exist/output\")" > %t.script
+# RUN: not ld.lld %t.o %t.script 2>&1 | \
+# RUN: FileCheck %s -check-prefixes=NO-DIR-OUTPUT,CHECK
+# RUN: echo "OUTPUT(\"%s/dir_is_a_file\")" > %t.script
+# RUN: not ld.lld %t.o %t.script 2>&1 | \
+# RUN: FileCheck %s -check-prefixes=DIR-IS-OUTPUT,CHECK
+
+# RUN: not ld.lld %t.o -o %t -Map=does_not_exist/output 2>&1 | \
+# RUN: FileCheck %s -check-prefixes=NO-DIR-MAP,CHECK
+# RUN: not ld.lld %t.o -o %t -Map=%s/dir_is_a_file 2>&1 | \
+# RUN: FileCheck %s -check-prefixes=DIR-IS-MAP,CHECK
+
+# NO-DIR-OUTPUT: error: cannot open output file does_not_exist/output:
+# DIR-IS-OUTPUT: error: cannot open output file {{.*}}/dir_is_a_file:
+# NO-DIR-MAP: error: cannot open map file does_not_exist/output:
+# DIR-IS-MAP: error: cannot open map file {{.*}}/dir_is_a_file:
+
+# We should exit before doing the actual link. If an undefined symbol error is
+# discovered we haven't bailed out early as expected.
+# CHECK-NOT: undefined_symbol
+
+# RUN: not ld.lld %t.o -o / 2>&1 | FileCheck %s -check-prefixes=ROOT,CHECK
+# ROOT: error: cannot open output file /
+
+ .globl _start
+_start:
+ call undefined_symbol
diff --git a/test/ELF/edata-etext.s b/test/ELF/edata-etext.s
index 7723adf94e23..3b0ba49ad1af 100644
--- a/test/ELF/edata-etext.s
+++ b/test/ELF/edata-etext.s
@@ -18,9 +18,9 @@
# CHECK-NEXT: 3 .bss 00000006 0000000000202004 BSS
# CHECK: SYMBOL TABLE:
# CHECK-NEXT: 0000000000000000 *UND* 00000000
-# CHECK-NEXT: 0000000000202002 *ABS* 00000000 _edata
-# CHECK-NEXT: 000000000020200a *ABS* 00000000 _end
-# CHECK-NEXT: 0000000000201001 *ABS* 00000000 _etext
+# CHECK-NEXT: 0000000000202002 .data 00000000 _edata
+# CHECK-NEXT: 000000000020200a .data 00000000 _end
+# CHECK-NEXT: 0000000000201001 .text 00000000 _etext
# CHECK-NEXT: 0000000000201000 .text 00000000 _start
# RUN: ld.lld -r %t.o -o %t2
diff --git a/test/ELF/eh-frame-dyn-rel.s b/test/ELF/eh-frame-dyn-rel.s
index 91baf597c723..289e6c0150d2 100644
--- a/test/ELF/eh-frame-dyn-rel.s
+++ b/test/ELF/eh-frame-dyn-rel.s
@@ -2,9 +2,11 @@
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
// RUN: not ld.lld %t.o %t.o -o %t -shared 2>&1 | FileCheck %s
- .section bar,"axG",@progbits,foo,comdat
- .cfi_startproc
- .cfi_personality 0x8c, foo
- .cfi_endproc
+// CHECK: can't create dynamic relocation R_X86_64_64 against symbol: foo
+// CHECK: >>> defined in {{.*}}.o
+// CHECK: >>> referenced by {{.*}}.o:(.eh_frame+0x12)
-// CHECK: {{.*}}.o:(.eh_frame+0x12): can't create dynamic relocation R_X86_64_64 against symbol 'foo' defined in {{.*}}.o
+.section bar,"axG",@progbits,foo,comdat
+.cfi_startproc
+.cfi_personality 0x8c, foo
+.cfi_endproc
diff --git a/test/ELF/ehdr_start.s b/test/ELF/ehdr_start.s
index 9172feca5e9c..32bcf4b84751 100644
--- a/test/ELF/ehdr_start.s
+++ b/test/ELF/ehdr_start.s
@@ -2,8 +2,16 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
# RUN: ld.lld %t.o -o %t
-# RUN: llvm-objdump -t %t | FileCheck %s
-# CHECK: 0000000000200040 *ABS* 00000000 .hidden __ehdr_start
+# RUN: llvm-readobj -symbols %t | FileCheck %s
+# CHECK: Name: __ehdr_start (1)
+# CHECK-NEXT: Value: 0x200000
+# CHECK-NEXT: Size: 0
+# CHECK-NEXT: Binding: Local (0x0)
+# CHECK-NEXT: Type: None (0x0)
+# CHECK-NEXT: Other [ (0x2)
+# CHECK-NEXT: STV_HIDDEN (0x2)
+# CHECK-NEXT: ]
+# CHECK-NEXT: Section: .text (0x1)
.text
.global _start, __ehdr_start
@@ -11,6 +19,12 @@ _start:
.quad __ehdr_start
# RUN: ld.lld -r %t.o -o %t.r
-# RUN: llvm-objdump -t %t.r | FileCheck %s --check-prefix=RELOCATABLE
+# RUN: llvm-readobj -symbols %t.r | FileCheck %s --check-prefix=RELOCATABLE
-# RELOCATABLE: 0000000000000000 *UND* 00000000 __ehdr_start
+# RELOCATABLE: Name: __ehdr_start (1)
+# RELOCATABLE-NEXT: Value: 0x0
+# RELOCATABLE-NEXT: Size: 0
+# RELOCATABLE-NEXT: Binding: Global (0x1)
+# RELOCATABLE-NEXT: Type: None (0x0)
+# RELOCATABLE-NEXT: Other: 0
+# RELOCATABLE-NEXT: Section: Undefined (0x0)
diff --git a/test/ELF/emit-relocs-merge.s b/test/ELF/emit-relocs-merge.s
new file mode 100644
index 000000000000..3fecca23b735
--- /dev/null
+++ b/test/ELF/emit-relocs-merge.s
@@ -0,0 +1,20 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld --emit-relocs %t.o -o %t.so -shared
+# RUN: llvm-readobj -r %t.so | FileCheck %s
+
+# CHECK: Relocations [
+# CHECK-NEXT: Section ({{.*}}) .rela.dyn {
+# CHECK-NEXT: 0x1000 R_X86_64_64 zed 0x0
+# CHECK-NEXT: 0x1008 R_X86_64_64 zed 0x0
+# CHECK-NEXT: }
+# CHECK-NEXT: Section ({{.*}}) .rela.data {
+# CHECK-NEXT: 0x1000 R_X86_64_64 zed 0x0
+# CHECK-NEXT: 0x1008 R_X86_64_64 zed 0x0
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
+
+.section .data.foo,"aw",%progbits
+.quad zed
+.section .data.bar,"aw",%progbits
+.quad zed
diff --git a/test/ELF/emit-relocs-shared.s b/test/ELF/emit-relocs-shared.s
new file mode 100644
index 000000000000..7a0d7911831b
--- /dev/null
+++ b/test/ELF/emit-relocs-shared.s
@@ -0,0 +1,16 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld --emit-relocs %t.o -o %t.so -shared
+# RUN: llvm-readobj -r %t.so | FileCheck %s
+
+.data
+.quad foo
+
+# CHECK: Relocations [
+# CHECK-NEXT: Section (4) .rela.dyn {
+# CHECK-NEXT: 0x1000 R_X86_64_64 foo 0x0
+# CHECK-NEXT: }
+# CHECK-NEXT: Section (8) .rela.data {
+# CHECK-NEXT: 0x1000 R_X86_64_64 foo 0x0
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
diff --git a/test/ELF/emit-relocs.s b/test/ELF/emit-relocs.s
new file mode 100644
index 000000000000..dfe20589e97b
--- /dev/null
+++ b/test/ELF/emit-relocs.s
@@ -0,0 +1,99 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
+# RUN: ld.lld --emit-relocs %t1.o -o %t
+# RUN: llvm-readobj -t -r %t | FileCheck %s
+
+## Check single dash form.
+# RUN: ld.lld -emit-relocs %t1.o -o %t1
+# RUN: llvm-readobj -t -r %t1 | FileCheck %s
+
+## Check alias.
+# RUN: ld.lld -q %t1.o -o %t2
+# RUN: llvm-readobj -t -r %t2 | FileCheck %s
+
+# CHECK: Relocations [
+# CHECK-NEXT: Section ({{.*}}) .rela.text {
+# CHECK-NEXT: 0x201002 R_X86_64_32 .text 0x1
+# CHECK-NEXT: 0x201007 R_X86_64_PLT32 fn 0xFFFFFFFFFFFFFFFC
+# CHECK-NEXT: 0x20100E R_X86_64_32 .text 0xD
+# CHECK-NEXT: 0x201013 R_X86_64_PLT32 fn2 0xFFFFFFFFFFFFFFFC
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
+# CHECK-NEXT: Symbols [
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name:
+# CHECK-NEXT: Value: 0x0
+# CHECK-NEXT: Size: 0
+# CHECK-NEXT: Binding: Local
+# CHECK-NEXT: Type: None
+# CHECK-NEXT: Other: 0
+# CHECK-NEXT: Section: Undefined
+# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name: bar
+# CHECK-NEXT: Value: 0x201001
+# CHECK-NEXT: Size: 0
+# CHECK-NEXT: Binding: Local
+# CHECK-NEXT: Type: None
+# CHECK-NEXT: Other: 0
+# CHECK-NEXT: Section: .text
+# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name: foo
+# CHECK-NEXT: Value: 0x20100D
+# CHECK-NEXT: Size: 0
+# CHECK-NEXT: Binding: Local
+# CHECK-NEXT: Type: None
+# CHECK-NEXT: Other: 0
+# CHECK-NEXT: Section: .text
+# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name:
+# CHECK-NEXT: Value: 0x201000
+# CHECK-NEXT: Size: 0
+# CHECK-NEXT: Binding: Local
+# CHECK-NEXT: Type: Section
+# CHECK-NEXT: Other: 0
+# CHECK-NEXT: Section: .text
+# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name: fn
+# CHECK-NEXT: Value: 0x201000
+# CHECK-NEXT: Size: 0
+# CHECK-NEXT: Binding: Global
+# CHECK-NEXT: Type: Function
+# CHECK-NEXT: Other: 0
+# CHECK-NEXT: Section: .text
+# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name: fn2
+# CHECK-NEXT: Value: 0x20100C
+# CHECK-NEXT: Size: 0
+# CHECK-NEXT: Binding: Global
+# CHECK-NEXT: Type: Function
+# CHECK-NEXT: Other: 0
+# CHECK-NEXT: Section: .text
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
+
+.section .text,"ax",@progbits,unique,0
+.globl fn
+.type fn,@function
+fn:
+ nop
+
+bar:
+ movl $bar, %edx
+ callq fn@PLT
+ nop
+
+.section .text,"ax",@progbits,unique,1
+.globl fn2
+.type fn2,@function
+fn2:
+ nop
+
+foo:
+ movl $foo, %edx
+ callq fn2@PLT
+ nop
diff --git a/test/ELF/emulation.s b/test/ELF/emulation.s
index a54faeaa832a..05efd0b94cb2 100644
--- a/test/ELF/emulation.s
+++ b/test/ELF/emulation.s
@@ -274,7 +274,8 @@
# MIPSEL-NEXT: EF_MIPS_CPIC
# MIPSEL-NEXT: ]
-# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %tmips64
+# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux -position-independent \
+# RUN: %s -o %tmips64
# RUN: ld.lld -m elf64btsmip -e _start %tmips64 -o %t2mips64
# RUN: llvm-readobj -file-headers %t2mips64 | FileCheck --check-prefix=MIPS64 %s
# RUN: ld.lld %tmips64 -e _start -o %t3mips64
@@ -301,7 +302,8 @@
# MIPS64-NEXT: EF_MIPS_PIC
# MIPS64-NEXT: ]
-# RUN: llvm-mc -filetype=obj -triple=mips64el-unknown-linux %s -o %tmips64el
+# RUN: llvm-mc -filetype=obj -triple=mips64el-unknown-linux \
+# RUN: -position-independent %s -o %tmips64el
# RUN: ld.lld -m elf64ltsmip -e _start %tmips64el -o %t2mips64el
# RUN: llvm-readobj -file-headers %t2mips64el | FileCheck --check-prefix=MIPS64EL %s
# RUN: ld.lld %tmips64el -e _start -o %t3mips64el
diff --git a/test/ELF/end-abs.s b/test/ELF/end-abs.s
new file mode 100644
index 000000000000..2199ce23ad04
--- /dev/null
+++ b/test/ELF/end-abs.s
@@ -0,0 +1,11 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld %t.o -o %t -pie
+# RUN: llvm-readobj -r %t | FileCheck %s
+
+# CHECK: Relocations [
+# CHECK-NEXT: ]
+
+.global _start
+_start:
+.long _end - .
diff --git a/test/ELF/gc-debuginfo-tls.s b/test/ELF/gc-debuginfo-tls.s
index 9884a578cca9..d1a250b9c944 100644
--- a/test/ELF/gc-debuginfo-tls.s
+++ b/test/ELF/gc-debuginfo-tls.s
@@ -4,15 +4,15 @@
# RUN: llvm-readobj -symbols %t1 | FileCheck %s --check-prefix=GC
# RUN: llvm-readobj -symbols %t2 | FileCheck %s --check-prefix=NOGC
-# NOGC: Symbol {
-# NOGC: Name: .tbss
-# NOGC: Value: 0x1000
-# NOGC: Size: 0
-# NOGC: Binding: Local
-# NOGC: Type: TLS
-# NOGC: Other: 0
-# NOGC: Section: .tbss
-# NOGC: }
+# NOGC: Symbol {
+# NOGC: Name: patatino
+# NOGC-NEXT: Value: 0x0
+# NOGC-NEXT: Size: 0
+# NOGC-NEXT: Binding: Local
+# NOGC-NEXT: Type: TLS
+# NOGC-NEXT: Other: 0
+# NOGC-NEXT: Section: .tbss
+# NOGC-NEXT: }
# GC-NOT: tbss
diff --git a/test/ELF/gc-merge-local-sym.s b/test/ELF/gc-merge-local-sym.s
index b02a3a4e4762..a4540af4d9cc 100644
--- a/test/ELF/gc-merge-local-sym.s
+++ b/test/ELF/gc-merge-local-sym.s
@@ -15,7 +15,7 @@
// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
// CHECK-NEXT: AddressAlignment: 1
-// CHECK-NEXT: EntrySize: 1
+// CHECK-NEXT: EntrySize: 0
// CHECK-NEXT: SectionData (
// CHECK-NEXT: 0000: 61626300 |abc.|
// CHECK-NEXT: )
diff --git a/test/ELF/gc-sections-merge-addend.s b/test/ELF/gc-sections-merge-addend.s
index 8595f5802be5..1c1f6ee2389b 100644
--- a/test/ELF/gc-sections-merge-addend.s
+++ b/test/ELF/gc-sections-merge-addend.s
@@ -16,7 +16,7 @@
// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
// CHECK-NEXT: AddressAlignment: 1
-// CHECK-NEXT: EntrySize: 1
+// CHECK-NEXT: EntrySize: 0
// CHECK-NEXT: SectionData (
// CHECK-NEXT: 0000: 62617200 |bar.|
// CHECK-NEXT: )
diff --git a/test/ELF/gc-sections-merge-implicit-addend.s b/test/ELF/gc-sections-merge-implicit-addend.s
index 8a7c804a830a..c725e294a187 100644
--- a/test/ELF/gc-sections-merge-implicit-addend.s
+++ b/test/ELF/gc-sections-merge-implicit-addend.s
@@ -16,7 +16,7 @@
// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
// CHECK-NEXT: AddressAlignment: 1
-// CHECK-NEXT: EntrySize: 1
+// CHECK-NEXT: EntrySize: 0
// CHECK-NEXT: SectionData (
// CHECK-NEXT: 0000: 62617200 |bar.|
// CHECK-NEXT: )
diff --git a/test/ELF/gc-sections-merge.s b/test/ELF/gc-sections-merge.s
index ef2688659871..d7b3eaeca751 100644
--- a/test/ELF/gc-sections-merge.s
+++ b/test/ELF/gc-sections-merge.s
@@ -18,7 +18,7 @@
// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
// CHECK-NEXT: AddressAlignment: 1
-// CHECK-NEXT: EntrySize: 1
+// CHECK-NEXT: EntrySize: 0
// CHECK-NEXT: SectionData (
// CHECK-NEXT: 0000: 666F6F00 62617200 |foo.bar.|
// CHECK-NEXT: )
@@ -36,7 +36,7 @@
// GC-NEXT: Link: 0
// GC-NEXT: Info: 0
// GC-NEXT: AddressAlignment: 1
-// GC-NEXT: EntrySize: 1
+// GC-NEXT: EntrySize: 0
// GC-NEXT: SectionData (
// GC-NEXT: 0000: 666F6F00 |foo.|
// GC-NEXT: )
diff --git a/test/ELF/gc-sections-metadata-startstop.s b/test/ELF/gc-sections-metadata-startstop.s
new file mode 100644
index 000000000000..10c0b5477b25
--- /dev/null
+++ b/test/ELF/gc-sections-metadata-startstop.s
@@ -0,0 +1,33 @@
+# LINK_ORDER cnamed sections are not kept alive by the __start_* reference.
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld --gc-sections %t.o -o %t
+# RUN: llvm-objdump -section-headers -t %t | FileCheck %s
+
+# CHECK: Sections:
+# CHECK-NOT: yy
+# CHECK: xx {{.*}} DATA
+# CHECK-NOT: yy
+
+# CHECK: SYMBOL TABLE:
+# CHECK: xx 00000000 __start_xx
+# CHECK: w *UND* 00000000 __start_yy
+
+.weak __start_xx
+.weak __start_yy
+
+.global _start
+_start:
+.quad __start_xx
+.quad __start_yy
+
+.section xx,"a"
+.quad 0
+
+.section .foo,"a"
+.quad 0
+
+.section yy,"ao",@progbits,.foo
+.quad 0
+
diff --git a/test/ELF/gc-sections-metadata.s b/test/ELF/gc-sections-metadata.s
new file mode 100644
index 000000000000..2e696f8752bd
--- /dev/null
+++ b/test/ELF/gc-sections-metadata.s
@@ -0,0 +1,38 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld --gc-sections %t.o -o %t
+# RUN: llvm-objdump -section-headers %t | FileCheck %s
+
+# CHECK: 1 .foo1
+# CHECK-NEXT: bar1
+# CHECK-NEXT: .zed1
+# CHECK-NEXT: .text
+# CHECK-NEXT: .comment
+# CHECK-NEXT: .symtab
+# CHECK-NEXT: .shstrtab
+# CHECK-NEXT: .strtab
+
+.global _start
+_start:
+.quad .foo1
+
+.section .foo1,"a"
+.quad 0
+
+.section .foo2,"a"
+.quad 0
+
+.section bar1,"ao",@progbits,.foo1
+.quad .zed1
+.quad .foo1
+
+.section bar2,"ao",@progbits,.foo2
+.quad .zed2
+.quad .foo2
+
+.section .zed1,"a"
+.quad 0
+
+.section .zed2,"a"
+.quad 0
diff --git a/test/ELF/gc-sections-metadata2.s b/test/ELF/gc-sections-metadata2.s
new file mode 100644
index 000000000000..3a3b640b280a
--- /dev/null
+++ b/test/ELF/gc-sections-metadata2.s
@@ -0,0 +1,19 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld --gc-sections %t.o -o %t
+# RUN: llvm-objdump -section-headers %t | FileCheck %s
+
+# CHECK: .foo
+# CHECK: .bar
+# CHECK: .zed
+
+.globl _start
+_start:
+.quad .foo
+
+.section .foo,"a"
+.quad 0
+.section .bar,"ao",@progbits,.foo
+.quad 0
+.section .zed,"ao",@progbits,.foo
+.quad 0
diff --git a/test/ELF/gnu-hash-table.s b/test/ELF/gnu-hash-table.s
index 4e845998f167..0e37574aaa7c 100644
--- a/test/ELF/gnu-hash-table.s
+++ b/test/ELF/gnu-hash-table.s
@@ -56,7 +56,7 @@
# I386-NEXT: Link:
# I386-NEXT: Info: 0
# I386-NEXT: AddressAlignment: 4
-# I386-NEXT: EntrySize: 4
+# I386-NEXT: EntrySize: 0
# I386: ]
# I386: DynamicSymbols [
# I386: Symbol {
diff --git a/test/ELF/gnustack.s b/test/ELF/gnustack.s
index 6fc937354e69..c506fb807c62 100644
--- a/test/ELF/gnustack.s
+++ b/test/ELF/gnustack.s
@@ -5,26 +5,30 @@
# RUN: ld.lld %t1 -o %t
# RUN: llvm-readobj --program-headers -s %t | FileCheck --check-prefix=RW %s
-# RW: Sections [
-# RW-NOT: Name: .note.GNU-stack
-# RW: ProgramHeaders [
-# RW: ProgramHeader {
-# RW: Type: PT_GNU_STACK
-# RW-NEXT: Offset: 0x0
-# RW-NEXT: VirtualAddress: 0x0
-# RW-NEXT: PhysicalAddress: 0x0
-# RW-NEXT: FileSize: 0
-# RW-NEXT: MemSize: 0
-# RW-NEXT: Flags [
-# RW-NEXT: PF_R
-# RW-NEXT: PF_W
-# RW-NEXT: ]
-# RW-NEXT: Alignment: 0
-# RW-NEXT: }
+# RW: Type: PT_GNU_STACK
+# RW-NEXT: Offset: 0x0
+# RW-NEXT: VirtualAddress: 0x0
+# RW-NEXT: PhysicalAddress: 0x0
+# RW-NEXT: FileSize: 0
+# RW-NEXT: MemSize: 0
+# RW-NEXT: Flags [
+# RW-NEXT: PF_R
+# RW-NEXT: PF_W
# RW-NEXT: ]
+# RW-NEXT: Alignment: 0
-# RWX-NOT: Name: .note.GNU-stack
-# RWX-NOT: Type: PT_GNU_STACK
+# RWX: Type: PT_GNU_STACK
+# RWX-NEXT: Offset: 0x0
+# RWX-NEXT: VirtualAddress: 0x0
+# RWX-NEXT: PhysicalAddress: 0x0
+# RWX-NEXT: FileSize: 0
+# RWX-NEXT: MemSize: 0
+# RWX-NEXT: Flags [
+# RWX-NEXT: PF_R
+# RWX-NEXT: PF_W
+# RWX-NEXT: PF_X
+# RWX-NEXT: ]
+# RWX-NEXT: Alignment: 0
.globl _start
_start:
diff --git a/test/ELF/got32-i386.s b/test/ELF/got32-i386.s
new file mode 100644
index 000000000000..468aaf1f0d53
--- /dev/null
+++ b/test/ELF/got32-i386.s
@@ -0,0 +1,23 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o
+# RUN: ld.lld %t.o -o %t
+# RUN: llvm-objdump -section-headers -d %t | FileCheck %s
+
+## We have R_386_GOT32 relocation here.
+.globl foo
+.type foo, @function
+foo:
+ nop
+
+_start:
+ movl foo@GOT, %ebx
+
+## 73728 == 0x12000 == ADDR(.got)
+# CHECK: _start:
+# CHECK-NEXT: 11001: 8b 1d {{.*}} movl 73728, %ebx
+# CHECK: Sections:
+# CHECK: Name Size Address
+# CHECK: .got 00000004 0000000000012000
+
+# RUN: not ld.lld %t.o -o %t -pie 2>&1 | FileCheck %s --check-prefix=ERR
+# ERR: relocation R_386_GOT32 against 'foo' without base register can not be used when PIC enabled
diff --git a/test/ELF/got32x-i386.s b/test/ELF/got32x-i386.s
new file mode 100644
index 000000000000..9a67d1997f2b
--- /dev/null
+++ b/test/ELF/got32x-i386.s
@@ -0,0 +1,47 @@
+# REQUIRES: x86
+
+## i386-got32x-baseless.elf is a file produced using GNU as v.2.27
+## using following code and command line:
+## (as --32 -o base.o base.s)
+##
+## .text
+## .globl foo
+## .type foo, @function
+## foo:
+## nop
+##
+## _start:
+## movl foo@GOT, %eax
+## movl foo@GOT, %ebx
+## movl foo@GOT(%eax), %eax
+## movl foo@GOT(%ebx), %eax
+##
+## Result file contains four R_386_GOT32X relocations. Generated code
+## is also a four mov instructions. And first two has no base register:
+## <_start>:
+## 1: 8b 05 00 00 00 00 mov 0x0,%eax
+## 7: 8b 1d 00 00 00 00 mov 0x0,%ebx
+## d: 8b 80 00 00 00 00 mov 0x0(%eax),%eax
+## 13: 8b 83 00 00 00 00 mov 0x0(%ebx),%eax
+##
+## R_386_GOT32X is computed as G + A - GOT, but if it used without base
+## register, it should be calculated as G + A. Using without base register
+## is only allowed for non-PIC code.
+##
+# RUN: ld.lld %S/Inputs/i386-got32x-baseless.elf -o %t1
+# RUN: llvm-objdump -section-headers -d %t1 | FileCheck %s
+
+## 73728 == 0x12000 == ADDR(.got)
+# CHECK: _start:
+# CHECK-NEXT: 11001: 8b 05 {{.*}} movl 73728, %eax
+# CHECK-NEXT: 11007: 8b 1d {{.*}} movl 73728, %ebx
+# CHECK-NEXT: 1100d: 8b 80 {{.*}} movl -4(%eax), %eax
+# CHECK-NEXT: 11013: 8b 83 {{.*}} movl -4(%ebx), %eax
+# CHECK: Sections:
+# CHECK: Name Size Address
+# CHECK: .got 00000004 0000000000012000
+
+# RUN: not ld.lld %S/Inputs/i386-got32x-baseless.elf -o %t1 -pie 2>&1 | \
+# RUN: FileCheck %s --check-prefix=ERR
+# ERR: relocation R_386_GOT32X against 'foo' without base register can not be used when PIC enabled
+# ERR: relocation R_386_GOT32X against 'foo' without base register can not be used when PIC enabled
diff --git a/test/ELF/hidden-vis-shared.s b/test/ELF/hidden-vis-shared.s
new file mode 100644
index 000000000000..f3fa206895a3
--- /dev/null
+++ b/test/ELF/hidden-vis-shared.s
@@ -0,0 +1,18 @@
+// REQUIRES: x86
+
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/shared.s -o %t2.o
+// RUN: ld.lld -shared %t2.o -o %t2.so
+// RUN: ld.lld %t.o %t2.so -o %t
+// RUN: llvm-readobj -r %t | FileCheck %s
+// RUN: ld.lld %t2.so %t.o -o %t
+// RUN: llvm-readobj -r %t | FileCheck %s
+
+// CHECK: Relocations [
+// CHECK-NEXT: ]
+
+.global _start
+_start:
+callq bar
+.hidden bar
+.weak bar
diff --git a/test/ELF/i386-pc16.test b/test/ELF/i386-pc16.test
index 46c54ebb1510..14f8b501d083 100644
--- a/test/ELF/i386-pc16.test
+++ b/test/ELF/i386-pc16.test
@@ -1,11 +1,11 @@
# REQUIRES: x86
# RUN: yaml2obj %s -o %t.o
-# RUN: ld.lld %t.o -o %t.exe
+# RUN: ld.lld -Ttext 0x0 %t.o -o %t.exe
# RUN: llvm-objdump -s -section=.text %t.exe 2>&1 | FileCheck %s
# CHECK: Contents of section .text:
-# CHECK-NEXT: 11000 56441111 52341111
+# CHECK-NEXT: 0000 45231111 41231111
!ELF
FileHeader:
@@ -36,5 +36,5 @@ Symbols:
- Name: _start
Type: STT_FUNC
Section: .text
- Value: 0x12345
+ Value: 0x1234
Size: 4
diff --git a/test/ELF/i386-pc8-pc16-addend.s b/test/ELF/i386-pc8-pc16-addend.s
new file mode 100644
index 000000000000..9d6424df3600
--- /dev/null
+++ b/test/ELF/i386-pc8-pc16-addend.s
@@ -0,0 +1,17 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=i386-pc-linux-gnu %s -o %t1.o
+
+# RUN: ld.lld %t1.o -o %t.out
+# RUN: llvm-objdump -s -t %t.out | FileCheck %s
+# CHECK: Contents of section .text:
+# CHECK-NEXT: 11000 020000
+## 0x11003 - 0x11000 + addend(-1) = 0x02
+## 0x11003 - 0x11001 + addend(-2) = 0x0000
+# CHECK: SYMBOL TABLE:
+# CHECK: 00011003 .und
+
+.byte und-.-1
+.short und-.-2
+
+.section .und, "ax"
+und:
diff --git a/test/ELF/i386-pc8.s b/test/ELF/i386-pc8.s
new file mode 100644
index 000000000000..65cbd21ccb62
--- /dev/null
+++ b/test/ELF/i386-pc8.s
@@ -0,0 +1,15 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=i386-pc-linux-gnu %s -o %t1.o
+# RUN: ld.lld -Ttext 0x0 %t1.o -o %t.out
+# RUN: llvm-objdump -s -section=.text %t.out | FileCheck %s
+
+# CHECK: Contents of section .text:
+# CHECK-NEXT: 0000 15253748
+
+.byte und-.+0x11
+.byte und-.+0x22
+.byte und+0x33
+.byte und+0x44
+
+.section .und, "ax"
+und:
diff --git a/test/ELF/i386-reloc-16.s b/test/ELF/i386-reloc-16.s
new file mode 100644
index 000000000000..db9dc0b36908
--- /dev/null
+++ b/test/ELF/i386-reloc-16.s
@@ -0,0 +1,14 @@
+// REQUIRES: x86
+
+// RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %S/Inputs/x86-64-reloc-16.s -o %t1
+// RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %S/Inputs/x86-64-reloc-16-error.s -o %t2
+// RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %s -o %t
+// RUN: ld.lld -shared %t %t1 -o %t3
+
+// CHECK: Contents of section .text:
+// CHECK-NEXT: 200000 42
+
+// RUN: not ld.lld -shared %t %t2 -o %t4 2>&1 | FileCheck --check-prefix=ERROR %s
+// ERROR: relocation R_386_16 out of range
+
+.short foo
diff --git a/test/ELF/i386-reloc-8.s b/test/ELF/i386-reloc-8.s
new file mode 100644
index 000000000000..b2e4426910e6
--- /dev/null
+++ b/test/ELF/i386-reloc-8.s
@@ -0,0 +1,14 @@
+// REQUIRES: x86
+
+// RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %S/Inputs/i386-reloc-8.s -o %t1
+// RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %S/Inputs/i386-reloc-8-error.s -o %t2
+// RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %s -o %t
+// RUN: ld.lld -shared %t %t1 -o %t3
+
+// CHECK: Contents of section .text:
+// CHECK-NEXT: 200000 42
+
+// RUN: not ld.lld -shared %t %t2 -o %t4 2>&1 | FileCheck --check-prefix=ERROR %s
+// ERROR: relocation R_386_8 out of range
+
+.byte foo
diff --git a/test/ELF/i386-reloc8-reloc16-addend.s b/test/ELF/i386-reloc8-reloc16-addend.s
new file mode 100644
index 000000000000..42a57cedbca3
--- /dev/null
+++ b/test/ELF/i386-reloc8-reloc16-addend.s
@@ -0,0 +1,17 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=i386-pc-linux-gnu %s -o %t1.o
+
+# RUN: ld.lld -Ttext=0x0 %t1.o -o %t.out
+# RUN: llvm-objdump -s -t %t.out | FileCheck %s
+# CHECK: Contents of section .text:
+# CHECK-NEXT: 0000 020100
+## 0x3 + addend(-1) = 0x02
+## 0x3 + addend(-2) = 0x0100
+# CHECK: SYMBOL TABLE:
+# CHECK: 00000003 .und
+
+.byte und-1
+.short und-2
+
+.section .und, "ax"
+und:
diff --git a/test/ELF/icf-absolute.s b/test/ELF/icf-absolute.s
new file mode 100644
index 000000000000..601322477dae
--- /dev/null
+++ b/test/ELF/icf-absolute.s
@@ -0,0 +1,20 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-absolute.s -o %t2
+# RUN: ld.lld %t %t2 -o %t3 --icf=all --verbose | FileCheck %s
+
+# CHECK: selected .text.f1
+# CHECK: removed .text.f2
+
+.globl _start, f1, f2
+_start:
+ ret
+
+.section .text.f1, "ax"
+f1:
+ .byte a1
+
+.section .text.f2, "ax"
+f2:
+ .byte a2
diff --git a/test/ELF/icf8.s b/test/ELF/icf8.s
new file mode 100644
index 000000000000..51163eab69ef
--- /dev/null
+++ b/test/ELF/icf8.s
@@ -0,0 +1,14 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld %t.o -o %t.so --icf=all -shared
+# RUN: llvm-objdump -t %t.so | FileCheck %s
+
+# CHECK: zed
+
+ .section .foo,"ax",@progbits
+ nop
+
+ .section .bar,"ax",@progbits
+zed:
+ nop
diff --git a/test/ELF/icf9.s b/test/ELF/icf9.s
new file mode 100644
index 000000000000..c5a532915cc7
--- /dev/null
+++ b/test/ELF/icf9.s
@@ -0,0 +1,20 @@
+# REQUIRES: x86
+
+### Make sure that we do not merge data.
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: ld.lld %t -o %t2 --icf=all --verbose | FileCheck %s
+
+# CHECK-NOT: selected .data.d1
+# CHECK-NOT: selected .data.d2
+
+.globl _start, d1, d2
+_start:
+ ret
+
+.section .data.f1, "a"
+d1:
+ .byte 1
+
+.section .data.f2, "a"
+d2:
+ .byte 1
diff --git a/test/ELF/incompatible-section-types.s b/test/ELF/incompatible-section-types.s
deleted file mode 100644
index 3cc168c2646c..000000000000
--- a/test/ELF/incompatible-section-types.s
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-// RUN: not ld.lld -shared %t.o -o %t 2>&1 | FileCheck %s
-
-// CHECK: error: Section has different type from others with the same name {{.*}}incompatible-section-types.s.tmp.o:(.foo)
-
-.section .foo, "aw", @progbits, unique, 1
-.quad 0
-
-.section .foo, "aw", @init_array, unique, 2
-.quad 0
diff --git a/test/ELF/init-fini-progbits.s b/test/ELF/init-fini-progbits.s
new file mode 100644
index 000000000000..a8749446f702
--- /dev/null
+++ b/test/ELF/init-fini-progbits.s
@@ -0,0 +1,19 @@
+// REQUIRES: x86
+
+// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+// RUN: ld.lld %t -o %t.exe
+// RUN: llvm-readobj -sections %t.exe | FileCheck %s
+
+// CHECK: Name: .init_array
+// CHECK-NEXT: Type: SHT_INIT_ARRAY
+// CHECK: Name: .fini_array
+// CHECK-NEXT: Type: SHT_FINI_ARRAY
+
+.globl _start
+_start:
+ nop
+
+.section .init_array.100, "aw", @progbits
+ .byte 0
+.section .fini_array.100, "aw", @progbits
+ .byte 0
diff --git a/test/ELF/invalid-cie-length.s b/test/ELF/invalid-cie-length.s
index e5ba27cf4616..c6da95e609d6 100644
--- a/test/ELF/invalid-cie-length.s
+++ b/test/ELF/invalid-cie-length.s
@@ -3,7 +3,8 @@
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
// RUN: not ld.lld %t -o %t2 2>&1 | FileCheck %s
- .section .eh_frame
- .byte 0
+.section .eh_frame
+.byte 0
-// CHECK: {{.*}}:(.eh_frame+0x0): CIE/FDE too small
+// CHECK: error: corrupted .eh_frame: CIE/FDE too small
+// CHECK-NEXT: >>> defined in {{.*}}:(.eh_frame+0x0)
diff --git a/test/ELF/invalid-cie-length2.s b/test/ELF/invalid-cie-length2.s
index 4aea66952134..9140280ba5a7 100644
--- a/test/ELF/invalid-cie-length2.s
+++ b/test/ELF/invalid-cie-length2.s
@@ -3,7 +3,8 @@
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
// RUN: not ld.lld %t -o %t2 2>&1 | FileCheck %s
- .section .eh_frame
- .long 42
+.section .eh_frame
+.long 42
-// CHECK: {{.*}}:(.eh_frame+0x0): CIE/FDE ends past the end of the section
+// CHECK: error: corrupted .eh_frame: CIE/FDE ends past the end of the section
+// CHECK-NEXT: >>> defined in {{.*}}:(.eh_frame+0x0)
diff --git a/test/ELF/invalid-cie-length3.s b/test/ELF/invalid-cie-length3.s
index ebd2690a9d98..fcbfa7f52ba8 100644
--- a/test/ELF/invalid-cie-length3.s
+++ b/test/ELF/invalid-cie-length3.s
@@ -3,7 +3,9 @@
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
// RUN: not ld.lld %t -o %t2 2>&1 | FileCheck %s
- .section .eh_frame
- .long 0xFFFFFFFC
+.section .eh_frame
+.long 0xFFFFFFFC
+
+// CHECK: error: corrupted .eh_frame: CIE/FDE ends past the end of the section
+// CHECK-NEXT: >>> defined in {{.*}}:(.eh_frame+0x0)
-// CHECK: {{.*}}:(.eh_frame+0x0): CIE/FDE ends past the end of the section
diff --git a/test/ELF/invalid-cie-length4.s b/test/ELF/invalid-cie-length4.s
index 8c7cc00dfcaf..04f8eb2cca6b 100644
--- a/test/ELF/invalid-cie-length4.s
+++ b/test/ELF/invalid-cie-length4.s
@@ -3,8 +3,9 @@
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
// RUN: not ld.lld %t -o %t2 2>&1 | FileCheck %s
- .section .eh_frame
- .long 0xFFFFFFFF
- .byte 0
+.section .eh_frame
+.long 0xFFFFFFFF
+.byte 0
-// CHECK: {{.*}}:(.eh_frame+0x0): CIE/FDE too large
+// CHECK: error: corrupted .eh_frame: CIE/FDE too large
+// CHECK-NEXT: >>> defined in {{.*}}:(.eh_frame+0x0)
diff --git a/test/ELF/invalid-fde-rel.s b/test/ELF/invalid-fde-rel.s
index 9fb73d2158de..f43b9da30033 100644
--- a/test/ELF/invalid-fde-rel.s
+++ b/test/ELF/invalid-fde-rel.s
@@ -1,7 +1,11 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
-// RUN: not ld.lld %t -o %t2 2>&1 | FileCheck %s
+// RUN: ld.lld %t -o %t2
+// RUN: llvm-objdump -h %t2 | FileCheck %s
+
+// This resembles what gold -r produces when it discards the section
+// the fde points to.
.section .eh_frame
.long 0x14
@@ -29,4 +33,4 @@
.long 0x0
.long 0x0
-// CHECK: FDE doesn't reference another section
+// CHECK: 1 .eh_frame 00000018
diff --git a/test/ELF/invalid-linkerscript.test b/test/ELF/invalid-linkerscript.test
index 3316becce1dc..280686eff41b 100644
--- a/test/ELF/invalid-linkerscript.test
+++ b/test/ELF/invalid-linkerscript.test
@@ -50,5 +50,5 @@
# RUN: echo "OUTPUT_FORMAT(x y z)" > %t8
# RUN: not ld.lld %t8 no-such-file 2>&1 | FileCheck -check-prefix=ERR8 %s
-# ERR8: unexpected token: y
+# ERR8: , expected, but got y
# ERR8: cannot open no-such-file:
diff --git a/test/ELF/invalid/broken-relaxation-x64.s b/test/ELF/invalid/broken-relaxation-x64.test
index 10d4655847d5..10d4655847d5 100644
--- a/test/ELF/invalid/broken-relaxation-x64.s
+++ b/test/ELF/invalid/broken-relaxation-x64.test
diff --git a/test/ELF/invalid/dynamic-section-size.s b/test/ELF/invalid/dynamic-section-size.s
index 7d12904801e4..323dabaa9016 100644
--- a/test/ELF/invalid/dynamic-section-size.s
+++ b/test/ELF/invalid/dynamic-section-size.s
@@ -1,4 +1,4 @@
## dynamic-section-sh_size.elf has incorrect sh_size of dynamic section.
# RUN: not ld.lld %p/Inputs/dynamic-section-sh_size.elf -o %t2 2>&1 | \
# RUN: FileCheck %s
-# CHECK: getSectionContentsAsArray failed: Invalid data was encountered while parsing the file
+# CHECK: error: {{.*}}: invalid sh_entsize
diff --git a/test/ELF/invalid/invalid-relocation-x64.s b/test/ELF/invalid/invalid-relocation-x64.test
index 4934874bf167..d52cf87c1b35 100644
--- a/test/ELF/invalid/invalid-relocation-x64.s
+++ b/test/ELF/invalid/invalid-relocation-x64.test
@@ -26,5 +26,5 @@ Sections:
Type: R_X86_64_NONE
# RUN: not ld.lld %p/Inputs/invalid-relocation-x64.elf -o %t2 2>&1 | FileCheck %s
-# CHECK: do not know how to handle relocation 'Unknown' (152)
-# CHECK: do not know how to handle relocation 'Unknown' (153)
+# CHECK: {{.*}}invalid-relocation-x64.elf: unknown relocation type: Unknown (152)
+# CHECK: {{.*}}invalid-relocation-x64.elf: unknown relocation type: Unknown (153)
diff --git a/test/ELF/invalid/mips-invalid-options-descriptor.s b/test/ELF/invalid/mips-invalid-options-descriptor.s
index b47bd9037cc5..b23ecee6d0d2 100644
--- a/test/ELF/invalid/mips-invalid-options-descriptor.s
+++ b/test/ELF/invalid/mips-invalid-options-descriptor.s
@@ -2,4 +2,4 @@
## .MIPS.options with size of zero.
# RUN: not ld.lld %p/Inputs/mips-invalid-options-descriptor.elf -o %t2 2>&1 | \
# RUN: FileCheck %s
-# CHECK: error: invalid section offset
+# CHECK: error: {{.*}}: invalid section offset
diff --git a/test/ELF/libsearch.s b/test/ELF/libsearch.s
index 20783c5b6465..32be866a66a9 100644
--- a/test/ELF/libsearch.s
+++ b/test/ELF/libsearch.s
@@ -22,7 +22,8 @@
// Should not link because of undefined symbol _bar
// RUN: not ld.lld -o %t3 %t.o %tbar.o 2>&1 \
// RUN: | FileCheck --check-prefix=UNDEFINED %s
-// UNDEFINED: error: {{.*}}:(.bar+0x0): undefined symbol '_bar'
+// UNDEFINED: error: undefined symbol: _bar
+// UNDEFINED: >>> referenced by {{.*}}:(.bar+0x0)
// Should fail if cannot find specified library (without -L switch)
// RUN: not ld.lld -o %t3 %t.o -lls 2>&1 \
diff --git a/test/ELF/linkerscript/Inputs/lazy-symbols.s b/test/ELF/linkerscript/Inputs/lazy-symbols.s
new file mode 100644
index 000000000000..dd28fcbd5255
--- /dev/null
+++ b/test/ELF/linkerscript/Inputs/lazy-symbols.s
@@ -0,0 +1,2 @@
+.globl foo
+foo:
diff --git a/test/ELF/linkerscript/absolute.s b/test/ELF/linkerscript/absolute.s
index e4b156e2f012..54f1c7037d23 100644
--- a/test/ELF/linkerscript/absolute.s
+++ b/test/ELF/linkerscript/absolute.s
@@ -4,6 +4,11 @@
# RUN: ld.lld -o %t --script %t.script %t.o
# RUN: llvm-readobj --symbols %t | FileCheck %s
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: echo "PROVIDE(foo = 1 + ABSOLUTE(ADDR(.text)));" > %t.script
+# RUN: ld.lld -o %t --script %t.script %t.o
+# RUN: llvm-readobj --symbols %t | FileCheck --check-prefix=CHECK-RHS %s
+
# CHECK: Name: foo
# CHECK-NEXT: Value:
# CHECK-NEXT: Size:
@@ -13,6 +18,18 @@
# CHECK-NEXT: Section: Absolute
# CHECK-NEXT: }
+# CHECK-RHS: Name: foo
+# CHECK-RHS-NEXT: Value: 0x201001
+# CHECK-RHS-NEXT: Size:
+# CHECK-RHS-NEXT: Binding:
+# CHECK-RHS-NEXT: Type:
+# CHECK-RHS-NEXT: Other:
+# CHECK-RHS-NEXT: Section: Absolute
+# CHECK-RHS-NEXT: }
+
.text
.globl _start
_start:
+ nop
+
+.global foo
diff --git a/test/ELF/linkerscript/addr-zero.s b/test/ELF/linkerscript/addr-zero.s
new file mode 100644
index 000000000000..71251d3acfff
--- /dev/null
+++ b/test/ELF/linkerscript/addr-zero.s
@@ -0,0 +1,18 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: echo "SECTIONS { foo = ADDR(.text) - ABSOLUTE(ADDR(.text)); };" > %t.script
+# RUN: ld.lld -o %t.so --script %t.script %t.o -shared
+# RUN: llvm-readobj --symbols %t.so | FileCheck %s
+
+# Test that the script creates a non absolute symbol with value
+# 0 I.E., a symbol that refers to the load address.
+
+# CHECK: Symbol {
+# CHECK: Name: foo
+# CHECK-NEXT: Value: 0x0
+# CHECK-NEXT: Size: 0
+# CHECK-NEXT: Binding: Global
+# CHECK-NEXT: Type: None
+# CHECK-NEXT: Other: 0
+# CHECK-NEXT: Section: .text
+# CHECK-NEXT: }
diff --git a/test/ELF/linkerscript/align.s b/test/ELF/linkerscript/align.s
index 1e50fed3fa83..ffeb1acbd027 100644
--- a/test/ELF/linkerscript/align.s
+++ b/test/ELF/linkerscript/align.s
@@ -2,43 +2,25 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
## Check that ALIGN command workable using location counter
-# RUN: echo "SECTIONS { \
-# RUN: . = 0x10000; \
-# RUN: .aaa : \
-# RUN: { \
-# RUN: *(.aaa) \
-# RUN: } \
-# RUN: . = ALIGN(4096); \
-# RUN: .bbb : \
-# RUN: { \
-# RUN: *(.bbb) \
-# RUN: } \
+# RUN: echo "SECTIONS { \
+# RUN: . = 0x10000; \
+# RUN: .aaa : { *(.aaa) } \
+# RUN: . = ALIGN(4096); \
+# RUN: .bbb : { *(.bbb) } \
# RUN: . = ALIGN(4096 * 4); \
-# RUN: .ccc : \
-# RUN: { \
-# RUN: *(.ccc) \
-# RUN: } \
+# RUN: .ccc : { *(.ccc) } \
# RUN: }" > %t.script
# RUN: ld.lld -o %t1 --script %t.script %t
# RUN: llvm-objdump -section-headers %t1 | FileCheck %s
## Check that the two argument version of ALIGN command works
-# RUN: echo "SECTIONS { \
+# RUN: echo "SECTIONS { \
# RUN: . = ALIGN(0x1234, 0x10000); \
-# RUN: .aaa : \
-# RUN: { \
-# RUN: *(.aaa) \
-# RUN: } \
-# RUN: . = ALIGN(., 4096); \
-# RUN: .bbb : \
-# RUN: { \
-# RUN: *(.bbb) \
-# RUN: } \
-# RUN: . = ALIGN(., 4096 * 4); \
-# RUN: .ccc : \
-# RUN: { \
-# RUN: *(.ccc) \
-# RUN: } \
+# RUN: .aaa : { *(.aaa) } \
+# RUN: . = ALIGN(., 4096); \
+# RUN: .bbb : { *(.bbb) } \
+# RUN: . = ALIGN(., 4096 * 4); \
+# RUN: .ccc : { *(.ccc) } \
# RUN: }" > %t.script
# RUN: ld.lld -o %t1 --script %t.script %t
# RUN: llvm-objdump -section-headers %t1 | FileCheck %s
@@ -51,23 +33,38 @@
# CHECK-NEXT: 3 .ccc 00000008 0000000000014000 DATA
## Check output sections ALIGN modificator
-# RUN: echo "SECTIONS { \
-# RUN: . = 0x10000; \
-# RUN: .aaa : \
-# RUN: { \
-# RUN: *(.aaa) \
-# RUN: } \
-# RUN: .bbb : ALIGN(4096) \
-# RUN: { \
-# RUN: *(.bbb) \
-# RUN: } \
-# RUN: .ccc : ALIGN(4096 * 4) \
-# RUN: { \
-# RUN: *(.ccc) \
-# RUN: } \
+# RUN: echo "SECTIONS { \
+# RUN: . = 0x10000; \
+# RUN: .aaa : { *(.aaa) } \
+# RUN: .bbb : ALIGN(4096) { *(.bbb) } \
+# RUN: .ccc : ALIGN(4096 * 4) { *(.ccc) } \
# RUN: }" > %t2.script
# RUN: ld.lld -o %t2 --script %t2.script %t
-# RUN: llvm-objdump -section-headers %t1 | FileCheck %s
+# RUN: llvm-objdump -section-headers %t2 | FileCheck %s
+
+## Check use of variables in align expressions:
+# RUN: echo "VAR = 0x1000; \
+# RUN: __code_base__ = 0x10000; \
+# RUN: SECTIONS { \
+# RUN: . = __code_base__; \
+# RUN: .aaa : { *(.aaa) } \
+# RUN: .bbb : ALIGN(VAR) { *(.bbb) } \
+# RUN: . = ALIGN(., VAR * 4); \
+# RUN: .ccc : { *(.ccc) } \
+# RUN: __start_bbb = ADDR(.bbb); \
+# RUN: __end_bbb = ALIGN(__start_bbb + SIZEOF(.bbb), VAR); \
+# RUN: }" > %t3.script
+# RUN: ld.lld -o %t3 --script %t3.script %t
+# RUN: llvm-objdump -section-headers %t3 | FileCheck %s
+# RUN: llvm-objdump -t %t3 | FileCheck -check-prefix SYMBOLS %s
+
+# SYMBOLS-LABEL: SYMBOL TABLE:
+# SYMBOLS-NEXT: 0000000000000000 *UND* 00000000
+# SYMBOLS-NEXT: 0000000000014008 .text 00000000 _start
+# SYMBOLS-NEXT: 0000000000010000 *ABS* 00000000 __code_base__
+# SYMBOLS-NEXT: 0000000000001000 *ABS* 00000000 VAR
+# SYMBOLS-NEXT: 0000000000011000 .bbb 00000000 __start_bbb
+# SYMBOLS-NEXT: 0000000000012000 *ABS* 00000000 __end_bbb
.global _start
_start:
diff --git a/test/ELF/linkerscript/alternate-sections.s b/test/ELF/linkerscript/alternate-sections.s
index 6d3004af9a80..fd74a8a967f3 100644
--- a/test/ELF/linkerscript/alternate-sections.s
+++ b/test/ELF/linkerscript/alternate-sections.s
@@ -4,25 +4,27 @@
# RUN: ld.lld -o %t --script %t.script %t.o -shared
# RUN: llvm-readobj -s -section-data %t | FileCheck %s
-# This test shows an oddity in lld. When a linker script alternates among
-# different types of output section in the same command, the sections are
-# reordered.
-# In this test we go from regular, to merge and back to regular. The reason
-# for the reordering is that we need two create two output sections and
-# one cannot be in the middle of another.
-# If this ever becomes a problem, some options would be:
-# * Adding an extra layer in between input section and output sections (Chunk).
-# With that this example would have 3 chunks, but only one output section.
-# This would unfortunately complicate the non-script case too.
-# * Just create three output sections.
-# * If having three output sections causes problem, have linkerscript specific
-# code to write the section table and section indexes. That way we could
-# keep 3 sections internally but not expose that.
-
-# CHECK: Name: abc
-# CHECK: 0000: 01000000 00000000 02000000 00000000 |
-# CHECK: Name: abc
-# CHECK: 0000: 61626331 323300 |abc123.|
+# CHECK: Section {
+# CHECK: Index:
+# CHECK: Name: abc
+# CHECK-NEXT: Type: SHT_PROGBIT
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: SHF_ALLOC
+# CHECK-NEXT: SHF_MERGE
+# CHECK-NEXT: SHF_STRINGS
+# CHECK-NEXT: ]
+# CHECK-NEXT: Address:
+# CHECK-NEXT: Offset:
+# CHECK-NEXT: Size:
+# CHECK-NEXT: Link:
+# CHECK-NEXT: Info:
+# CHECK-NEXT: AddressAlignment:
+# CHECK-NEXT: EntrySize:
+# CHECK-NEXT: SectionData (
+# CHECK-NEXT: 0000: 01000000 00000000 61626331 32330002 |........abc123..|
+# CHECK-NEXT: 0010: 00000000 000000 |.......|
+# CHECK-NEXT: )
+# CHECK-NEXT: }
.section foo, "a"
.quad 1
diff --git a/test/ELF/linkerscript/assert.s b/test/ELF/linkerscript/assert.s
index 06eeaeec3b99..73cc940669b9 100644
--- a/test/ELF/linkerscript/assert.s
+++ b/test/ELF/linkerscript/assert.s
@@ -5,10 +5,6 @@
# RUN: ld.lld -shared -o %t1 --script %t1.script %t1.o
# RUN: llvm-readobj %t1 > /dev/null
-# RUN: echo "SECTIONS { ASSERT(ASSERT(42, fail) == 42, fail) }" > %t2.script
-# RUN: ld.lld -shared -o %t2 --script %t2.script %t1.o
-# RUN: llvm-readobj %t2 > /dev/null
-
# RUN: echo "SECTIONS { ASSERT(0, fail) }" > %t3.script
# RUN: not ld.lld -shared -o %t3 --script %t3.script %t1.o > %t.log 2>&1
# RUN: FileCheck %s -check-prefix=FAIL < %t.log
diff --git a/test/ELF/linkerscript/at-addr.s b/test/ELF/linkerscript/at-addr.s
new file mode 100644
index 000000000000..0eddf3d9e3fb
--- /dev/null
+++ b/test/ELF/linkerscript/at-addr.s
@@ -0,0 +1,39 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: echo "SECTIONS { . = 0x1000; \
+# RUN: .aaa : AT(ADDR(.aaa) - 0x500) { *(.aaa) } \
+# RUN: .bbb : AT(ADDR(.bbb) - 0x500) { *(.bbb) } \
+# RUN: .ccc : AT(ADDR(.ccc) - 0x500) { *(.ccc) } \
+# RUN: }" > %t.script
+# RUN: ld.lld %t --script %t.script -o %t2
+# RUN: llvm-readobj -program-headers %t2 | FileCheck %s
+
+# CHECK: Type: PT_LOAD
+# CHECK-NEXT: Offset: 0x0
+# CHECK-NEXT: VirtualAddress: 0x0
+# CHECK-NEXT: PhysicalAddress: 0x0
+# CHECK: Type: PT_LOAD
+# CHECK-NEXT: Offset: 0x1000
+# CHECK-NEXT: VirtualAddress: 0x1000
+# CHECK-NEXT: PhysicalAddress: 0xB00
+# CHECK: Type: PT_LOAD
+# CHECK-NEXT: Offset: 0x1008
+# CHECK-NEXT: VirtualAddress: 0x1008
+# CHECK-NEXT: PhysicalAddress: 0xB08
+# CHECK: Type: PT_LOAD
+# CHECK-NEXT: Offset: 0x1010
+# CHECK-NEXT: VirtualAddress: 0x1010
+# CHECK-NEXT: PhysicalAddress: 0xB10
+
+.global _start
+_start:
+ nop
+
+.section .aaa, "a"
+.quad 0
+
+.section .bbb, "a"
+.quad 0
+
+.section .ccc, "a"
+.quad 0
diff --git a/test/ELF/linkerscript/at.s b/test/ELF/linkerscript/at.s
index a6b6198710ea..26441f1ffd9e 100644
--- a/test/ELF/linkerscript/at.s
+++ b/test/ELF/linkerscript/at.s
@@ -2,22 +2,11 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: echo "SECTIONS { \
# RUN: . = 0x1000; \
-# RUN: .aaa : AT(0x2000) \
-# RUN: { \
-# RUN: *(.aaa) \
-# RUN: } \
-# RUN: .bbb : \
-# RUN: { \
-# RUN: *(.bbb) \
-# RUN: } \
-# RUN: .ccc : AT(0x3000) \
-# RUN: { \
-# RUN: *(.ccc) \
-# RUN: } \
-# RUN: .ddd : AT(0x4000) \
-# RUN: { \
-# RUN: *(.ddd) \
-# RUN: } \
+# RUN: .aaa : AT(0x2000) { *(.aaa) } \
+# RUN: .bbb : { *(.bbb) } \
+# RUN: .ccc : AT(0x3000) { *(.ccc) } \
+# RUN: .ddd : AT(0x4000) { *(.ddd) } \
+# RUN: .eee 0x5000 : AT(0x5000) { *(.eee) } \
# RUN: }" > %t.script
# RUN: ld.lld %t --script %t.script -o %t2
# RUN: llvm-readobj -program-headers %t2 | FileCheck %s
@@ -79,6 +68,19 @@
# CHECK-NEXT: Offset: 0x1018
# CHECK-NEXT: VirtualAddress: 0x1018
# CHECK-NEXT: PhysicalAddress: 0x4000
+# CHECK-NEXT: FileSize: 8
+# CHECK-NEXT: MemSize: 8
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: PF_R
+# CHECK-NEXT: PF_X
+# CHECK-NEXT: ]
+# CHECK-NEXT: Alignment: 4096
+# CHECK-NEXT: }
+# CHECK-NEXT: ProgramHeader {
+# CHECK-NEXT: Type: PT_LOAD
+# CHECK-NEXT: Offset: 0x2000
+# CHECK-NEXT: VirtualAddress: 0x5000
+# CHECK-NEXT: PhysicalAddress: 0x5000
# CHECK-NEXT: FileSize: 9
# CHECK-NEXT: MemSize: 9
# CHECK-NEXT: Flags [
@@ -117,3 +119,6 @@ _start:
.section .ddd, "a"
.quad 0
+
+.section .eee, "a"
+.quad 0
diff --git a/test/ELF/linkerscript/constructor.s b/test/ELF/linkerscript/constructor.s
new file mode 100644
index 000000000000..acb86fd88e27
--- /dev/null
+++ b/test/ELF/linkerscript/constructor.s
@@ -0,0 +1,13 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: echo "SECTIONS { foo : { *(.foo) CONSTRUCTORS } }" > %t.script
+# RUN: ld.lld -o %t1 --script %t.script %t.o
+
+# RUN: llvm-objdump -section-headers %t1 | FileCheck %s
+# CHECK: Sections:
+# CHECK-NEXT: Idx Name Size
+# CHECK-NEXT: 0 00000000
+# CHECK-NEXT: 1 foo 00000001
+
+.section foo, "a"
+.byte 0
diff --git a/test/ELF/linkerscript/discard-print-gc.s b/test/ELF/linkerscript/discard-print-gc.s
new file mode 100644
index 000000000000..2a230e53dc2b
--- /dev/null
+++ b/test/ELF/linkerscript/discard-print-gc.s
@@ -0,0 +1,19 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -triple x86_64-pc-linux %s -o %t.o -filetype=obj
+# RUN: ld.lld -o %t.so --gc-sections %t.o --print-gc-sections -shared 2>&1 | \
+# RUN: FileCheck -check-prefix=CHECK %s
+
+# RUN: echo "SECTIONS { /DISCARD/ : { *(.foo) } }" > %t.script
+# RUN: ld.lld -o %t.so -T %t.script %t.o --print-gc-sections -shared 2>&1 | \
+# RUN: FileCheck -check-prefix=QUIET --allow-empty %s
+
+# RUN: echo "SECTIONS { .foo : { *(.foo) } }" > %t2.script
+# RUN: ld.lld -o %t.so -T %t2.script --gc-sections %t.o --print-gc-sections -shared 2>&1 | \
+# RUN: FileCheck -check-prefix=CHECK %s
+
+.section .foo,"a"
+.quad 0
+
+# CHECK: removing unused section from '.foo'
+# QUIET-NOT: removing unused section from '.foo'
diff --git a/test/ELF/linkerscript/discard-section-metadata.s b/test/ELF/linkerscript/discard-section-metadata.s
new file mode 100644
index 000000000000..961615d51c98
--- /dev/null
+++ b/test/ELF/linkerscript/discard-section-metadata.s
@@ -0,0 +1,32 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: echo "SECTIONS { /DISCARD/ : { *(.foo) } }" > %t.script
+# RUN: ld.lld -o %t1 --script %t.script %t
+# RUN: llvm-objdump -section-headers %t1 | FileCheck %s
+
+# CHECK-NOT: .foo
+# CHECK-NOT: .bar
+# CHECK-NOT: .zed
+# CHECK-NOT: .moo
+
+## Sections dependency tree for testcase is:
+## (.foo)
+## | |
+## | --(.bar)
+## |
+## --(.zed)
+## |
+## --(.moo)
+##
+
+.section .foo,"a"
+.quad 0
+
+.section .bar,"ao",@progbits,.foo
+.quad 0
+
+.section .zed,"ao",@progbits,.foo
+.quad 0
+
+.section .moo,"ao",@progbits,.zed
+.quad 0
diff --git a/test/ELF/linkerscript/edata-etext.s b/test/ELF/linkerscript/edata-etext.s
index fdf5ec1f5671..ab723ce1316e 100644
--- a/test/ELF/linkerscript/edata-etext.s
+++ b/test/ELF/linkerscript/edata-etext.s
@@ -2,9 +2,12 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: echo "SECTIONS { }" > %t.script
# RUN: not ld.lld %t.o -script %t.script -o %t 2>&1 | FileCheck %s
-# CHECK: error: {{.*}}:(.text+0x0): undefined symbol '_edata'
-# CHECK: error: {{.*}}:(.text+0x8): undefined symbol '_etext'
-# CHECK: error: {{.*}}:(.text+0x10): undefined symbol '_end'
+# CHECK: error: undefined symbol: _edata
+# CHECK: >>> referenced by {{.*}}:(.text+0x0)
+# CHECK: error: undefined symbol: _etext
+# CHECK: >>> referenced by {{.*}}:(.text+0x8)
+# CHECK: error: undefined symbol: _end
+# CHECK: >>> referenced by {{.*}}:(.text+0x10)
.global _start,_end,_etext,_edata
.text
diff --git a/test/ELF/linkerscript/eh-frame-reloc-out-of-range.s b/test/ELF/linkerscript/eh-frame-reloc-out-of-range.s
new file mode 100644
index 000000000000..54c0cc74d394
--- /dev/null
+++ b/test/ELF/linkerscript/eh-frame-reloc-out-of-range.s
@@ -0,0 +1,27 @@
+## Check that error is correctly reported when .eh_frame reloc
+## is out of range
+
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: echo "PHDRS { eh PT_LOAD; text PT_LOAD; } \
+# RUN: SECTIONS { . = 0x10000; \
+# RUN: .eh_frame_hdr : { *(.eh_frame_hdr*) } : eh \
+# RUN: .eh_frame : { *(.eh_frame) } : eh \
+# RUN: . = 0xF00000000; \
+# RUN: .text : { *(.text*) } : text \
+# RUN: }" > %t.script
+# RUN: not ld.lld %t.o -T %t.script -o %t 2>&1 | FileCheck %s
+
+# CHECK: error: {{.*}}:(.eh_frame+0x20): relocation R_X86_64_PC32 out of range
+
+ .text
+ .globl _start
+_start:
+ .cfi_startproc
+ .cfi_lsda 0, _ex
+ nop
+ .cfi_endproc
+
+ .data
+_ex:
+ .word 0
diff --git a/test/ELF/linkerscript/eh-frame.s b/test/ELF/linkerscript/eh-frame.s
new file mode 100644
index 000000000000..750f74eb36c6
--- /dev/null
+++ b/test/ELF/linkerscript/eh-frame.s
@@ -0,0 +1,19 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: echo "SECTIONS { \
+# RUN: .eh_frame : { *(.eh_frame) } \
+# RUN: }" > %t.script
+# RUN: ld.lld -o %t1 --script %t.script %t
+# RUN: llvm-objdump -s -section=".eh_frame" %t1 | FileCheck %s
+
+# CHECK: 0000 14000000 00000000 017a5200 01781001
+# CHECK-NEXT: 0010 1b0c0708 90010000
+
+.global _start
+_start:
+ nop
+
+.section .dah,"ax",@progbits
+.cfi_startproc
+ nop
+.cfi_endproc
diff --git a/test/ELF/linkerscript/ehdr_start.s b/test/ELF/linkerscript/ehdr_start.s
index 0ae4a4dcfbc9..935fa2bf3391 100644
--- a/test/ELF/linkerscript/ehdr_start.s
+++ b/test/ELF/linkerscript/ehdr_start.s
@@ -3,7 +3,8 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
# RUN: echo "SECTIONS { }" > %t.script
# RUN: not ld.lld %t.o -script %t.script -o %t 2>&1 | FileCheck %s
-# CHECK: error: {{.*}}:(.text+0x0): undefined symbol '__ehdr_start'
+# CHECK: error: undefined symbol: __ehdr_start
+# CHECK: >>> referenced by {{.*}}:(.text+0x0)
.text
.global _start, __ehdr_start
diff --git a/test/ELF/linkerscript/emit-reloc.s b/test/ELF/linkerscript/emit-reloc.s
new file mode 100644
index 000000000000..725f314a9772
--- /dev/null
+++ b/test/ELF/linkerscript/emit-reloc.s
@@ -0,0 +1,17 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: echo "SECTIONS { .rela.dyn : { *(.rela.data) } }" > %t.script
+# RUN: ld.lld -T %t.script --emit-relocs %t.o -o %t.so -shared
+# RUN: llvm-readobj -r %t.so | FileCheck %s
+
+.data
+.quad .foo
+
+# CHECK: Relocations [
+# CHECK-NEXT: Section ({{.*}}) .rela.dyn {
+# CHECK-NEXT: 0x66 R_X86_64_64 .foo 0x0
+# CHECK-NEXT: }
+# CHECK-NEXT: Section ({{.*}}) .rela.data {
+# CHECK-NEXT: 0x66 R_X86_64_64 .foo 0x0
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
diff --git a/test/ELF/linkerscript/emit-relocs-discard.s b/test/ELF/linkerscript/emit-relocs-discard.s
new file mode 100644
index 000000000000..2f1f6c6b4b0a
--- /dev/null
+++ b/test/ELF/linkerscript/emit-relocs-discard.s
@@ -0,0 +1,14 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: echo "SECTIONS { /DISCARD/ : { *(.bbb) } }" > %t.script
+# RUN: ld.lld --emit-relocs --script %t.script %t.o -o %t1
+# RUN: llvm-readobj -r %t1 | FileCheck %s
+
+# CHECK: Relocations [
+# CHECK-NEXT: ]
+
+.section .aaa,"",@progbits
+.Lfoo:
+
+.section .bbb,"",@progbits
+.long .Lfoo
diff --git a/test/ELF/linkerscript/emit-relocs-ehframe-discard.s b/test/ELF/linkerscript/emit-relocs-ehframe-discard.s
new file mode 100644
index 000000000000..9df0e8ce9dcb
--- /dev/null
+++ b/test/ELF/linkerscript/emit-relocs-ehframe-discard.s
@@ -0,0 +1,11 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
+# RUN: echo "SECTIONS { /DISCARD/ : { *(.eh_frame) } }" > %t.script
+# RUN: ld.lld --emit-relocs --script %t.script %t1.o -o %t
+# RUN: llvm-objdump -section-headers %t | FileCheck %s
+
+# CHECK-NOT: .rela.eh_frame
+
+.section .foo,"ax",@progbits
+.cfi_startproc
+.cfi_endproc
diff --git a/test/ELF/linkerscript/empty-load.s b/test/ELF/linkerscript/empty-load.s
index 0a87d5727474..ea58d71402d1 100644
--- a/test/ELF/linkerscript/empty-load.s
+++ b/test/ELF/linkerscript/empty-load.s
@@ -5,8 +5,7 @@
# RUN: llvm-objdump -private-headers %t1 | FileCheck %s
## We expect 2 PT_LOAD segments
-# CHECK: PHDR
-# CHECK-NEXT: filesz {{0x[0-9a-f]+}} memsz {{0x[0-9a-f]+}} flags r--
+# CHECK: Program Header:
# CHECK-NEXT: LOAD
# CHECK-NEXT: filesz {{0x[0-9a-f]+}} memsz {{0x[0-9a-f]+}} flags rw-
# CHECK-NEXT: LOAD
diff --git a/test/ELF/linkerscript/excludefile.s b/test/ELF/linkerscript/excludefile.s
index 8a154354dbc2..95b9534d9535 100644
--- a/test/ELF/linkerscript/excludefile.s
+++ b/test/ELF/linkerscript/excludefile.s
@@ -13,11 +13,13 @@
# CHECK: _start:
# CHECK-NEXT: : 48 c7 c0 3c 00 00 00 movq $60, %rax
# CHECK-NEXT: : 48 c7 c7 2a 00 00 00 movq $42, %rdi
-# CHECK-NEXT: : 00 00 addb %al, (%rax)
+# CHECK-NEXT: : cc int3
+# CHECK-NEXT: : cc int3
# CHECK: _potato:
# CHECK-NEXT: : 90 nop
# CHECK-NEXT: : 90 nop
-# CHECK-NEXT: : 00 00 addb %al, (%rax)
+# CHECK-NEXT: : cc int3
+# CHECK-NEXT: : cc int3
# CHECK: tomato:
# CHECK-NEXT: : b8 01 00 00 00 movl $1, %eax
@@ -31,7 +33,8 @@
# EXCLUDE: _start:
# EXCLUDE-NEXT: : 48 c7 c0 3c 00 00 00 movq $60, %rax
# EXCLUDE-NEXT: : 48 c7 c7 2a 00 00 00 movq $42, %rdi
-# EXCLUDE-NEXT: : 00 00 addb %al, (%rax)
+# EXCLUDE-NEXT: : cc int3
+# EXCLUDE-NEXT: : cc int3
# EXCLUDE: _potato:
# EXCLUDE-NEXT: : 90 nop
# EXCLUDE-NEXT: : 90 nop
diff --git a/test/ELF/linkerscript/expr-invalid-sec.s b/test/ELF/linkerscript/expr-invalid-sec.s
new file mode 100644
index 000000000000..9476be3c3b14
--- /dev/null
+++ b/test/ELF/linkerscript/expr-invalid-sec.s
@@ -0,0 +1,6 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: echo "SECTIONS { foo = ADDR(.text) + ADDR(.text); };" > %t.script
+# RUN: not ld.lld -o %t.so --script %t.script %t.o -shared 2>&1 | FileCheck %s
+
+# CHECK: At least one side of the expression must be absolute
diff --git a/test/ELF/linkerscript/expr-sections.s b/test/ELF/linkerscript/expr-sections.s
new file mode 100644
index 000000000000..eb60009cd971
--- /dev/null
+++ b/test/ELF/linkerscript/expr-sections.s
@@ -0,0 +1,22 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: echo "SECTIONS { \
+# RUN: . = . + 4; \
+# RUN: .text : { \
+# RUN: *(.text) \
+# RUN: foo1 = ADDR(.text) + 1; bar1 = 1 + ADDR(.text); \
+# RUN: foo2 = ADDR(.text) & 1; bar2 = 1 & ADDR(.text); \
+# RUN: foo3 = ADDR(.text) | 1; bar3 = 1 | ADDR(.text); \
+# RUN: } \
+# RUN: };" > %t.script
+# RUN: ld.lld -o %t.so --script %t.script %t.o -shared
+# RUN: llvm-objdump -t -h %t.so | FileCheck %s
+
+# CHECK: 1 .text 00000000 0000000000000004 TEXT DATA
+
+# CHECK: 0000000000000005 .text 00000000 foo1
+# CHECK: 0000000000000005 .text 00000000 bar1
+# CHECK: 0000000000000000 .text 00000000 foo2
+# CHECK: 0000000000000000 .text 00000000 bar2
+# CHECK: 0000000000000005 .text 00000000 foo3
+# CHECK: 0000000000000005 .text 00000000 bar3
diff --git a/test/ELF/linkerscript/fill-exec-sections.s b/test/ELF/linkerscript/fill-exec-sections.s
new file mode 100644
index 000000000000..f61d6da1db33
--- /dev/null
+++ b/test/ELF/linkerscript/fill-exec-sections.s
@@ -0,0 +1,40 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+
+## Check that padding of executable sections are filled with trap bytes if not
+## otherwise specified in the script.
+# RUN: echo "SECTIONS { .exec : { *(.exec*) } }" > %t.script
+# RUN: ld.lld -o %t.out --script %t.script %t
+# RUN: llvm-objdump -s %t.out | FileCheck %s --check-prefix=EXEC
+# EXEC: 0000 66cccccc cccccccc cccccccc cccccccc
+# EXEC-NEXT: 0010 66
+
+## Check that a fill expression or command overrides the default filler...
+# RUN: echo "SECTIONS { .exec : { *(.exec*) }=0x11223344 }" > %t2.script
+# RUN: ld.lld -o %t2.out --script %t2.script %t
+# RUN: llvm-objdump -s %t2.out | FileCheck %s --check-prefix=OVERRIDE
+# RUN: echo "SECTIONS { .exec : { FILL(0x11223344); *(.exec*) } }" > %t3.script
+# RUN: ld.lld -o %t3.out --script %t3.script %t
+# RUN: llvm-objdump -s %t3.out | FileCheck %s --check-prefix=OVERRIDE
+# OVERRIDE: Contents of section .exec:
+# OVERRIDE-NEXT: 0000 66112233 44112233 44112233 44112233
+# OVERRIDE-NEXT: 0010 66
+
+## ...even for a value of zero.
+# RUN: echo "SECTIONS { .exec : { *(.exec*) }=0x00000000 }" > %t4.script
+# RUN: ld.lld -o %t4.out --script %t4.script %t
+# RUN: llvm-objdump -s %t4.out | FileCheck %s --check-prefix=ZERO
+# RUN: echo "SECTIONS { .exec : { FILL(0x00000000); *(.exec*) } }" > %t5.script
+# RUN: ld.lld -o %t5.out --script %t5.script %t
+# RUN: llvm-objdump -s %t5.out | FileCheck %s --check-prefix=ZERO
+# ZERO: Contents of section .exec:
+# ZERO-NEXT: 0000 66000000 00000000 00000000 00000000
+# ZERO-NEXT: 0010 66
+
+.section .exec.1,"ax"
+.align 16
+.byte 0x66
+
+.section .exec.2,"ax"
+.align 16
+.byte 0x66
diff --git a/test/ELF/linkerscript/fill.s b/test/ELF/linkerscript/fill.s
index 57a19e0943d0..604506084a74 100644
--- a/test/ELF/linkerscript/fill.s
+++ b/test/ELF/linkerscript/fill.s
@@ -2,7 +2,8 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
# RUN: echo "SECTIONS { \
# RUN: .out : { \
-# RUN: FILL(0x11111111); \
+# RUN: FILL(0x11111111) \
+# RUN: . += 2; \
# RUN: *(.aaa) \
# RUN: . += 4; \
# RUN: *(.bbb) \
@@ -15,7 +16,7 @@
# RUN: llvm-objdump -s %t | FileCheck %s
# CHECK: Contents of section .out:
-# CHECK-NEXT: aa222222 22bb2222 22222222 2222
+# CHECK-NEXT: 2222aa22 222222bb 22222222 22222222
.text
.globl _start
diff --git a/test/ELF/linkerscript/huge-temporary-file.s b/test/ELF/linkerscript/huge-temporary-file.s
new file mode 100644
index 000000000000..d58709cf8f8d
--- /dev/null
+++ b/test/ELF/linkerscript/huge-temporary-file.s
@@ -0,0 +1,12 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: echo "SECTIONS { .text 0x2000 : {. = 0x10 ; *(.text) } }" > %t.script
+# RUN: not ld.lld %t --script %t.script -o %t1
+
+## This inputs previously created a 4gb temporarily fine under 32 bit
+## configuration. Issue was fixed. There is no clean way to check that from here.
+## This testcase added for documentation purposes.
+
+.globl _start
+_start:
+nop
diff --git a/test/ELF/linkerscript/lazy-symbols.s b/test/ELF/linkerscript/lazy-symbols.s
new file mode 100644
index 000000000000..22dffeef979b
--- /dev/null
+++ b/test/ELF/linkerscript/lazy-symbols.s
@@ -0,0 +1,13 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/lazy-symbols.s -o %t1
+# RUN: llvm-ar rcs %tar %t1
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t2
+# RUN: echo "foo = 1;" > %t.script
+# RUN: ld.lld %t2 %tar --script %t.script -o %tout
+# RUN: llvm-readobj -symbols %tout | FileCheck %s
+
+# This test is to ensure a linker script can define a symbol which have the same
+# name as a lazy symbol.
+
+# CHECK: Name: foo
+# CHECK-NEXT: Value: 0x1
diff --git a/test/ELF/linkerscript/locationcounter.s b/test/ELF/linkerscript/locationcounter.s
deleted file mode 100644
index c57a17c5c9cb..000000000000
--- a/test/ELF/linkerscript/locationcounter.s
+++ /dev/null
@@ -1,189 +0,0 @@
-# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-# RUN: echo "SECTIONS { \
-# RUN: . = 0xFFF0; \
-# RUN: . = . + 0x10; \
-# RUN: .plus : { *(.plus) } \
-# RUN: . = 0x11010 - 0x10; \
-# RUN: .minus : { *(.minus) } \
-# RUN: . = 0x24000 / 0x2; \
-# RUN: .div : { *(.div) } \
-# RUN: . = 0x11000 + 0x1000 * 0x2; \
-# RUN: .mul : { *(.mul) } \
-# RUN: . = 0x10000 + (0x1000 + 0x1000) * 0x2; \
-# RUN: .bracket : { *(.bracket) } \
-# RUN: . = 0x17000 & 0x15000; \
-# RUN: .and : { *(.and) } \
-# RUN: . = 0x1 ? 0x16000 : 0x999999; \
-# RUN: .ternary1 : { *(.ternary1) } \
-# RUN: . = 0x0 ? 0x999999 : 0x17000; \
-# RUN: .ternary2 : { *(.ternary2) } \
-# RUN: . = 0x0 < 0x1 ? 0x18000 : 0x999999; \
-# RUN: .less : { *(.less) } \
-# RUN: . = 0x1 <= 0x1 ? 0x19000 : 0x999999; \
-# RUN: .lesseq : { *(.lesseq) } \
-# RUN: . = 0x1 > 0x0 ? 0x20000 : 0x999999; \
-# RUN: .great : { *(.great) } \
-# RUN: . = 0x1 >= 0x1 ? 0x21000 : 0x999999; \
-# RUN: .greateq : { *(.greateq) } \
-# RUN: . = 0x1 == 0x1 ? 0x22000 : 0x999999; \
-# RUN: .eq : { *(.eq) } \
-# RUN: . = 0x2 != 0x1 ? 0x23000 : 0x999999; \
-# RUN: .neq : { *(.neq) } \
-# RUN: . = CONSTANT (MAXPAGESIZE) * 0x24; \
-# RUN: .maxpagesize : { *(.maxpagesize) } \
-# RUN: . = CONSTANT (COMMONPAGESIZE) * 0x25; \
-# RUN: .commonpagesize : { *(.commonpagesize) } \
-# RUN: . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)); \
-# RUN: .datasegmentalign : { *(.datasegmentalign) } \
-# RUN: . = DATA_SEGMENT_END (.); \
-# RUN: . = 0x27000; \
-# RUN: . += 0x1000; \
-# RUN: .plusassign : { *(.plusassign) } \
-# RUN: . = ((. + 0x1fff) & ~(0x1000 + -1)); \
-# RUN: .unary : { *(.unary) } \
-# RUN: . = 0x30000 + (1 + 1 << 5); \
-# RUN: .shiftl : { *(.shiftl) } \
-# RUN: . = 0x30000 + (1 + 1023 >> 2); \
-# RUN: .shiftr : { *(.shiftr) } \
-
-# RUN: }" > %t.script
-# RUN: ld.lld %t --script %t.script -o %t2
-# RUN: llvm-objdump -section-headers %t2 | FileCheck %s
-
-# CHECK: .plus {{.*}} 0000000000010000
-# CHECK: .minus {{.*}} 0000000000011000
-# CHECK: .div {{.*}} 0000000000012000
-# CHECK: .mul {{.*}} 0000000000013000
-# CHECK: .bracket {{.*}} 0000000000014000
-# CHECK: .and {{.*}} 0000000000015000
-# CHECK: .ternary1 {{.*}} 0000000000016000
-# CHECK: .ternary2 {{.*}} 0000000000017000
-# CHECK: .less {{.*}} 0000000000018000
-# CHECK: .lesseq {{.*}} 0000000000019000
-# CHECK: .great {{.*}} 0000000000020000
-# CHECK: .greateq {{.*}} 0000000000021000
-# CHECK: .eq {{.*}} 0000000000022000
-# CHECK: .neq {{.*}} 0000000000023000
-# CHECK: .maxpagesize {{.*}} 0000000000024000
-# CHECK: .commonpagesize {{.*}} 0000000000025000
-# CHECK: .datasegmentalign {{.*}} 0000000000026000
-# CHECK: .plusassign {{.*}} 0000000000028000
-# CHECK: .unary {{.*}} 000000000002a000
-# CHECK: .shiftl {{.*}} 0000000000030040
-# CHECK: .shiftr {{.*}} 0000000000030100
-
-## Mailformed number error.
-# RUN: echo "SECTIONS { \
-# RUN: . = 0x12Q41; \
-# RUN: }" > %t.script
-# RUN: not ld.lld %t --script %t.script -o %t2 2>&1 | \
-# RUN: FileCheck --check-prefix=NUMERR %s
-# NUMERR: malformed number: 0x12Q41
-
-## Missing closing bracket.
-# RUN: echo "SECTIONS { \
-# RUN: . = 0x10000 + (0x1000 + 0x1000 * 0x2; \
-# RUN: }" > %t.script
-# RUN: not ld.lld %t --script %t.script -o %t2 2>&1 | \
-# RUN: FileCheck --check-prefix=BRACKETERR %s
-# BRACKETERR: ) expected, but got ;
-
-## Missing opening bracket.
-# RUN: echo "SECTIONS { \
-# RUN: . = 0x10000 + 0x1000 + 0x1000) * 0x2; \
-# RUN: }" > %t.script
-# RUN: not ld.lld %t --script %t.script -o %t2 2>&1 | \
-# RUN: FileCheck --check-prefix=BRACKETERR2 %s
-# BRACKETERR2: ; expected, but got )
-
-## Empty expression.
-# RUN: echo "SECTIONS { \
-# RUN: . = ; \
-# RUN: }" > %t.script
-# RUN: not ld.lld %t --script %t.script -o %t2 2>&1 | \
-# RUN: FileCheck --check-prefix=ERREXPR %s
-# ERREXPR: malformed number: ;
-
-## Div by zero error.
-# RUN: echo "SECTIONS { \
-# RUN: . = 0x10000 / 0x0; \
-# RUN: }" > %t.script
-# RUN: not ld.lld %t --script %t.script -o %t2 2>&1 | \
-# RUN: FileCheck --check-prefix=DIVZERO %s
-# DIVZERO: division by zero
-
-## Broken ternary operator expression.
-# RUN: echo "SECTIONS { \
-# RUN: . = 0x1 ? 0x2; \
-# RUN: }" > %t.script
-# RUN: not ld.lld %t --script %t.script -o %t2 2>&1 | \
-# RUN: FileCheck --check-prefix=TERNERR %s
-# TERNERR: : expected, but got ;
-
-.globl _start
-_start:
-nop
-
-.section .plus, "a"
-.quad 0
-
-.section .minus, "a"
-.quad 0
-
-.section .div, "a"
-.quad 0
-
-.section .mul, "a"
-.quad 0
-
-.section .bracket, "a"
-.quad 0
-
-.section .and, "a"
-.quad 0
-
-.section .ternary1, "a"
-.quad 0
-
-.section .ternary2, "a"
-.quad 0
-
-.section .less, "a"
-.quad 0
-
-.section .lesseq, "a"
-.quad 0
-
-.section .great, "a"
-.quad 0
-
-.section .greateq, "a"
-.quad 0
-
-.section .eq, "a"
-.quad 0
-
-.section .neq, "a"
-.quad 0
-
-.section .maxpagesize, "a"
-.quad 0
-
-.section .commonpagesize, "a"
-.quad 0
-
-.section .datasegmentalign, "a"
-.quad 0
-
-.section .plusassign, "a"
-.quad 0
-
-.section .unary, "a"
-.quad 0
-
-.section .shiftl, "a"
-.quad 0
-
-.section .shiftr, "a"
-.quad 0
diff --git a/test/ELF/linkerscript/locationcountererr.s b/test/ELF/linkerscript/locationcountererr.s
index 7664d8d46917..113e102d4bc2 100644
--- a/test/ELF/linkerscript/locationcountererr.s
+++ b/test/ELF/linkerscript/locationcountererr.s
@@ -1,8 +1,10 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-# RUN: echo "SECTIONS { .text 0x2000 : {. = 0x10 ; *(.text) } }" > %t.script
+
+# RUN: echo "SECTIONS {" > %t.script
+# RUN: echo ".text 0x2000 : {. = 0x10 ; *(.text) } }" >> %t.script
# RUN: not ld.lld %t --script %t.script -o %t1 2>&1 | FileCheck %s
-# CHECK: unable to move location counter backward for: .text
+# CHECK: {{.*}}.script:2: unable to move location counter backward for: .text
.globl _start
_start:
diff --git a/test/ELF/linkerscript/locationcountererr2.s b/test/ELF/linkerscript/locationcountererr2.s
new file mode 100644
index 000000000000..e711f77a3f71
--- /dev/null
+++ b/test/ELF/linkerscript/locationcountererr2.s
@@ -0,0 +1,9 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: echo "SECTIONS {" > %t.script
+# RUN: echo ". = 0x20; . = 0x10; }" >> %t.script
+# RUN: not ld.lld %t.o --script %t.script -o %t -shared 2>&1 | FileCheck %s
+# CHECK: {{.*}}.script:2: unable to move location counter backward
+
+# RUN: echo "SECTIONS { . = 0x20; . = ASSERT(0x1, "foo"); }" > %t2.script
+# RUN: ld.lld %t.o --script %t2.script -o %t -shared
diff --git a/test/ELF/linkerscript/memory.s b/test/ELF/linkerscript/memory.s
new file mode 100644
index 000000000000..774a6f92ab17
--- /dev/null
+++ b/test/ELF/linkerscript/memory.s
@@ -0,0 +1,114 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+
+## Check simple RAM-only memory region.
+
+# RUN: echo "MEMORY { ram (rwx) : ORIGIN = 0x8000, LENGTH = 256K } \
+# RUN: SECTIONS { \
+# RUN: .text : { *(.text) } > ram \
+# RUN: .data : { *(.data) } > ram \
+# RUN: }" > %t.script
+# RUN: ld.lld -o %t1 --script %t.script %t
+# RUN: llvm-objdump -section-headers %t1 | FileCheck -check-prefix=RAM %s
+
+# RAM: 1 .text 00000001 0000000000008000 TEXT DATA
+# RAM-NEXT: 2 .data 00001000 0000000000008001 DATA
+
+## Check RAM and ROM memory regions.
+
+# RUN: echo "MEMORY { \
+# RUN: ram (rwx) : ORIGIN = 0, LENGTH = 1024M \
+# RUN: rom (rx) : org = (0x80 * 0x1000 * 0x1000), len = 64M \
+# RUN: } \
+# RUN: SECTIONS { \
+# RUN: .text : { *(.text) } > rom \
+# RUN: .data : { *(.data) } > ram \
+# RUN: }" > %t.script
+# RUN: ld.lld -o %t1 --script %t.script %t
+# RUN: llvm-objdump -section-headers %t1 | FileCheck -check-prefix=RAMROM %s
+
+# RAMROM: 1 .text 00000001 0000000080000000 TEXT DATA
+# RAMROM-NEXT: 2 .data 00001000 0000000000000000 DATA
+
+## Check memory region placement by attributes.
+
+# RUN: echo "MEMORY { \
+# RUN: ram (!rx) : ORIGIN = 0, LENGTH = 1024M \
+# RUN: rom (rx) : o = 0x80000000, l = 64M \
+# RUN: } \
+# RUN: SECTIONS { \
+# RUN: .text : { *(.text) } \
+# RUN: .data : { *(.data) } > ram \
+# RUN: }" > %t.script
+# RUN: ld.lld -o %t1 --script %t.script %t
+# RUN: llvm-objdump -section-headers %t1 | FileCheck -check-prefix=ATTRS %s
+
+# ATTRS: 1 .text 00000001 0000000080000000 TEXT DATA
+# ATTRS: 2 .data 00001000 0000000000000000 DATA
+
+## Check bad `ORIGIN`.
+
+# RUN: echo "MEMORY { ram (rwx) : XYZ = 0x8000 } }" > %t.script
+# RUN: not ld.lld -o %t2 --script %t.script %t 2>&1 \
+# RUN: | FileCheck -check-prefix=ERR1 %s
+# ERR1: {{.*}}.script:1: expected one of: ORIGIN, org, or o
+
+## Check bad `LENGTH`.
+
+# RUN: echo "MEMORY { ram (rwx) : ORIGIN = 0x8000, XYZ = 256K } }" > %t.script
+# RUN: not ld.lld -o %t2 --script %t.script %t 2>&1 \
+# RUN: | FileCheck -check-prefix=ERR2 %s
+# ERR2: {{.*}}.script:1: expected one of: LENGTH, len, or l
+
+## Check duplicate regions.
+
+# RUN: echo "MEMORY { ram (rwx) : o = 8, l = 256K ram (rx) : o = 0, l = 256K }" > %t.script
+# RUN: not ld.lld -o %t2 --script %t.script %t 2>&1 \
+# RUN: | FileCheck -check-prefix=ERR3 %s
+# ERR3: {{.*}}.script:1: region 'ram' already defined
+
+## Check no region available.
+
+# RUN: echo "MEMORY { ram (!rx) : ORIGIN = 0x8000, LENGTH = 256K } \
+# RUN: SECTIONS { \
+# RUN: .text : { *(.text) } \
+# RUN: .data : { *(.data) } > ram \
+# RUN: }" > %t.script
+# RUN: not ld.lld -o %t2 --script %t.script %t 2>&1 \
+# RUN: | FileCheck -check-prefix=ERR4 %s
+# ERR4: {{.*}}: no memory region specified for section '.text'
+
+## Check undeclared region.
+
+# RUN: echo "SECTIONS { .text : { *(.text) } > ram }" > %t.script
+# RUN: not ld.lld -o %t2 --script %t.script %t 2>&1 \
+# RUN: | FileCheck -check-prefix=ERR5 %s
+# ERR5: {{.*}}: memory region 'ram' not declared
+
+## Check region overflow.
+
+# RUN: echo "MEMORY { ram (rwx) : ORIGIN = 0, LENGTH = 2K } \
+# RUN: SECTIONS { \
+# RUN: .text : { *(.text) } > ram \
+# RUN: .data : { *(.data) } > ram \
+# RUN: }" > %t.script
+# RUN: not ld.lld -o %t2 --script %t.script %t 2>&1 \
+# RUN: | FileCheck -check-prefix=ERR6 %s
+# ERR6: {{.*}}: section '.data' will not fit in region 'ram': overflowed by 2049 bytes
+
+## Check invalid region attributes.
+
+# RUN: echo "MEMORY { ram (abc) : ORIGIN = 8000, LENGTH = 256K } }" > %t.script
+# RUN: not ld.lld -o %t2 --script %t.script %t 2>&1 \
+# RUN: | FileCheck -check-prefix=ERR7 %s
+# ERR7: {{.*}}.script:1: invalid memory region attribute
+
+.text
+.global _start
+_start:
+ nop
+
+.data
+b:
+ .long 1
+ .zero 4092
diff --git a/test/ELF/linkerscript/merge-sections-syms.s b/test/ELF/linkerscript/merge-sections-syms.s
new file mode 100644
index 000000000000..713d334a1a5a
--- /dev/null
+++ b/test/ELF/linkerscript/merge-sections-syms.s
@@ -0,0 +1,49 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+
+# RUN: echo "SECTIONS { \
+# RUN: . = SIZEOF_HEADERS; \
+# RUN: .rodata : { *(.aaa) *(.bbb) A = .; *(.ccc) B = .; } \
+# RUN: }" > %t.script
+# RUN: ld.lld -o %t.so --script %t.script %t.o -shared
+# RUN: llvm-readobj --dyn-symbols %t.so | FileCheck %s
+
+# CHECK: DynamicSymbols [
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name:
+# CHECK-NEXT: Value:
+# CHECK-NEXT: Size:
+# CHECK-NEXT: Binding:
+# CHECK-NEXT: Type:
+# CHECK-NEXT: Other:
+# CHECK-NEXT: Section:
+# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name: A
+# CHECK-NEXT: Value: 0x195
+# CHECK-NEXT: Size:
+# CHECK-NEXT: Binding:
+# CHECK-NEXT: Type:
+# CHECK-NEXT: Other:
+# CHECK-NEXT: Section:
+# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name: B
+# CHECK-NEXT: Value: 0x196
+# CHECK-NEXT: Size:
+# CHECK-NEXT: Binding:
+# CHECK-NEXT: Type:
+# CHECK-NEXT: Other:
+# CHECK-NEXT: Section:
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
+
+
+.section .aaa,"a"
+.byte 11
+
+.section .bbb,"aMS",@progbits,1
+.asciz "foo"
+
+.section .ccc,"a"
+.byte 33
diff --git a/test/ELF/linkerscript/merge-sections.s b/test/ELF/linkerscript/merge-sections.s
index 7252fe576674..ae53ebc4d400 100644
--- a/test/ELF/linkerscript/merge-sections.s
+++ b/test/ELF/linkerscript/merge-sections.s
@@ -17,61 +17,19 @@
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x[[ADDR1:.*]]
# CHECK-NEXT: Offset: 0x[[ADDR1]]
-# CHECK-NEXT: Size: 4
-# CHECK-NEXT: Link: 0
-# CHECK-NEXT: Info: 0
-# CHECK-NEXT: AddressAlignment: 1
-# CHECK-NEXT: EntrySize: 1
-# CHECK-NEXT: }
-# CHECK-NEXT: Section {
-# CHECK-NEXT: Index:
-# CHECK-NEXT: Name: .foo
-# CHECK-NEXT: Type: SHT_PROGBITS
-# CHECK-NEXT: Flags [
-# CHECK-NEXT: SHF_ALLOC
-# CHECK-NEXT: SHF_MERGE
-# CHECK-NEXT: ]
-# CHECK-NEXT: Address: 0x
-# CHECK-NEXT: Offset: 0x
-# CHECK-NEXT: Size: 1
-# CHECK-NEXT: Link: 0
-# CHECK-NEXT: Info: 0
-# CHECK-NEXT: AddressAlignment: 1
-# CHECK-NEXT: EntrySize: 1
-# CHECK-NEXT: }
-# CHECK-NEXT: Section {
-# CHECK-NEXT: Index:
-# CHECK-NEXT: Name: .foo
-# CHECK-NEXT: Type: SHT_PROGBITS
-# CHECK-NEXT: Flags [
-# CHECK-NEXT: SHF_ALLOC
-# CHECK-NEXT: SHF_MERGE
-# CHECK-NEXT: ]
-# CHECK-NEXT: Address: 0x
-# CHECK-NEXT: Offset: 0x
-# CHECK-NEXT: Size: 2
+# CHECK-NEXT: Size: 14
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
# CHECK-NEXT: AddressAlignment: 2
-# CHECK-NEXT: EntrySize: 2
+# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: }
-# CHECK-NEXT: Section {
-# CHECK-NEXT: Index:
-# CHECK-NEXT: Name:
-# CHECK-NEXT: Type:
-# CHECK-NEXT: Flags [
-# CHECK-NEXT: SHF_ALLOC
-# CHECK-NEXT: SHF_EXECINSTR
-# CHECK-NEXT: ]
-# CHECK-NEXT: Address: 0x[[ADDR2:.*]]
-# CHECK-NEXT: Offset: 0x[[ADDR2]]
-
# CHECK: Name: begin
# CHECK-NEXT: Value: 0x[[ADDR1]]
# CHECK: Name: end
-# CHECK-NEXT: Value: 0x[[ADDR2]]
+# 0x19E = begin + sizeof(.foo) = 0x190 + 0xE
+# CHECK-NEXT: Value: 0x19E
.section .foo.1a,"aMS",@progbits,1
.asciz "foo"
diff --git a/test/ELF/linkerscript/no-space.s b/test/ELF/linkerscript/no-space.s
index a96797269e43..fc9e5b13325f 100644
--- a/test/ELF/linkerscript/no-space.s
+++ b/test/ELF/linkerscript/no-space.s
@@ -10,17 +10,15 @@
# RUN: llvm-readobj -elf-output-style=GNU -l %t | FileCheck %s
# There is not enough address space available for the header, so just start the PT_LOAD
-# after it.
+# after it. Don't create a PT_PHDR as the header is not allocated.
# CHECK: Program Headers:
# CHECK-NEXT: Type Offset VirtAddr PhysAddr
-# CHECK-NEXT: PHDR
# CHECK-NEXT: LOAD 0x001000 0x0000000000000000 0x0000000000000000
# CHECK: Section to Segment mapping:
# CHECK-NEXT: Segment Sections...
-# CHECK-NEXT: 00
-# CHECK-NEXT: 01 foo .text .dynsym .hash .dynstr
+# CHECK-NEXT: 00 foo .text .dynsym .hash .dynstr
.section foo, "a"
.quad 0
diff --git a/test/ELF/linkerscript/non-absolute.s b/test/ELF/linkerscript/non-absolute.s
new file mode 100644
index 000000000000..a0e9e7dc6782
--- /dev/null
+++ b/test/ELF/linkerscript/non-absolute.s
@@ -0,0 +1,30 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o
+# RUN: echo "SECTIONS { A = . - 0x10; B = A + 0x1; }" > %t.script
+# RUN: ld.lld -shared %t1.o --script %t.script -o %t
+# RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=DUMP
+# RUN: llvm-readobj -t %t | FileCheck %s --check-prefix=SYMBOL
+
+# DUMP: Disassembly of section .text:
+# DUMP-NEXT: foo:
+# DUMP-NEXT: 0: {{.*}} -21(%rip), %eax
+
+# SYMBOL: Symbol {
+# SYMBOL: Name: B
+# SYMBOL-NEXT: Value: 0xFFFFFFFFFFFFFFF1
+# SYMBOL-NEXT: Size: 0
+# SYMBOL-NEXT: Binding: Local
+# SYMBOL-NEXT: Type: None
+# SYMBOL-NEXT: Other [
+# SYMBOL-NEXT: STV_HIDDEN
+# SYMBOL-NEXT: ]
+# SYMBOL-NEXT: Section: .text
+# SYMBOL-NEXT: }
+
+.text
+.globl foo
+.type foo, @function
+foo:
+ movl B(%rip), %eax
+
+.hidden B
diff --git a/test/ELF/linkerscript/non-absolute2.s b/test/ELF/linkerscript/non-absolute2.s
new file mode 100644
index 000000000000..97c34d31a912
--- /dev/null
+++ b/test/ELF/linkerscript/non-absolute2.s
@@ -0,0 +1,12 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o
+# RUN: echo "SECTIONS { A = . + 0x1; . += 0x1000; }" > %t.script
+# RUN: ld.lld -shared %t1.o --script %t.script -o %t
+# RUN: llvm-objdump -section-headers -t %t | FileCheck %s
+
+# CHECK: Sections:
+# CHECK-NEXT: Idx Name Size Address
+# CHECK-NEXT: 0 00000000 0000000000000000
+# CHECK-NEXT: 1 .text 00000000 0000000000001000
+
+# CHECK: 0000000000000001 .text 00000000 A
diff --git a/test/ELF/linkerscript/non-alloc.s b/test/ELF/linkerscript/non-alloc.s
index 2060129a8020..861c74996b85 100644
--- a/test/ELF/linkerscript/non-alloc.s
+++ b/test/ELF/linkerscript/non-alloc.s
@@ -10,15 +10,13 @@
# CHECK: Program Headers:
# CHECK-NEXT: Type
-# CHECK-NEXT: PHDR
# CHECK-NEXT: LOAD {{.*}} R E
# CHECK-NEXT: LOAD {{.*}} RW
# CHECK: Section to Segment mapping:
# CHECK-NEXT: Segment Sections...
-# CHECK-NEXT: 00
-# CHECK-NEXT: 01 .text .dynsym .hash .dynstr
-# CHECK-NEXT: 02 .dynamic
+# CHECK-NEXT: 00 .text .dynsym .hash .dynstr
+# CHECK-NEXT: 01 .dynamic
nop
.section foo
diff --git a/test/ELF/linkerscript/numbers.s b/test/ELF/linkerscript/numbers.s
index 653f94bd4e6e..d4fd13fd8197 100644
--- a/test/ELF/linkerscript/numbers.s
+++ b/test/ELF/linkerscript/numbers.s
@@ -28,27 +28,35 @@
# CHECK-NEXT: 6 .mega2 00000008 0000000000200000
## Mailformed number errors.
-# RUN: echo "SECTIONS { \
-# RUN: . = 0x11h; \
-# RUN: }" > %t2.script
+# RUN: echo "SECTIONS { . = 0x11h; }" > %t2.script
# RUN: not ld.lld %t --script %t2.script -o %t3 2>&1 | \
# RUN: FileCheck --check-prefix=ERR1 %s
# ERR1: malformed number: 0x11h
-# RUN: echo "SECTIONS { \
-# RUN: . = 0x11k; \
-# RUN: }" > %t3.script
+# RUN: echo "SECTIONS { . = 0x11k; }" > %t3.script
# RUN: not ld.lld %t --script %t3.script -o %t4 2>&1 | \
# RUN: FileCheck --check-prefix=ERR2 %s
# ERR2: malformed number: 0x11k
-# RUN: echo "SECTIONS { \
-# RUN: . = 0x11m; \
-# RUN: }" > %t4.script
+# RUN: echo "SECTIONS { . = 0x11m; }" > %t4.script
# RUN: not ld.lld %t --script %t4.script -o %t5 2>&1 | \
# RUN: FileCheck --check-prefix=ERR3 %s
# ERR3: malformed number: 0x11m
+## Make sure that numbers can be followed by a ":" with and without a space,
+## e.g. "0x100 :" or "0x100:"
+# RUN: echo "SECTIONS { \
+# RUN: .hex1 0x400 : { *(.hex.1) } \
+# RUN: .hex2 0x500:{ *(.hex.2) } \
+# RUN: }" > %t5.script
+# RUN: ld.lld %t --script %t5.script -o %t6
+# RUN: llvm-objdump -section-headers %t6 | FileCheck -check-prefix=SECADDR %s
+# SECADDR: Sections:
+# SECADDR-NEXT: Idx Name Size Address
+# SECADDR-NEXT: 0 00000000 0000000000000000
+# SECADDR-NEXT: 1 .hex1 00000008 0000000000000400
+# SECADDR-NEXT: 2 .hex2 00000008 0000000000000500
+
.globl _start
_start:
nop
diff --git a/test/ELF/linkerscript/obj-symbol-value.s b/test/ELF/linkerscript/obj-symbol-value.s
new file mode 100644
index 000000000000..1c0b1190e815
--- /dev/null
+++ b/test/ELF/linkerscript/obj-symbol-value.s
@@ -0,0 +1,19 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: echo "SECTIONS { foo = bar; .bar : { *(.bar*) } }" > %t.script
+# RUN: ld.lld %t.o --script %t.script -o %t.so -shared
+# RUN: llvm-readobj -t %t.so | FileCheck %s
+
+# CHECK: Symbol {
+# CHECK: Name: bar
+# CHECK-NEXT: Value: 0x[[VAL:.*]]
+# CHECK: Name: foo
+# CHECK-NEXT: Value: 0x[[VAL]]
+
+.section .bar.1, "a"
+.quad 0
+
+.section .bar.2, "a"
+.quad 0
+.global bar
+bar:
diff --git a/test/ELF/linkerscript/operators.s b/test/ELF/linkerscript/operators.s
new file mode 100644
index 000000000000..470558d29df1
--- /dev/null
+++ b/test/ELF/linkerscript/operators.s
@@ -0,0 +1,93 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: echo "SECTIONS { \
+# RUN: plus = 1 + 2 + 3; \
+# RUN: minus = 5 - 1; \
+# RUN: div = 6 / 2; \
+# RUN: mul = 1 + 2 * 3; \
+# RUN: nospace = 1+2*6/3; \
+# RUN: braces = 1 + (2 + 3) * 4; \
+# RUN: and = 0xbb & 0xee; \
+# RUN: ternary1 = 1 ? 1 : 2; \
+# RUN: ternary2 = 0 ? 1 : 2; \
+# RUN: less = 1 < 0 ? 1 : 2; \
+# RUN: lesseq = 1 <= 1 ? 1 : 2; \
+# RUN: greater = 0 > 1 ? 1 : 2; \
+# RUN: greatereq = 1 >= 1 ? 1 : 2; \
+# RUN: eq = 1 == 1 ? 1 : 2; \
+# RUN: neq = 1 != 1 ? 1 : 2; \
+# RUN: plusassign = 1; \
+# RUN: plusassign += 2; \
+# RUN: unary = -1 + 3; \
+# RUN: lshift = 1 << 5; \
+# RUN: rshift = 0xff >> 3; \
+# RUN: maxpagesize = CONSTANT (MAXPAGESIZE); \
+# RUN: commonpagesize = CONSTANT (COMMONPAGESIZE); \
+# RUN: . = 0xfff0; \
+# RUN: datasegmentalign = DATA_SEGMENT_ALIGN (0xffff, 0); \
+# RUN: }" > %t.script
+# RUN: ld.lld %t --script %t.script -o %t2
+# RUN: llvm-objdump -t %t2 | FileCheck %s
+
+# CHECK: 00000000000006 *ABS* 00000000 plus
+# CHECK: 00000000000004 *ABS* 00000000 minus
+# CHECK: 00000000000003 *ABS* 00000000 div
+# CHECK: 00000000000007 *ABS* 00000000 mul
+# CHECK: 00000000000005 *ABS* 00000000 nospace
+# CHECK: 00000000000015 *ABS* 00000000 braces
+# CHECK: 000000000000aa *ABS* 00000000 and
+# CHECK: 00000000000001 *ABS* 00000000 ternary1
+# CHECK: 00000000000002 *ABS* 00000000 ternary2
+# CHECK: 00000000000002 *ABS* 00000000 less
+# CHECK: 00000000000001 *ABS* 00000000 lesseq
+# CHECK: 00000000000002 *ABS* 00000000 greater
+# CHECK: 00000000000001 *ABS* 00000000 greatereq
+# CHECK: 00000000000001 *ABS* 00000000 eq
+# CHECK: 00000000000002 *ABS* 00000000 neq
+# CHECK: 00000000000003 *ABS* 00000000 plusassign
+# CHECK: 00000000000002 *ABS* 00000000 unary
+# CHECK: 00000000000020 *ABS* 00000000 lshift
+# CHECK: 0000000000001f *ABS* 00000000 rshift
+# CHECK: 00000000001000 *ABS* 00000000 maxpagesize
+# CHECK: 00000000001000 *ABS* 00000000 commonpagesize
+# CHECK: 0000000000ffff *ABS* 00000000 datasegmentalign
+
+## Mailformed number error.
+# RUN: echo "SECTIONS { . = 0x12Q41; }" > %t.script
+# RUN: not ld.lld %t --script %t.script -o %t2 2>&1 | \
+# RUN: FileCheck --check-prefix=NUMERR %s
+# NUMERR: malformed number: 0x12Q41
+
+## Missing closing bracket.
+# RUN: echo "SECTIONS { . = (1; }" > %t.script
+# RUN: not ld.lld %t --script %t.script -o %t2 2>&1 | \
+# RUN: FileCheck --check-prefix=BRACKETERR %s
+# BRACKETERR: ) expected, but got ;
+
+## Missing opening bracket.
+# RUN: echo "SECTIONS { . = 1); }" > %t.script
+# RUN: not ld.lld %t --script %t.script -o %t2 2>&1 | \
+# RUN: FileCheck --check-prefix=BRACKETERR2 %s
+# BRACKETERR2: ; expected, but got )
+
+## Empty expression.
+# RUN: echo "SECTIONS { . = ; }" > %t.script
+# RUN: not ld.lld %t --script %t.script -o %t2 2>&1 | \
+# RUN: FileCheck --check-prefix=ERREXPR %s
+# ERREXPR: malformed number: ;
+
+## Div by zero error.
+# RUN: echo "SECTIONS { . = 1 / 0; }" > %t.script
+# RUN: not ld.lld %t --script %t.script -o %t2 2>&1 | \
+# RUN: FileCheck --check-prefix=DIVZERO %s
+# DIVZERO: division by zero
+
+## Broken ternary operator expression.
+# RUN: echo "SECTIONS { . = 1 ? 2; }" > %t.script
+# RUN: not ld.lld %t --script %t.script -o %t2 2>&1 | \
+# RUN: FileCheck --check-prefix=TERNERR %s
+# TERNERR: : expected, but got ;
+
+.globl _start
+_start:
+nop
diff --git a/test/ELF/linkerscript/orphan-first-cmd.s b/test/ELF/linkerscript/orphan-first-cmd.s
index 3fb3b31b9a40..263cb30d6868 100644
--- a/test/ELF/linkerscript/orphan-first-cmd.s
+++ b/test/ELF/linkerscript/orphan-first-cmd.s
@@ -4,7 +4,7 @@
# RUN: foo = 123; \
# RUN: . = 0x1000; \
# RUN: . = 0x2000; \
-# RUN: .bar : { . = . + 1; } \
+# RUN: .bar : { *(.bar) } \
# RUN: }" > %t.script
# RUN: ld.lld -o %t -T %t.script %t.o -shared
# RUN: llvm-readobj -s %t | FileCheck %s
@@ -16,3 +16,5 @@
# CHECK-NEXT: SHF_EXECINSTR
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x1000
+
+.section .bar, "aw"
diff --git a/test/ELF/linkerscript/out-of-order.s b/test/ELF/linkerscript/out-of-order.s
new file mode 100644
index 000000000000..9c6547a68643
--- /dev/null
+++ b/test/ELF/linkerscript/out-of-order.s
@@ -0,0 +1,10 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-linux %s -o %t.o
+# RUN: echo "SECTIONS { .data 0x4000 : { *(.data) } .text 0x2000 : { *(.text) } }" > %t.script
+# RUN: not ld.lld -o %t.so --script %t.script %t.o -shared 2>&1 | FileCheck %s
+
+# CHECK: error: {{.*}}.script:1: unable to move location counter backward
+
+.quad 0
+.data
+.quad 0
diff --git a/test/ELF/linkerscript/output-too-large.s b/test/ELF/linkerscript/output-too-large.s
new file mode 100644
index 000000000000..db021eaa99e0
--- /dev/null
+++ b/test/ELF/linkerscript/output-too-large.s
@@ -0,0 +1,8 @@
+# RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %s -o %t.o
+# RUN: echo "SECTIONS { .text : { . = 0xffffffff; *(.text*); } }" > %t.script
+# RUN: not ld.lld --script %t.script %t.o -o %t 2>&1 | FileCheck %s
+# CHECK: error: output file too large
+
+.global _start
+_start:
+ nop
diff --git a/test/ELF/linkerscript/outputarch.s b/test/ELF/linkerscript/outputarch.s
index 99089615cb17..dd3bf93611b4 100644
--- a/test/ELF/linkerscript/outputarch.s
+++ b/test/ELF/linkerscript/outputarch.s
@@ -1,10 +1,4 @@
# REQUIRES: x86
-# RUN: echo "OUTPUT_ARCH(x)" > %t.script
+# RUN: echo "OUTPUT_ARCH(All data written here is ignored)" > %t.script
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-freebsd %s -o %t1
# RUN: ld.lld -shared -o %t2 %t1 %t.script
-# RUN: llvm-readobj %t2 > /dev/null
-
-# RUN: echo "OUTPUT_ARCH(x, y)" > %t.script
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-freebsd %s -o %t1
-# RUN: not ld.lld -shared -o %t2 %t1 %t.script
-# RUN: llvm-readobj %t2 > /dev/null
diff --git a/test/ELF/linkerscript/outsections-addr.s b/test/ELF/linkerscript/outsections-addr.s
index 003b2771c336..fda9bc994340 100644
--- a/test/ELF/linkerscript/outsections-addr.s
+++ b/test/ELF/linkerscript/outsections-addr.s
@@ -1,22 +1,10 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-# RUN: echo "SECTIONS { \
-# RUN: .aaa 0x2000 : \
-# RUN: { \
-# RUN: *(.aaa) \
-# RUN: } \
-# RUN: .bbb 0x1 ? 0x3000 : 0x4000 : \
-# RUN: { \
-# RUN: *(.bbb) \
-# RUN: } \
-# RUN: .ccc ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) : \
-# RUN: { \
-# RUN: *(.ccc) \
-# RUN: } \
-# RUN: .ddd 0x5001 : \
-# RUN: { \
-# RUN: *(.ddd) \
-# RUN: } \
+# RUN: echo "SECTIONS { \
+# RUN: .aaa 0x2000 : { *(.aaa) } \
+# RUN: .bbb 0x1 ? 0x3000 : 0x4000 : { *(.bbb) } \
+# RUN: .ccc ALIGN(CONSTANT(MAXPAGESIZE)) + (. & (CONSTANT(MAXPAGESIZE) - 1)) : { *(.ccc) } \
+# RUN: .ddd 0x5001 : { *(.ddd) } \
# RUN: }" > %t.script
# RUN: ld.lld %t --script %t.script -o %tout
# RUN: llvm-readobj -s %tout | FileCheck %s
diff --git a/test/ELF/linkerscript/page-size.s b/test/ELF/linkerscript/page-size.s
index 3d97816a68ee..330339d67223 100644
--- a/test/ELF/linkerscript/page-size.s
+++ b/test/ELF/linkerscript/page-size.s
@@ -44,9 +44,7 @@
# CHECK-NEXT: Alignment: 16384
# CHECK-NEXT: }
-# RUN: echo "SECTIONS { \
-# RUN: symbol = CONSTANT(MAXPAGESIZE); \
-# RUN: }" > %t.script
+# RUN: echo "SECTIONS { symbol = CONSTANT(MAXPAGESIZE); }" > %t.script
# RUN: ld.lld -z max-page-size=0x4000 -o %t1 --script %t.script %t
# RUN: llvm-objdump -t %t1 | FileCheck -check-prefix CHECK-SCRIPT %s
diff --git a/test/ELF/linkerscript/pt_gnu_eh_frame.s b/test/ELF/linkerscript/pt_gnu_eh_frame.s
new file mode 100644
index 000000000000..81b4c6307d4c
--- /dev/null
+++ b/test/ELF/linkerscript/pt_gnu_eh_frame.s
@@ -0,0 +1,13 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: echo "SECTIONS { /DISCARD/ : { *(.eh_frame*) *(.eh_frame_hdr*) } }" > %t.script
+# RUN: ld.lld -o %t1 --eh-frame-hdr --script %t.script %t
+
+.global _start
+_start:
+ nop
+
+.section .dah,"ax",@progbits
+.cfi_startproc
+ nop
+.cfi_endproc
diff --git a/test/ELF/linkerscript/section-align.s b/test/ELF/linkerscript/section-align.s
new file mode 100644
index 000000000000..f4bdb0feac6d
--- /dev/null
+++ b/test/ELF/linkerscript/section-align.s
@@ -0,0 +1,62 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+
+# RUN: echo "SECTIONS { \
+# RUN: .aaa : ALIGN(4096) { *(.aaa) } \
+# RUN: .bbb : ALIGN(4096 * 4) { *(.bbb) } \
+# RUN: .ccc : ALIGN(4096 * 8) { *(.ccc) } \
+# RUN: }" > %t.script
+# RUN: ld.lld -o %t1 --script %t.script %t
+# RUN: llvm-readobj -sections %t1 | FileCheck %s
+
+.global _start
+_start:
+ nop
+
+// CHECK: Name: .aaa
+// CHECK-NEXT: Type: SHT_PROGBITS
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: SHF_ALLOC
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address:
+// CHECK-NEXT: Offset:
+// CHECK-NEXT: Size: 8
+// CHECK-NEXT: Link: 0
+// CHECK-NEXT: Info: 0
+// CHECK-NEXT: AddressAlignment: 4096
+// CHECK-NEXT: EntrySize:
+
+.section .aaa, "a"
+.quad 0
+
+// CHECK: Name: .bbb
+// CHECK-NEXT: Type: SHT_PROGBITS
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: SHF_ALLOC
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address:
+// CHECK-NEXT: Offset:
+// CHECK-NEXT: Size: 8
+// CHECK-NEXT: Link: 0
+// CHECK-NEXT: Info: 0
+// CHECK-NEXT: AddressAlignment: 16384
+// CHECK-NEXT: EntrySize:
+
+.section .bbb, "a"
+.quad 0
+
+// CHECK: Name: .ccc
+// CHECK-NEXT: Type: SHT_PROGBITS
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: SHF_ALLOC
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address:
+// CHECK-NEXT: Offset:
+// CHECK-NEXT: Size: 8
+// CHECK-NEXT: Link: 0
+// CHECK-NEXT: Info: 0
+// CHECK-NEXT: AddressAlignment: 32768
+// CHECK-NEXT: EntrySize:
+
+.section .ccc, "a"
+.quad 0
diff --git a/test/ELF/linkerscript/sections-gc.s b/test/ELF/linkerscript/sections-gc.s
new file mode 100644
index 000000000000..d71dc652511f
--- /dev/null
+++ b/test/ELF/linkerscript/sections-gc.s
@@ -0,0 +1,19 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: echo "SECTIONS { .text : { *(.text*) } }" > %t.script
+# RUN: ld.lld %t --gc-sections --script %t.script -o %t1
+# RUN: llvm-objdump -section-headers %t1 | FileCheck %s
+
+# CHECK: Sections:
+# CHECK-NEXT: Name Size
+# CHECK: .text 00000001
+
+.section .text.foo, "ax"
+.global _start
+_start:
+ nop
+
+.section .text.bar, "ax"
+.global bar
+bar:
+ nop
diff --git a/test/ELF/linkerscript/sections-gc2.s b/test/ELF/linkerscript/sections-gc2.s
new file mode 100644
index 000000000000..e2941aa57ed6
--- /dev/null
+++ b/test/ELF/linkerscript/sections-gc2.s
@@ -0,0 +1,31 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: echo "SECTIONS { \
+# RUN: used_in_reloc : { *(used_in_reloc) } \
+# RUN: used_in_script : { *(used_in_script) } \
+# RUN: .text : { *(.text) } \
+# RUN: }" > %t.script
+# RUN: ld.lld -T %t.script -o %t.so %t.o --gc-sections
+# RUN: llvm-objdump -h %t.so | FileCheck %s
+
+# CHECK: Idx Name Size Address Type
+# CHECK-NEXT: 0
+# CHECK-NEXT: used_in_reloc
+# CHECK-NEXT: .text
+# CHECK-NEXT: .comment
+# CHECK-NEXT: .symtab
+# CHECK-NEXT: .shstrtab
+# CHECK-NEXT: .strtab
+
+ .global _start
+_start:
+ .quad __start_used_in_reloc
+
+ .section unused,"a"
+ .quad 0
+
+ .section used_in_script,"a"
+ .quad __start_used_in_script
+
+ .section used_in_reloc,"a"
+ .quad 0
diff --git a/test/ELF/linkerscript/sections-padding.s b/test/ELF/linkerscript/sections-padding.s
index 51d3a88fadf6..91ced2ef7a1e 100644
--- a/test/ELF/linkerscript/sections-padding.s
+++ b/test/ELF/linkerscript/sections-padding.s
@@ -5,13 +5,13 @@
# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x1122 }" > %t.script
# RUN: ld.lld -o %t.out --script %t.script %t
# RUN: llvm-objdump -s %t.out | FileCheck -check-prefix=YES %s
-# YES: 66001122 00001122 00001122 00001122
+# YES: 66000011 22000011 22000011 22000011
## Confirming that address was correct:
# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x99887766 }" > %t.script
# RUN: ld.lld -o %t.out --script %t.script %t
# RUN: llvm-objdump -s %t.out | FileCheck -check-prefix=YES2 %s
-# YES2: 66887766 99887766 99887766 99887766
+# YES2: 66998877 66998877 66998877 66998877
## Default padding value is 0x00:
# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } }" > %t.script
@@ -23,7 +23,7 @@
# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =777 }" > %t.script
# RUN: ld.lld -o %t.out --script %t.script %t
# RUN: llvm-objdump -s %t.out | FileCheck -check-prefix=DEC %s
-# DEC: 66000309 00000309 00000309 00000309
+# DEC: 66000003 09000003 09000003 09000003
## Invalid hex value:
# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x99XX }" > %t.script
@@ -36,6 +36,11 @@
# RUN: ld.lld -o %t.out --script %t.script %t
# RUN: llvm-objdump -s %t.out | FileCheck -check-prefix=YES %s
+## Check case with optional comma following output section command:
+# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x1122, .a : { *(.a*) } }" > %t.script
+# RUN: ld.lld -o %t.out --script %t.script %t
+# RUN: llvm-objdump -s %t.out | FileCheck -check-prefix=YES %s
+
.section .mysec.1,"a"
.align 16
.byte 0x66
diff --git a/test/ELF/linkerscript/sections-sort.s b/test/ELF/linkerscript/sections-sort.s
index cf1fd3e57827..0e99851910f4 100644
--- a/test/ELF/linkerscript/sections-sort.s
+++ b/test/ELF/linkerscript/sections-sort.s
@@ -1,10 +1,7 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
-# RUN: echo "SECTIONS { \
-# RUN: .text : { *(.text) } \
-# RUN: foo : { *(foo) } \
-# RUN: } " > %t.script
+# RUN: echo "SECTIONS { .text : {*(.text)} foo : {*(foo)}}" > %t.script
# RUN: ld.lld -o %t --script %t.script %t.o -shared
# RUN: llvm-objdump --section-headers %t | FileCheck %s
diff --git a/test/ELF/linkerscript/sections.s b/test/ELF/linkerscript/sections.s
index 2cb9395e6692..1a2323c001dc 100644
--- a/test/ELF/linkerscript/sections.s
+++ b/test/ELF/linkerscript/sections.s
@@ -66,22 +66,11 @@
# SEC-SWAP-NAMES: 7 .shstrtab 0000003b {{[0-9a-f]*}}
# SEC-SWAP-NAMES: 8 .strtab 00000008 {{[0-9a-f]*}}
-# .shstrtab from the input object file is discarded.
-# RUN: echo "SECTIONS { \
-# RUN: /DISCARD/ : { *(.shstrtab) } }" > %t.script
-# RUN: ld.lld -o %t5 --script %t.script %t
-# RUN: llvm-objdump -section-headers %t5 | \
+# Attemp to discard .shstrtab section.
+# RUN: echo "SECTIONS { /DISCARD/ : { *(.shstrtab) } }" > %t.script
+# RUN: not ld.lld -o %t5 --script %t.script %t 2>&1 | \
# RUN: FileCheck -check-prefix=SEC-DISCARD %s
-
-# Idx Name Size
-# SEC-DISCARD: 1 .text 0000000e {{[0-9a-f]*}} TEXT DATA
-# SEC-DISCARD: 2 .data 00000020 {{[0-9a-f]*}} DATA
-# SEC-DISCARD: 3 other 00000003 {{[0-9a-f]*}} DATA
-# SEC-DISCARD: 4 .bss 00000002 {{[0-9a-f]*}} BSS
-# SEC-DISCARD: 5 .comment 00000008 {{[0-9a-f]*}}
-# SEC-DISCARD: 6 .symtab 00000030 {{[0-9a-f]*}}
-# SEC-DISCARD: 7 .shstrtab 0000003b {{[0-9a-f]*}}
-# SEC-DISCARD: 8 .strtab 00000008 {{[0-9a-f]*}}
+# SEC-DISCARD: discarding .shstrtab section is not allowed
# Multiple SECTIONS command specifying additional input section descriptions
# for the same output section description - input sections are merged into
@@ -104,6 +93,11 @@
# SEC-MULTI: 6 .shstrtab 00000035 {{[0-9a-f]*}}
# SEC-MULTI: 7 .strtab 00000008 {{[0-9a-f]*}}
+# Input section pattern contains additional semicolon.
+# Case found in linux kernel script. Check we are able to parse it.
+# RUN: echo "SECTIONS { .text : { ;;*(.text);;S = 0;; } }" > %t.script
+# RUN: ld.lld -o /dev/null --script %t.script %t
+
.globl _start
_start:
mov $60, %rax
diff --git a/test/ELF/linkerscript/symbol-assignexpr.s b/test/ELF/linkerscript/symbol-assignexpr.s
index 5132ab11d821..14a1f0890ca6 100644
--- a/test/ELF/linkerscript/symbol-assignexpr.s
+++ b/test/ELF/linkerscript/symbol-assignexpr.s
@@ -40,9 +40,7 @@
# CHECK-NEXT: 0000000000029000 *ABS* 00000000 symbol11
# CHECK-NEXT: 0000000000001235 *ABS* 00000000 symbol12
-# RUN: echo "SECTIONS { \
-# RUN: symbol2 = symbol; \
-# RUN: }" > %t2.script
+# RUN: echo "SECTIONS { symbol2 = symbol; }" > %t2.script
# RUN: not ld.lld -o %t2 --script %t2.script %t 2>&1 \
# RUN: | FileCheck -check-prefix=ERR %s
# ERR: {{.*}}.script:1: symbol not found: symbol
diff --git a/test/ELF/linkerscript/symbol-only.s b/test/ELF/linkerscript/symbol-only.s
index 76d54f01cdc7..2fb57260b333 100644
--- a/test/ELF/linkerscript/symbol-only.s
+++ b/test/ELF/linkerscript/symbol-only.s
@@ -12,7 +12,7 @@
# CHECK: Sections:
# CHECK-NEXT: Idx Name Size Address
# CHECK-NEXT: 0 00000000 0000000000000000
-# CHECK: abc 00000000 [[ADDR:[0-9a-f]*]] BSS
+# CHECK: abc 00000000 [[ADDR:[0-9a-f]*]] DATA
# CHECK-NEXT: bar 00000000 0000000000001000 DATA
# CHECK: SYMBOL TABLE:
diff --git a/test/ELF/linkerscript/symbol-reserved.s b/test/ELF/linkerscript/symbol-reserved.s
new file mode 100644
index 000000000000..ccbe761738ba
--- /dev/null
+++ b/test/ELF/linkerscript/symbol-reserved.s
@@ -0,0 +1,16 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: echo "PROVIDE_HIDDEN(newsym = __ehdr_start + 5);" > %t.script
+# RUN: ld.lld -o %t1 %t.script %t
+# RUN: llvm-objdump -t %t1 | FileCheck %s
+
+# CHECK: 0000000000200005 .text 00000000 .hidden newsym
+
+# RUN: ld.lld -o %t1.so %t.script %t -shared
+# RUN: llvm-objdump -t %t1.so | FileCheck --check-prefix=SHARED %s
+
+# SHARED: 0000000000000005 .dynsym 00000000 .hidden newsym
+
+.global _start
+_start:
+ lea newsym(%rip),%rax
diff --git a/test/ELF/linkerscript/symbols-non-alloc.s b/test/ELF/linkerscript/symbols-non-alloc.s
new file mode 100644
index 000000000000..4184487a7817
--- /dev/null
+++ b/test/ELF/linkerscript/symbols-non-alloc.s
@@ -0,0 +1,16 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+
+# RUN: echo "SECTIONS { . = SIZEOF_HEADERS; \
+# RUN: .text : { *(.text) } \
+# RUN: .nonalloc : { *(.nonalloc) } \
+# RUN: Sym = .; \
+# RUN: }" > %t.script
+# RUN: ld.lld -o %t2 --script %t.script %t
+# RUN: llvm-objdump -section-headers -t %t2 | FileCheck %s
+
+# CHECK: SYMBOL TABLE:
+# CHECK: 00000000000000f0 .nonalloc 00000000 Sym
+
+.section .nonalloc,""
+ .quad 0
diff --git a/test/ELF/lto/Inputs/cache.ll b/test/ELF/lto/Inputs/cache.ll
new file mode 100644
index 000000000000..092890299177
--- /dev/null
+++ b/test/ELF/lto/Inputs/cache.ll
@@ -0,0 +1,10 @@
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @_start() {
+entry:
+ call void (...) @globalfunc()
+ ret i32 0
+}
+
+declare void @globalfunc(...)
diff --git a/test/ELF/lto/archive-no-index.ll b/test/ELF/lto/archive-no-index.ll
new file mode 100644
index 000000000000..0dca16ba04fb
--- /dev/null
+++ b/test/ELF/lto/archive-no-index.ll
@@ -0,0 +1,39 @@
+; REQUIRES: x86
+; Tests that we suggest that LTO symbols missing from an archive index
+; may be the cause of undefined references, but only if we both
+; encountered an empty archive index and undefined references (to prevent
+; noisy false alarms).
+
+; RUN: rm -fr %T/archive-no-index
+; RUN: mkdir %T/archive-no-index
+; RUN: llvm-as %S/Inputs/archive.ll -o %T/archive-no-index/f.o
+; RUN: llvm-ar cr %T/archive-no-index/libf.a
+; RUN: llvm-ar qS %T/archive-no-index/libf.a %T/archive-no-index/f.o
+; RUN: llvm-as %s -o %t.o
+; RUN: not ld.lld -emain -m elf_x86_64 %t.o -o %t %T/archive-no-index/libf.a \
+; RUN: 2>&1 | FileCheck --check-prefix=NOTE %s
+
+; RUN: llvm-ar crs %T/archive-no-index/libfs.a %T/archive-no-index/f.o
+; RUN: ld.lld -emain -m elf_x86_64 %t.o -o %t %T/archive-no-index/libf.a \
+; RUN: %T/archive-no-index/libfs.a
+
+; RUN: llvm-as %S/Inputs/archive-3.ll -o %T/archive-no-index/foo.o
+; RUN: llvm-ar crs %T/archive-no-index/libfoo.a %T/archive-no-index/foo.o
+; RUN: not ld.lld -emain -m elf_x86_64 %t.o -o %t %T/archive-no-index/libfoo.a \
+; RUN: 2>&1 | FileCheck --check-prefix=NO-NOTE %s
+
+; NOTE: undefined symbol: f
+; NOTE: archive listed no symbols
+
+; NO-NOTE: undefined symbol: f
+; NO-NOTE-NOT: archive listed no symbols
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @f()
+
+define i32 @main() {
+ call void @f()
+ ret i32 0
+}
diff --git a/test/ELF/lto/cache.ll b/test/ELF/lto/cache.ll
new file mode 100644
index 000000000000..55e3a3d6f6cd
--- /dev/null
+++ b/test/ELF/lto/cache.ll
@@ -0,0 +1,21 @@
+; REQUIRES: x86
+
+; RUN: opt -module-hash -module-summary %s -o %t.o
+; RUN: opt -module-hash -module-summary %p/Inputs/cache.ll -o %t2.o
+
+; RUN: rm -Rf %t.cache && mkdir %t.cache
+; Create two files that would be removed by cache pruning due to age.
+; We should only remove files matching the pattern "llvmcache-*".
+; RUN: touch -t 197001011200 %t.cache/llvmcache-foo %t.cache/foo
+; RUN: ld.lld --thinlto-cache-dir=%t.cache --thinlto-cache-policy prune_after=1h -o %t3 %t2.o %t.o
+
+; Two cached objects, plus a timestamp file and "foo", minus the file we removed.
+; RUN: ls %t.cache | count 4
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @globalfunc() #0 {
+entry:
+ ret void
+}
diff --git a/test/ELF/lto/codemodel.ll b/test/ELF/lto/codemodel.ll
new file mode 100644
index 000000000000..cc126202f299
--- /dev/null
+++ b/test/ELF/lto/codemodel.ll
@@ -0,0 +1,20 @@
+; REQUIRES: x86
+; RUN: llvm-as %s -o %t.o
+; RUN: ld.lld -m elf_x86_64 %t.o -o %ts -mllvm -code-model=small
+; RUN: ld.lld -m elf_x86_64 %t.o -o %tl -mllvm -code-model=large
+; RUN: llvm-objdump -d %ts | FileCheck %s --check-prefix=CHECK-SMALL
+; RUN: llvm-objdump -d %tl | FileCheck %s --check-prefix=CHECK-LARGE
+
+target triple = "x86_64-unknown-linux-gnu"
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+@data = internal constant [0 x i32] []
+
+define i32* @_start() nounwind readonly {
+entry:
+; CHECK-SMALL-LABEL: _start:
+; CHECK-SMALL: movl $2097440, %eax
+; CHECK-LARGE-LABEL: _start:
+; CHECK-LARGE: movabsq $2097440, %rax
+ ret i32* getelementptr ([0 x i32], [0 x i32]* @data, i64 0, i64 0)
+}
diff --git a/test/ELF/lto/combined-lto-object-name.ll b/test/ELF/lto/combined-lto-object-name.ll
index f46efc4f7387..76564f90c665 100644
--- a/test/ELF/lto/combined-lto-object-name.ll
+++ b/test/ELF/lto/combined-lto-object-name.ll
@@ -11,4 +11,6 @@ define void @_start() {
ret void
}
-; CHECK: error: ld-temp.o:(function _start): undefined symbol 'foo'
+; CHECK: error: undefined symbol: foo
+; CHECK: >>> referenced by ld-temp.o
+; CHECK: {{.*}}:(_start)
diff --git a/test/ELF/lto/duplicated.ll b/test/ELF/lto/duplicated.ll
index 903592c46067..156748117a23 100644
--- a/test/ELF/lto/duplicated.ll
+++ b/test/ELF/lto/duplicated.ll
@@ -1,7 +1,11 @@
; REQUIRES: x86
; RUN: llvm-as %s -o %t.o
; RUN: not ld.lld -m elf_x86_64 %t.o %t.o -o %t.so -shared 2>&1 | FileCheck %s
-; CHECK: duplicate symbol 'f' in {{.*}}.o and {{.*}}.o
+
+; CHECK: duplicate symbol: f
+; CHECK-NEXT: >>> defined in {{.*}}.o
+; CHECK-NEXT: >>> defined in {{.*}}.o
+
target triple = "x86_64-unknown-linux-gnu"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
diff --git a/test/ELF/lto/opt-remarks.ll b/test/ELF/lto/opt-remarks.ll
new file mode 100644
index 000000000000..88304205caba
--- /dev/null
+++ b/test/ELF/lto/opt-remarks.ll
@@ -0,0 +1,68 @@
+; RUN: llvm-as %s -o %t.o
+
+; RUN: rm -f %t.yaml
+; RUN: ld.lld --opt-remarks-filename %t.yaml %t.o -o %t -shared -save-temps
+; RUN: llvm-dis %t.0.4.opt.bc -o - | FileCheck %s
+; RUN: ld.lld --opt-remarks-with-hotness --opt-remarks-filename %t.hot.yaml \
+; RUN: %t.o -o %t -shared
+; RUN: cat %t.yaml | FileCheck %s -check-prefix=YAML
+; RUN: cat %t.hot.yaml | FileCheck %s -check-prefix=YAML-HOT
+
+; Check that @tinkywinky is inlined after optimizations.
+; CHECK-LABEL: define i32 @main
+; CHECK-NEXT: %a.i = call i32 @patatino()
+; CHECK-NEXT: ret i32 %a.i
+; CHECK-NEXT: }
+
+; YAML: --- !Analysis
+; YAML-NEXT: Pass: inline
+; YAML-NEXT: Name: CanBeInlined
+; YAML-NEXT: Function: main
+; YAML-NEXT: Args:
+; YAML-NEXT: - Callee: tinkywinky
+; YAML-NEXT: - String: ' can be inlined into '
+; YAML-NEXT: - Caller: main
+; YAML-NEXT: - String: ' with cost='
+; YAML-NEXT: - Cost: '0'
+; YAML-NEXT: - String: ' (threshold='
+; YAML-NEXT: - Threshold: '337'
+; YAML-NEXT: - String: ')'
+; YAML-NEXT: ...
+; YAML-NEXT: --- !Passed
+; YAML-NEXT: Pass: inline
+; YAML-NEXT: Name: Inlined
+; YAML-NEXT: Function: main
+; YAML-NEXT: Args:
+; YAML-NEXT: - Callee: tinkywinky
+; YAML-NEXT: - String: ' inlined into '
+; YAML-NEXT: - Caller: main
+; YAML-NEXT: ...
+
+; YAML-HOT: ...
+; YAML-HOT: --- !Passed
+; YAML-HOT: Pass: inline
+; YAML-HOT-NEXT: Name: Inlined
+; YAML-HOT-NEXT: Function: main
+; YAML-HOT-NEXT: Hotness: 300
+; YAML-HOT-NEXT: Args:
+; YAML-HOT-NEXT: - Callee: tinkywinky
+; YAML-HOT-NEXT: - String: ' inlined into '
+; YAML-HOT-NEXT: - Caller: main
+; YAML-HOT-NEXT: ...
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-scei-ps4"
+
+declare i32 @patatino()
+
+define i32 @tinkywinky() {
+ %a = call i32 @patatino()
+ ret i32 %a
+}
+
+define i32 @main() !prof !0 {
+ %i = call i32 @tinkywinky()
+ ret i32 %i
+}
+
+!0 = !{!"function_entry_count", i64 300}
diff --git a/test/ELF/lto/parallel-internalize.ll b/test/ELF/lto/parallel-internalize.ll
index a7ee4b35877e..da5bdc6892a8 100644
--- a/test/ELF/lto/parallel-internalize.ll
+++ b/test/ELF/lto/parallel-internalize.ll
@@ -1,9 +1,10 @@
; REQUIRES: x86
; RUN: llvm-as -o %t.bc %s
+; RUN: rm -f %t.lto.o %t1.lto.o
; RUN: ld.lld -m elf_x86_64 --lto-partitions=2 -save-temps -o %t %t.bc \
; RUN: -e foo --lto-O0
; RUN: llvm-readobj -t -dyn-symbols %t | FileCheck %s
-; RUN: llvm-nm %t0.lto.o | FileCheck --check-prefix=CHECK0 %s
+; RUN: llvm-nm %t.lto.o | FileCheck --check-prefix=CHECK0 %s
; RUN: llvm-nm %t1.lto.o | FileCheck --check-prefix=CHECK1 %s
; CHECK: Symbols [
diff --git a/test/ELF/lto/parallel.ll b/test/ELF/lto/parallel.ll
index c5d7ca4e2cf1..a1c15af380f0 100644
--- a/test/ELF/lto/parallel.ll
+++ b/test/ELF/lto/parallel.ll
@@ -1,7 +1,8 @@
; REQUIRES: x86
; RUN: llvm-as -o %t.bc %s
+; RUN: rm -f %t.lto.o %t1.lto.o
; RUN: ld.lld -m elf_x86_64 --lto-partitions=2 -save-temps -o %t %t.bc -shared
-; RUN: llvm-nm %t0.lto.o | FileCheck --check-prefix=CHECK0 %s
+; RUN: llvm-nm %t.lto.o | FileCheck --check-prefix=CHECK0 %s
; RUN: llvm-nm %t1.lto.o | FileCheck --check-prefix=CHECK1 %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
diff --git a/test/ELF/lto/thinlto.ll b/test/ELF/lto/thinlto.ll
index 160c83a18abf..2036c554a76d 100644
--- a/test/ELF/lto/thinlto.ll
+++ b/test/ELF/lto/thinlto.ll
@@ -3,19 +3,20 @@
; RUN: opt -module-summary %p/Inputs/thinlto.ll -o %t2.o
; First force single-threaded mode
+; RUN: rm -f %t.lto.o %t1.lto.o
; RUN: ld.lld -save-temps --thinlto-jobs=1 -shared %t.o %t2.o -o %t
-; RUN: llvm-nm %t0.lto.o | FileCheck %s --check-prefix=NM1-SINGLE
-; RUN: llvm-nm %t1.lto.o | FileCheck %s --check-prefix=NM2-SINGLE
-
-; NM1-SINGLE: T f
-; NM2-SINGLE: T g
+; RUN: llvm-nm %t.lto.o | FileCheck %s --check-prefix=NM1
+; RUN: llvm-nm %t1.lto.o | FileCheck %s --check-prefix=NM2
; Next force multi-threaded mode
+; RUN: rm -f %t2.lto.o %t21.lto.o
; RUN: ld.lld -save-temps --thinlto-jobs=2 -shared %t.o %t2.o -o %t2
-; RUN: llvm-nm %t20.lto.o | FileCheck %s --check-prefix=NM1
+; RUN: llvm-nm %t2.lto.o | FileCheck %s --check-prefix=NM1
; RUN: llvm-nm %t21.lto.o | FileCheck %s --check-prefix=NM2
; NM1: T f
+; NM1-NOT: U g
+
; NM2: T g
; Then check without --thinlto-jobs (which currently default to hardware_concurrency)
diff --git a/test/ELF/map-file.s b/test/ELF/map-file.s
new file mode 100644
index 000000000000..e74c91645cb9
--- /dev/null
+++ b/test/ELF/map-file.s
@@ -0,0 +1,62 @@
+// REQUIRES: x86
+
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/map-file2.s -o %t2.o
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/map-file3.s -o %t3.o
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/map-file4.s -o %t4.o
+// RUN: rm -f %t4.a
+// RUN: llvm-ar rc %t4.a %t4.o
+// RUN: ld.lld %t1.o %t2.o %t3.o %t4.a -o %t -M | FileCheck %s
+// RUN: ld.lld %t1.o %t2.o %t3.o %t4.a -o %t -print-map | FileCheck %s
+// RUN: ld.lld %t1.o %t2.o %t3.o %t4.a -o %t -Map=%t.map
+// RUN: FileCheck %s < %t.map
+
+.global _start
+_start:
+ call baz
+.global _Z1fi
+_Z1fi:
+.cfi_startproc
+.cfi_endproc
+nop
+.weak bar
+bar:
+.long bar - .
+.long zed - .
+local:
+.comm common,4,16
+
+// CHECK: Address Size Align Out In File Symbol
+// CHECK-NEXT: 0000000000200158 0000000000000030 8 .eh_frame
+// CHECK-NEXT: 0000000000200158 0000000000000030 8 .eh_frame
+// CHECK-NEXT: 0000000000201000 0000000000000015 4 .text
+// CHECK-NEXT: 0000000000201000 000000000000000e 4 .text
+// CHECK-NEXT: 0000000000201000 000000000000000e 4 {{.*}}{{/|\\}}map-file.s.tmp1.o
+// CHECK-NEXT: 000000000020100e 0000000000000000 0 local
+// CHECK-NEXT: 0000000000201005 0000000000000000 0 f(int)
+// CHECK-NEXT: 0000000000201000 0000000000000000 0 _start
+// CHECK-NEXT: 0000000000201010 0000000000000002 4 {{.*}}{{/|\\}}map-file.s.tmp2.o
+// CHECK-NEXT: 0000000000201010 0000000000000000 0 foo
+// CHECK-NEXT: 0000000000201011 0000000000000000 0 bar
+// CHECK-NEXT: 0000000000201012 0000000000000000 1 .text.zed
+// CHECK-NEXT: 0000000000201012 0000000000000000 1 {{.*}}{{/|\\}}map-file.s.tmp2.o
+// CHECK-NEXT: 0000000000201012 0000000000000000 0 zed
+// CHECK-NEXT: 0000000000201014 0000000000000000 4 .text
+// CHECK-NEXT: 0000000000201014 0000000000000000 4 {{.*}}{{/|\\}}map-file.s.tmp3.o
+// CHECK-NEXT: 0000000000201014 0000000000000000 0 bah
+// CHECK-NEXT: 0000000000201014 0000000000000001 4 {{.*}}{{/|\\}}map-file.s.tmp4.a(map-file.s.tmp4.o)
+// CHECK-NEXT: 0000000000201014 0000000000000000 0 baz
+// CHECK-NEXT: 0000000000202000 0000000000000004 16 .bss
+// CHECK-NEXT: 0000000000202000 0000000000000004 16 COMMON
+// CHECK-NEXT: 0000000000000000 0000000000000008 1 .comment
+// CHECK-NEXT: 0000000000000000 0000000000000008 1 .comment
+// CHECK-NEXT: 0000000000000000 00000000000000f0 8 .symtab
+// CHECK-NEXT: 0000000000000000 00000000000000f0 8 .symtab
+// CHECK-NEXT: 0000000000000000 0000000000000039 1 .shstrtab
+// CHECK-NEXT: 0000000000000000 0000000000000039 1 .shstrtab
+// CHECK-NEXT: 0000000000000000 000000000000002f 1 .strtab
+// CHECK-NEXT: 0000000000000000 000000000000002f 1 .strtab
+
+// RUN: not ld.lld %t1.o %t2.o %t3.o %t4.a -o %t -Map=/ 2>&1 \
+// RUN: | FileCheck -check-prefix=FAIL %s
+// FAIL: cannot open map file /
diff --git a/test/ELF/merge-reloc.s b/test/ELF/merge-reloc.s
index 2447e3e9444f..934ac3b9384e 100644
--- a/test/ELF/merge-reloc.s
+++ b/test/ELF/merge-reloc.s
@@ -10,7 +10,7 @@
# CHECK: Section {
# CHECK: Index:
-# CHECK: Name: .data
+# CHECK: Name: .rodata
# CHECK-NEXT: Type: SHT_PROGBITS
# CHECK-NEXT: Flags [
# CHECK-NEXT: SHF_ALLOC
@@ -29,7 +29,7 @@
# CHECK-NEXT: }
# CHECK: Section {
# CHECK: Index:
-# CHECK: Name: .data
+# CHECK: Name: .rodata
# CHECK-NEXT: Type: SHT_PROGBITS
# CHECK-NEXT: Flags [
# CHECK-NEXT: SHF_ALLOC
@@ -66,7 +66,7 @@
# CHECK-NEXT: )
# CHECK-NEXT: }
- .section .data.1,"aM",@progbits,4
+ .section .rodata.1,"aM",@progbits,4
.align 4
.global foo
foo:
@@ -74,7 +74,7 @@ foo:
.long 0x42
.long 0x42
- .section .data.2,"aM",@progbits,8
+ .section .rodata.2,"aM",@progbits,8
.align 8
.global bar
bar:
diff --git a/test/ELF/merge-string-align.s b/test/ELF/merge-string-align.s
index 0cb1afc8ba7d..bcad6ee2d963 100644
--- a/test/ELF/merge-string-align.s
+++ b/test/ELF/merge-string-align.s
@@ -34,10 +34,10 @@
// CHECK-NEXT: 0010: 62617200 |bar.|
// CHECK-NEXT: )
- .section .rodata.str1.1,"aMS",@progbits,1
+ .section .rodata2,"aMS",@progbits,1
.asciz "foo"
-// CHECK: Name: .rodata
+// CHECK: Name: .rodata2
// CHECK-NEXT: Type: SHT_PROGBITS
// CHECK-NEXT: Flags [
// CHECK-NEXT: SHF_ALLOC
diff --git a/test/ELF/merge-string.s b/test/ELF/merge-string.s
index ffcafdea28a4..13c89f029711 100644
--- a/test/ELF/merge-string.s
+++ b/test/ELF/merge-string.s
@@ -7,7 +7,7 @@
// RUN: ld.lld -O0 %t.o -o %t.so -shared
// RUN: llvm-readobj -s -section-data -t %t.so | FileCheck --check-prefix=NOMERGE %s
- .section .rodata.str1.1,"aMS",@progbits,1
+ .section .rodata1,"aMS",@progbits,1
.asciz "abc"
foo:
.ascii "a"
@@ -15,13 +15,13 @@ bar:
.asciz "bc"
.asciz "bc"
- .section .rodata.str2.2,"aMS",@progbits,2
+ .section .rodata2,"aMS",@progbits,2
.align 2
zed:
.short 20
.short 0
-// CHECK: Name: .rodata
+// CHECK: Name: .rodata1
// CHECK-NEXT: Type: SHT_PROGBITS
// CHECK-NEXT: Flags [
// CHECK-NEXT: SHF_ALLOC
@@ -34,12 +34,12 @@ zed:
// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
// CHECK-NEXT: AddressAlignment: 1
-// CHECK-NEXT: EntrySize: 1
+// CHECK-NEXT: EntrySize: 0
// CHECK-NEXT: SectionData (
// CHECK-NEXT: 0000: 61626300 |abc.|
// CHECK-NEXT: )
-// NOTAIL: Name: .rodata
+// NOTAIL: Name: .rodata1
// NOTAIL-NEXT: Type: SHT_PROGBITS
// NOTAIL-NEXT: Flags [
// NOTAIL-NEXT: SHF_ALLOC
@@ -52,28 +52,30 @@ zed:
// NOTAIL-NEXT: Link: 0
// NOTAIL-NEXT: Info: 0
// NOTAIL-NEXT: AddressAlignment: 1
-// NOTAIL-NEXT: EntrySize: 1
+// NOTAIL-NEXT: EntrySize: 0
// NOTAIL-NEXT: SectionData (
// NOTAIL-NEXT: 0000: 61626300 626300 |abc.bc.|
// NOTAIL-NEXT: )
-// NOMERGE: Name: .rodata
+// NOMERGE: Name: .rodata1
// NOMERGE-NEXT: Type: SHT_PROGBITS
// NOMERGE-NEXT: Flags [
// NOMERGE-NEXT: SHF_ALLOC
+// NOMERGE-NEXT: SHF_MERGE
+// NOMERGE-NEXT: SHF_STRINGS
// NOMERGE-NEXT: ]
// NOMERGE-NEXT: Address: 0x1C8
// NOMERGE-NEXT: Offset: 0x1C8
-// NOMERGE-NEXT: Size: 16
+// NOMERGE-NEXT: Size: 11
// NOMERGE-NEXT: Link: 0
// NOMERGE-NEXT: Info: 0
-// NOMERGE-NEXT: AddressAlignment: 2
-// NOMERGE-NEXT: EntrySize: 0
+// NOMERGE-NEXT: AddressAlignment: 1
+// NOMERGE-NEXT: EntrySize: 1
// NOMERGE-NEXT: SectionData (
-// NOMERGE-NEXT: 0000: 61626300 61626300 62630000 14000000 |abc.abc.bc......|
+// NOMERGE-NEXT: 0000: 61626300 61626300 626300 |abc.abc.bc.|
// NOMERGE-NEXT: )
-// CHECK: Name: .rodata
+// CHECK: Name: .rodata2
// CHECK-NEXT: Type: SHT_PROGBITS
// CHECK-NEXT: Flags [
// CHECK-NEXT: SHF_ALLOC
@@ -86,7 +88,7 @@ zed:
// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
// CHECK-NEXT: AddressAlignment: 2
-// CHECK-NEXT: EntrySize: 2
+// CHECK-NEXT: EntrySize: 0
// CHECK-NEXT: SectionData (
// CHECK-NEXT: 0000: 14000000 |....|
// CHECK-NEXT: )
diff --git a/test/ELF/merge.s b/test/ELF/merge.s
index b84d33a3411e..fba41346c536 100644
--- a/test/ELF/merge.s
+++ b/test/ELF/merge.s
@@ -29,7 +29,7 @@ zed:
// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
// CHECK-NEXT: AddressAlignment: 4
-// CHECK-NEXT: EntrySize: 4
+// CHECK-NEXT: EntrySize: 0
// CHECK-NEXT: SectionData (
// CHECK-NEXT: 0000: 10000000 42000000
// CHECK-NEXT: )
diff --git a/test/ELF/mips-elf-flags-err.s b/test/ELF/mips-elf-flags-err.s
index eab8377b17e2..28d93eb6bea7 100644
--- a/test/ELF/mips-elf-flags-err.s
+++ b/test/ELF/mips-elf-flags-err.s
@@ -20,7 +20,7 @@
# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux \
# RUN: -mcpu=mips64r6 %S/Inputs/mips-dynamic.s -o %t1.o
# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux \
-# RUN: -mcpu=octeon %s -o %t2.o
+# RUN: -position-independent -mcpu=octeon %s -o %t2.o
# RUN: not ld.lld %t1.o %t2.o -o %t.exe 2>&1 \
# RUN: | FileCheck -check-prefix=R6OCTEON %s
@@ -35,9 +35,9 @@
# Check that lld take in account EF_MIPS_MACH_XXX ISA flags
# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux \
-# RUN: -mcpu=mips64 %S/Inputs/mips-dynamic.s -o %t1.o
+# RUN: -position-independent -mcpu=mips64 %S/Inputs/mips-dynamic.s -o %t1.o
# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux \
-# RUN: -mcpu=octeon %s -o %t2.o
+# RUN: -position-independent -mcpu=octeon %s -o %t2.o
# RUN: ld.lld %t1.o %t2.o -o %t.exe
# RUN: llvm-readobj -h %t.exe | FileCheck -check-prefix=OCTEON %s
@@ -79,8 +79,7 @@ __start:
# OCTEON-NEXT: EF_MIPS_ARCH_64R2
# OCTEON-NEXT: EF_MIPS_CPIC
# OCTEON-NEXT: EF_MIPS_MACH_OCTEON
-# OCTEON-NEXT: EF_MIPS_PIC
-# OCTEON-NEXT: ]
+# OCTEON: ]
# N32O32: error: {{.*}}mips-elf-flags-err.s.tmp2.o is incompatible with {{.*}}mips-elf-flags-err.s.tmp1.o
diff --git a/test/ELF/mips-elf-flags.s b/test/ELF/mips-elf-flags.s
index 26dc42ded546..f8f916c9353d 100644
--- a/test/ELF/mips-elf-flags.s
+++ b/test/ELF/mips-elf-flags.s
@@ -2,7 +2,7 @@
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
# RUN: %S/Inputs/mips-dynamic.s -o %t-so.o
-# RUN: ld.lld %t-so.o -shared -o %t.so
+# RUN: ld.lld %t-so.o --gc-sections -shared -o %t.so
# RUN: llvm-readobj -h -mips-abi-flags %t.so | FileCheck -check-prefix=SO %s
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
@@ -30,7 +30,7 @@
# RUN: | FileCheck -check-prefix=EXE-R6 %s
# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux \
-# RUN: -mcpu=octeon %s -o %t.o
+# RUN: -position-independent -mcpu=octeon %s -o %t.o
# RUN: ld.lld %t.o -o %t.exe
# RUN: llvm-readobj -h -mips-abi-flags %t.exe \
# RUN: | FileCheck -check-prefix=OCTEON %s
diff --git a/test/ELF/mips-got-string.s b/test/ELF/mips-got-string.s
new file mode 100644
index 000000000000..598865c681f6
--- /dev/null
+++ b/test/ELF/mips-got-string.s
@@ -0,0 +1,28 @@
+# Check R_MIPS_GOT16 relocation against merge section.
+
+# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux -o %t.o %s
+# RUN: ld.lld -shared -o %t.so %t.o
+# RUN: llvm-readobj -t -mips-plt-got %t.so | FileCheck %s
+
+# REQUIRES: mips
+
+# CHECK: Symbol {
+# CHECK: Name: $.str
+# CHECK-NEXT: Value: 0xF4
+# CHECK: }
+
+# CHECK: Local entries [
+# CHECK-NEXT: Entry {
+# CHECK-NEXT: Address:
+# CHECK-NEXT: Access: -32744
+# CHECK-NEXT: Initial: 0x0
+# CHECK: }
+# CHECK: ]
+
+ .text
+ lw $t9, %got($.str)($gp)
+ addiu $a0, $t9, %lo($.str)
+
+ .section .rodata.str,"aMS",@progbits,1
+$.str:
+ .asciz "foo"
diff --git a/test/ELF/mips-got16-relocatable.s b/test/ELF/mips-got16-relocatable.s
new file mode 100644
index 000000000000..963efeb4686e
--- /dev/null
+++ b/test/ELF/mips-got16-relocatable.s
@@ -0,0 +1,40 @@
+# Check writing updated addend for R_MIPS_GOT16 relocation,
+# when produce a relocatable output.
+
+# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux -o %t.o %s
+# RUN: ld.lld -r -o %t %t.o %t.o
+# RUN: llvm-objdump -d -r %t | FileCheck -check-prefix=OBJ %s
+# RUN: ld.lld -shared -o %t.so %t
+# RUN: llvm-objdump -d %t.so | FileCheck -check-prefix=SO %s
+
+# REQUIRES: mips
+
+# OBJ: Disassembly of section .text:
+# OBJ-NEXT: .text:
+# OBJ-NEXT: 0: 8f 99 00 00 lw $25, 0($gp)
+# OBJ-NEXT: 00000000: R_MIPS_GOT16 .data
+# OBJ-NEXT: 4: 27 24 00 00 addiu $4, $25, 0
+# OBJ-NEXT: 00000004: R_MIPS_LO16 .data
+# OBJ-NEXT: 8: 00 00 00 00 nop
+# OBJ-NEXT: c: 00 00 00 00 nop
+# OBJ-NEXT: 10: 8f 99 00 00 lw $25, 0($gp)
+# OBJ-NEXT: 00000010: R_MIPS_GOT16 .data
+# OBJ-NEXT: 14: 27 24 00 10 addiu $4, $25, 16
+# OBJ-NEXT: 00000014: R_MIPS_LO16 .data
+
+# SO: Disassembly of section .text:
+# SO-NEXT: .text:
+# SO-NEXT: 10000: 8f 99 80 18 lw $25, -32744($gp)
+# SO-NEXT: 10004: 27 24 00 00 addiu $4, $25, 0
+# SO-NEXT: 10008: 00 00 00 00 nop
+# SO-NEXT: 1000c: 00 00 00 00 nop
+# SO-NEXT: 10010: 8f 99 80 18 lw $25, -32744($gp)
+# SO-NEXT: 10014: 27 24 00 10 addiu $4, $25, 16
+
+ .text
+ lw $t9, %got(.data)($gp)
+ addiu $a0, $t9, %lo(.data)
+
+ .data
+data:
+ .word 0
diff --git a/test/ELF/mips-gp-ext.s b/test/ELF/mips-gp-ext.s
index ff459380764c..98b9cbc06d28 100644
--- a/test/ELF/mips-gp-ext.s
+++ b/test/ELF/mips-gp-ext.s
@@ -36,7 +36,7 @@
# ^-- 0-0x10c
# REL: 00000000 .text 00000000 foo
-# REL: 0000010c *ABS* 00000000 .hidden _gp_disp
+# REL: 00000000 *ABS* 00000000 .hidden _gp_disp
# REL: 0000010c *ABS* 00000000 .hidden _gp
# ABS: Contents of section .text:
@@ -56,7 +56,7 @@
# ^-- 0-0x200
# ABS: 00000000 .text 00000000 foo
-# ABS: 00000200 *ABS* 00000000 .hidden _gp_disp
+# ABS: 00000000 *ABS* 00000000 .hidden _gp_disp
# ABS: 00000200 *ABS* 00000000 .hidden _gp
.text
diff --git a/test/ELF/mips-gprel-sec.s b/test/ELF/mips-gprel-sec.s
new file mode 100644
index 000000000000..dc54f87216da
--- /dev/null
+++ b/test/ELF/mips-gprel-sec.s
@@ -0,0 +1,37 @@
+# Check order of gp-relative sections, i.e. sections with SHF_MIPS_GPREL flag.
+
+# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
+# RUN: ld.lld %t.o -shared -o %t.so
+# RUN: llvm-readobj -s %t.so | FileCheck %s
+
+# REQUIRES: mips
+
+ .text
+ nop
+
+ .sdata
+ .word 0
+
+# CHECK: Section {
+# CHECK: Name: .got
+# CHECK-NEXT: Type: SHT_PROGBITS
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: SHF_ALLOC
+# CHECK-NEXT: SHF_MIPS_GPREL
+# CHECK-NEXT: SHF_WRITE
+# CHECK-NEXT: ]
+# CHECK-NEXT: Address: 0x20000
+# CHECK-NEXT: Offset: 0x20000
+# CHECK: }
+# CHECK: Section {
+# CHECK-NEXT: Index:
+# CHECK-NEXT: Name: .sdata
+# CHECK-NEXT: Type: SHT_PROGBITS
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: SHF_ALLOC
+# CHECK-NEXT: SHF_MIPS_GPREL
+# CHECK-NEXT: SHF_WRITE
+# CHECK-NEXT: ]
+# CHECK-NEXT: Address: 0x20008
+# CHECK-NEXT: Offset: 0x20008
+# CHECK: }
diff --git a/test/ELF/mips-npic-call-pic-os.s b/test/ELF/mips-npic-call-pic-os.s
new file mode 100644
index 000000000000..131289e596e8
--- /dev/null
+++ b/test/ELF/mips-npic-call-pic-os.s
@@ -0,0 +1,138 @@
+# REQUIRES: mips
+# Check LA25 stubs creation with caller in different Output Section to callee.
+# This stub code is necessary when non-PIC code calls PIC function.
+
+# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
+# RUN: %p/Inputs/mips-fpic.s -o %t-fpic.o
+# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
+# RUN: %p/Inputs/mips-fnpic.s -o %t-fnpic.o
+# RUN: ld.lld -r %t-fpic.o %t-fnpic.o -o %t-sto-pic.o
+# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
+# RUN: %p/Inputs/mips-pic.s -o %t-pic.o
+# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t-npic.o
+# RUN: ld.lld %t-npic.o %t-pic.o %t-sto-pic.o -o %t.exe
+# RUN: llvm-objdump -d %t.exe | FileCheck %s
+
+# CHECK: Disassembly of section .text:
+# CHECK-NEXT: __LA25Thunk_foo1a:
+# CHECK-NEXT: 20000: 3c 19 00 02 lui $25, 2
+# CHECK-NEXT: 20004: 08 00 80 08 j 131104 <foo1a>
+# CHECK-NEXT: 20008: 27 39 00 20 addiu $25, $25, 32
+# CHECK-NEXT: 2000c: 00 00 00 00 nop
+# CHECK: __LA25Thunk_foo1b:
+# CHECK-NEXT: 20010: 3c 19 00 02 lui $25, 2
+# CHECK-NEXT: 20014: 08 00 80 09 j 131108 <foo1b>
+# CHECK-NEXT: 20018: 27 39 00 24 addiu $25, $25, 36
+# CHECK-NEXT: 2001c: 00 00 00 00 nop
+# CHECK: foo1a:
+# CHECK-NEXT: 20020: 00 00 00 00 nop
+# CHECK: foo1b:
+# CHECK-NEXT: 20024: 00 00 00 00 nop
+# CHECK: __LA25Thunk_foo2:
+# CHECK-NEXT: 20028: 3c 19 00 02 lui $25, 2
+# CHECK-NEXT: 2002c: 08 00 80 10 j 131136 <foo2>
+# CHECK-NEXT: 20030: 27 39 00 40 addiu $25, $25, 64
+# CHECK-NEXT: 20034: 00 00 00 00 nop
+# CHECK-NEXT: 20038: 00 00 00 00 nop
+# CHECK-NEXT: 2003c: 00 00 00 00 nop
+# CHECK: foo2:
+# CHECK-NEXT: 20040: 00 00 00 00 nop
+# CHECK: __LA25Thunk_fpic:
+# CHECK-NEXT: 20044: 3c 19 00 02 lui $25, 2
+# CHECK-NEXT: 20048: 08 00 80 18 j 131168 <fpic>
+# CHECK-NEXT: 2004c: 27 39 00 60 addiu $25, $25, 96
+# CHECK-NEXT: 20050: 00 00 00 00 nop
+# CHECK-NEXT: 20054: 00 00 00 00 nop
+# CHECK-NEXT: 20058: 00 00 00 00 nop
+# CHECK-NEXT: 2005c: 00 00 00 00 nop
+# CHECK: fpic:
+# CHECK-NEXT: 20060: 00 00 00 00 nop
+# CHECK-NEXT: 20064: 00 00 00 00 nop
+# CHECK-NEXT: 20068: 00 00 00 00 nop
+# CHECK-NEXT: 2006c: 00 00 00 00 nop
+# CHECK: fnpic:
+# CHECK-NEXT: 20070: 00 00 00 00 nop
+# CHECK-NEXT: Disassembly of section differentos:
+# CHECK-NEXT: __start:
+# CHECK-NEXT: 20074: 0c 00 80 00 jal 131072 <__LA25Thunk_foo1a>
+# CHECK-NEXT: 20078: 00 00 00 00 nop
+# CHECK-NEXT: 2007c: 0c 00 80 0a jal 131112 <__LA25Thunk_foo2>
+# CHECK-NEXT: 20080: 00 00 00 00 nop
+# CHECK-NEXT: 20084: 0c 00 80 04 jal 131088 <__LA25Thunk_foo1b>
+# CHECK-NEXT: 20088: 00 00 00 00 nop
+# CHECK-NEXT: 2008c: 0c 00 80 0a jal 131112 <__LA25Thunk_foo2>
+# CHECK-NEXT: 20090: 00 00 00 00 nop
+# CHECK-NEXT: 20094: 0c 00 80 11 jal 131140 <__LA25Thunk_fpic>
+# CHECK-NEXT: 20098: 00 00 00 00 nop
+# CHECK-NEXT: 2009c: 0c 00 80 1c jal 131184 <fnpic>
+# CHECK-NEXT: 200a0: 00 00 00 00 nop
+
+# Make sure the thunks are created properly no matter how
+# objects are laid out.
+#
+# RUN: ld.lld %t-pic.o %t-npic.o %t-sto-pic.o -o %t.exe
+# RUN: llvm-objdump -d %t.exe | FileCheck -check-prefix=REVERSE %s
+
+# REVERSE: Disassembly of section .text:
+# REVERSE-NEXT: __LA25Thunk_foo1a:
+# REVERSE-NEXT: 20000: 3c 19 00 02 lui $25, 2
+# REVERSE-NEXT: 20004: 08 00 80 08 j 131104 <foo1a>
+# REVERSE-NEXT: 20008: 27 39 00 20 addiu $25, $25, 32
+# REVERSE-NEXT: 2000c: 00 00 00 00 nop
+# REVERSE: __LA25Thunk_foo1b:
+# REVERSE-NEXT: 20010: 3c 19 00 02 lui $25, 2
+# REVERSE-NEXT: 20014: 08 00 80 09 j 131108 <foo1b>
+# REVERSE-NEXT: 20018: 27 39 00 24 addiu $25, $25, 36
+# REVERSE-NEXT: 2001c: 00 00 00 00 nop
+# REVERSE: foo1a:
+# REVERSE-NEXT: 20020: 00 00 00 00 nop
+# REVERSE: foo1b:
+# REVERSE-NEXT: 20024: 00 00 00 00 nop
+# REVERSE: __LA25Thunk_foo2:
+# REVERSE-NEXT: 20028: 3c 19 00 02 lui $25, 2
+# REVERSE-NEXT: 2002c: 08 00 80 10 j 131136 <foo2>
+# REVERSE-NEXT: 20030: 27 39 00 40 addiu $25, $25, 64
+# REVERSE-NEXT: 20034: 00 00 00 00 nop
+# REVERSE-NEXT: 20038: 00 00 00 00 nop
+# REVERSE-NEXT: 2003c: 00 00 00 00 nop
+# REVERSE: foo2:
+# REVERSE-NEXT: 20040: 00 00 00 00 nop
+# REVERSE-NEXT: 20044: 00 00 00 00 nop
+# REVERSE-NEXT: 20048: 00 00 00 00 nop
+# REVERSE-NEXT: 2004c: 00 00 00 00 nop
+# REVERSE: __LA25Thunk_fpic:
+# REVERSE-NEXT: 20050: 3c 19 00 02 lui $25, 2
+# REVERSE-NEXT: 20054: 08 00 80 18 j 131168 <fpic>
+# REVERSE-NEXT: 20058: 27 39 00 60 addiu $25, $25, 96
+# REVERSE-NEXT: 2005c: 00 00 00 00 nop
+# REVERSE: fpic:
+# REVERSE-NEXT: 20060: 00 00 00 00 nop
+# REVERSE-NEXT: 20064: 00 00 00 00 nop
+# REVERSE-NEXT: 20068: 00 00 00 00 nop
+# REVERSE-NEXT: 2006c: 00 00 00 00 nop
+# REVERSE: fnpic:
+# REVERSE-NEXT: 20070: 00 00 00 00 nop
+# REVERSE-NEXT: Disassembly of section differentos:
+# REVERSE-NEXT: __start:
+# REVERSE-NEXT: 20074: 0c 00 80 00 jal 131072 <__LA25Thunk_foo1a>
+# REVERSE-NEXT: 20078: 00 00 00 00 nop
+# REVERSE-NEXT: 2007c: 0c 00 80 0a jal 131112 <__LA25Thunk_foo2>
+# REVERSE-NEXT: 20080: 00 00 00 00 nop
+# REVERSE-NEXT: 20084: 0c 00 80 04 jal 131088 <__LA25Thunk_foo1b>
+# REVERSE-NEXT: 20088: 00 00 00 00 nop
+# REVERSE-NEXT: 2008c: 0c 00 80 0a jal 131112 <__LA25Thunk_foo2>
+# REVERSE-NEXT: 20090: 00 00 00 00 nop
+# REVERSE-NEXT: 20094: 0c 00 80 14 jal 131152 <__LA25Thunk_fpic>
+# REVERSE-NEXT: 20098: 00 00 00 00 nop
+# REVERSE-NEXT: 2009c: 0c 00 80 1c jal 131184 <fnpic>
+# REVERSE-NEXT: 200a0: 00 00 00 00 nop
+
+ .section differentos, "ax", %progbits
+ .globl __start
+__start:
+ jal foo1a
+ jal foo2
+ jal foo1b
+ jal foo2
+ jal fpic
+ jal fnpic
diff --git a/test/ELF/mips-npic-call-pic.s b/test/ELF/mips-npic-call-pic.s
index 76c392e1f66c..a5a99d719983 100644
--- a/test/ELF/mips-npic-call-pic.s
+++ b/test/ELF/mips-npic-call-pic.s
@@ -15,60 +15,65 @@
# CHECK: Disassembly of section .text:
# CHECK-NEXT: __start:
-# CHECK-NEXT: 20000: 0c 00 80 0e jal 131128 <foo1b+0x4>
-# ^-- .pic.foo1a
+# CHECK-NEXT: 20000: 0c 00 80 0c jal 131120 <__LA25Thunk_foo1a>
# CHECK-NEXT: 20004: 00 00 00 00 nop
-# CHECK-NEXT: 20008: 0c 00 80 19 jal 131172 <foo2+0x4>
-# ^-- .pic.foo2
+# CHECK-NEXT: 20008: 0c 00 80 16 jal 131160 <__LA25Thunk_foo2>
# CHECK-NEXT: 2000c: 00 00 00 00 nop
-# CHECK-NEXT: 20010: 0c 00 80 12 jal 131144 <foo1b+0x14>
-# ^-- .pic.foo1b
+# CHECK-NEXT: 20010: 0c 00 80 10 jal 131136 <__LA25Thunk_foo1b>
# CHECK-NEXT: 20014: 00 00 00 00 nop
-# CHECK-NEXT: 20018: 0c 00 80 19 jal 131172 <foo2+0x4>
-# ^-- .pic.foo2
+# CHECK-NEXT: 20018: 0c 00 80 16 jal 131160 <__LA25Thunk_foo2>
# CHECK-NEXT: 2001c: 00 00 00 00 nop
-# CHECK-NEXT: 20020: 0c 00 80 25 jal 131220 <fnpic+0x4>
-# ^-- .pic.fpic
+# CHECK-NEXT: 20020: 0c 00 80 1d jal 131188 <__LA25Thunk_fpic>
# CHECK-NEXT: 20024: 00 00 00 00 nop
-# CHECK-NEXT: 20028: 0c 00 80 24 jal 131216 <fnpic>
+# CHECK-NEXT: 20028: 0c 00 80 28 jal 131232 <fnpic>
# CHECK-NEXT: 2002c: 00 00 00 00 nop
#
-# CHECK: foo1a:
-# CHECK-NEXT: 20030: 00 00 00 00 nop
-#
-# CHECK: foo1b:
-# CHECK-NEXT: 20034: 00 00 00 00 nop
-#
-# CHECK-NEXT: 20038: 3c 19 00 02 lui $25, 2
-# CHECK-NEXT: 2003c: 08 00 80 0c j 131120 <foo1a>
-# CHECK-NEXT: 20040: 27 39 00 30 addiu $25, $25, 48
-# CHECK-NEXT: 20044: 00 00 00 00 nop
-# CHECK-NEXT: 20048: 3c 19 00 02 lui $25, 2
-# CHECK-NEXT: 2004c: 08 00 80 0d j 131124 <foo1b>
-# CHECK-NEXT: 20050: 27 39 00 34 addiu $25, $25, 52
+# CHECK: __LA25Thunk_foo1a:
+# CHECK-NEXT: 20030: 3c 19 00 02 lui $25, 2
+# CHECK-NEXT: 20034: 08 00 80 14 j 131152 <foo1a>
+# CHECK-NEXT: 20038: 27 39 00 50 addiu $25, $25, 80
+# CHECK-NEXT: 2003c: 00 00 00 00 nop
+
+# CHECK: __LA25Thunk_foo1b:
+# CHECK-NEXT: 20040: 3c 19 00 02 lui $25, 2
+# CHECK-NEXT: 20044: 08 00 80 15 j 131156 <foo1b>
+# CHECK-NEXT: 20048: 27 39 00 54 addiu $25, $25, 84
+# CHECK-NEXT: 2004c: 00 00 00 00 nop
+
+# CHECK: foo1a:
+# CHECK-NEXT: 20050: 00 00 00 00 nop
+
+# CHECK: foo1b:
# CHECK-NEXT: 20054: 00 00 00 00 nop
-# CHECK-NEXT: 20058: 00 00 00 00 nop
-# CHECK-NEXT: 2005c: 00 00 00 00 nop
-#
-# CHECK: foo2:
-# CHECK-NEXT: 20060: 00 00 00 00 nop
-#
-# CHECK-NEXT: 20064: 3c 19 00 02 lui $25, 2
-# CHECK-NEXT: 20068: 08 00 80 18 j 131168 <foo2>
-# CHECK-NEXT: 2006c: 27 39 00 60 addiu $25, $25, 96
+
+# CHECK: __LA25Thunk_foo2:
+# CHECK-NEXT: 20058: 3c 19 00 02 lui $25, 2
+# CHECK-NEXT: 2005c: 08 00 80 1c j 131184 <foo2>
+# CHECK-NEXT: 20060: 27 39 00 70 addiu $25, $25, 112
+# CHECK-NEXT: 20064: 00 00 00 00 nop
+# CHECK-NEXT: 20068: 00 00 00 00 nop
+# CHECK-NEXT: 2006c: 00 00 00 00 nop
+
+# CHECK: foo2:
# CHECK-NEXT: 20070: 00 00 00 00 nop
-# CHECK-NEXT: 20074: 00 00 00 00 nop
-# CHECK-NEXT: 20078: 00 00 00 00 nop
-# CHECK-NEXT: 2007c: 00 00 00 00 nop
-#
-# CHECK: fpic:
-# CHECK-NEXT: 20080: 00 00 00 00 nop
-#
-# CHECK: fnpic:
+
+# CHECK: __LA25Thunk_fpic:
+# CHECK-NEXT: 20074: 3c 19 00 02 lui $25, 2
+# CHECK-NEXT: 20078: 08 00 80 24 j 131216 <fpic>
+# CHECK-NEXT: 2007c: 27 39 00 90 addiu $25, $25, 144
+# CHECK-NEXT: 20080: 00 00 00 00 nop
+# CHECK-NEXT: 20084: 00 00 00 00 nop
+# CHECK-NEXT: 20088: 00 00 00 00 nop
+# CHECK-NEXT: 2008c: 00 00 00 00 nop
+
+# CHECK: fpic:
# CHECK-NEXT: 20090: 00 00 00 00 nop
-# CHECK-NEXT: 20094: 3c 19 00 02 lui $25, 2
-# CHECK-NEXT: 20098: 08 00 80 20 j 131200 <fpic>
-# CHECK-NEXT: 2009c: 27 39 00 80 addiu $25, $25, 128
+# CHECK-NEXT: 20094: 00 00 00 00 nop
+# CHECK-NEXT: 20098: 00 00 00 00 nop
+# CHECK-NEXT: 2009c: 00 00 00 00 nop
+
+# CHECK: fnpic:
+# CHECK-NEXT: 200a0: 00 00 00 00 nop
# Make sure the thunks are created properly no matter how
# objects are laid out.
@@ -76,54 +81,58 @@
# RUN: ld.lld %t-pic.o %t-npic.o %t-sto-pic.o -o %t.exe
# RUN: llvm-objdump -d %t.exe | FileCheck -check-prefix=REVERSE %s
-# REVERSE: foo1a:
-# REVERSE-NEXT: 20000: 00 00 00 00 nop
-#
-# REVERSE: foo1b:
-# REVERSE-NEXT: 20004: 00 00 00 00 nop
-# REVERSE-NEXT: 20008: 3c 19 00 02 lui $25, 2
-# REVERSE-NEXT: 2000c: 08 00 80 00 j 131072 <foo1a>
-# REVERSE-NEXT: 20010: 27 39 00 00 addiu $25, $25, 0
-# REVERSE-NEXT: 20014: 00 00 00 00 nop
-# REVERSE-NEXT: 20018: 3c 19 00 02 lui $25, 2
-# REVERSE-NEXT: 2001c: 08 00 80 01 j 131076 <foo1b>
-# REVERSE-NEXT: 20020: 27 39 00 04 addiu $25, $25, 4
+# REVERSE: Disassembly of section .text:
+# REVERSE-NEXT: __LA25Thunk_foo1a:
+# REVERSE-NEXT: 20000: 3c 19 00 02 lui $25, 2
+# REVERSE-NEXT: 20004: 08 00 80 08 j 131104 <foo1a>
+# REVERSE-NEXT: 20008: 27 39 00 20 addiu $25, $25, 32
+# REVERSE-NEXT: 2000c: 00 00 00 00 nop
+# REVERSE: __LA25Thunk_foo1b:
+# REVERSE-NEXT: 20010: 3c 19 00 02 lui $25, 2
+# REVERSE-NEXT: 20014: 08 00 80 09 j 131108 <foo1b>
+# REVERSE-NEXT: 20018: 27 39 00 24 addiu $25, $25, 36
+# REVERSE-NEXT: 2001c: 00 00 00 00 nop
+# REVERSE: foo1a:
+# REVERSE-NEXT: 20020: 00 00 00 00 nop
+# REVERSE: foo1b:
# REVERSE-NEXT: 20024: 00 00 00 00 nop
-# REVERSE-NEXT: 20028: 00 00 00 00 nop
-# REVERSE-NEXT: 2002c: 00 00 00 00 nop
-#
-# REVERSE: foo2:
-# REVERSE-NEXT: 20030: 00 00 00 00 nop
-# REVERSE-NEXT: 20034: 3c 19 00 02 lui $25, 2
-# REVERSE-NEXT: 20038: 08 00 80 0c j 131120 <foo2>
-# REVERSE-NEXT: 2003c: 27 39 00 30 addiu $25, $25, 48
+# REVERSE: __LA25Thunk_foo2:
+# REVERSE-NEXT: 20028: 3c 19 00 02 lui $25, 2
+# REVERSE-NEXT: 2002c: 08 00 80 10 j 131136 <foo2>
+# REVERSE-NEXT: 20030: 27 39 00 40 addiu $25, $25, 64
+# REVERSE-NEXT: 20034: 00 00 00 00 nop
+# REVERSE-NEXT: 20038: 00 00 00 00 nop
+# REVERSE-NEXT: 2003c: 00 00 00 00 nop
+# REVERSE: foo2:
# REVERSE-NEXT: 20040: 00 00 00 00 nop
# REVERSE-NEXT: 20044: 00 00 00 00 nop
# REVERSE-NEXT: 20048: 00 00 00 00 nop
# REVERSE-NEXT: 2004c: 00 00 00 00 nop
-#
-# REVERSE: __start:
-# REVERSE-NEXT: 20050: 0c 00 80 02 jal 131080 <foo1b+0x4>
+# REVERSE: __start:
+# REVERSE-NEXT: 20050: 0c 00 80 00 jal 131072 <__LA25Thunk_foo1a>
# REVERSE-NEXT: 20054: 00 00 00 00 nop
-# REVERSE-NEXT: 20058: 0c 00 80 0d jal 131124 <foo2+0x4>
+# REVERSE-NEXT: 20058: 0c 00 80 0a jal 131112 <__LA25Thunk_foo2>
# REVERSE-NEXT: 2005c: 00 00 00 00 nop
-# REVERSE-NEXT: 20060: 0c 00 80 06 jal 131096 <foo1b+0x14>
+# REVERSE-NEXT: 20060: 0c 00 80 04 jal 131088 <__LA25Thunk_foo1b>
# REVERSE-NEXT: 20064: 00 00 00 00 nop
-# REVERSE-NEXT: 20068: 0c 00 80 0d jal 131124 <foo2+0x4>
+# REVERSE-NEXT: 20068: 0c 00 80 0a jal 131112 <__LA25Thunk_foo2>
# REVERSE-NEXT: 2006c: 00 00 00 00 nop
-# REVERSE-NEXT: 20070: 0c 00 80 25 jal 131220 <fnpic+0x4>
+# REVERSE-NEXT: 20070: 0c 00 80 20 jal 131200 <__LA25Thunk_fpic>
# REVERSE-NEXT: 20074: 00 00 00 00 nop
-# REVERSE-NEXT: 20078: 0c 00 80 24 jal 131216 <fnpic>
+# REVERSE-NEXT: 20078: 0c 00 80 28 jal 131232 <fnpic>
# REVERSE-NEXT: 2007c: 00 00 00 00 nop
-#
-# REVERSE: fpic:
-# REVERSE-NEXT: 20080: 00 00 00 00 nop
-#
-# REVERSE: fnpic:
+# REVERSE: __LA25Thunk_fpic:
+# REVERSE-NEXT: 20080: 3c 19 00 02 lui $25, 2
+# REVERSE-NEXT: 20084: 08 00 80 24 j 131216 <fpic>
+# REVERSE-NEXT: 20088: 27 39 00 90 addiu $25, $25, 144
+# REVERSE-NEXT: 2008c: 00 00 00 00 nop
+# REVERSE: fpic:
# REVERSE-NEXT: 20090: 00 00 00 00 nop
-# REVERSE-NEXT: 20094: 3c 19 00 02 lui $25, 2
-# REVERSE-NEXT: 20098: 08 00 80 20 j 131200 <fpic>
-# REVERSE-NEXT: 2009c: 27 39 00 80 addiu $25, $25, 128
+# REVERSE-NEXT: 20094: 00 00 00 00 nop
+# REVERSE-NEXT: 20098: 00 00 00 00 nop
+# REVERSE-NEXT: 2009c: 00 00 00 00 nop
+# REVERSE: fnpic:
+# REVERSE-NEXT: 200a0: 00 00 00 00 nop
.text
.globl __start
diff --git a/test/ELF/mips-options.s b/test/ELF/mips-options.s
index edafd09c8da4..18f5af8ece6e 100644
--- a/test/ELF/mips-options.s
+++ b/test/ELF/mips-options.s
@@ -6,7 +6,7 @@
# RUN: echo "SECTIONS { \
# RUN: . = 0x100000000; \
# RUN: .got : { *(.got) } }" > %t.rel.script
-# RUN: ld.lld %t1.o %t2.o --script %t.rel.script -shared -o %t.so
+# RUN: ld.lld %t1.o %t2.o --gc-sections --script %t.rel.script -shared -o %t.so
# RUN: llvm-readobj -symbols -mips-options %t.so | FileCheck %s
# REQUIRES: mips
diff --git a/test/ELF/mips-reginfo.s b/test/ELF/mips-reginfo.s
index dd4771c98b8d..4024a2f6634f 100644
--- a/test/ELF/mips-reginfo.s
+++ b/test/ELF/mips-reginfo.s
@@ -3,7 +3,7 @@
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t1.o
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
# RUN: %S/Inputs/mips-dynamic.s -o %t2.o
-# RUN: ld.lld %t1.o %t2.o -shared -o %t.so
+# RUN: ld.lld %t1.o %t2.o --gc-sections -shared -o %t.so
# RUN: llvm-readobj -symbols -mips-reginfo %t.so | FileCheck %s
# REQUIRES: mips
diff --git a/test/ELF/mips-sto-pic-flag.s b/test/ELF/mips-sto-pic-flag.s
index 4d7923346496..3960ba322387 100644
--- a/test/ELF/mips-sto-pic-flag.s
+++ b/test/ELF/mips-sto-pic-flag.s
@@ -19,8 +19,8 @@
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: .text
# CHECK-NEXT: }
-# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: foo1a
+# CHECK: Symbol {
+# CHECK: Name: foo1a
# CHECK-NEXT: Value:
# CHECK-NEXT: Size:
# CHECK-NEXT: Binding: Global
diff --git a/test/ELF/mips-tls-64.s b/test/ELF/mips-tls-64.s
index 259dd1f56b02..db29789ee117 100644
--- a/test/ELF/mips-tls-64.s
+++ b/test/ELF/mips-tls-64.s
@@ -29,8 +29,7 @@
# DIS-NEXT: 30040 00000000 00000000 00000000 00000001
# DIS-NEXT: 30050 ffffffff ffff8004 ffffffff ffff9004
-# DIS: 0000000000040000 l .tdata 00000000 .tdata
-# DIS: 0000000000040000 l .tdata 00000000 loc
+# DIS: 0000000000000000 l .tdata 00000000 loc
# DIS: 0000000000000004 g .tdata 00000000 bar
# DIS: 0000000000000000 g *UND* 00000000 foo
diff --git a/test/ELF/mips-tls-hilo.s b/test/ELF/mips-tls-hilo.s
index fb026a40bbb1..47fadaa34b80 100644
--- a/test/ELF/mips-tls-hilo.s
+++ b/test/ELF/mips-tls-hilo.s
@@ -21,8 +21,7 @@
# DIS-NEXT: 2000c: 24 62 90 00 addiu $2, $3, -28672
# %lo(loc0 - .tdata - 0x7000) --^
-# DIS: 00040000 l .tdata 00000000 .tdata
-# DIS: 00040000 l .tdata 00000000 loc0
+# DIS: 00000000 l .tdata 00000000 loc0
# CHECK: Relocations [
# CHECK-NEXT: ]
diff --git a/test/ELF/mips-tls.s b/test/ELF/mips-tls.s
index fd8bab8fa3a2..b64f8db75731 100644
--- a/test/ELF/mips-tls.s
+++ b/test/ELF/mips-tls.s
@@ -27,8 +27,7 @@
# DIS-NEXT: 30020 00000000 00000001 00000000 00000001
# DIS-NEXT: 30030 ffff8004 ffff9004
-# DIS: 00040000 l .tdata 00000000 .tdata
-# DIS: 00040000 l .tdata 00000000 loc
+# DIS: 00000000 l .tdata 00000000 loc
# DIS: 00000004 g .tdata 00000000 bar
# DIS: 00000000 g *UND* 00000000 foo
diff --git a/test/ELF/no-dynamic-linker.s b/test/ELF/no-dynamic-linker.s
new file mode 100644
index 000000000000..f5c7f4b8d072
--- /dev/null
+++ b/test/ELF/no-dynamic-linker.s
@@ -0,0 +1,12 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/shared.s -o %tso.o
+# RUN: ld.lld -shared %tso.o -o %t.so
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+
+# RUN: ld.lld -dynamic-linker foo --no-dynamic-linker %t.o %t.so -o %t
+# RUN: llvm-readobj --program-headers %t | FileCheck %s --check-prefix=NODL
+# NODL-NOT: PT_INTERP
+
+# RUN: ld.lld --no-dynamic-linker -dynamic-linker foo %t.o %t.so -o %t
+# RUN: llvm-readobj --program-headers %t | FileCheck %s --check-prefix=WITHDL
+# WITHDL: PT_INTERP
diff --git a/test/ELF/no-merge.s b/test/ELF/no-merge.s
index 5d8b8570ab49..c8132c259e96 100644
--- a/test/ELF/no-merge.s
+++ b/test/ELF/no-merge.s
@@ -1,25 +1,19 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
-# RUN: echo "SECTIONS { .data : {*(.data.*)} }" > %t0.script
+# RUN: echo "SECTIONS { .rodata : {*(.rodata.*)} }" > %t0.script
# RUN: ld.lld %t.o -o %t0.out --script %t0.script
-# RUN: llvm-objdump -s %t0.out | FileCheck %s --check-prefix=OPT
-# OPT: Contents of section .data:
-# OPT-NEXT: 0000 01
-# OPT-NEXT: Contents of section .data:
-# OPT-NEXT: 0001 6100
-# OPT-NEXT: Contents of section .data:
-# OPT-NEXT: 0003 03
+# RUN: llvm-objdump -s %t0.out | FileCheck %s
# RUN: ld.lld -O0 %t.o -o %t1.out --script %t0.script
-# RUN: llvm-objdump -s %t1.out | FileCheck %s --check-prefix=NOOPT
-# NOOPT: Contents of section .data:
-# NOOPT-NEXT: 0000 01610003
+# RUN: llvm-objdump -s %t1.out | FileCheck %s
+# CHECK: Contents of section .rodata:
+# CHECK-NEXT: 0000 01610003
-.section .data.aw,"aw",@progbits
+.section .rodata.a,"a",@progbits
.byte 1
-.section .data.ams,"aMS",@progbits,1
+.section .rodata.ams,"aMS",@progbits,1
.asciz "a"
-.section .data.am,"aM",@progbits,1
+.section .rodata.am,"aM",@progbits,1
.byte 3
diff --git a/test/ELF/no-soname.s b/test/ELF/no-soname.s
new file mode 100644
index 000000000000..d2c15ed8f9cd
--- /dev/null
+++ b/test/ELF/no-soname.s
@@ -0,0 +1,31 @@
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: mkdir -p %T/no-soname
+// RUN: ld.lld %t.o -shared -o %T/no-soname/libfoo.so
+
+// RUN: ld.lld %t.o %T/no-soname/libfoo.so -o %t
+// RUN: llvm-readobj --dynamic-table %t | FileCheck %s
+
+// CHECK: 0x0000000000000001 NEEDED SharedLibrary ({{.*}}/no-soname/libfoo.so)
+// CHECK-NOT: NEEDED
+
+// RUN: ld.lld %t.o %T/no-soname/../no-soname/libfoo.so -o %t
+// RUN: llvm-readobj --dynamic-table %t | FileCheck %s --check-prefix=CHECK2
+
+// CHECK2: 0x0000000000000001 NEEDED SharedLibrary ({{.*}}/no-soname/../no-soname/libfoo.so)
+// CHECK2-NOT: NEEDED
+
+// RUN: ld.lld %t.o -L%T/no-soname/../no-soname -lfoo -o %t
+// RUN: llvm-readobj --dynamic-table %t | FileCheck %s --check-prefix=CHECK3
+
+// CHECK3: 0x0000000000000001 NEEDED SharedLibrary (libfoo.so)
+// CHECK3-NOT: NEEDED
+
+// RUN: ld.lld %t.o -shared -soname libbar.so -o %T/no-soname/libbar.so
+// RUN: ld.lld %t.o %T/no-soname/libbar.so -o %t
+// RUN: llvm-readobj --dynamic-table %t | FileCheck %s --check-prefix=CHECK4
+
+// CHECK4: 0x0000000000000001 NEEDED SharedLibrary (libbar.so)
+// CHECK4-NOT: NEEDED
+
+.global _start
+_start:
diff --git a/test/ELF/note-contiguous.s b/test/ELF/note-contiguous.s
new file mode 100644
index 000000000000..f49d0b68ca33
--- /dev/null
+++ b/test/ELF/note-contiguous.s
@@ -0,0 +1,24 @@
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: echo "SECTIONS { \
+// RUN: .note : { *(.note.a) *(.note.b) } \
+// RUN: }" > %t.script
+// RUN: ld.lld %t.o --script %t.script -o %t
+// RUN: llvm-readobj -program-headers %t | FileCheck %s
+
+// CHECK: Type: PT_NOTE
+// CHECK-NEXT: Offset: 0x1000
+// CHECK-NEXT: VirtualAddress: 0x0
+// CHECK-NEXT: PhysicalAddress: 0x0
+// CHECK-NEXT: FileSize: 16
+// CHECK-NEXT: MemSize: 16
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: PF_R
+// CHECK-NEXT: ]
+// CHECK-NEXT: Alignment: 1
+
+.section .note.a, "a", @note
+.quad 0
+
+.section .note.b, "a", @note
+.quad 0
diff --git a/test/ELF/note-loadaddr.c b/test/ELF/note-loadaddr.c
new file mode 100644
index 000000000000..6d2ebaeeaa0a
--- /dev/null
+++ b/test/ELF/note-loadaddr.c
@@ -0,0 +1,35 @@
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: echo "SECTIONS { \
+// RUN: .note.a : AT(0x1000) { *(.note.a) } \
+// RUN: .note.b : AT(0x2000) { *(.note.b) } \
+// RUN: }" > %t.script
+// RUN: ld.lld %t.o --script %t.script -o %t
+// RUN: llvm-readobj -program-headers %t | FileCheck %s
+
+// CHECK: Type: PT_NOTE
+// CHECK-NEXT: Offset: 0x1000
+// CHECK-NEXT: VirtualAddress: 0x0
+// CHECK-NEXT: PhysicalAddress: 0x1000
+// CHECK-NEXT: FileSize: 8
+// CHECK-NEXT: MemSize: 8
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: PF_R
+// CHECK-NEXT: ]
+// CHECK-NEXT: Alignment: 1
+// CHECK: Type: PT_NOTE
+// CHECK-NEXT: Offset: 0x1008
+// CHECK-NEXT: VirtualAddress: 0x8
+// CHECK-NEXT: PhysicalAddress: 0x2000
+// CHECK-NEXT: FileSize: 8
+// CHECK-NEXT: MemSize: 8
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: PF_R
+// CHECK-NEXT: ]
+// CHECK-NEXT: Alignment: 1
+
+.section .note.a, "a", @note
+.quad 0
+
+.section .note.b, "a", @note
+.quad 0
diff --git a/test/ELF/note-multiple.s b/test/ELF/note-multiple.s
new file mode 100644
index 000000000000..cebe8aa80b49
--- /dev/null
+++ b/test/ELF/note-multiple.s
@@ -0,0 +1,43 @@
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: echo "SECTIONS { \
+// RUN: .note.a : { *(.note.a) } \
+// RUN: .b : { *(.b) } \
+// RUN: .c : { *(.c) } \
+// RUN: .note.d : { *(.note.d) } \
+// RUN: }" > %t.script
+// RUN: ld.lld %t.o --script %t.script -o %t
+// RUN: llvm-readobj -program-headers %t | FileCheck %s
+
+// CHECK: Type: PT_NOTE
+// CHECK-NEXT: Offset: 0x1000
+// CHECK-NEXT: VirtualAddress: 0x0
+// CHECK-NEXT: PhysicalAddress: 0x0
+// CHECK-NEXT: FileSize: 8
+// CHECK-NEXT: MemSize: 8
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: PF_R
+// CHECK-NEXT: ]
+// CHECK-NEXT: Alignment: 1
+// CHECK: Type: PT_NOTE
+// CHECK-NEXT: Offset: 0x1018
+// CHECK-NEXT: VirtualAddress: 0x18
+// CHECK-NEXT: PhysicalAddress: 0x18
+// CHECK-NEXT: FileSize: 8
+// CHECK-NEXT: MemSize: 8
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: PF_R
+// CHECK-NEXT: ]
+// CHECK-NEXT: Alignment: 1
+
+.section .note.a, "a", @note
+.quad 0
+
+.section .b, "a"
+.quad 0
+
+.section .c, "a"
+.quad 0
+
+.section .note.d, "a", @note
+.quad 0
diff --git a/test/ELF/plt-i686.s b/test/ELF/plt-i686.s
index e169bd4d70f5..9a2c7f53dc59 100644
--- a/test/ELF/plt-i686.s
+++ b/test/ELF/plt-i686.s
@@ -135,23 +135,23 @@
// DISASMSHARED-NEXT: 1013: e9 e8 ff ff ff jmp -24
// DISASMSHARED-NEXT: Disassembly of section .plt:
// DISASMSHARED-NEXT: .plt:
-// DISASMSHARED-NEXT: 1020: ff b3 04 00 00 00 pushl 4(%ebx)
-// DISASMSHARED-NEXT: 1026: ff a3 08 00 00 00 jmpl *8(%ebx)
+// DISASMSHARED-NEXT: 1020: ff b3 04 20 00 00 pushl 8196(%ebx)
+// DISASMSHARED-NEXT: 1026: ff a3 08 20 00 00 jmpl *8200(%ebx)
// DISASMSHARED-NEXT: 102c: 90 nop
// DISASMSHARED-NEXT: 102d: 90 nop
// DISASMSHARED-NEXT: 102e: 90 nop
// DISASMSHARED-NEXT: 102f: 90 nop
-// DISASMSHARED-NEXT: 1030: ff a3 0c 00 00 00 jmpl *12(%ebx)
+// DISASMSHARED-NEXT: 1030: ff a3 0c 20 00 00 jmpl *8204(%ebx)
// DISASMSHARED-NEXT: 1036: 68 00 00 00 00 pushl $0
// DISASMSHARED-NEXT: 103b: e9 e0 ff ff ff jmp -32 <.plt>
-// DISASMSHARED-NEXT: 1040: ff a3 10 00 00 00 jmpl *16(%ebx)
+// DISASMSHARED-NEXT: 1040: ff a3 10 20 00 00 jmpl *8208(%ebx)
// DISASMSHARED-NEXT: 1046: 68 08 00 00 00 pushl $8
// DISASMSHARED-NEXT: 104b: e9 d0 ff ff ff jmp -48 <.plt>
// DISASMPIE: Disassembly of section .plt:
// DISASMPIE-NEXT: .plt:
-// DISASMPIE-NEXT: 1020: ff b3 04 00 00 00 pushl 4(%ebx)
-// DISASMPIE-NEXT: 1026: ff a3 08 00 00 00 jmpl *8(%ebx)
+// DISASMPIE-NEXT: 1020: ff b3 04 20 00 00 pushl 8196(%ebx)
+// DISASMPIE-NEXT: 1026: ff a3 08 20 00 00 jmpl *8200(%ebx)
// DISASMPIE-NEXT: 102c: 90 nop
// DISASMPIE-NEXT: 102d: 90 nop
// DISASMPIE-NEXT: 102e: 90 nop
diff --git a/test/ELF/pre_init_fini_array_missing.s b/test/ELF/pre_init_fini_array_missing.s
index de976805d76c..7dabfa7a6966 100644
--- a/test/ELF/pre_init_fini_array_missing.s
+++ b/test/ELF/pre_init_fini_array_missing.s
@@ -1,6 +1,8 @@
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
// RUN: ld.lld %t -o %t2
// RUN: llvm-objdump -d %t2 | FileCheck %s
+// RUN: ld.lld -pie %t -o %t3
+// RUN: llvm-objdump -d %t3 | FileCheck --check-prefix=PIE %s
// REQUIRES: x86
.globl _start
@@ -28,3 +30,14 @@ _start:
// CHECK-NEXT: 20100f: e8 ec ef df ff callq -2101268
// CHECK-NEXT: 201014: e8 e7 ef df ff callq -2101273
// CHECK-NEXT: 201019: e8 e2 ef df ff callq -2101278
+
+// In position-independent binaries, they resolve to the image base.
+
+// PIE: Disassembly of section .text:
+// PIE-NEXT: _start:
+// PIE-NEXT: 1000: e8 fb ef ff ff callq -4101
+// PIE-NEXT: 1005: e8 f6 ef ff ff callq -4106
+// PIE-NEXT: 100a: e8 f1 ef ff ff callq -4111
+// PIE-NEXT: 100f: e8 ec ef ff ff callq -4116
+// PIE-NEXT: 1014: e8 e7 ef ff ff callq -4121
+// PIE-NEXT: 1019: e8 e2 ef ff ff callq -4126
diff --git a/test/ELF/relocatable-bss.s b/test/ELF/relocatable-bss.s
index 0411bf339c43..becfbaed62df 100644
--- a/test/ELF/relocatable-bss.s
+++ b/test/ELF/relocatable-bss.s
@@ -20,7 +20,7 @@
# CHECK-NEXT: Version:
# CHECK-NEXT: Entry:
# CHECK-NEXT: ProgramHeaderOffset:
-# CHECK-NEXT: SectionHeaderOffset: 0xA8
+# CHECK-NEXT: SectionHeaderOffset: 0xD8
# CHECK-NEXT: Flags [
# CHECK-NEXT: ]
# CHECK-NEXT: HeaderSize:
diff --git a/test/ELF/relocatable-common.s b/test/ELF/relocatable-common.s
index b1b6edba2a36..3ead775492fc 100644
--- a/test/ELF/relocatable-common.s
+++ b/test/ELF/relocatable-common.s
@@ -14,21 +14,21 @@
# RUN: llvm-readobj -symbols -r %t | FileCheck -check-prefix=DEFCOMM %s
# CHECK: Symbol {
-# CHECK: Name: common (1)
+# CHECK: Name: common
# CHECK-NEXT: Value: 0x4
# CHECK-NEXT: Size: 4
-# CHECK-NEXT: Binding: Global (0x1)
-# CHECK-NEXT: Type: Object (0x1)
+# CHECK-NEXT: Binding: Global
+# CHECK-NEXT: Type: Object
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: Common (0xFFF2)
# CHECK-NEXT: }
# DEFCOMM: Symbol {
-# DEFCOMM: Name: common (1)
+# DEFCOMM: Name: common
# DEFCOMM-NEXT: Value: 0x0
# DEFCOMM-NEXT: Size: 4
-# DEFCOMM-NEXT: Binding: Global (0x1)
-# DEFCOMM-NEXT: Type: Object (0x1)
+# DEFCOMM-NEXT: Binding: Global
+# DEFCOMM-NEXT: Type: Object
# DEFCOMM-NEXT: Other: 0
# DEFCOMM-NEXT: Section: COMMON (0x2)
# DEFCOMM-NEXT: }
diff --git a/test/ELF/relocatable-eh-frame-hdr.s b/test/ELF/relocatable-eh-frame-hdr.s
new file mode 100644
index 000000000000..f7b57249d506
--- /dev/null
+++ b/test/ELF/relocatable-eh-frame-hdr.s
@@ -0,0 +1,11 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld --eh-frame-hdr -r %t.o -o %t
+# RUN: llvm-readobj -s %t | FileCheck %s
+
+# CHECK: Sections [
+# CHECK-NOT: Name: .eh_frame_hdr
+
+.section .foo,"ax",@progbits
+.cfi_startproc
+.cfi_endproc
diff --git a/test/ELF/relocatable-eh-frame.s b/test/ELF/relocatable-eh-frame.s
new file mode 100644
index 000000000000..c2e5ec63f865
--- /dev/null
+++ b/test/ELF/relocatable-eh-frame.s
@@ -0,0 +1,19 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld -r %t.o %t.o -o %t
+# RUN: llvm-readobj -r %t | FileCheck %s
+# RUN: ld.lld %t -o %t.so -shared
+# RUN: llvm-objdump -h %t.so | FileCheck --check-prefix=DSO %s
+
+# DSO: .eh_frame 00000030
+
+# CHECK: Relocations [
+# CHECK-NEXT: Section ({{.*}}) .rela.eh_frame {
+# CHECK-NEXT: 0x20 R_X86_64_PC32 .foo 0x0
+# CHECK-NEXT: 0x50 R_X86_64_NONE - 0x0
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
+
+.section .foo,"aG",@progbits,bar,comdat
+.cfi_startproc
+.cfi_endproc
diff --git a/test/ELF/relocatable-ehframe.s b/test/ELF/relocatable-ehframe.s
index d48402099c36..2d302e5988f0 100644
--- a/test/ELF/relocatable-ehframe.s
+++ b/test/ELF/relocatable-ehframe.s
@@ -10,13 +10,13 @@
# CHECK-NEXT: ]
# CHECK-NEXT: Address:
# CHECK-NEXT: Offset
-# CHECK-NEXT: Size: 9
+# CHECK-NEXT: Size: 8
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
# CHECK-NEXT: AddressAlignment: 1
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: SectionData (
-# CHECK-NEXT: 0000: 00005F73 74617274 00 |.._start.|
+# CHECK-NEXT: 0000: 005F7374 61727400 |._start.|
# CHECK-NEXT: )
# CHECK: Relocations [
diff --git a/test/ELF/relocatable-non-alloc.s b/test/ELF/relocatable-non-alloc.s
new file mode 100644
index 000000000000..f1915800c777
--- /dev/null
+++ b/test/ELF/relocatable-non-alloc.s
@@ -0,0 +1,10 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/relocatable-non-alloc.s -o %t2.o
+# RUN: ld.lld %t2.o %t2.o -r -o %t3.o
+# RUN: ld.lld %t1.o %t3.o -o %t.o | FileCheck -allow-empty %s
+
+# CHECK-NOT: has non-ABS reloc
+
+.globl _start
+_start:
diff --git a/test/ELF/relocatable-section-symbol.s b/test/ELF/relocatable-section-symbol.s
new file mode 100644
index 000000000000..9ac3a91d2c24
--- /dev/null
+++ b/test/ELF/relocatable-section-symbol.s
@@ -0,0 +1,49 @@
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld -r -o %t %t.o %t.o
+# RUN: llvm-readobj -r %t | FileCheck --check-prefix=RELA %s
+
+# RELA: Relocations [
+# RELA-NEXT: Section ({{.*}}) .rela.data {
+# RELA-NEXT: 0x0 R_X86_64_32 .text 0x1
+# RELA-NEXT: 0x4 R_X86_64_32 .text 0x5
+# RELA-NEXT: }
+# RELA-NEXT: ]
+
+
+# RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o
+# RUN: ld.lld -r -o %t %t.o %t.o
+# RUN: llvm-readobj -r -s -section-data %t | FileCheck --check-prefix=REL %s
+
+
+# REL: Section {
+# REL: Index:
+# REL: Name: .data
+# REL-NEXT: Type: SHT_PROGBITS
+# REL-NEXT: Flags [
+# REL-NEXT: SHF_ALLOC
+# REL-NEXT: SHF_WRITE
+# REL-NEXT: ]
+# REL-NEXT: Address:
+# REL-NEXT: Offset:
+# REL-NEXT: Size:
+# REL-NEXT: Link:
+# REL-NEXT: Info:
+# REL-NEXT: AddressAlignment:
+# REL-NEXT: EntrySize:
+# REL-NEXT: SectionData (
+# REL-NEXT: 0000: 01000000 05000000 |
+# REL-NEXT: )
+# REL-NEXT: }
+
+
+# REL: Relocations [
+# REL-NEXT: Section ({{.*}}) .rel.data {
+# REL-NEXT: 0x0 R_386_32 .text 0x0
+# REL-NEXT: 0x4 R_386_32 .text 0x0
+# REL-NEXT: }
+# REL-NEXT: ]
+
+
+.long 42
+.data
+.long .text + 1
diff --git a/test/ELF/relocatable-symbol-name.s b/test/ELF/relocatable-symbol-name.s
new file mode 100644
index 000000000000..d8a85dd4b815
--- /dev/null
+++ b/test/ELF/relocatable-symbol-name.s
@@ -0,0 +1,28 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld -r %t.o -o %t
+# RUN: llvm-readobj -t %t | FileCheck %s
+
+# Test that the section symbol has st_name equal to zero. GNU objdump
+# requires this to print relocations against the section.
+
+# CHECK: Symbols [
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name:
+# CHECK-NEXT: Value:
+# CHECK-NEXT: Size:
+# CHECK-NEXT: Binding:
+# CHECK-NEXT: Type:
+# CHECK-NEXT: Other:
+# CHECK-NEXT: Section:
+# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name: (0)
+# CHECK-NEXT: Value:
+# CHECK-NEXT: Size:
+# CHECK-NEXT: Binding:
+# CHECK-NEXT: Type: Section
+# CHECK-NEXT: Other:
+# CHECK-NEXT: Section: .text
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
diff --git a/test/ELF/relocatable.s b/test/ELF/relocatable.s
index 14e9d605892e..00572d07cbb9 100644
--- a/test/ELF/relocatable.s
+++ b/test/ELF/relocatable.s
@@ -30,7 +30,7 @@
# CHECK-NEXT: Version: 1
# CHECK-NEXT: Entry: 0x0
# CHECK-NEXT: ProgramHeaderOffset: 0x0
-# CHECK-NEXT: SectionHeaderOffset: 0x2C0
+# CHECK-NEXT: SectionHeaderOffset:
# CHECK-NEXT: Flags [
# CHECK-NEXT: ]
# CHECK-NEXT: HeaderSize: 64
diff --git a/test/ELF/relocation-copy-align-common.s b/test/ELF/relocation-copy-align-common.s
new file mode 100644
index 000000000000..a94c208a8b22
--- /dev/null
+++ b/test/ELF/relocation-copy-align-common.s
@@ -0,0 +1,40 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux \
+# RUN: %p/Inputs/relocation-copy-align-common.s -o %t2.o
+# RUN: ld.lld -shared %t2.o -o %t.so
+# RUN: ld.lld %t.o %t.so -o %t3
+# RUN: llvm-readobj -s -r --expand-relocs %t3 | FileCheck %s
+
+# CHECK: Section {
+# CHECK: Index:
+# CHECK: Name: .bss
+# CHECK-NEXT: Type: SHT_NOBITS
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: SHF_ALLOC
+# CHECK-NEXT: SHF_WRITE
+# CHECK-NEXT: ]
+# CHECK-NEXT: Address: 0x203000
+# CHECK-NEXT: Offset: 0x20B0
+# CHECK-NEXT: Size: 16
+# CHECK-NEXT: Link: 0
+# CHECK-NEXT: Info: 0
+# CHECK-NEXT: AddressAlignment: 8
+# CHECK-NEXT: EntrySize: 0
+# CHECK-NEXT: }
+
+# CHECK: Relocations [
+# CHECK-NEXT: Section {{.*}} .rela.dyn {
+# CHECK-NEXT: Relocation {
+# CHECK-NEXT: Offset: 0x203008
+# CHECK-NEXT: Type: R_X86_64_COPY
+# CHECK-NEXT: Symbol: foo
+# CHECK-NEXT: Addend: 0x0
+# CHECK-NEXT: }
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
+
+.global _start
+_start:
+.comm sym1,4,4
+movl $5, foo
diff --git a/test/ELF/relocation-group.test b/test/ELF/relocation-group.test
new file mode 100644
index 000000000000..0820ff8b9352
--- /dev/null
+++ b/test/ELF/relocation-group.test
@@ -0,0 +1,43 @@
+# RUN: yaml2obj %s -o %t.o
+# RUN: ld.lld %t.o %t.o -o %t -r
+# RUN: llvm-readobj -s %t | FileCheck %s
+
+# CHECK: Name: .text.foo
+# CHECK: Name: .rela.text.foo
+
+## YAML below corresponds to following asm code:
+## .section .text,"axG",@progbits,foo,comdat
+## .quad bar
+## gas 2.27 does not include .rela.text to group in that case:
+## COMDAT group section [ 1] `.group' [foo] contains 1 sections:
+## [Index] Name
+## [ 5] .text
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .group
+ Type: SHT_GROUP
+ Link: .symtab
+ Info: foo
+ Members:
+ - SectionOrType: GRP_COMDAT
+ - SectionOrType: .text.foo
+ - Name: .text.foo
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR, SHF_GROUP ]
+ - Name: .rela.text.foo
+ Type: SHT_RELA
+ Flags: [ SHF_INFO_LINK ]
+ Link: .symtab
+ Info: .text.foo
+ Relocations:
+ - Offset: 0x0000000000000000
+ Symbol: foo
+ Type: R_X86_64_64
+Symbols:
+ Global:
+ - Name: foo
diff --git a/test/ELF/relocation-nocopy.s b/test/ELF/relocation-nocopy.s
new file mode 100644
index 000000000000..533277dc8ec3
--- /dev/null
+++ b/test/ELF/relocation-nocopy.s
@@ -0,0 +1,19 @@
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/relocation-copy.s -o %t2.o
+// RUN: ld.lld -shared %t2.o -o %t.so
+// RUN: not ld.lld -z nocopyreloc %t.o %t.so -o %t3 2>&1 | FileCheck %s
+
+// CHECK: unresolvable relocation R_X86_64_32S against symbol 'x'
+// CHECK: unresolvable relocation R_X86_64_32S against symbol 'y'
+// CHECK: unresolvable relocation R_X86_64_32S against symbol 'z'
+
+.text
+.global _start
+_start:
+movl $5, x
+movl $7, y
+movl $9, z
+movl $x, %edx
+movl $y, %edx
+movl $z, %edx
diff --git a/test/ELF/relocation-none-aarch64.test b/test/ELF/relocation-none-aarch64.test
new file mode 100644
index 000000000000..dd67c8c0fb2e
--- /dev/null
+++ b/test/ELF/relocation-none-aarch64.test
@@ -0,0 +1,24 @@
+# REQUIRES: aarch64
+
+# RUN: yaml2obj %s -o %t.o
+# RUN: ld.lld %t.o -o %t.out
+
+!ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_AARCH64
+Sections:
+ - Type: SHT_PROGBITS
+ Name: .text
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ Content: "00000000"
+ - Type: SHT_RELA
+ Name: .rela.text
+ Link: .symtab
+ Info: .text
+ Relocations:
+ - Offset: 0
+ Symbol: ''
+ Type: R_AARCH64_NONE
diff --git a/test/ELF/relocation-relative-absolute.s b/test/ELF/relocation-relative-absolute.s
index e1636c734a88..2a343fddca76 100644
--- a/test/ELF/relocation-relative-absolute.s
+++ b/test/ELF/relocation-relative-absolute.s
@@ -7,6 +7,8 @@
.globl _start
_start:
-# CHECK: {{.*}}input1.o:(.text+0x1): relocation R_X86_64_PLT32 cannot refer to absolute symbol 'answer' defined in {{.*}}input2.o
+# CHECK: error: relocation R_X86_64_PLT32 cannot refer to absolute symbol: answer
+# CHECK-NEXT: >>> defined in {{.*}}input2.o
+# CHECK-NEXT: >>> referenced by {{.*}}o:(.text+0x1)
call answer@PLT
diff --git a/test/ELF/relro-omagic.s b/test/ELF/relro-omagic.s
index 35a92db2f07a..6e9d59a35279 100644
--- a/test/ELF/relro-omagic.s
+++ b/test/ELF/relro-omagic.s
@@ -1,6 +1,6 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o
-# RUN: ld.lld -shared %t2.o -o %t2.so
+# RUN: ld.lld -shared %t2.o -o %t2.so -soname relro-omagic.s.tmp2.so
# RUN: ld.lld -N %t.o %t2.so -o %t
# RUN: llvm-objdump -section-headers %t | FileCheck --check-prefix=NORELRO %s
# RUN: llvm-readobj --program-headers %t | FileCheck --check-prefix=NOPHDRS %s
diff --git a/test/ELF/reproduce.s b/test/ELF/reproduce.s
index c7955e02a822..94823d6d377f 100644
--- a/test/ELF/reproduce.s
+++ b/test/ELF/reproduce.s
@@ -60,6 +60,14 @@
# CHECK-NEXT: repro2/{{.*}}/file2
# CHECK-NEXT: repro2/{{.*}}/file
+## Check that directory path is stripped from -o <file-path>
+# RUN: mkdir -p %t.dir/build3/a/b/c
+# RUN: cd %t.dir
+# RUN: ld.lld build1/foo.o -o build3/a/b/c/bar -shared --as-needed --reproduce repro3.tar
+# RUN: tar xf repro3.tar
+# RUN: FileCheck %s --check-prefix=RSP3 < repro3/response.txt
+# RSP3: -o bar
+
.globl _start
_start:
mov $60, %rax
diff --git a/test/ELF/resolution-end.s b/test/ELF/resolution-end.s
index 72c8e9569fba..aa1c999fb79a 100644
--- a/test/ELF/resolution-end.s
+++ b/test/ELF/resolution-end.s
@@ -21,19 +21,18 @@
# CHECK-NEXT: AddressAlignment:
# CHECK-NEXT: EntrySize:
# CHECK-NEXT: SectionData (
-# CHECK-NEXT: 0000: 80202000 00000000
+# CHECK-NEXT: 0000: 80202000 00000000 80202000 00000000
# CHECK-NEXT: )
# CHECK: Symbol {
# CHECK: Name: _end
# CHECK-NEXT: Value: 0x202080
-# CHECK-NEXT: Size:
-# CHECK-NEXT: Binding: Global
-# CHECK-NEXT: Type:
-# CHECK-NEXT: Other:
-# CHECK-NEXT: Section:
-# CHECK-NEXT: }
+
+# CHECK: Symbol {
+# CHECK: Name: end
+# CHECK-NEXT: Value: 0x202080
.global _start
_start:
.quad _end
+.quad end
diff --git a/test/ELF/retain-symbols-file.s b/test/ELF/retain-symbols-file.s
index b146bd797b5c..aa7d35d914eb 100644
--- a/test/ELF/retain-symbols-file.s
+++ b/test/ELF/retain-symbols-file.s
@@ -3,20 +3,50 @@
# RUN: echo "bar" > %t_retain.txt
# RUN: echo "foo" >> %t_retain.txt
# RUN: ld.lld -shared --retain-symbols-file=%t_retain.txt %t -o %t2
-# RUN: llvm-readobj -s -sd -t %t2 | FileCheck %s
+# RUN: llvm-readobj --dyn-symbols %t2 | FileCheck %s
## Check separate form.
# RUN: ld.lld -shared --retain-symbols-file %t_retain.txt %t -o %t2
-# RUN: llvm-readobj -s -sd -t %t2 | FileCheck %s
+# RUN: llvm-readobj --dyn-symbols %t2 | FileCheck %s
-# CHECK: Symbols [
+# CHECK: DynamicSymbols [
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name: @
+# CHECK-NEXT: Value:
+# CHECK-NEXT: Size:
+# CHECK-NEXT: Binding:
+# CHECK-NEXT: Type:
+# CHECK-NEXT: Other:
+# CHECK-NEXT: Section:
+# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: (0)
-# CHECK: Symbol {
# CHECK-NEXT: Name: bar
-# CHECK: Symbol {
+# CHECK-NEXT: Value:
+# CHECK-NEXT: Size:
+# CHECK-NEXT: Binding: Global
+# CHECK-NEXT: Type:
+# CHECK-NEXT: Other:
+# CHECK-NEXT: Section: .text
+# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: foo
-# CHECK-NOT: Symbol
+# CHECK-NEXT: Value:
+# CHECK-NEXT: Size:
+# CHECK-NEXT: Binding: Global
+# CHECK-NEXT: Type:
+# CHECK-NEXT: Other:
+# CHECK-NEXT: Section: .text
+# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name: und
+# CHECK-NEXT: Value:
+# CHECK-NEXT: Size:
+# CHECK-NEXT: Binding: Global
+# CHECK-NEXT: Type:
+# CHECK-NEXT: Other:
+# CHECK-NEXT: Section: Undefined
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
.text
.globl _start
diff --git a/test/ELF/retain-und.s b/test/ELF/retain-und.s
new file mode 100644
index 000000000000..2f346754d1a0
--- /dev/null
+++ b/test/ELF/retain-und.s
@@ -0,0 +1,18 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: echo > %t.retain
+# RUN: echo "{ local: *; }; " > %t.script
+# RUN: ld.lld -shared --version-script %t.script %t.o -o %t1.so
+# RUN: ld.lld -shared --retain-symbols-file %t.retain %t.o -o %t2.so
+# RUN: llvm-readobj -r %t1.so | FileCheck %s
+# RUN: llvm-readobj -r %t2.so | FileCheck %s
+
+# CHECK: Relocations [
+# CHECK-NEXT: Section ({{.*}}) .rela.dyn {
+# CHECK-NEXT: 0x{{.*}} R_X86_64_64 foo 0x0
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
+
+.data
+.quad foo
+.weak foo
diff --git a/test/ELF/section-name.s b/test/ELF/section-name.s
index 4ff974768335..caf574f2c106 100644
--- a/test/ELF/section-name.s
+++ b/test/ELF/section-name.s
@@ -53,6 +53,6 @@ _start:
// CHECK: 9 .data.rel.ro 00000004
// CHECK: 10 .bss 00000002
// CHECK: 11 .comment 00000008
-// CHECK: 12 .symtab 00000060
+// CHECK: 12 .symtab 00000030
// CHECK: 13 .shstrtab 00000075
-// CHECK: 14 .strtab 0000001d
+// CHECK: 14 .strtab 00000008
diff --git a/test/ELF/splitstacks.s b/test/ELF/splitstacks.s
index 6506b48a2513..3b7e67e5c2b0 100644
--- a/test/ELF/splitstacks.s
+++ b/test/ELF/splitstacks.s
@@ -2,7 +2,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
# RUN: not ld.lld %t1.o -o %t 2>&1 | FileCheck %s
-# CHECK: objects using splitstacks are not supported
+# CHECK: .o: object file compiled with -fsplit-stack is not supported
.globl _start
_start:
diff --git a/test/ELF/startstop-gccollect.s b/test/ELF/startstop-gccollect.s
index 589ccafafcca..daff08187cdf 100644
--- a/test/ELF/startstop-gccollect.s
+++ b/test/ELF/startstop-gccollect.s
@@ -6,24 +6,26 @@
# RUN: llvm-objdump -d %tout | FileCheck -check-prefix=DISASM %s
## Check that foo and bar sections are not garbage collected,
-## we do not want to reclaim sections if they can be referred
+## we do not want to reclaim sections if they are referred
## by __start_* and __stop_* symbols.
# RUN: ld.lld %t --gc-sections -o %tout
# RUN: llvm-objdump -d %tout | FileCheck -check-prefix=DISASM %s
# DISASM: _start:
-# DISASM-NEXT: 201000: 90 nop
+# DISASM-NEXT: 201000: e8 05 00 00 00 callq 5 <__start_foo>
+# DISASM-NEXT: 201005: e8 01 00 00 00 callq 1 <__start_bar>
# DISASM-NEXT: Disassembly of section foo:
-# DISASM-NEXT: foo:
-# DISASM-NEXT: 201001: 90 nop
+# DISASM-NEXT: __start_foo:
+# DISASM-NEXT: 20100a: 90 nop
# DISASM-NEXT: Disassembly of section bar:
-# DISASM-NEXT: bar:
-# DISASM-NEXT: 201002: 90 nop
+# DISASM-NEXT: __start_bar:
+# DISASM-NEXT: 20100b: 90 nop
.global _start
.text
_start:
- nop
+ callq __start_foo
+ callq __start_bar
.section foo,"ax"
nop
diff --git a/test/ELF/static-with-export-dynamic.s b/test/ELF/static-with-export-dynamic.s
new file mode 100644
index 000000000000..8634835d9aa7
--- /dev/null
+++ b/test/ELF/static-with-export-dynamic.s
@@ -0,0 +1,32 @@
+// RUN: llvm-mc -filetype=obj -triple=i686-unknown-cloudabi %s -o %t.o
+// RUN: ld.lld --export-dynamic %t.o -o %t
+// RUN: llvm-readobj -dyn-symbols %t | FileCheck %s
+// REQUIRES: x86
+
+// Ensure that a dynamic symbol table is present when --export-dynamic
+// is passed in, even when creating statically linked executables.
+//
+// CHECK: DynamicSymbols [
+// CHECK-NEXT: Symbol {
+// CHECK-NEXT: Name:
+// CHECK-NEXT: Value: 0x0
+// CHECK-NEXT: Size: 0
+// CHECK-NEXT: Binding: Local
+// CHECK-NEXT: Type: None
+// CHECK-NEXT: Other: 0
+// CHECK-NEXT: Section: Undefined
+// CHECK-NEXT: }
+// CHECK-NEXT: Symbol {
+// CHECK-NEXT: Name: _start
+// CHECK-NEXT: Value: 0x11000
+// CHECK-NEXT: Size: 0
+// CHECK-NEXT: Binding: Global
+// CHECK-NEXT: Type: None
+// CHECK-NEXT: Other: 0
+// CHECK-NEXT: Section: .text
+// CHECK-NEXT: }
+// CHECK-NEXT: ]
+
+.global _start
+_start:
+ ret
diff --git a/test/ELF/sysroot.s b/test/ELF/sysroot.s
index 0b7b17260e58..358b4d9dfa5b 100644
--- a/test/ELF/sysroot.s
+++ b/test/ELF/sysroot.s
@@ -9,7 +9,8 @@
// Should not link because of undefined symbol _bar
// RUN: not ld.lld -o %t/r %t/m.o 2>&1 \
// RUN: | FileCheck --check-prefix=UNDEFINED %s
-// UNDEFINED: error: {{.*}}:(.text+0x1): undefined symbol '_bar'
+// UNDEFINED: error: undefined symbol: _bar
+// UNDEFINED: >>> referenced by {{.*}}:(.text+0x1)
// We need to be sure that there is no suitable library in the /lib directory
// RUN: not ld.lld -o %t/r %t/m.o -L/lib -l:libls.a 2>&1 \
diff --git a/test/ELF/tls-mismatch.s b/test/ELF/tls-mismatch.s
index aee1f73dedce..21994d19af32 100644
--- a/test/ELF/tls-mismatch.s
+++ b/test/ELF/tls-mismatch.s
@@ -2,7 +2,10 @@
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/tls-mismatch.s -o %t2
// RUN: not ld.lld %t %t2 -o %t3 2>&1 | FileCheck %s
-// CHECK: TLS attribute mismatch for symbol 'tlsvar'
+
+// CHECK: TLS attribute mismatch: tlsvar
+// CHECK: >>> defined in
+// CHECK: >>> defined in
.globl _start,tlsvar
_start:
diff --git a/test/ELF/tls-static.s b/test/ELF/tls-static.s
index b098b68b03f1..81ecc82758d7 100644
--- a/test/ELF/tls-static.s
+++ b/test/ELF/tls-static.s
@@ -10,4 +10,5 @@
_start:
call __tls_get_addr
-// CHECK: error: {{.*}}:(.text+0x1): undefined symbol '__tls_get_addr'
+// CHECK: error: undefined symbol: __tls_get_addr
+// CHECK: >>> referenced by {{.*}}:(.text+0x1)
diff --git a/test/ELF/trace-symbols.s b/test/ELF/trace-symbols.s
index 7f6bca8be216..eb8e17c709a5 100644
--- a/test/ELF/trace-symbols.s
+++ b/test/ELF/trace-symbols.s
@@ -10,7 +10,7 @@
# RUN: llvm-ar rcs %t1.a %t1
# RUN: llvm-ar rcs %t2.a %t2
-# RUN: ld.lld -y foo -trace-symbol=common -trace-symbol=hsymbol \
+# RUN: ld.lld -y foo -trace-symbol common -trace-symbol=hsymbol \
# RUN: %t %t1 %t2 -o %t3 2>&1 | FileCheck -check-prefix=OBJECTRFOO %s
# OBJECTRFOO: trace-symbols.s.tmp: reference to foo
diff --git a/test/ELF/ttext-tdata-tbss.s b/test/ELF/ttext-tdata-tbss.s
index c31c56e75692..a52d88b49572 100644
--- a/test/ELF/ttext-tdata-tbss.s
+++ b/test/ELF/ttext-tdata-tbss.s
@@ -9,7 +9,8 @@
# CHECK-NEXT: .aw PROGBITS 0000000000202000 002000 000008
# CHECK-NEXT: .data PROGBITS 0000000000202008 002008 000008
# CHECK-NEXT: .bss NOBITS 0000000000202010 002010 000008
-# CHECK: PHDR
+# CHECK: Type
+# CHECK-NEXT: PHDR
# CHECK-NEXT: LOAD 0x000000 0x0000000000200000
## With .text at 0 there is no space to allocate the headers.
@@ -20,7 +21,7 @@
# USER1-NEXT: .bss NOBITS 0000000000008000 002008 000008
# USER1-NEXT: .rodata PROGBITS 0000000000009000 003000 000008
# USER1-NEXT: .aw PROGBITS 000000000000a000 004000 000008
-# USER1: PHDR
+# USER1: Type
# USER1-NEXT: LOAD 0x001000 0x0000000000000000
## With .text at 0x1000 there is space to allocate the headers.
@@ -31,7 +32,8 @@
# USER2-NEXT: .bss NOBITS 0000000000008000 002008 000008
# USER2-NEXT: .rodata PROGBITS 0000000000009000 003000 000008
# USER2-NEXT: .aw PROGBITS 000000000000a000 004000 000008
-# USER2: PHDR
+# USER2: Type
+# USER2-NEXT: PHDR
# USER2-NEXT: LOAD 0x000000 0x0000000000000000
## With .text well above 200000 we don't need to change the image base
@@ -42,7 +44,8 @@
# USER3-NEX: .aw PROGBITS 0000000000203000 003000 000008
# USER3-NEX: .data PROGBITS 0000000000203008 003008 000008
# USER3-NEX: .bss NOBITS 0000000000203010 003010 000008
-# USER3: PHDR
+# USER3: Type
+# USER3-NEXT: PHDR
# USER3-NEXT: LOAD 0x000000 0x0000000000200000
.text
diff --git a/test/ELF/undef-shared.s b/test/ELF/undef-shared.s
index 3f01ec25f511..bc38b6082765 100644
--- a/test/ELF/undef-shared.s
+++ b/test/ELF/undef-shared.s
@@ -1,15 +1,18 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
# RUN: not ld.lld %t.o -o %t.so -shared 2>&1 | FileCheck %s
-# CHECK: error: {{.*}}:(.data+0x0): undefined symbol 'hidden'
+# CHECK: error: undefined symbol: hidden
+# CHECK: >>> referenced by {{.*}}:(.data+0x0)
.global hidden
.hidden hidden
-# CHECK: error: {{.*}}:(.data+0x8): undefined symbol 'internal'
+# CHECK: error: undefined symbol: internal
+# CHECK: >>> referenced by {{.*}}:(.data+0x8)
.global internal
.internal internal
-# CHECK: error: {{.*}}:(.data+0x10): undefined symbol 'protected'
+# CHECK: error: undefined symbol: protected
+# CHECK: >>> referenced by {{.*}}:(.data+0x10)
.global protected
.protected protected
diff --git a/test/ELF/undef-with-plt-addr.s b/test/ELF/undef-with-plt-addr.s
index 2e2fc20be3f6..d34859c04e8f 100644
--- a/test/ELF/undef-with-plt-addr.s
+++ b/test/ELF/undef-with-plt-addr.s
@@ -5,6 +5,9 @@
// RUN: ld.lld %t.o %t2.so -o %t3
// RUN: llvm-readobj -t -s -r %t3 | FileCheck %s
+// Test that -z nocopyreloc doesn't prevent the plt hack.
+// RUN: ld.lld %t.o %t2.so -o %t3 -z nocopyreloc
+
.globl _start
_start:
movabsq $set_data, %rax
diff --git a/test/ELF/undef.s b/test/ELF/undef.s
index d0f95a3b6381..49f84108f64a 100644
--- a/test/ELF/undef.s
+++ b/test/ELF/undef.s
@@ -5,17 +5,37 @@
# RUN: llvm-ar rc %t2.a %t2.o
# RUN: not ld.lld %t.o %t2.a %t3.o -o %t.exe 2>&1 | FileCheck %s
# RUN: not ld.lld -pie %t.o %t2.a %t3.o -o %t.exe 2>&1 | FileCheck %s
-# CHECK: error: undef.s:(.text+0x1): undefined symbol 'foo'
-# CHECK: error: undef.s:(.text+0x6): undefined symbol 'bar'
-# CHECK: error: undef.s:(.text+0x10): undefined symbol 'foo(int)'
-# CHECK: error: {{.*}}2.a({{.*}}.o):(.text+0x0): undefined symbol 'zed2'
-# CHECK: error: dir{{/|\\}}undef-debug.s:3: undefined symbol 'zed3'
-# CHECK: error: dir{{/|\\}}undef-debug.s:7: undefined symbol 'zed4'
-# CHECK: error: dir{{/|\\}}undef-debug.s:11: undefined symbol 'zed5'
+
+# CHECK: error: undefined symbol: foo
+# CHECK: >>> referenced by undef.s
+# CHECK: {{.*}}:(.text+0x1)
+
+# CHECK: error: undefined symbol: bar
+# CHECK: >>> referenced by undef.s
+# CHECK: >>> {{.*}}:(.text+0x6)
+
+# CHECK: error: undefined symbol: foo(int)
+# CHECK: >>> referenced by undef.s
+# CHECK: >>> {{.*}}:(.text+0x10)
+
+# CHECK: error: undefined symbol: zed2
+# CHECK: >>> referenced by {{.*}}.o:(.text+0x0) in archive {{.*}}2.a
+
+# CHECK: error: undefined symbol: zed3
+# CHECK: >>> referenced by undef-debug.s:3 (dir{{/|\\}}undef-debug.s:3)
+# CHECK: >>> {{.*}}.o:(.text+0x0)
+
+# CHECK: error: undefined symbol: zed4
+# CHECK: >>> referenced by undef-debug.s:7 (dir{{/|\\}}undef-debug.s:7)
+# CHECK: >>> {{.*}}.o:(.text.1+0x0)
+
+# CHECK: error: undefined symbol: zed5
+# CHECK: >>> referenced by undef-debug.s:11 (dir{{/|\\}}undef-debug.s:11)
+# CHECK: >>> {{.*}}.o:(.text.2+0x0)
# RUN: not ld.lld %t.o %t2.a -o %t.exe -no-demangle 2>&1 | \
# RUN: FileCheck -check-prefix=NO-DEMANGLE %s
-# NO-DEMANGLE: error: undef.s:(.text+0x10): undefined symbol '_Z3fooi'
+# NO-DEMANGLE: error: undefined symbol: _Z3fooi
.file "undef.s"
diff --git a/test/ELF/unknown-reloc.s b/test/ELF/unknown-reloc.s
deleted file mode 100644
index b674a3bbc657..000000000000
--- a/test/ELF/unknown-reloc.s
+++ /dev/null
@@ -1,14 +0,0 @@
-# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=i386-pc-linux-gnu %s -o %t1.o
-# RUN: llvm-mc -filetype=obj -triple=i386-pc-linux-gnu %S/Inputs/unknown-reloc.s -o %t2.o
-# RUN: not ld.lld %t1.o %t2.o -o %t.out 2>&1 | FileCheck %s
-
-# CHECK: do not know how to handle relocation 'R_386_PC8' (23)
-# CHECK: do not know how to handle relocation 'R_386_8' (22)
-
-.text
-.global foo
-foo:
-
-.byte und-foo
-.byte foo
diff --git a/test/ELF/unresolved-symbols.s b/test/ELF/unresolved-symbols.s
index 3c33b9245786..18656dcceca3 100644
--- a/test/ELF/unresolved-symbols.s
+++ b/test/ELF/unresolved-symbols.s
@@ -6,7 +6,8 @@
## Check that %t2.o contains undefined symbol undef.
# RUN: not ld.lld %t1.o %t2.o -o %t 2>&1 | \
# RUN: FileCheck -check-prefix=UNDCHECK %s
-# UNDCHECK: error: {{.*}}2.o:(.text+0x1): undefined symbol 'undef'
+# UNDCHECK: error: undefined symbol: undef
+# UNDCHECK: >>> referenced by {{.*}}2.o:(.text+0x1)
## Error out if unknown option value was set.
# RUN: not ld.lld %t1.o %t2.o -o %t --unresolved-symbols=xxx 2>&1 | \
@@ -19,7 +20,9 @@
# RUN: llvm-readobj %t1_1 > /dev/null 2>&1
# RUN: not ld.lld %t2.o -o %t1_2 --unresolved-symbols=ignore-all --no-undefined 2>&1 | \
# RUN: FileCheck -check-prefix=ERRUND %s
-# ERRUND: error: {{.*}}:(.text+0x1): undefined symbol 'undef'
+# ERRUND: error: undefined symbol: undef
+# ERRUND: >>> referenced by {{.*}}:(.text+0x1)
+
## Also ignore all should not produce error for symbols from DSOs.
# RUN: ld.lld %t1.o %t.so -o %t1_3 --unresolved-symbols=ignore-all
# RUN: llvm-readobj %t1_3 > /dev/null 2>&1
@@ -56,8 +59,7 @@
# RUN: llvm-readobj %t6_1 > /dev/null 2>&1
# RUN: not ld.lld %t2.o -o %t7 --unresolved-symbols=report-all 2>&1 | \
# RUN: FileCheck -check-prefix=ERRUND %s
-# RUN: not ld.lld %t2.o -o %t7_1 2>&1 | \
-# RUN: FileCheck -check-prefix=ERRUND %s
+# RUN: not ld.lld %t2.o -o %t7_1 2>&1 | FileCheck -check-prefix=ERRUND %s
.globl _start
_start:
diff --git a/test/ELF/verneed-local.s b/test/ELF/verneed-local.s
index 94336fddad48..9ab6cd791484 100644
--- a/test/ELF/verneed-local.s
+++ b/test/ELF/verneed-local.s
@@ -2,7 +2,8 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: not ld.lld %t.o %S/Inputs/verneed1.so -o %t 2>&1 | FileCheck %s
-# CHECK: error: {{.*}}:(.text+0x1): undefined symbol 'f3'
+# CHECK: error: undefined symbol: f3
+# CHECK: >>> referenced by {{.*}}:(.text+0x1)
.globl _start
_start:
call f3
diff --git a/test/ELF/version-script-copy-rel.s b/test/ELF/version-script-copy-rel.s
new file mode 100644
index 000000000000..42d922e7dc98
--- /dev/null
+++ b/test/ELF/version-script-copy-rel.s
@@ -0,0 +1,24 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/copy-in-shared.s -o %t1.o
+# RUN: echo "FOOVER { global: *; };" > %t.script
+# RUN: ld.lld --version-script %t.script -shared %t1.o -o %t.so
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t2.o
+# RUN: ld.lld %t2.o %t.so -o %tout
+# RUN: llvm-readobj -dyn-symbols %tout | FileCheck %s
+
+# CHECK: DynamicSymbols [
+# CHECK: Symbol {
+# CHECK: Name: foo@FOOVER
+# CHECK-NEXT: Value:
+# CHECK-NEXT: Size:
+# CHECK-NEXT: Binding: Global
+# CHECK-NEXT: Type: Object
+# CHECK-NEXT: Other:
+# CHECK-NEXT: Section: .bss.rel.ro
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
+
+.text
+.global _start
+_start:
+movl $0, foo
diff --git a/test/ELF/version-script-extern-exact.s b/test/ELF/version-script-extern-exact.s
index 1ac2f6395ab6..bfd44e589ac5 100644
--- a/test/ELF/version-script-extern-exact.s
+++ b/test/ELF/version-script-extern-exact.s
@@ -3,12 +3,20 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: echo "FOO { global: extern \"C++\" { \"aaa*\"; }; };" > %t.script
# RUN: ld.lld --version-script %t.script -shared %t.o -o %t.so
-# RUN: llvm-readobj -V -dyn-symbols %t.so | FileCheck %s
+# RUN: llvm-readobj -dyn-symbols %t.so | FileCheck %s --check-prefix=NOMATCH
-# CHECK: Symbol {
-# CHECK: Name: _Z3aaaPf@
-# CHECK: Symbol {
-# CHECK: Name: _Z3aaaPi@
+# NOMATCH: DynamicSymbols [
+# NOMATCH-NOT: _Z3aaaPf@@FOO
+# NOMATCH-NOT: _Z3aaaPi@@FOO
+# NOMATCH: ]
+
+# RUN: echo "FOO { global: extern \"C++\" { \"aaa*\"; aaa*; }; };" > %t2.script
+# RUN: ld.lld --version-script %t2.script -shared %t.o -o %t2.so
+# RUN: llvm-readobj -dyn-symbols %t2.so | FileCheck %s --check-prefix=MATCH
+# MATCH: DynamicSymbols [
+# MATCH: _Z3aaaPf@@FOO
+# MATCH: _Z3aaaPi@@FOO
+# MATCH: ]
.text
.globl _Z3aaaPi
diff --git a/test/ELF/version-script-extern-wildcards-anon.s b/test/ELF/version-script-extern-wildcards-anon.s
index 790d985e2b0c..5ba2f7d21bd4 100644
--- a/test/ELF/version-script-extern-wildcards-anon.s
+++ b/test/ELF/version-script-extern-wildcards-anon.s
@@ -7,6 +7,7 @@
# RUN: extern "C++" { \
# RUN: "foo(int)"; \
# RUN: z*; \
+# RUN: std::q*; \
# RUN: }; \
# RUN: local: *; \
# RUN: }; ' > %t.script
@@ -50,6 +51,15 @@
# CHECK-NEXT: Other:
# CHECK-NEXT: Section:
# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name: _ZSt3qux
+# CHECK-NEXT: Value:
+# CHECK-NEXT: Size:
+# CHECK-NEXT: Binding: Global
+# CHECK-NEXT: Type:
+# CHECK-NEXT: Other:
+# CHECK-NEXT: Section:
+# CHECK-NEXT: }
# CHECK-NEXT: ]
.global _Z3fooi
@@ -60,3 +70,5 @@ _Z3bari:
_Z3zedi:
.global _Z3bazi
_Z3bazi:
+.global _ZSt3qux
+_ZSt3qux:
diff --git a/test/ELF/version-script-glob.s b/test/ELF/version-script-glob.s
index 330c068ba91d..8149ead8292f 100644
--- a/test/ELF/version-script-glob.s
+++ b/test/ELF/version-script-glob.s
@@ -14,6 +14,9 @@ bar1:
.globl zed1
zed1:
+ .globl local
+local:
+
# CHECK: DynamicSymbols [
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name:
@@ -43,3 +46,27 @@ zed1:
# CHECK-NEXT: Section: .text
# CHECK-NEXT: }
# CHECK-NEXT: ]
+
+# RUN: echo "{ global : local; local: *; };" > %t1.script
+# RUN: ld.lld -shared --version-script %t1.script %t.o -o %t1.so
+
+# LOCAL: DynamicSymbols [
+# LOCAL-NEXT: Symbol {
+# LOCAL-NEXT: Name:
+# LOCAL-NEXT: Value: 0x0
+# LOCAL-NEXT: Size: 0
+# LOCAL-NEXT: Binding: Local
+# LOCAL-NEXT: Type: None
+# LOCAL-NEXT: Other: 0
+# LOCAL-NEXT: Section: Undefined
+# LOCAL-NEXT: }
+# LOCAL-NEXT: Symbol {
+# LOCAL-NEXT: Name: local
+# LOCAL-NEXT: Value: 0x1000
+# LOCAL-NEXT: Size: 0
+# LOCAL-NEXT: Binding: Global
+# LOCAL-NEXT: Type: None
+# LOCAL-NEXT: Other: 0
+# LOCAL-NEXT: Section: .text
+# LOCAL-NEXT: }
+# LOCAL-NEXT: ]
diff --git a/test/ELF/version-script.s b/test/ELF/version-script.s
index 7453981ab9cc..72f9eeb944d1 100644
--- a/test/ELF/version-script.s
+++ b/test/ELF/version-script.s
@@ -14,7 +14,8 @@
# RUN: ld.lld --version-script %t3.script -shared %t.o %t2.so -o %t3.so
# RUN: llvm-readobj -dyn-symbols %t3.so | FileCheck --check-prefix=DSO2 %s
-# RUN: echo "VERSION_1.0 { global: foo1; local: *; };" > %t4.script
+## Also check that both "global:" and "global :" forms are accepted
+# RUN: echo "VERSION_1.0 { global : foo1; local : *; };" > %t4.script
# RUN: echo "VERSION_2.0 { global: foo3; local: *; };" >> %t4.script
# RUN: ld.lld --version-script %t4.script -shared %t.o %t2.so -o %t4.so
# RUN: llvm-readobj -dyn-symbols %t4.so | FileCheck --check-prefix=VERDSO %s
diff --git a/test/ELF/warn-unresolved-symbols-hidden.s b/test/ELF/warn-unresolved-symbols-hidden.s
new file mode 100644
index 000000000000..04691f9af948
--- /dev/null
+++ b/test/ELF/warn-unresolved-symbols-hidden.s
@@ -0,0 +1,14 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: not ld.lld -shared %t.o -o %t.so -z defs --warn-unresolved-symbols 2>&1| FileCheck %s
+
+# CHECK: warning: undefined symbol: foo
+# CHECK: error: undefined symbol: bar
+# CHECK: error: undefined symbol: zed
+
+.data
+.quad foo
+.hidden bar
+.quad bar
+.protected zed
+.quad zed
diff --git a/test/ELF/warn-unresolved-symbols.s b/test/ELF/warn-unresolved-symbols.s
new file mode 100644
index 000000000000..3342c6ce50a2
--- /dev/null
+++ b/test/ELF/warn-unresolved-symbols.s
@@ -0,0 +1,51 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o
+
+## The link should fail with an undef error by default
+# RUN: not ld.lld %t1.o -o %t3 2>&1 | \
+# RUN: FileCheck -check-prefix=ERRUND %s
+
+## --error-unresolved-symbols should generate an error
+# RUN: not ld.lld %t1.o -o %t4 --error-unresolved-symbols 2>&1 | \
+# RUN: FileCheck -check-prefix=ERRUND %s
+
+## --warn-unresolved-symbols should generate a warning
+# RUN: ld.lld %t1.o -o %t5 --warn-unresolved-symbols 2>&1 | \
+# RUN: FileCheck -check-prefix=WARNUND %s
+
+## Test that the last option wins
+# RUN: ld.lld %t1.o -o %t5 --error-unresolved-symbols --warn-unresolved-symbols 2>&1 | \
+# RUN: FileCheck -check-prefix=WARNUND %s
+# RUN: not ld.lld %t1.o -o %t6 --warn-unresolved-symbols --error-unresolved-symbols 2>&1 | \
+# RUN: FileCheck -check-prefix=ERRUND %s
+
+## Do not report undefines if linking relocatable or shared.
+## And while we're at it, check that we can accept single -
+## variants of these options.
+# RUN: ld.lld -r %t1.o -o %t7 -error-unresolved-symbols 2>&1 | \
+# RUN: FileCheck -allow-empty -check-prefix=NOERR %s
+# RUN: ld.lld -shared %t1.o -o %t8.so --error-unresolved-symbols 2>&1 | \
+# RUN: FileCheck -allow-empty -check-prefix=NOERR %s
+# RUN: ld.lld -r %t1.o -o %t9 -warn-unresolved-symbols 2>&1 | \
+# RUN: FileCheck -allow-empty -check-prefix=NOWARN %s
+# RUN: ld.lld -shared %t1.o -o %t10.so --warn-unresolved-symbols 2>&1 | \
+# RUN: FileCheck -allow-empty -check-prefix=NOWARN %s
+
+# ERRUND: error: undefined symbol: undef
+# ERRUND: >>> referenced by {{.*}}:(.text+0x1)
+
+# WARNUND: warning: undefined symbol: undef
+# WARNUND: >>> referenced by {{.*}}:(.text+0x1)
+
+# NOERR-NOT: error: undefined symbol: undef
+# NOERR-NOT: >>> referenced by {{.*}}:(.text+0x1)
+
+# NOWARN-NOT: warning: undefined symbol: undef
+# NOWARN-NOT: >>> referenced by {{.*}}:(.text+0x1)
+
+.globl _start
+_start:
+
+.globl _shared
+_shared:
+ callq undef@PLT
diff --git a/test/ELF/x86-64-dyn-rel-error.s b/test/ELF/x86-64-dyn-rel-error.s
index 354fcc09e8a8..ee39e2cb83fd 100644
--- a/test/ELF/x86-64-dyn-rel-error.s
+++ b/test/ELF/x86-64-dyn-rel-error.s
@@ -9,4 +9,4 @@ _start:
.data
.long bar
-// CHECK: {{.*}}:(.data+0x0): relocation R_X86_64_32 cannot be used against shared object; recompile with -fPIC.
+// CHECK: relocation R_X86_64_32 cannot be used against shared object; recompile with -fPIC
diff --git a/test/ELF/x86-64-dyn-rel-error2.s b/test/ELF/x86-64-dyn-rel-error2.s
index 88a180da6274..e316aeae54f4 100644
--- a/test/ELF/x86-64-dyn-rel-error2.s
+++ b/test/ELF/x86-64-dyn-rel-error2.s
@@ -4,9 +4,11 @@
// RUN: ld.lld %t2.o -shared -o %t2.so
// RUN: not ld.lld %t.o %t2.so -o %t 2>&1 | FileCheck %s
+// CHECK: relocation R_X86_64_PC32 cannot be used against shared object; recompile with -fPIC
+// CHECK: >>> defined in {{.*}}.so
+// CHECK: >>> referenced by {{.*}}.o:(.data+0x0)
+
.global _start
_start:
.data
.long bar - .
-
-// CHECK: {{.*}}:(.data+0x0): relocation R_X86_64_PC32 cannot be used against shared object; recompile with -fPIC.
diff --git a/test/ELF/x86-64-reloc-16.s b/test/ELF/x86-64-reloc-16.s
new file mode 100644
index 000000000000..2954d9900cfa
--- /dev/null
+++ b/test/ELF/x86-64-reloc-16.s
@@ -0,0 +1,14 @@
+// REQUIRES: x86
+
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/x86-64-reloc-16.s -o %t1
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/x86-64-reloc-16-error.s -o %t2
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
+// RUN: ld.lld -shared %t %t1 -o %t3
+
+// CHECK: Contents of section .text:
+// CHECK-NEXT: 200000 42
+
+// RUN: not ld.lld -shared %t %t2 -o %t4 2>&1 | FileCheck --check-prefix=ERROR %s
+// ERROR: relocation R_X86_64_16 out of range
+
+.short foo
diff --git a/test/ELF/x86-64-reloc-32-fpic.s b/test/ELF/x86-64-reloc-32-fpic.s
index 5726d36e9ad7..e3e7c6834d21 100644
--- a/test/ELF/x86-64-reloc-32-fpic.s
+++ b/test/ELF/x86-64-reloc-32-fpic.s
@@ -1,7 +1,10 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
# RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
-# CHECK: {{.*}}:(.data+0x0): relocation R_X86_64_32 cannot be used against shared object; recompile with -fPIC.
+
+# CHECK: relocation R_X86_64_32 cannot be used against shared object; recompile with -fPIC
+# CHECK: >>> defined in {{.*}}
+# CHECK: >>> referenced by {{.*}}:(.data+0x0)
.data
.long _shared
diff --git a/test/ELF/x86-64-reloc-8.s b/test/ELF/x86-64-reloc-8.s
new file mode 100644
index 000000000000..1c3831fafa20
--- /dev/null
+++ b/test/ELF/x86-64-reloc-8.s
@@ -0,0 +1,14 @@
+// REQUIRES: x86
+
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/x86-64-reloc-8.s -o %t1
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/x86-64-reloc-8-error.s -o %t2
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
+// RUN: ld.lld -shared %t %t1 -o %t3
+
+// CHECK: Contents of section .text:
+// CHECK-NEXT: 200000 42
+
+// RUN: not ld.lld -shared %t %t2 -o %t4 2>&1 | FileCheck --check-prefix=ERROR %s
+// ERROR: relocation R_X86_64_8 out of range
+
+.byte foo
diff --git a/test/ELF/x86-64-reloc-pc32-fpic.s b/test/ELF/x86-64-reloc-pc32-fpic.s
index 3c9f3e0bdb38..399bf604f806 100644
--- a/test/ELF/x86-64-reloc-pc32-fpic.s
+++ b/test/ELF/x86-64-reloc-pc32-fpic.s
@@ -1,7 +1,10 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
# RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
-# CHECK: {{.*}}:(.data+0x1): relocation R_X86_64_PC32 cannot be used against shared object; recompile with -fPIC.
+
+# CHECK: relocation R_X86_64_PC32 cannot be used against shared object; recompile with -fPIC
+# CHECK: >>> defined in {{.*}}
+# CHECK: >>> referenced by {{.*}}:(.data+0x1)
.data
call _shared
diff --git a/test/ELF/zdefs.s b/test/ELF/zdefs.s
index 420f602c41ae..93c61e14ccb6 100644
--- a/test/ELF/zdefs.s
+++ b/test/ELF/zdefs.s
@@ -2,6 +2,7 @@
# RUN: ld.lld -shared %t.o -o %t1.so
# RUN: not ld.lld -z defs -shared %t.o -o %t1.so 2>&1 | FileCheck -check-prefix=ERR %s
-# ERR: error: {{.*}}:(.text+0x1): undefined symbol 'foo'
+# ERR: error: undefined symbol: foo
+# ERR: >>> referenced by {{.*}}:(.text+0x1)
callq foo@PLT
diff --git a/test/ELF/zstack-size.s b/test/ELF/zstack-size.s
index 36fbd03766ce..23eed0a79ecc 100644
--- a/test/ELF/zstack-size.s
+++ b/test/ELF/zstack-size.s
@@ -1,20 +1,33 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: ld.lld -z stack-size=0x1000 %t -o %t1
-# RUN: llvm-readobj -program-headers %t1 | FileCheck %s
+# RUN: llvm-readobj -program-headers %t1 | FileCheck %s -check-prefix=CHECK1
+
+# RUN: ld.lld -z stack-size=0 %t -o %t2
+# RUN: llvm-readobj -program-headers %t2 | FileCheck %s -check-prefix=CHECK2
.global _start
_start:
nop
-# CHECK: Type: PT_GNU_STACK (0x6474E551)
-# CHECK-NEXT: Offset: 0x0
-# CHECK-NEXT: VirtualAddress: 0x0
-# CHECK-NEXT: PhysicalAddress: 0x0
-# CHECK-NEXT: FileSize: 0
-# CHECK-NEXT: MemSize: 4096
-# CHECK-NEXT: Flags [ (0x6)
-# CHECK-NEXT: PF_R (0x4)
-# CHECK-NEXT: PF_W (0x2)
-# CHECK-NEXT: ]
-# CHECK-NEXT: Alignment: 0
+# CHECK1: Type: PT_GNU_STACK (0x6474E551)
+# CHECK1-NEXT: Offset: 0x0
+# CHECK1-NEXT: VirtualAddress: 0x0
+# CHECK1-NEXT: PhysicalAddress: 0x0
+# CHECK1-NEXT: FileSize: 0
+# CHECK1-NEXT: MemSize: 4096
+# CHECK1-NEXT: Flags [ (0x6)
+# CHECK1-NEXT: PF_R (0x4)
+# CHECK1-NEXT: PF_W (0x2)
+# CHECK1-NEXT: ]
+
+# CHECK2: Type: PT_GNU_STACK (0x6474E551)
+# CHECK2-NEXT: Offset: 0x0
+# CHECK2-NEXT: VirtualAddress: 0x0
+# CHECK2-NEXT: PhysicalAddress: 0x0
+# CHECK2-NEXT: FileSize: 0
+# CHECK2-NEXT: MemSize: 0
+# CHECK2-NEXT: Flags [ (0x6)
+# CHECK2-NEXT: PF_R (0x4)
+# CHECK2-NEXT: PF_W (0x2)
+# CHECK2-NEXT: ]
diff --git a/test/ELF/ztext-text-notext.s b/test/ELF/ztext-text-notext.s
new file mode 100644
index 000000000000..964ffe1fa6d8
--- /dev/null
+++ b/test/ELF/ztext-text-notext.s
@@ -0,0 +1,36 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/ztext-text-notext.s -o %t2.o
+# RUN: ld.lld %t2.o -o %t2.so -shared
+# RUN: ld.lld -z notext %t.o %t2.so -o %t -shared
+# RUN: llvm-readobj -dynamic-table -r %t | FileCheck %s
+# RUN: ld.lld -z notext %t.o %t2.so -o %t2 -pie
+# RUN: llvm-readobj -dynamic-table -r %t2 | FileCheck %s
+# RUN: ld.lld -z notext %t.o %t2.so -o %t3
+# RUN: llvm-readobj -dynamic-table -r %t3 | FileCheck --check-prefix=STATIC %s
+
+# If the preference is to have text relocations, don't create plt of copy relocations.
+
+# CHECK: Relocations [
+# CHECK-NEXT: Section {{.*}} .rela.dyn {
+# CHECK-NEXT: 0x1000 R_X86_64_RELATIVE - 0x1000
+# CHECK-NEXT: 0x1008 R_X86_64_64 bar 0x0
+# CHECK-NEXT: 0x1010 R_X86_64_PC64 zed 0x0
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
+# CHECK: DynamicSection [
+# CHECK: 0x0000000000000016 TEXTREL 0x0
+
+# STATIC: Relocations [
+# STATIC-NEXT: Section {{.*}} .rela.dyn {
+# STATIC-NEXT: 0x201008 R_X86_64_64 bar 0x0
+# STATIC-NEXT: 0x201010 R_X86_64_PC64 zed 0x0
+# STATIC-NEXT: }
+# STATIC-NEXT: ]
+# STATIC: DynamicSection [
+# STATIC: 0x0000000000000016 TEXTREL 0x0
+
+foo:
+.quad foo
+.quad bar
+.quad zed - .
diff --git a/test/lit.cfg b/test/lit.cfg
index 0db879312413..85469ff6fb73 100644
--- a/test/lit.cfg
+++ b/test/lit.cfg
@@ -66,18 +66,24 @@ config.llvm_obj_root = getattr(config, 'llvm_obj_root', None)
# Tweak the PATH to include the tools dir and the scripts dir.
if lld_obj_root is not None:
+ lld_tools_dir = getattr(config, 'lld_tools_dir', None)
+ if not lld_tools_dir:
+ lit_config.fatal('No LLD tools dir set!')
llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
if not llvm_tools_dir:
lit_config.fatal('No LLVM tools dir set!')
- path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH']))
+ path = os.path.pathsep.join((lld_tools_dir, llvm_tools_dir, config.environment['PATH']))
path = os.path.pathsep.join((os.path.join(getattr(config, 'llvm_src_root', None),'test','Scripts'),path))
config.environment['PATH'] = path
+ lld_libs_dir = getattr(config, 'lld_libs_dir', None)
+ if not lld_libs_dir:
+ lit_config.fatal('No LLD libs dir set!')
llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
if not llvm_libs_dir:
lit_config.fatal('No LLVM libs dir set!')
- path = os.path.pathsep.join((llvm_libs_dir,
+ path = os.path.pathsep.join((lld_libs_dir, llvm_libs_dir,
config.environment.get('LD_LIBRARY_PATH','')))
config.environment['LD_LIBRARY_PATH'] = path
@@ -174,10 +180,10 @@ for pattern in tool_patterns:
pattern)
tool_pipe = tool_match.group(2)
tool_name = tool_match.group(4)
- tool_path = lit.util.which(tool_name, llvm_tools_dir)
+ tool_path = lit.util.which(tool_name, config.environment['PATH'])
if not tool_path:
# Warn, but still provide a substitution.
- lit_config.note('Did not find ' + tool_name + ' in ' + llvm_tools_dir)
+ lit_config.note('Did not find ' + tool_name + ' in ' + path)
tool_path = llvm_tools_dir + '/' + tool_name
config.substitutions.append((pattern, tool_pipe + tool_path))
@@ -196,7 +202,7 @@ if execute_external:
config.available_features.add('shell')
# zlib compression library
-if config.have_zlib == "1":
+if config.have_zlib:
config.available_features.add("zlib")
# Running on Darwin OS
diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in
index 5293f24c1251..1fb8d3690708 100644
--- a/test/lit.site.cfg.in
+++ b/test/lit.site.cfg.in
@@ -6,9 +6,11 @@ config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
config.lld_obj_root = "@LLD_BINARY_DIR@"
+config.lld_libs_dir = "@LLVM_LIBRARY_OUTPUT_INTDIR@"
+config.lld_tools_dir = "@LLVM_RUNTIME_OUTPUT_INTDIR@"
config.target_triple = "@TARGET_TRIPLE@"
config.python_executable = "@PYTHON_EXECUTABLE@"
-config.have_zlib = "@HAVE_LIBZ@"
+config.have_zlib = @HAVE_LIBZ@
# Support substitution of the tools and libs dirs with user parameters. This is
# used when we can't determine the tool dir at configuration time.