aboutsummaryrefslogtreecommitdiff
path: root/test/ELF
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-01-19 10:05:49 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-01-19 10:05:49 +0000
commite2fd426bdafe9f5c10066d3926ece6e342184a67 (patch)
treebfbbb5fd38554e6b8988b7a217e9fd0623728d7d /test/ELF
parent84c4061b34e048f47e5eb4fbabc1558495e8157c (diff)
Vendor import of lld trunk r351319 (just before the release_80 branchvendor/lld/lld-trunk-r351319
Notes
Notes: svn path=/vendor/lld/dist/; revision=343179 svn path=/vendor/lld/lld-trunk-r351319/; revision=343180; tag=vendor/lld/lld-trunk-r351319
Diffstat (limited to 'test/ELF')
-rw-r--r--test/ELF/Inputs/bad-reloc-target.test21
-rw-r--r--test/ELF/Inputs/copy-rel-tls.s12
-rw-r--r--test/ELF/Inputs/gdb-index-invalid-ranges.obj.s2
-rw-r--r--test/ELF/Inputs/gdb-index-multiple-cu-2.s45
-rw-r--r--test/ELF/Inputs/hexagon-shared.s3
-rw-r--r--test/ELF/Inputs/i386-linkonce.s11
-rw-r--r--test/ELF/Inputs/ppc64-bsymbolic-local-def.s14
-rw-r--r--test/ELF/Inputs/ppc64-no-split-stack.s8
-rw-r--r--test/ELF/Inputs/ppc64-tls-ie-le.s29
-rw-r--r--test/ELF/Inputs/ppc64le-quadword-ldst.obin0 -> 1032 bytes
-rw-r--r--test/ELF/Inputs/wrap-with-archive.s5
-rw-r--r--test/ELF/Inputs/x86-64-split-stack-extra.s10
-rw-r--r--test/ELF/aarch64-abs16.s20
-rw-r--r--test/ELF/aarch64-abs32.s20
-rw-r--r--test/ELF/aarch64-call26-thunk.s10
-rw-r--r--test/ELF/aarch64-combined-dynrel-ifunc.s51
-rw-r--r--test/ELF/aarch64-combined-dynrel.s41
-rw-r--r--test/ELF/aarch64-condb-reloc.s30
-rw-r--r--test/ELF/aarch64-copy.s32
-rw-r--r--test/ELF/aarch64-copy2.s2
-rw-r--r--test/ELF/aarch64-cortex-a53-843419-abs-mapsyms.s22
-rw-r--r--test/ELF/aarch64-cortex-a53-843419-cli.s2
-rw-r--r--test/ELF/aarch64-cortex-a53-843419-large.s74
-rw-r--r--test/ELF/aarch64-cortex-a53-843419-large2.s19
-rw-r--r--test/ELF/aarch64-cortex-a53-843419-recognize.s490
-rw-r--r--test/ELF/aarch64-cortex-a53-843419-tlsrelax.s38
-rw-r--r--test/ELF/aarch64-data-relocs.s4
-rw-r--r--test/ELF/aarch64-gnu-ifunc-address.s40
-rw-r--r--test/ELF/aarch64-gnu-ifunc-plt.s80
-rw-r--r--test/ELF/aarch64-gnu-ifunc.s46
-rw-r--r--test/ELF/aarch64-gnu-ifunc2.s52
-rw-r--r--test/ELF/aarch64-gnu-ifunc3.s49
-rw-r--r--test/ELF/aarch64-jump26-thunk.s10
-rw-r--r--test/ELF/aarch64-lo12-alignment.s8
-rw-r--r--test/ELF/aarch64-prel16.s24
-rw-r--r--test/ELF/aarch64-prel32.s24
-rw-r--r--test/ELF/aarch64-relocs.s50
-rw-r--r--test/ELF/aarch64-thunk-pi.s4
-rw-r--r--test/ELF/aarch64-thunk-section-location.s8
-rw-r--r--test/ELF/aarch64-tls-gdie.s14
-rw-r--r--test/ELF/aarch64-tls-gdle.s12
-rw-r--r--test/ELF/aarch64-tls-ie.s22
-rw-r--r--test/ELF/aarch64-tls-iele.s10
-rw-r--r--test/ELF/aarch64-tls-le.s29
-rw-r--r--test/ELF/aarch64-tlsld-ldst.s52
-rw-r--r--test/ELF/aarch64-tstbr14-reloc.s26
-rw-r--r--test/ELF/aarch64-undefined-weak.s24
-rw-r--r--test/ELF/amdgpu-elf-flags-err.s4
-rw-r--r--test/ELF/amdgpu-elf-flags.s4
-rw-r--r--test/ELF/amdgpu-kernels.s2
-rw-r--r--test/ELF/archive-fetch.s15
-rw-r--r--test/ELF/arm-bl-v6-inrange.s47
-rw-r--r--test/ELF/arm-bl-v6.s33
-rw-r--r--test/ELF/arm-blx-v4t.s7
-rw-r--r--test/ELF/arm-branch-rangethunk.s6
-rw-r--r--test/ELF/arm-branch-undef-weak-plt-thunk.s4
-rw-r--r--test/ELF/arm-combined-dynrel-ifunc.s49
-rw-r--r--test/ELF/arm-extreme-range-pi-thunk.s82
-rw-r--r--test/ELF/arm-long-thunk-converge.s2
-rw-r--r--test/ELF/arm-thumb-branch-rangethunk.s4
-rw-r--r--test/ELF/arm-thumb-branch.s4
-rw-r--r--test/ELF/arm-thumb-condbranch-thunk.s2
-rw-r--r--test/ELF/arm-thumb-interwork-shared.s2
-rw-r--r--test/ELF/arm-thumb-interwork-thunk-range.s2
-rw-r--r--test/ELF/arm-thumb-interwork-thunk-v5.s66
-rw-r--r--test/ELF/arm-thumb-interwork-thunk.s2
-rw-r--r--test/ELF/arm-thumb-mix-range-thunk-os.s2
-rw-r--r--test/ELF/arm-thumb-plt-range-thunk-os.s2
-rw-r--r--test/ELF/arm-thumb-range-thunk-os.s2
-rw-r--r--test/ELF/arm-thumb-thunk-empty-pass.s2
-rw-r--r--test/ELF/arm-thumb-thunk-symbols.s2
-rw-r--r--test/ELF/arm-thumb-thunk-v6m.s61
-rw-r--r--test/ELF/arm-thumb-undefined-weak-narrow.test50
-rw-r--r--test/ELF/arm-thunk-edgecase.s2
-rw-r--r--test/ELF/arm-thunk-largesection.s11
-rw-r--r--test/ELF/arm-thunk-linkerscript-dotexpr.s2
-rw-r--r--test/ELF/arm-thunk-linkerscript-large.s5
-rw-r--r--test/ELF/arm-thunk-linkerscript-orphan.s2
-rw-r--r--test/ELF/arm-thunk-linkerscript-sort.s2
-rw-r--r--test/ELF/arm-thunk-linkerscript.s2
-rw-r--r--test/ELF/arm-thunk-multipass.s2
-rw-r--r--test/ELF/arm-thunk-nosuitable.s5
-rw-r--r--test/ELF/arm-thunk-re-add.s2
-rw-r--r--test/ELF/arm-thunk-section-too-large.s2
-rw-r--r--test/ELF/arm-tls-le32.s12
-rw-r--r--test/ELF/arm-tls-norelax-ie-le.s4
-rw-r--r--test/ELF/arm-v4bx.test40
-rw-r--r--test/ELF/arm-v5-reloc-error.s31
-rw-r--r--test/ELF/as-needed-in-regular.s24
-rw-r--r--test/ELF/as-needed-not-in-regular.s32
-rw-r--r--test/ELF/as-needed-weak.s2
-rw-r--r--test/ELF/bad-reloc-target.test29
-rw-r--r--test/ELF/basic-aarch64.s16
-rw-r--r--test/ELF/basic-ppc64.s51
-rw-r--r--test/ELF/basic32.s16
-rw-r--r--test/ELF/basic64be.s65
-rw-r--r--test/ELF/bsymbolic-undef.s4
-rw-r--r--test/ELF/cgprofile-obj.s44
-rw-r--r--test/ELF/cgprofile-shared-warn.s21
-rw-r--r--test/ELF/cgprofile-txt2.s38
-rw-r--r--test/ELF/common-gc2.s4
-rw-r--r--test/ELF/compressed-debug-input-err.s4
-rw-r--r--test/ELF/conflict.s1
-rw-r--r--test/ELF/copy-rel-tls.s15
-rw-r--r--test/ELF/debug-line-str.s136
-rw-r--r--test/ELF/debug-relocation-none.test58
-rw-r--r--test/ELF/defsym.s19
-rw-r--r--test/ELF/dont-export-hidden.s2
-rw-r--r--test/ELF/driver-access.test2
-rw-r--r--test/ELF/driver.test3
-rw-r--r--test/ELF/dt_flags.s5
-rw-r--r--test/ELF/dynamic-list-locals.s7
-rw-r--r--test/ELF/dynamic-list-preempt.s8
-rw-r--r--test/ELF/dynamic-list-unexpected-end.s7
-rw-r--r--test/ELF/dynamic-list-wildcard.s6
-rw-r--r--test/ELF/dynamic-list.s22
-rw-r--r--test/ELF/dynamic-reloc.s2
-rw-r--r--test/ELF/dynsym-no-rosegment.s4
-rw-r--r--test/ELF/dynsym-pie.s2
-rw-r--r--test/ELF/edata-etext.s1
-rw-r--r--test/ELF/emit-relocs-icf1.s32
-rw-r--r--test/ELF/emit-relocs-icf2.s36
-rw-r--r--test/ELF/empty-pack-dyn-relocs.s11
-rw-r--r--test/ELF/empty-ver.s2
-rw-r--r--test/ELF/empty-ver2.s4
-rw-r--r--test/ELF/emulation-aarch64.s34
-rw-r--r--test/ELF/emulation-arm.s27
-rw-r--r--test/ELF/emulation-mips.s189
-rw-r--r--test/ELF/emulation-ppc.s75
-rw-r--r--test/ELF/emulation-x86.s205
-rw-r--r--test/ELF/emulation.s396
-rw-r--r--test/ELF/execute-only-mixed-data.s2
-rw-r--r--test/ELF/format-binary.test12
-rw-r--r--test/ELF/gc-sections-implicit-addend.s6
-rw-r--r--test/ELF/gc-sections-linker-defined-symbol.s2
-rw-r--r--test/ELF/gdb-index-base-addr.s2
-rw-r--r--test/ELF/gdb-index-dwarf5-low-high.s49
-rw-r--r--test/ELF/gdb-index-invalid-ranges.s42
-rw-r--r--test/ELF/gdb-index-multiple-cu-2.s36
-rw-r--r--test/ELF/gdb-index-multiple-cu.s88
-rw-r--r--test/ELF/gdb-index-no-debug.s8
-rw-r--r--test/ELF/gdb-index-ranges.s2
-rw-r--r--test/ELF/gdb-index-rng-lists.s202
-rw-r--r--test/ELF/gdb-index.s2
-rw-r--r--test/ELF/global-offset-table-position-redef-err.s14
-rw-r--r--test/ELF/gnu-hash-table-copy.s8
-rw-r--r--test/ELF/gnu-hash-table-rwsegment.s4
-rw-r--r--test/ELF/gnu-hash-table.s54
-rw-r--r--test/ELF/gnu-ifunc-empty.s16
-rw-r--r--test/ELF/gnu-ifunc-i386.s38
-rw-r--r--test/ELF/gnu-ifunc-plt-i386.s64
-rw-r--r--test/ELF/gnu-ifunc-plt.s8
-rw-r--r--test/ELF/gnu-ifunc-relative.s16
-rw-r--r--test/ELF/gnu-ifunc-shared.s6
-rw-r--r--test/ELF/gnu-ifunc.s4
-rw-r--r--test/ELF/gnu-unique.s4
-rw-r--r--test/ELF/got-i386.s18
-rw-r--r--test/ELF/got32-i386-pie-rw.s2
-rw-r--r--test/ELF/got32-i386.s4
-rw-r--r--test/ELF/got32x-i386.s10
-rw-r--r--test/ELF/hexagon-eflag.s7
-rw-r--r--test/ELF/hexagon-shared.s46
-rw-r--r--test/ELF/hexagon.s206
-rw-r--r--test/ELF/i386-linkonce.s9
-rw-r--r--test/ELF/i386-pc8-pc16-addend.s8
-rw-r--r--test/ELF/i386-retpoline-nopic.s96
-rw-r--r--test/ELF/icf13.s1
-rw-r--r--test/ELF/icf15.s1
-rw-r--r--test/ELF/icf16.s1
-rw-r--r--test/ELF/icf17.s1
-rw-r--r--test/ELF/image-base.s3
-rw-r--r--test/ELF/incompatible-ar-first.s1
-rw-r--r--test/ELF/incompatible.s1
-rw-r--r--test/ELF/invalid-linkerscript.test8
-rw-r--r--test/ELF/invalid/Inputs/shentsize-zero.elfbin512 -> 0 bytes
-rw-r--r--test/ELF/invalid/Inputs/sht-group.elfbin480 -> 0 bytes
-rwxr-xr-xtest/ELF/invalid/Inputs/undefined-local-symbol-in-dso.sobin0 -> 5080 bytes
-rw-r--r--test/ELF/invalid/comdat-broken.test25
-rw-r--r--test/ELF/invalid/ehframe-broken-relocation.test31
-rw-r--r--test/ELF/invalid/invalid-soname.test18
-rw-r--r--test/ELF/invalid/linkorder-invalid-sec.test16
-rw-r--r--test/ELF/invalid/linkorder-invalid-sec2.test16
-rw-r--r--test/ELF/invalid/merge-invalid-size.s3
-rw-r--r--test/ELF/invalid/merge-zero-size.test21
-rw-r--r--test/ELF/invalid/non-terminated-string.test19
-rw-r--r--test/ELF/invalid/sht-group-wrong-section.test22
-rw-r--r--test/ELF/invalid/sht-group.s3
-rw-r--r--test/ELF/invalid/sht-group.test18
-rw-r--r--test/ELF/invalid/undefined-local-symbol-in-dso.test66
-rw-r--r--test/ELF/lazy-arch-conflict.s7
-rw-r--r--test/ELF/linkerscript/Inputs/at6.s11
-rw-r--r--test/ELF/linkerscript/Inputs/at7.s7
-rw-r--r--test/ELF/linkerscript/Inputs/at8.s8
-rw-r--r--test/ELF/linkerscript/align-r.test2
-rw-r--r--test/ELF/linkerscript/align4.test1
-rw-r--r--test/ELF/linkerscript/at6.test30
-rw-r--r--test/ELF/linkerscript/at7.test28
-rw-r--r--test/ELF/linkerscript/at8.test31
-rw-r--r--test/ELF/linkerscript/discard-section-err.s20
-rw-r--r--test/ELF/linkerscript/filename-spec.s1
-rw-r--r--test/ELF/linkerscript/icf.s11
-rw-r--r--test/ELF/linkerscript/info-section-type.s9
-rw-r--r--test/ELF/linkerscript/lazy-symbols.test1
-rw-r--r--test/ELF/linkerscript/map-file.test8
-rw-r--r--test/ELF/linkerscript/map-file2.test22
-rw-r--r--test/ELF/linkerscript/memory-include.test23
-rw-r--r--test/ELF/linkerscript/merge-nonalloc.s14
-rw-r--r--test/ELF/linkerscript/no-filename-spec.s17
-rw-r--r--test/ELF/linkerscript/non-alloc-segment.s2
-rw-r--r--test/ELF/linkerscript/non-alloc.s2
-rw-r--r--test/ELF/linkerscript/orphan-discard.s2
-rw-r--r--test/ELF/linkerscript/orphan-phdrs.s2
-rw-r--r--test/ELF/linkerscript/ouputformat.s9
-rw-r--r--test/ELF/linkerscript/output-section-include.test30
-rw-r--r--test/ELF/linkerscript/output-too-large.s6
-rw-r--r--test/ELF/linkerscript/phdrs.s8
-rw-r--r--test/ELF/linkerscript/provide-shared2.s2
-rw-r--r--test/ELF/linkerscript/relocatable-discard.s21
-rw-r--r--test/ELF/linkerscript/section-include.test32
-rw-r--r--test/ELF/linkerscript/sections-va-overflow.test4
-rw-r--r--test/ELF/linkerscript/segment-none.s4
-rw-r--r--test/ELF/linkerscript/sizeof.s1
-rw-r--r--test/ELF/linkerscript/sizeofheaders.s1
-rw-r--r--test/ELF/linkerscript/sort-init.s6
-rw-r--r--test/ELF/linkerscript/sort-non-script.s2
-rw-r--r--test/ELF/linkerscript/symbol-assignexpr.s1
-rw-r--r--test/ELF/linkerscript/symbol-location.s15
-rw-r--r--test/ELF/linkerscript/symbol-memoryexpr.s1
-rw-r--r--test/ELF/linkerscript/target.s18
-rw-r--r--test/ELF/linkerscript/unused-synthetic.s2
-rw-r--r--test/ELF/linkerscript/version-script.s6
-rw-r--r--test/ELF/local-dynamic.s4
-rw-r--r--test/ELF/local-ver-preemptible.s22
-rw-r--r--test/ELF/lto-plugin-ignore.s4
-rw-r--r--test/ELF/lto/Inputs/libcall-archive.s2
-rw-r--r--test/ELF/lto/amdgcn.ll12
-rw-r--r--test/ELF/lto/cache.ll22
-rw-r--r--test/ELF/lto/data-ordering-lto.s2
-rw-r--r--test/ELF/lto/defsym.ll4
-rw-r--r--test/ELF/lto/dynamic-list.ll2
-rw-r--r--test/ELF/lto/emit-llvm.ll14
-rw-r--r--test/ELF/lto/libcall-archive.ll7
-rw-r--r--test/ELF/lto/ltopasses-custom.ll4
-rw-r--r--test/ELF/lto/opt-remarks.ll10
-rw-r--r--test/ELF/lto/ppc64le.ll12
-rw-r--r--test/ELF/lto/r600.ll12
-rw-r--r--test/ELF/lto/relocatable.ll9
-rw-r--r--test/ELF/lto/section-name.ll4
-rw-r--r--test/ELF/lto/shlib-undefined.ll2
-rw-r--r--test/ELF/lto/symbol-ordering-lto.s2
-rw-r--r--test/ELF/lto/thinlto-obj-path.ll3
-rw-r--r--test/ELF/lto/thinlto-object-suffix-replace.ll12
-rw-r--r--test/ELF/lto/undefined-puts.ll2
-rw-r--r--test/ELF/lto/version-script.ll2
-rw-r--r--test/ELF/lto/wrap-2.ll8
-rw-r--r--test/ELF/map-file-i686.s24
-rw-r--r--test/ELF/merge-string-error.s2
-rw-r--r--test/ELF/mergeable-errors.s8
-rw-r--r--test/ELF/mips-32.s4
-rw-r--r--test/ELF/mips-64.s4
-rw-r--r--test/ELF/mips-dynamic.s6
-rw-r--r--test/ELF/mips-dynsym-sort.s6
-rw-r--r--test/ELF/mips-gnu-hash.s2
-rw-r--r--test/ELF/mips-got-and-copy.s4
-rw-r--r--test/ELF/mips-got-extsym.s2
-rw-r--r--test/ELF/mips-got-relocs.s4
-rw-r--r--test/ELF/mips-got16-relocatable.s8
-rw-r--r--test/ELF/mips-got16.s2
-rw-r--r--test/ELF/mips-hilo.s6
-rw-r--r--test/ELF/mips-mgot.s14
-rw-r--r--test/ELF/mips-micro-jal.s12
-rw-r--r--test/ELF/mips-micro-plt.s2
-rw-r--r--test/ELF/mips-npic-call-pic-os.s35
-rw-r--r--test/ELF/mips-npic-call-pic-script.s114
-rw-r--r--test/ELF/mips-npic-call-pic.s25
-rw-r--r--test/ELF/mips-sto-plt.s4
-rw-r--r--test/ELF/mips-tls-64.s6
-rw-r--r--test/ELF/mips-tls-hilo.s2
-rw-r--r--test/ELF/mips-tls-static-64.s4
-rw-r--r--test/ELF/mips-tls-static.s4
-rw-r--r--test/ELF/mips-tls.s6
-rw-r--r--test/ELF/mips-traps.s22
-rw-r--r--test/ELF/msp430.s43
-rw-r--r--test/ELF/no-obj.s1
-rw-r--r--test/ELF/note-first-page.s12
-rw-r--r--test/ELF/oformat-binary.s1
-rw-r--r--test/ELF/pack-dyn-relocs-loop.s66
-rw-r--r--test/ELF/pack-dyn-relocs-tls-aarch64.s34
-rw-r--r--test/ELF/pack-dyn-relocs-tls-x86-64.s23
-rw-r--r--test/ELF/plt-aarch64.s82
-rw-r--r--test/ELF/plt-i686.s68
-rw-r--r--test/ELF/plt.s10
-rw-r--r--test/ELF/ppc-relocs.s17
-rw-r--r--test/ELF/ppc64-bsymbolic-toc-restore.s68
-rw-r--r--test/ELF/ppc64-call-reach.s94
-rw-r--r--test/ELF/ppc64-dq.s32
-rw-r--r--test/ELF/ppc64-dtprel.s8
-rw-r--r--test/ELF/ppc64-entry-point.s (renamed from test/ELF/ppc64_entry_point.s)15
-rw-r--r--test/ELF/ppc64-error-missaligned-dq.s26
-rw-r--r--test/ELF/ppc64-error-missaligned-ds.s26
-rw-r--r--test/ELF/ppc64-func-entry-points.s2
-rw-r--r--test/ELF/ppc64-gd-to-ie.s8
-rw-r--r--test/ELF/ppc64-general-dynamic-tls.s12
-rw-r--r--test/ELF/ppc64-got-indirect.s4
-rw-r--r--test/ELF/ppc64-got-off.s67
-rw-r--r--test/ELF/ppc64-initial-exec-tls.s12
-rw-r--r--test/ELF/ppc64-local-dynamic.s12
-rw-r--r--test/ELF/ppc64-local-exec-tls.s4
-rw-r--r--test/ELF/ppc64-long-branch.s121
-rw-r--r--test/ELF/ppc64-rel-so-local-calls.s4
-rw-r--r--test/ELF/ppc64-relocs.s49
-rw-r--r--test/ELF/ppc64-shared-long_branch.s114
-rw-r--r--test/ELF/ppc64-split-stack-adjust-fail.s53
-rw-r--r--test/ELF/ppc64-split-stack-adjust-overflow.s64
-rw-r--r--test/ELF/ppc64-split-stack-adjust-size-success.s108
-rw-r--r--test/ELF/ppc64-split-stack-prologue-adjust-success.s224
-rw-r--r--test/ELF/ppc64-tls-gd-le-small.s61
-rw-r--r--test/ELF/ppc64-tls-gd-le.s12
-rw-r--r--test/ELF/ppc64-tls-ie-le.s140
-rw-r--r--test/ELF/ppc64-tls-ld-le.s12
-rw-r--r--test/ELF/ppc64-toc-addis-nop-lqsq.s73
-rw-r--r--test/ELF/ppc64-toc-addis-nop.s272
-rw-r--r--test/ELF/ppc64-toc-rel.s30
-rw-r--r--test/ELF/ppc64-toc-restore-recursive-call.s52
-rw-r--r--test/ELF/ppc64-toc-restore.s2
-rw-r--r--test/ELF/ppc64-tocopt-option.s14
-rw-r--r--test/ELF/pr34660.s2
-rw-r--r--test/ELF/progname.s2
-rw-r--r--test/ELF/protected-shared.s4
-rw-r--r--test/ELF/push-state.s3
-rw-r--r--test/ELF/relative-dynamic-reloc-ppc64.s4
-rw-r--r--test/ELF/relative-dynamic-reloc.s4
-rw-r--r--test/ELF/relocatable-bss.s2
-rw-r--r--test/ELF/relocatable-comdat-multiple.s4
-rw-r--r--test/ELF/relocatable-comdat.s2
-rw-r--r--test/ELF/relocatable-comdat2.s4
-rw-r--r--test/ELF/relocatable-compressed-input.s2
-rw-r--r--test/ELF/relocatable-many-sections.s18
-rw-r--r--test/ELF/relocatable-rel-iplt.s56
-rw-r--r--test/ELF/relocatable.s16
-rw-r--r--test/ELF/relocation-b-aarch64.test4
-rw-r--r--test/ELF/relocation-before-merge-start.s9
-rw-r--r--test/ELF/relocation-common.s12
-rw-r--r--test/ELF/relocation-copy-i686.s14
-rw-r--r--test/ELF/relocation-i686.s30
-rw-r--r--test/ELF/relocation-past-merge-end.s2
-rw-r--r--test/ELF/relocation-size-shared.s15
-rw-r--r--test/ELF/relocation-size.s13
-rw-r--r--test/ELF/reproduce-backslash.s2
-rw-r--r--test/ELF/retain-symbols-file.s2
-rw-r--r--test/ELF/riscv-branch.test119
-rw-r--r--test/ELF/riscv-call.test95
-rw-r--r--test/ELF/riscv-hi20-lo12.test86
-rw-r--r--test/ELF/riscv-jal-error.test93
-rw-r--r--test/ELF/riscv-jal.test161
-rw-r--r--test/ELF/riscv-pcrel-hilo.test103
-rw-r--r--test/ELF/shared.s20
-rw-r--r--test/ELF/sort-norosegment.s2
-rw-r--r--test/ELF/static-error.s13
-rw-r--r--test/ELF/static-with-export-dynamic.s2
-rw-r--r--test/ELF/strip-debug.s4
-rw-r--r--test/ELF/symbol-ordering-file-warnings.s13
-rw-r--r--test/ELF/textrel.s40
-rw-r--r--test/ELF/tls-i686.s20
-rw-r--r--test/ELF/tls-in-archive.s1
-rw-r--r--test/ELF/tls-opt-gdiele-i686.s20
-rw-r--r--test/ELF/tls-opt-i686.s32
-rw-r--r--test/ELF/tls-opt-iele-i686-nopic.s42
-rw-r--r--test/ELF/tls-static.s1
-rw-r--r--test/ELF/tls-weak-undef.s1
-rw-r--r--test/ELF/trace-ar.s1
-rw-r--r--test/ELF/trace-symbols.s2
-rw-r--r--test/ELF/undef-broken-debug.test2
-rw-r--r--test/ELF/undef-version-script.s6
-rw-r--r--test/ELF/undef-with-plt-addr-i686.s4
-rw-r--r--test/ELF/undef.s5
-rw-r--r--test/ELF/verdef-defaultver.s8
-rw-r--r--test/ELF/verdef.s4
-rw-r--r--test/ELF/verneed.s4
-rw-r--r--test/ELF/version-exclude-libs.s1
-rw-r--r--test/ELF/version-script-complex-wildcards.s8
-rw-r--r--test/ELF/version-script-extern-undefined.s4
-rw-r--r--test/ELF/version-script-extern-wildcards.s2
-rw-r--r--test/ELF/version-script-extern.s4
-rw-r--r--test/ELF/version-script-extern2.s2
-rw-r--r--test/ELF/version-script-hide-so-symbol.s2
-rw-r--r--test/ELF/version-script-locals-extern.s8
-rw-r--r--test/ELF/version-script-symver2.s2
-rw-r--r--test/ELF/version-script-weak.s2
-rw-r--r--test/ELF/version-script.s28
-rw-r--r--test/ELF/version-wildcard.test4
-rw-r--r--test/ELF/visibility.s2
-rw-r--r--test/ELF/weak-undef-export.s4
-rw-r--r--test/ELF/weak-undef.s4
-rw-r--r--test/ELF/wrap-entry.s13
-rw-r--r--test/ELF/wrap-no-real.s58
-rw-r--r--test/ELF/wrap-plt.s45
-rw-r--r--test/ELF/wrap-with-archive.s13
-rw-r--r--test/ELF/wrap.s2
-rw-r--r--test/ELF/x86-64-combined-dynrel.s40
-rw-r--r--test/ELF/x86-64-reloc-error2.s12
-rw-r--r--test/ELF/x86-64-reloc-gotoff64.s2
-rw-r--r--test/ELF/x86-64-reloc-gotpc64.s2
-rw-r--r--test/ELF/x86-64-reloc-range-debug-loc.s2
-rw-r--r--test/ELF/x86-64-reloc-range.s2
-rw-r--r--test/ELF/x86-64-retpoline-znow-static-iplt.s26
-rw-r--r--test/ELF/x86-64-split-stack-prologue-adjust-fail.s12
-rw-r--r--test/ELF/x86-64-split-stack-prologue-adjust-shared.s31
-rw-r--r--test/ELF/x86-64-split-stack-prologue-adjust-silent.s2
-rw-r--r--test/ELF/x86-64-split-stack-prologue-adjust-success.s35
-rw-r--r--test/ELF/znotext-plt-relocations-protected.s7
-rw-r--r--test/ELF/zstack-size.s3
412 files changed, 7785 insertions, 2030 deletions
diff --git a/test/ELF/Inputs/bad-reloc-target.test b/test/ELF/Inputs/bad-reloc-target.test
new file mode 100644
index 000000000000..dabd005881f4
--- /dev/null
+++ b/test/ELF/Inputs/bad-reloc-target.test
@@ -0,0 +1,21 @@
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ - Name: .rela.text
+ Type: SHT_RELA
+ Link: .symtab
+ Info: 99
+ Relocations:
+ - Offset: 0x0000000000000000
+ Symbol: foo
+ Type: R_X86_64_64
+Symbols:
+ Global:
+ - Name: foo \ No newline at end of file
diff --git a/test/ELF/Inputs/copy-rel-tls.s b/test/ELF/Inputs/copy-rel-tls.s
new file mode 100644
index 000000000000..c34b6925e809
--- /dev/null
+++ b/test/ELF/Inputs/copy-rel-tls.s
@@ -0,0 +1,12 @@
+.bss
+.global foo
+.type foo, @object
+.size foo, 4
+foo:
+
+.section .tbss,"awT",@nobits
+.global tfoo
+.skip 0x2000
+.type tfoo,@object
+.size tfoo, 4
+tfoo:
diff --git a/test/ELF/Inputs/gdb-index-invalid-ranges.obj.s b/test/ELF/Inputs/gdb-index-invalid-ranges.obj.s
new file mode 100644
index 000000000000..d7e0bd29d2f8
--- /dev/null
+++ b/test/ELF/Inputs/gdb-index-invalid-ranges.obj.s
@@ -0,0 +1,2 @@
+main:
+ callq f1
diff --git a/test/ELF/Inputs/gdb-index-multiple-cu-2.s b/test/ELF/Inputs/gdb-index-multiple-cu-2.s
new file mode 100644
index 000000000000..80c738eab1ff
--- /dev/null
+++ b/test/ELF/Inputs/gdb-index-multiple-cu-2.s
@@ -0,0 +1,45 @@
+.globl _start
+_start:
+
+.section .debug_abbrev,"",@progbits
+ .byte 1 # Abbreviation Code
+ .byte 17 # DW_TAG_compile_unit
+ .byte 1 # DW_CHILDREN_yes
+ .ascii "\264B" # DW_AT_GNU_pubnames
+ .byte 25 # DW_FORM_flag_present
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 2 # Abbreviation Code
+ .byte 46 # DW_TAG_subprogram
+ .byte 0 # DW_CHILDREN_no
+ .byte 3 # DW_AT_name
+ .byte 8 # DW_FORM_string
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 0
+
+.section .debug_info,"",@progbits
+.Lcu_begin0:
+ .long .Lcu_end0 - .Lcu_begin0 - 4
+ .short 4 # DWARF version number
+ .long 0 # Offset Into Abbrev. Section
+ .byte 4 # Address Size
+.Ldie:
+ .byte 1 # Abbrev [1] DW_TAG_compile_unit
+ .byte 2 # Abbrev [2] DW_TAG_subprogram
+ .asciz "_start" # DW_AT_name
+ .byte 0
+.Lcu_end0:
+
+# .debug_gnu_pubnames has just one set, associated with .Lcu_begin1 (CuIndex: 1)
+.section .debug_gnu_pubnames,"",@progbits
+ .long .LpubNames_end0 - .LpubNames_begin0
+.LpubNames_begin0:
+ .short 2 # Version
+ .long .Lcu_begin0 # CU Offset
+ .long .Lcu_end0 - .Lcu_begin0
+ .long .Ldie - .Lcu_begin0
+ .byte 48 # Attributes: FUNCTION, EXTERNAL
+ .asciz "_start" # External Name
+ .long 0
+.LpubNames_end0:
diff --git a/test/ELF/Inputs/hexagon-shared.s b/test/ELF/Inputs/hexagon-shared.s
new file mode 100644
index 000000000000..a014dd1e08db
--- /dev/null
+++ b/test/ELF/Inputs/hexagon-shared.s
@@ -0,0 +1,3 @@
+.global bar
+bar:
+ jumpr lr
diff --git a/test/ELF/Inputs/i386-linkonce.s b/test/ELF/Inputs/i386-linkonce.s
new file mode 100644
index 000000000000..b5906cc79657
--- /dev/null
+++ b/test/ELF/Inputs/i386-linkonce.s
@@ -0,0 +1,11 @@
+.section .gnu.linkonce.t.__i686.get_pc_thunk.bx
+.global __i686.get_pc_thunk.bx
+__i686.get_pc_thunk.bx:
+ mov (%esp),%ebx
+ ret
+
+.section .text
+.global _strchr1
+_strchr1:
+ call __i686.get_pc_thunk.bx
+ ret
diff --git a/test/ELF/Inputs/ppc64-bsymbolic-local-def.s b/test/ELF/Inputs/ppc64-bsymbolic-local-def.s
new file mode 100644
index 000000000000..10eec6ca3198
--- /dev/null
+++ b/test/ELF/Inputs/ppc64-bsymbolic-local-def.s
@@ -0,0 +1,14 @@
+ .abiversion 2
+ .section ".text"
+
+ .p2align 2
+ .global def
+ .type def, @function
+def:
+.Ldef_gep:
+ addis 2, 12, .TOC.-.Ldef_gep@ha
+ addi 2, 2, .TOC.-.Ldef_gep@l
+.Ldef_lep:
+ .localentry def, .-def
+ li 3, 55
+ blr
diff --git a/test/ELF/Inputs/ppc64-no-split-stack.s b/test/ELF/Inputs/ppc64-no-split-stack.s
new file mode 100644
index 000000000000..83717677266d
--- /dev/null
+++ b/test/ELF/Inputs/ppc64-no-split-stack.s
@@ -0,0 +1,8 @@
+ .abiversion 2
+ .p2align 2
+ .global nss_callee
+ .type nss_callee, @function
+nss_callee:
+ li 3, 1
+ blr
+
diff --git a/test/ELF/Inputs/ppc64-tls-ie-le.s b/test/ELF/Inputs/ppc64-tls-ie-le.s
new file mode 100644
index 000000000000..1d7ccc8f8875
--- /dev/null
+++ b/test/ELF/Inputs/ppc64-tls-ie-le.s
@@ -0,0 +1,29 @@
+ .text
+ .abiversion 2
+ .type c,@object # @c
+ .section .tdata,"awT",@progbits
+ .globl c
+c:
+ .byte 97 # 0x61
+ .size c, 1
+
+ .type s,@object # @s
+ .globl s
+ .p2align 1
+s:
+ .short 55 # 0x37
+ .size s, 2
+
+ .type i,@object # @i
+ .globl i
+ .p2align 2
+i:
+ .long 55 # 0x37
+ .size i, 4
+
+ .type l,@object # @l
+ .globl l
+ .p2align 3
+l:
+ .quad 55 # 0x37
+ .size l, 8
diff --git a/test/ELF/Inputs/ppc64le-quadword-ldst.o b/test/ELF/Inputs/ppc64le-quadword-ldst.o
new file mode 100644
index 000000000000..c17ef9e0209f
--- /dev/null
+++ b/test/ELF/Inputs/ppc64le-quadword-ldst.o
Binary files differ
diff --git a/test/ELF/Inputs/wrap-with-archive.s b/test/ELF/Inputs/wrap-with-archive.s
new file mode 100644
index 000000000000..93aaddc8806a
--- /dev/null
+++ b/test/ELF/Inputs/wrap-with-archive.s
@@ -0,0 +1,5 @@
+.global __executable_start
+.global __wrap_get_executable_start
+
+__wrap_get_executable_start:
+ movabs $__executable_start,%rdx
diff --git a/test/ELF/Inputs/x86-64-split-stack-extra.s b/test/ELF/Inputs/x86-64-split-stack-extra.s
new file mode 100644
index 000000000000..29c42185caa3
--- /dev/null
+++ b/test/ELF/Inputs/x86-64-split-stack-extra.s
@@ -0,0 +1,10 @@
+# This file is split out to provide better code coverage.
+ .global split
+ .type split,@function
+split:
+ retq
+
+ .size split,. - split
+
+ .section .note.GNU-stack,"",@progbits
+ .section .note.GNU-split-stack,"",@progbits
diff --git a/test/ELF/aarch64-abs16.s b/test/ELF/aarch64-abs16.s
index 20a65b1cf4a8..c9d88b31ae35 100644
--- a/test/ELF/aarch64-abs16.s
+++ b/test/ELF/aarch64-abs16.s
@@ -14,14 +14,14 @@ _start:
// RUN: llvm-objdump -s -section=.data %t2 | FileCheck %s
// CHECK: Contents of section .data:
-// 11000: S = 0x100, A = 0xfeff
-// S + A = 0xffff
-// 11002: S = 0x100, A = -0x8100
-// S + A = 0x8000
-// CHECK-NEXT: 20000 ffff0080
+// 210000: S = 0x100, A = 0xfeff
+// S + A = 0xffff
+// 210002: S = 0x100, A = -0x8100
+// S + A = 0x8000
+// CHECK-NEXT: 210000 ffff0080
-// RUN: not ld.lld %t.o %t255.o -o %t2
-// | FileCheck %s --check-prefix=OVERFLOW
-// RUN: not ld.lld %t.o %t257.o -o %t2
-// | FileCheck %s --check-prefix=OVERFLOW
-// OVERFLOW: Relocation R_AARCH64_ABS16 out of range: 65536 is not in [-32768, 65535]
+// RUN: not ld.lld %t.o %t255.o -o %t2 2>&1 | FileCheck %s --check-prefix=OVERFLOW1
+// OVERFLOW1: relocation R_AARCH64_ABS16 out of range: -32769 is not in [-32768, 32767]
+
+// RUN: not ld.lld %t.o %t257.o -o %t2 2>&1 | FileCheck %s --check-prefix=OVERFLOW2
+// OVERFLOW2: relocation R_AARCH64_ABS16 out of range: 65536 is not in [-32768, 32767]
diff --git a/test/ELF/aarch64-abs32.s b/test/ELF/aarch64-abs32.s
index b93f27a0bc4b..da2005dc97a6 100644
--- a/test/ELF/aarch64-abs32.s
+++ b/test/ELF/aarch64-abs32.s
@@ -14,14 +14,14 @@ _start:
// RUN: llvm-objdump -s -section=.data %t2 | FileCheck %s
// CHECK: Contents of section .data:
-// 20000: S = 0x100, A = 0xfffffeff
-// S + A = 0xffffffff
-// 20004: S = 0x100, A = -0x80000100
-// S + A = 0x80000000
-// CHECK-NEXT: 20000 ffffffff 00000080
+// 210000: S = 0x100, A = 0xfffffeff
+// S + A = 0xffffffff
+// 210004: S = 0x100, A = -0x80000100
+// S + A = 0x80000000
+// CHECK-NEXT: 210000 ffffffff 00000080
-// RUN: not ld.lld %t.o %t255.o -o %t2
-// | FileCheck %s --check-prefix=OVERFLOW
-// RUN: not ld.lld %t.o %t257.o -o %t2
-// | FileCheck %s --check-prefix=OVERFLOW
-// OVERFLOW: Relocation R_AARCH64_ABS32 out of range: 4294967296 is not in [-2147483648, 4294967295]
+// RUN: not ld.lld %t.o %t255.o -o %t2 2>&1 | FileCheck %s --check-prefix=OVERFLOW1
+// OVERFLOW1: relocation R_AARCH64_ABS32 out of range: -2147483649 is not in [-2147483648, 2147483647]
+
+// RUN: not ld.lld %t.o %t257.o -o %t2 2>&1 | FileCheck %s --check-prefix=OVERFLOW2
+// OVERFLOW2: relocation R_AARCH64_ABS32 out of range: 4294967296 is not in [-2147483648, 2147483647]
diff --git a/test/ELF/aarch64-call26-thunk.s b/test/ELF/aarch64-call26-thunk.s
index 067f6dbc2f7e..1ca079946842 100644
--- a/test/ELF/aarch64-call26-thunk.s
+++ b/test/ELF/aarch64-call26-thunk.s
@@ -11,11 +11,11 @@ _start:
// CHECK: Disassembly of section .text:
// CHECK-NEXT: _start:
-// CHECK-NEXT: 20000: 02 00 00 94 bl #8
+// CHECK-NEXT: 210000: 02 00 00 94 bl #8
// CHECK: __AArch64AbsLongThunk_big:
-// CHECK-NEXT: 20008: 50 00 00 58 ldr x16, #8
-// CHECK-NEXT: 2000c: 00 02 1f d6 br x16
+// CHECK-NEXT: 210008: 50 00 00 58 ldr x16, #8
+// CHECK-NEXT: 21000c: 00 02 1f d6 br x16
// CHECK: $d:
-// CHECK-NEXT: 20010: 00 00 00 00 .word 0x00000000
-// CHECK-NEXT: 20014: 10 00 00 00 .word 0x00000010
+// CHECK-NEXT: 210010: 00 00 00 00 .word 0x00000000
+// CHECK-NEXT: 210014: 10 00 00 00 .word 0x00000010
diff --git a/test/ELF/aarch64-combined-dynrel-ifunc.s b/test/ELF/aarch64-combined-dynrel-ifunc.s
new file mode 100644
index 000000000000..5e84b03d7b2e
--- /dev/null
+++ b/test/ELF/aarch64-combined-dynrel-ifunc.s
@@ -0,0 +1,51 @@
+// REQUIRES: AArch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/shared.s -o %t-lib.o
+// RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %s -o %t.o
+// RUN: ld.lld %t-lib.o --shared -o %t.so
+// RUN: echo "SECTIONS { \
+// RUN: .text : { *(.text) } \
+// RUN: .rela.dyn : { *(.rela.dyn) *(.rela.plt) } \
+// RUN: } " > %t.script
+// RUN: ld.lld %t.o -o %t.axf %t.so --script %t.script
+// RUN: llvm-readobj --section-headers --dynamic-table %t.axf | FileCheck %s
+
+// The linker script above combines the .rela.dyn and .rela.plt into a single
+// table. ELF is clear that the DT_PLTRELSZ should match the subset of
+// relocations that is associated with the PLT. It is less clear about what
+// the value of DT_RELASZ should be. ELF implies that it should be the size
+// of the single table so that DT_RELASZ includes DT_PLTRELSZ. The loader in
+// glibc permits this as long as .rela.plt comes after .rela.dyn in the
+// combined table. In the ARM case irelative relocations do not count as PLT
+// relocs. In the AArch64 case irelative relocations count as PLT relocs.
+
+.text
+.globl indirect
+.type indirect,@gnu_indirect_function
+indirect:
+ ret
+
+.globl bar // from Inputs/shared.s
+
+.text
+.globl _start
+.type _start,@function
+main:
+ bl indirect
+ bl bar
+ adrp x8, :got:indirect
+ ldr x8, [x8, :got_lo12:indirect]
+ adrp x8, :got:bar
+ ldr x8, [x8, :got_lo12:bar]
+ ret
+
+// CHECK: Name: .rela.dyn
+// CHECK-NEXT: Type: SHT_RELA
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: SHF_ALLOC
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address:
+// CHECK-NEXT: Offset:
+// CHECK-NEXT: Size: 72
+
+// CHECK: 0x0000000000000008 RELASZ 72
+// CHECK: 0x0000000000000002 PLTRELSZ 48
diff --git a/test/ELF/aarch64-combined-dynrel.s b/test/ELF/aarch64-combined-dynrel.s
new file mode 100644
index 000000000000..438c2509906e
--- /dev/null
+++ b/test/ELF/aarch64-combined-dynrel.s
@@ -0,0 +1,41 @@
+// REQUIRES: AArch64
+// RUN: llvm-mc --triple=aarch64-linux-gnu -filetype=obj -o %t.o %s
+// RUN: echo "SECTIONS { \
+// RUN: .text : { *(.text) } \
+// RUN: .rela.dyn : { *(.rela.dyn) *(.rela.plt) } \
+// RUN: } " > %t.script
+// RUN: ld.lld %t.o -o %t.so --shared --script %t.script
+// RUN: llvm-readobj --section-headers --dynamic-table %t.so | FileCheck %s
+
+// The linker script above combines the .rela.dyn and .rela.plt into a single
+// table. ELF is clear that the DT_PLTRELSZ should match the subset of
+// relocations that is associated with the PLT. It is less clear about what
+// the value of DT_RELASZ should be. ELF implies that it should be the size
+// of the single table so that DT_RELASZ includes DT_PLTRELSZ. The loader in
+// glibc permits this as long as .rela.plt comes after .rela.dyn in the
+// combined table.
+ .text
+ .globl func
+ .type func, %function
+ .globl foo
+ .type foo, %object
+
+ .globl _start
+ .type _start, %function
+_start:
+ bl func
+ adrp x8, :got:foo
+ ldr x8, [x8, :got_lo12:foo]
+ ret
+
+// CHECK: Name: .rela.dyn
+// CHECK-NEXT: Type: SHT_RELA
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: SHF_ALLOC
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address:
+// CHECK-NEXT: Offset:
+// CHECK-NEXT: Size: 48
+
+// CHECK: 0x0000000000000008 RELASZ 48
+// CHECK: 0x0000000000000002 PLTRELSZ 24
diff --git a/test/ELF/aarch64-condb-reloc.s b/test/ELF/aarch64-condb-reloc.s
index 8a7581480544..b7fe7779def0 100644
--- a/test/ELF/aarch64-condb-reloc.s
+++ b/test/ELF/aarch64-condb-reloc.s
@@ -12,21 +12,21 @@
# 0x1102c - 16 = 0x1101c
# CHECK: Disassembly of section .text:
# CHECK-NEXT: _foo:
-# CHECK-NEXT: 20000: {{.*}} nop
-# CHECK-NEXT: 20004: {{.*}} nop
-# CHECK-NEXT: 20008: {{.*}} nop
-# CHECK-NEXT: 2000c: {{.*}} nop
+# CHECK-NEXT: 210000: {{.*}} nop
+# CHECK-NEXT: 210004: {{.*}} nop
+# CHECK-NEXT: 210008: {{.*}} nop
+# CHECK-NEXT: 21000c: {{.*}} nop
# CHECK: _bar:
-# CHECK-NEXT: 20010: {{.*}} nop
-# CHECK-NEXT: 20014: {{.*}} nop
-# CHECK-NEXT: 20018: {{.*}} nop
+# CHECK-NEXT: 210010: {{.*}} nop
+# CHECK-NEXT: 210014: {{.*}} nop
+# CHECK-NEXT: 210018: {{.*}} nop
# CHECK: _dah:
-# CHECK-NEXT: 2001c: {{.*}} nop
-# CHECK-NEXT: 20020: {{.*}} nop
+# CHECK-NEXT: 21001c: {{.*}} nop
+# CHECK-NEXT: 210020: {{.*}} nop
# CHECK: _start:
-# CHECK-NEXT: 20024: {{.*}} b.eq #-36
-# CHECK-NEXT: 20028: {{.*}} b.eq #-24
-# CHECK-NEXT: 2002c: {{.*}} b.eq #-16
+# CHECK-NEXT: 210024: {{.*}} b.eq #-36
+# CHECK-NEXT: 210028: {{.*}} b.eq #-24
+# CHECK-NEXT: 21002c: {{.*}} b.eq #-16
#DSOREL: Section {
#DSOREL: Index:
@@ -79,14 +79,20 @@
#DSO-NEXT: 10044: {{.*}} nop
#DSO-NEXT: 10048: {{.*}} nop
#DSO-NEXT: 1004c: {{.*}} nop
+#DSO-EMPTY:
+#DSO-NEXT: _foo@plt:
#DSO-NEXT: 10050: {{.*}} adrp x16, #65536
#DSO-NEXT: 10054: {{.*}} ldr x17, [x16, #24]
#DSO-NEXT: 10058: {{.*}} add x16, x16, #24
#DSO-NEXT: 1005c: {{.*}} br x17
+#DSO-EMPTY:
+#DSO-NEXT: _bar@plt:
#DSO-NEXT: 10060: {{.*}} adrp x16, #65536
#DSO-NEXT: 10064: {{.*}} ldr x17, [x16, #32]
#DSO-NEXT: 10068: {{.*}} add x16, x16, #32
#DSO-NEXT: 1006c: {{.*}} br x17
+#DSO-EMPTY:
+#DSO-NEXT: _dah@plt:
#DSO-NEXT: 10070: {{.*}} adrp x16, #65536
#DSO-NEXT: 10074: {{.*}} ldr x17, [x16, #40]
#DSO-NEXT: 10078: {{.*}} add x16, x16, #40
diff --git a/test/ELF/aarch64-copy.s b/test/ELF/aarch64-copy.s
index 32e1c76df771..5a42c8db4796 100644
--- a/test/ELF/aarch64-copy.s
+++ b/test/ELF/aarch64-copy.s
@@ -22,7 +22,7 @@ _start:
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: SHF_WRITE
// CHECK-NEXT: ]
-// CHECK-NEXT: Address: 0x40000
+// CHECK-NEXT: Address: 0x230000
// CHECK-NEXT: Offset:
// CHECK-NEXT: Size: 24
// CHECK-NEXT: Link:
@@ -32,19 +32,19 @@ _start:
// CHECK: Relocations [
// CHECK-NEXT: Section ({{.*}}) .rela.dyn {
// CHECK-NEXT: Relocation {
-// CHECK-NEXT: Offset: 0x40000
+// CHECK-NEXT: Offset: 0x230000
// CHECK-NEXT: Type: R_AARCH64_COPY
// CHECK-NEXT: Symbol: x
// CHECK-NEXT: Addend: 0x0
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
-// CHECK-NEXT: Offset: 0x40010
+// CHECK-NEXT: Offset: 0x230010
// CHECK-NEXT: Type: R_AARCH64_COPY
// CHECK-NEXT: Symbol: y
// CHECK-NEXT: Addend: 0x0
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
-// CHECK-NEXT: Offset: 0x40014
+// CHECK-NEXT: Offset: 0x230014
// CHECK-NEXT: Type: R_AARCH64_COPY
// CHECK-NEXT: Symbol: z
// CHECK-NEXT: Addend: 0x0
@@ -54,21 +54,21 @@ _start:
// CHECK: Symbols [
// CHECK: Name: x
-// CHECK-NEXT: Value: 0x40000
+// CHECK-NEXT: Value: 0x230000
// CHECK-NEXT: Size: 4
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: Object
// CHECK-NEXT: Other:
// CHECK-NEXT: Section: .bss
// CHECK: Name: y
-// CHECK-NEXT: Value: 0x40010
+// CHECK-NEXT: Value: 0x230010
// CHECK-NEXT: Size: 4
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: Object
// CHECK-NEXT: Other:
// CHECK-NEXT: Section: .bss
// CHECK: Name: z
-// CHECK-NEXT: Value: 0x40014
+// CHECK-NEXT: Value: 0x230014
// CHECK-NEXT: Size: 4
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: Object
@@ -78,16 +78,16 @@ _start:
// CODE: Disassembly of section .text:
// CODE-NEXT: _start:
-// S(x) = 0x40000, A = 0, P = 0x20000
+// S(x) = 0x230000, A = 0, P = 0x210000
// S + A - P = 0x20000 = 131072
-// CODE-NEXT: 20000: {{.*}} adr x1, #131072
-// S(y) = 0x40010, A = 0, P = 0x20004
-// Page(S + A) - Page(P) = 0x40000 - 0x20000 = 0x20000 = 131072
-// CODE-NEXT: 20004: {{.*}} adrp x2, #131072
-// S(y) = 0x40010, A = 0
+// CODE-NEXT: 210000: {{.*}} adr x1, #131072
+// S(y) = 0x230010, A = 0, P = 0x210004
+// Page(S + A) - Page(P) = 0x230000 - 0x210000 = 0x20000 = 131072
+// CODE-NEXT: 210004: {{.*}} adrp x2, #131072
+// S(y) = 0x230010, A = 0
// (S + A) & 0xFFF = 0x10 = 16
-// CODE-NEXT: 20008: {{.*}} add x2, x2, #16
+// CODE-NEXT: 210008: {{.*}} add x2, x2, #16
// RODATA: Contents of section .rodata:
-// S(z) = 0x40014
-// RODATA-NEXT: 102e0 14000400
+// S(z) = 0x230014
+// RODATA-NEXT: 2002e0 14002300
diff --git a/test/ELF/aarch64-copy2.s b/test/ELF/aarch64-copy2.s
index 6f72e21470ae..5324c74d47db 100644
--- a/test/ELF/aarch64-copy2.s
+++ b/test/ELF/aarch64-copy2.s
@@ -19,7 +19,7 @@ _start:
// CHECK-NEXT: Section: Undefined
// CHECK: Name: foo
-// CHECK-NEXT: Value: 0x20030
+// CHECK-NEXT: Value: 0x210030
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: Function
diff --git a/test/ELF/aarch64-cortex-a53-843419-abs-mapsyms.s b/test/ELF/aarch64-cortex-a53-843419-abs-mapsyms.s
new file mode 100644
index 000000000000..608b1aceb0a0
--- /dev/null
+++ b/test/ELF/aarch64-cortex-a53-843419-abs-mapsyms.s
@@ -0,0 +1,22 @@
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %s -o %t
+// RUN: ld.lld --just-symbols %t -fix-cortex-a53-843419 -o %t.axf
+// RUN: llvm-readobj --symbols %t.axf | FileCheck %s
+
+// Check that we can gracefully handle --just-symbols, which gives a local
+// absolute mapping symbol (with no Section). Previously we assumed that all
+// mapping symbols were defined relative to a section and assert failed.
+
+ .text
+ .global _start
+ .type _start, %function
+_start: ret
+
+// CHECK: Name: $x.0
+// CHECK-NEXT: Value: 0x0
+// CHECK-NEXT: Size: 0
+// CHECK-NEXT: Binding: Local (0x0)
+// CHECK-NEXT: Type: None (0x0)
+// CHECK-NEXT: Other: 0
+// CHECK-NEXT: Section: Absolute (0xFFF1)
+// CHECK-NEXT: }
diff --git a/test/ELF/aarch64-cortex-a53-843419-cli.s b/test/ELF/aarch64-cortex-a53-843419-cli.s
index 9c1d4858b3a7..b19f6c3cd251 100644
--- a/test/ELF/aarch64-cortex-a53-843419-cli.s
+++ b/test/ELF/aarch64-cortex-a53-843419-cli.s
@@ -2,7 +2,7 @@
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
// RUN: not ld.lld %t -fix-cortex-a53-843419 -o /dev/null 2>&1 | FileCheck %s
-// CHECK: --fix-cortex-a53-843419 is only supported on AArch64 targets.
+// CHECK: --fix-cortex-a53-843419 is only supported on AArch64 targets
.globl entry
.text
.quad 0
diff --git a/test/ELF/aarch64-cortex-a53-843419-large.s b/test/ELF/aarch64-cortex-a53-843419-large.s
index 00c92ebeb182..c9021775337a 100644
--- a/test/ELF/aarch64-cortex-a53-843419-large.s
+++ b/test/ELF/aarch64-cortex-a53-843419-large.s
@@ -1,23 +1,23 @@
// REQUIRES: aarch64
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux %s -o %t.o
// RUN: ld.lld --fix-cortex-a53-843419 %t.o -o %t2
-// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 -start-address=131072 -stop-address=131084 | FileCheck --check-prefix=CHECK1 %s
-// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 -start-address=135168 -stop-address=135172 | FileCheck --check-prefix=CHECK2 %s
-// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 -start-address=139256 -stop-address=139272 | FileCheck --check-prefix=CHECK3 %s
-// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 -start-address=67256312 -stop-address=67256328 | FileCheck --check-prefix=CHECK4 %s
-// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 -start-address=100810760 -stop-address=100810776 | FileCheck --check-prefix=CHECK5 %s
-// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 -start-address=134352908 -stop-address=134352912 | FileCheck --check-prefix=CHECK6 %s
-// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 -start-address=134356988 -stop-address=134357012 | FileCheck --check-prefix=CHECK7 %s
+// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 -start-address=2162688 -stop-address=2162700 | FileCheck --check-prefix=CHECK1 %s
+// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 -start-address=2166784 -stop-address=2166788 | FileCheck --check-prefix=CHECK2 %s
+// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 -start-address=2170872 -stop-address=2170888 | FileCheck --check-prefix=CHECK3 %s
+// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 -start-address=69287928 -stop-address=69287944 | FileCheck --check-prefix=CHECK4 %s
+// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 -start-address=102842376 -stop-address=102842392 | FileCheck --check-prefix=CHECK5 %s
+// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 -start-address=136384524 -stop-address=136384528 | FileCheck --check-prefix=CHECK6 %s
+// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 -start-address=136388604 -stop-address=136388628 | FileCheck --check-prefix=CHECK7 %s
// Test case for Cortex-A53 Erratum 843419 in an OutputSection exceeding
// the maximum branch range. Both range extension thunks and patches are
-// required.
-
+// required.
+
// CHECK1: __AArch64AbsLongThunk_need_thunk_after_patch:
-// CHECK1-NEXT: 20000: 50 00 00 58 ldr x16, #8
-// CHECK1-NEXT: 20004: 00 02 1f d6 br x16
-// CHECK1: $d:
-// CHECK1-NEXT: 20008: 0c 10 02 08 .word 0x0802100c
-
+// CHECK1-NEXT: 210000: 50 00 00 58 ldr x16, #8
+// CHECK1-NEXT: 210004: 00 02 1f d6 br x16
+// CHECK1: $d:
+// CHECK1-NEXT: 210008: 0c 10 21 08 .word 0x0821100c
+
.section .text.01, "ax", %progbits
.balign 4096
.globl _start
@@ -29,7 +29,7 @@ _start:
.space 4096 - 12
// CHECK2: _start:
-// CHECK2-NEXT: 21000: 00 fc ff 97 bl #-4096
+// CHECK2-NEXT: 211000: 00 fc ff 97 bl #-4096
// Expect patch on pass 1
.section .text.03, "ax", %progbits
@@ -42,10 +42,10 @@ t3_ff8_ldr:
ret
// CHECK3: t3_ff8_ldr:
-// CHECK3-NEXT: 21ff8: 60 00 04 f0 adrp x0, #134279168
-// CHECK3-NEXT: 21ffc: 21 00 40 f9 ldr x1, [x1]
-// CHECK3-NEXT: 22000: 02 08 80 15 b #100671496
-// CHECK3-NEXT: 22004: c0 03 5f d6 ret
+// CHECK3-NEXT: 211ff8: 60 00 04 f0 adrp x0, #134279168
+// CHECK3-NEXT: 211ffc: 21 00 40 f9 ldr x1, [x1]
+// CHECK3-NEXT: 212000: 02 08 80 15 b #100671496
+// CHECK3-NEXT: 212004: c0 03 5f d6 ret
.section .text.04, "ax", %progbits
.space 64 * 1024 * 1024
@@ -63,20 +63,20 @@ t3_ff8_str:
ret
// CHECK4: t3_ff8_str:
-// CHECK4-NEXT: 4023ff8: 60 00 02 b0 adrp x0, #67162112
-// CHECK4-NEXT: 4023ffc: 21 00 40 f9 ldr x1, [x1]
-// CHECK4-NEXT: 4024000: 04 00 80 14 b #33554448
-// CHECK4-NEXT: 4024004: c0 03 5f d6 ret
+// CHECK4-NEXT: 4213ff8: 60 00 02 b0 adrp x0, #67162112
+// CHECK4-NEXT: 4213ffc: 21 00 40 f9 ldr x1, [x1]
+// CHECK4-NEXT: 4214000: 04 00 80 14 b #33554448
+// CHECK4-NEXT: 4214004: c0 03 5f d6 ret
.section .text.06, "ax", %progbits
.space 32 * 1024 * 1024
-// CHECK5: __CortexA53843419_21000:
-// CHECK5-NEXT: 6024008: 00 00 40 f9 ldr x0, [x0]
-// CHECK5-NEXT: 602400c: fe f7 7f 16 b #-100671496
-// CHECK5: __CortexA53843419_4023000:
-// CHECK5-NEXT: 6024010: 00 00 00 f9 str x0, [x0]
-// CHECK5-NEXT: 6024014: fc ff 7f 17 b #-33554448
+// CHECK5: __CortexA53843419_211000:
+// CHECK5-NEXT: 6214008: 00 00 40 f9 ldr x0, [x0]
+// CHECK5-NEXT: 621400c: fe f7 7f 16 b #-100671496
+// CHECK5: __CortexA53843419_4213000:
+// CHECK5-NEXT: 6214010: 00 00 00 f9 str x0, [x0]
+// CHECK5-NEXT: 6214014: fc ff 7f 17 b #-33554448
.section .text.07, "ax", %progbits
.space (32 * 1024 * 1024) - 12300
@@ -88,7 +88,7 @@ need_thunk_after_patch:
ret
// CHECK6: need_thunk_after_patch:
-// CHECK6-NEXT: 802100c: c0 03 5f d6 ret
+// CHECK6-NEXT: 821100c: c0 03 5f d6 ret
// Will need a patch on pass 2
.section .text.09, "ax", %progbits
@@ -102,13 +102,13 @@ t3_ffc_ldr:
ret
// CHECK7: t3_ffc_ldr:
-// CHECK7-NEXT: 8021ffc: 60 00 00 f0 adrp x0, #61440
-// CHECK7-NEXT: 8022000: 21 00 40 f9 ldr x1, [x1]
-// CHECK7-NEXT: 8022004: 02 00 00 14 b #8
-// CHECK7-NEXT: 8022008: c0 03 5f d6 ret
-// CHECK7: __CortexA53843419_8022004:
-// CHECK7-NEXT: 802200c: 00 00 40 f9 ldr x0, [x0]
-// CHECK7-NEXT: 8022010: fe ff ff 17 b #-8
+// CHECK7-NEXT: 8211ffc: 60 00 00 f0 adrp x0, #61440
+// CHECK7-NEXT: 8212000: 21 00 40 f9 ldr x1, [x1]
+// CHECK7-NEXT: 8212004: 02 00 00 14 b #8
+// CHECK7-NEXT: 8212008: c0 03 5f d6 ret
+// CHECK7: __CortexA53843419_8212004:
+// CHECK7-NEXT: 821200c: 00 00 40 f9 ldr x0, [x0]
+// CHECK7-NEXT: 8212010: fe ff ff 17 b #-8
.section .data
.globl dat
diff --git a/test/ELF/aarch64-cortex-a53-843419-large2.s b/test/ELF/aarch64-cortex-a53-843419-large2.s
new file mode 100644
index 000000000000..fdb8a445e004
--- /dev/null
+++ b/test/ELF/aarch64-cortex-a53-843419-large2.s
@@ -0,0 +1,19 @@
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux %s -o %t.o
+// RUN: ld.lld --fix-cortex-a53-843419 -Ttext=0x8000000 %t.o -o %t2
+// RUN: llvm-objdump -d --start-address=0x8001000 --stop-address=0x8001004 %t2 | FileCheck %s
+
+.section .text.01, "ax", %progbits
+.balign 4096
+.space 4096 - 8
+adrp x0, thunk
+ldr x1, [x1, #0]
+// CHECK: thunk:
+// CHECK-NEXT: b #67108872 <__CortexA53843419_8001000>
+thunk:
+ldr x0, [x0, :got_lo12:thunk]
+ret
+.space 64 * 1024 * 1024
+
+.section .text.02, "ax", %progbits
+.space 64 * 1024 * 1024
diff --git a/test/ELF/aarch64-cortex-a53-843419-recognize.s b/test/ELF/aarch64-cortex-a53-843419-recognize.s
index 174f18164bce..cde35919806e 100644
--- a/test/ELF/aarch64-cortex-a53-843419-recognize.s
+++ b/test/ELF/aarch64-cortex-a53-843419-recognize.s
@@ -26,13 +26,13 @@
// - Optional instruction 3 present or not.
// - Load or store for instruction 4.
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 21FF8 in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 211FF8 in unpatched output.
// CHECK: t3_ff8_ldr:
-// CHECK-NEXT: 21ff8: e0 01 00 f0 adrp x0, #258048
-// CHECK-NEXT: 21ffc: 21 00 40 f9 ldr x1, [x1]
-// CHECK-FIX: 22000: 03 c8 00 14 b #204812
-// CHECK-NOFIX: 22000: 00 00 40 f9 ldr x0, [x0]
-// CHECK-NEXT: 22004: c0 03 5f d6 ret
+// CHECK-NEXT: 211ff8: e0 01 00 f0 adrp x0, #258048
+// CHECK-NEXT: 211ffc: 21 00 40 f9 ldr x1, [x1]
+// CHECK-FIX: 212000: 03 c8 00 14 b #204812
+// CHECK-NOFIX: 212000: 00 00 40 f9 ldr x0, [x0]
+// CHECK-NEXT: 212004: c0 03 5f d6 ret
.section .text.01, "ax", %progbits
.balign 4096
.globl t3_ff8_ldr
@@ -44,13 +44,13 @@ t3_ff8_ldr:
ldr x0, [x0, :got_lo12:dat1]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 23FF8 in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 213FF8 in unpatched output.
// CHECK: t3_ff8_ldrsimd:
-// CHECK-NEXT: 23ff8: e0 01 00 b0 adrp x0, #249856
-// CHECK-NEXT: 23ffc: 21 00 40 bd ldr s1, [x1]
-// CHECK-FIX: 24000: 05 c0 00 14 b #196628
-// CHECK-NOFIX: 24000: 02 04 40 f9 ldr x2, [x0, #8]
-// CHECK-NEXT: 24004: c0 03 5f d6 ret
+// CHECK-NEXT: 213ff8: e0 01 00 b0 adrp x0, #249856
+// CHECK-NEXT: 213ffc: 21 00 40 bd ldr s1, [x1]
+// CHECK-FIX: 214000: 05 c0 00 14 b #196628
+// CHECK-NOFIX: 214000: 02 04 40 f9 ldr x2, [x0, #8]
+// CHECK-NEXT: 214004: c0 03 5f d6 ret
.section .text.02, "ax", %progbits
.balign 4096
.globl t3_ff8_ldrsimd
@@ -62,13 +62,13 @@ t3_ff8_ldrsimd:
ldr x2, [x0, :got_lo12:dat2]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 25FFC in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 215FFC in unpatched output.
// CHECK: t3_ffc_ldrpost:
-// CHECK-NEXT: 25ffc: c0 01 00 f0 adrp x0, #241664
-// CHECK-NEXT: 26000: 21 84 40 bc ldr s1, [x1], #8
-// CHECK-FIX: 26004: 06 b8 00 14 b #188440
-// CHECK-NOFIX: 26004: 03 08 40 f9 ldr x3, [x0, #16]
-// CHECK-NEXT: 26008: c0 03 5f d6 ret
+// CHECK-NEXT: 215ffc: c0 01 00 f0 adrp x0, #241664
+// CHECK-NEXT: 216000: 21 84 40 bc ldr s1, [x1], #8
+// CHECK-FIX: 216004: 06 b8 00 14 b #188440
+// CHECK-NOFIX: 216004: 03 08 40 f9 ldr x3, [x0, #16]
+// CHECK-NEXT: 216008: c0 03 5f d6 ret
.section .text.03, "ax", %progbits
.balign 4096
.globl t3_ffc_ldrpost
@@ -80,13 +80,13 @@ t3_ffc_ldrpost:
ldr x3, [x0, :got_lo12:dat3]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 27FF8 in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 217FF8 in unpatched output.
// CHECK: t3_ff8_strpre:
-// CHECK-NEXT: 27ff8: c0 01 00 b0 adrp x0, #233472
-// CHECK-NEXT: 27ffc: 21 8c 00 bc str s1, [x1, #8]!
-// CHECK-FIX: 28000: 09 b0 00 14 b #180260
-// CHECK-NOFIX: 28000: 02 00 40 f9 ldr x2, [x0]
-// CHECK-NEXT: 28004: c0 03 5f d6 ret
+// CHECK-NEXT: 217ff8: c0 01 00 b0 adrp x0, #233472
+// CHECK-NEXT: 217ffc: 21 8c 00 bc str s1, [x1, #8]!
+// CHECK-FIX: 218000: 09 b0 00 14 b #180260
+// CHECK-NOFIX: 218000: 02 00 40 f9 ldr x2, [x0]
+// CHECK-NEXT: 218004: c0 03 5f d6 ret
.section .text.04, "ax", %progbits
.balign 4096
.globl t3_ff8_strpre
@@ -98,13 +98,13 @@ t3_ff8_strpre:
ldr x2, [x0, :lo12:dat1]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 29FFC in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 219FFC in unpatched output.
// CHECK: t3_ffc_str:
-// CHECK-NEXT: 29ffc: bc 01 00 f0 adrp x28, #225280
-// CHECK-NEXT: 2a000: 42 00 00 f9 str x2, [x2]
-// CHECK-FIX: 2a004: 0a a8 00 14 b #172072
-// CHECK-NOFIX: 2a004: 9c 07 00 f9 str x28, [x28, #8]
-// CHECK-NEXT: 2a008: c0 03 5f d6 ret
+// CHECK-NEXT: 219ffc: bc 01 00 f0 adrp x28, #225280
+// CHECK-NEXT: 21a000: 42 00 00 f9 str x2, [x2]
+// CHECK-FIX: 21a004: 0a a8 00 14 b #172072
+// CHECK-NOFIX: 21a004: 9c 07 00 f9 str x28, [x28, #8]
+// CHECK-NEXT: 21a008: c0 03 5f d6 ret
.section .text.05, "ax", %progbits
.balign 4096
.globl t3_ffc_str
@@ -116,13 +116,13 @@ t3_ffc_str:
str x28, [x28, :lo12:dat2]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 2BFFC in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 21BFFC in unpatched output.
// CHECK: t3_ffc_strsimd:
-// CHECK-NEXT: 2bffc: bc 01 00 b0 adrp x28, #217088
-// CHECK-NEXT: 2c000: 44 00 00 b9 str w4, [x2]
-// CHECK-FIX: 2c004: 0c a0 00 14 b #163888
-// CHECK-NOFIX: 2c004: 84 0b 00 f9 str x4, [x28, #16]
-// CHECK-NEXT: 2c008: c0 03 5f d6 ret
+// CHECK-NEXT: 21bffc: bc 01 00 b0 adrp x28, #217088
+// CHECK-NEXT: 21c000: 44 00 00 b9 str w4, [x2]
+// CHECK-FIX: 21c004: 0c a0 00 14 b #163888
+// CHECK-NOFIX: 21c004: 84 0b 00 f9 str x4, [x28, #16]
+// CHECK-NEXT: 21c008: c0 03 5f d6 ret
.section .text.06, "ax", %progbits
.balign 4096
.globl t3_ffc_strsimd
@@ -134,13 +134,13 @@ t3_ffc_strsimd:
str x4, [x28, :lo12:dat3]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 2DFF8 in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 21DFF8 in unpatched output.
// CHECK: t3_ff8_ldrunpriv:
-// CHECK-NEXT: 2dff8: 9d 01 00 f0 adrp x29, #208896
-// CHECK-NEXT: 2dffc: 41 08 40 38 ldtrb w1, [x2]
-// CHECK-FIX: 2e000: 0f 98 00 14 b #155708
-// CHECK-NOFIX: 2e000: bd 03 40 f9 ldr x29, [x29]
-// CHECK-NEXT: 2e004: c0 03 5f d6 ret
+// CHECK-NEXT: 21dff8: 9d 01 00 f0 adrp x29, #208896
+// CHECK-NEXT: 21dffc: 41 08 40 38 ldtrb w1, [x2]
+// CHECK-FIX: 21e000: 0f 98 00 14 b #155708
+// CHECK-NOFIX: 21e000: bd 03 40 f9 ldr x29, [x29]
+// CHECK-NEXT: 21e004: c0 03 5f d6 ret
.section .text.07, "ax", %progbits
.balign 4096
.globl t3_ff8_ldrunpriv
@@ -152,13 +152,13 @@ t3_ff8_ldrunpriv:
ldr x29, [x29, :got_lo12:dat1]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 2FFFC in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 21FFFC in unpatched output.
// CHECK: t3_ffc_ldur:
-// CHECK-NEXT: 2fffc: 9d 01 00 b0 adrp x29, #200704
-// CHECK-NEXT: 30000: 42 40 40 b8 ldur w2, [x2, #4]
-// CHECK-FIX: 30004: 10 90 00 14 b #147520
-// CHECK-NOFIX: 30004: bd 07 40 f9 ldr x29, [x29, #8]
-// CHECK-NEXT: 30008: c0 03 5f d6 ret
+// CHECK-NEXT: 21fffc: 9d 01 00 b0 adrp x29, #200704
+// CHECK-NEXT: 220000: 42 40 40 b8 ldur w2, [x2, #4]
+// CHECK-FIX: 220004: 10 90 00 14 b #147520
+// CHECK-NOFIX: 220004: bd 07 40 f9 ldr x29, [x29, #8]
+// CHECK-NEXT: 220008: c0 03 5f d6 ret
.balign 4096
.globl t3_ffc_ldur
.type t3_ffc_ldur, %function
@@ -169,13 +169,13 @@ t3_ffc_ldur:
ldr x29, [x29, :got_lo12:dat2]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 31FFC in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 221FFC in unpatched output.
// CHECK: t3_ffc_sturh:
-// CHECK-NEXT: 31ffc: 72 01 00 f0 adrp x18, #192512
-// CHECK-NEXT: 32000: 43 40 00 78 sturh w3, [x2, #4]
-// CHECK-FIX: 32004: 12 88 00 14 b #139336
-// CHECK-NOFIX: 32004: 41 0a 40 f9 ldr x1, [x18, #16]
-// CHECK-NEXT: 32008: c0 03 5f d6 ret
+// CHECK-NEXT: 221ffc: 72 01 00 f0 adrp x18, #192512
+// CHECK-NEXT: 222000: 43 40 00 78 sturh w3, [x2, #4]
+// CHECK-FIX: 222004: 12 88 00 14 b #139336
+// CHECK-NOFIX: 222004: 41 0a 40 f9 ldr x1, [x18, #16]
+// CHECK-NEXT: 222008: c0 03 5f d6 ret
.section .text.09, "ax", %progbits
.balign 4096
.globl t3_ffc_sturh
@@ -187,13 +187,13 @@ t3_ffc_sturh:
ldr x1, [x18, :got_lo12:dat3]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 33FF8 in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 223FF8 in unpatched output.
// CHECK: t3_ff8_literal:
-// CHECK-NEXT: 33ff8: 72 01 00 b0 adrp x18, #184320
-// CHECK-NEXT: 33ffc: e3 ff ff 58 ldr x3, #-4
-// CHECK-FIX: 34000: 15 80 00 14 b #131156
-// CHECK-NOFIX: 34000: 52 02 40 f9 ldr x18, [x18]
-// CHECK-NEXT: 34004: c0 03 5f d6 ret
+// CHECK-NEXT: 223ff8: 72 01 00 b0 adrp x18, #184320
+// CHECK-NEXT: 223ffc: e3 ff ff 58 ldr x3, #-4
+// CHECK-FIX: 224000: 15 80 00 14 b #131156
+// CHECK-NOFIX: 224000: 52 02 40 f9 ldr x18, [x18]
+// CHECK-NEXT: 224004: c0 03 5f d6 ret
.section .text.10, "ax", %progbits
.balign 4096
.globl t3_ff8_literal
@@ -205,13 +205,13 @@ t3_ff8_literal:
ldr x18, [x18, :lo12:dat1]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 35FFC in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 225FFC in unpatched output.
// CHECK: t3_ffc_register:
-// CHECK-NEXT: 35ffc: 4f 01 00 f0 adrp x15, #176128
-// CHECK-NEXT: 36000: 43 68 61 f8 ldr x3, [x2, x1]
-// CHECK-FIX: 36004: 16 78 00 14 b #122968
-// CHECK-NOFIX: 36004: ea 05 40 f9 ldr x10, [x15, #8]
-// CHECK-NEXT: 36008: c0 03 5f d6 ret
+// CHECK-NEXT: 225ffc: 4f 01 00 f0 adrp x15, #176128
+// CHECK-NEXT: 226000: 43 68 61 f8 ldr x3, [x2, x1]
+// CHECK-FIX: 226004: 16 78 00 14 b #122968
+// CHECK-NOFIX: 226004: ea 05 40 f9 ldr x10, [x15, #8]
+// CHECK-NEXT: 226008: c0 03 5f d6 ret
.section .text.11, "ax", %progbits
.balign 4096
.globl t3_ffc_register
@@ -223,13 +223,13 @@ t3_ffc_register:
ldr x10, [x15, :lo12:dat2]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 37FF8 in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 227FF8 in unpatched output.
// CHECK: t3_ff8_stp:
-// CHECK-NEXT: 37ff8: 50 01 00 b0 adrp x16, #167936
-// CHECK-NEXT: 37ffc: 61 08 00 a9 stp x1, x2, [x3]
-// CHECK-FIX: 38000: 19 70 00 14 b #114788
-// CHECK-NOFIX: 38000: 0d 0a 40 f9 ldr x13, [x16, #16]
-// CHECK-NEXT: 38004: c0 03 5f d6 ret
+// CHECK-NEXT: 227ff8: 50 01 00 b0 adrp x16, #167936
+// CHECK-NEXT: 227ffc: 61 08 00 a9 stp x1, x2, [x3]
+// CHECK-FIX: 228000: 19 70 00 14 b #114788
+// CHECK-NOFIX: 228000: 0d 0a 40 f9 ldr x13, [x16, #16]
+// CHECK-NEXT: 228004: c0 03 5f d6 ret
.section .text.12, "ax", %progbits
.balign 4096
.globl t3_ff8_stp
@@ -241,13 +241,13 @@ t3_ff8_stp:
ldr x13, [x16, :lo12:dat3]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 39FFC in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 229FFC in unpatched output.
// CHECK: t3_ffc_stnp:
-// CHECK-NEXT: 39ffc: 27 01 00 f0 adrp x7, #159744
-// CHECK-NEXT: 3a000: 61 08 00 a8 stnp x1, x2, [x3]
-// CHECK-FIX: 3a004: 1a 68 00 14 b #106600
-// CHECK-NOFIX: 3a004: e9 00 40 f9 ldr x9, [x7]
-// CHECK-NEXT: 3a008: c0 03 5f d6 ret
+// CHECK-NEXT: 229ffc: 27 01 00 f0 adrp x7, #159744
+// CHECK-NEXT: 22a000: 61 08 00 a8 stnp x1, x2, [x3]
+// CHECK-FIX: 22a004: 1a 68 00 14 b #106600
+// CHECK-NOFIX: 22a004: e9 00 40 f9 ldr x9, [x7]
+// CHECK-NEXT: 22a008: c0 03 5f d6 ret
.section .text.13, "ax", %progbits
.balign 4096
.globl t3_ffc_stnp
@@ -259,13 +259,13 @@ t3_ffc_stnp:
ldr x9, [x7, :lo12:dat1]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 3BFFC in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 22BFFC in unpatched output.
// CHECK: t3_ffc_st1singlepost:
-// CHECK-NEXT: 3bffc: 37 01 00 b0 adrp x23, #151552
-// CHECK-NEXT: 3c000: 20 04 82 0d st1 { v0.b }[1], [x1], x2
-// CHECK-FIX: 3c004: 1c 60 00 14 b #98416
-// CHECK-NOFIX: 3c004: f6 06 40 f9 ldr x22, [x23, #8]
-// CHECK-NEXT: 3c008: c0 03 5f d6 ret
+// CHECK-NEXT: 22bffc: 37 01 00 b0 adrp x23, #151552
+// CHECK-NEXT: 22c000: 20 04 82 0d st1 { v0.b }[1], [x1], x2
+// CHECK-FIX: 22c004: 1c 60 00 14 b #98416
+// CHECK-NOFIX: 22c004: f6 06 40 f9 ldr x22, [x23, #8]
+// CHECK-NEXT: 22c008: c0 03 5f d6 ret
.section .text.14, "ax", %progbits
.balign 4096
.globl t3_ffc_st1singlepost
@@ -277,13 +277,13 @@ t3_ffc_st1singlepost:
ldr x22, [x23, :lo12:dat2]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 3DFF8 in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 22DFF8 in unpatched output.
// CHECK: t3_ff8_st1multiple:
-// CHECK-NEXT: 3dff8: 17 01 00 f0 adrp x23, #143360
-// CHECK-NEXT: 3dffc: 20 a0 00 4c st1 { v0.16b, v1.16b }, [x1]
-// CHECK-FIX: 3e000: 1f 58 00 14 b #90236
-// CHECK-NOFIX: 3e000: f8 0a 40 f9 ldr x24, [x23, #16]
-// CHECK-NEXT: 3e004: c0 03 5f d6 ret
+// CHECK-NEXT: 22dff8: 17 01 00 f0 adrp x23, #143360
+// CHECK-NEXT: 22dffc: 20 a0 00 4c st1 { v0.16b, v1.16b }, [x1]
+// CHECK-FIX: 22e000: 1f 58 00 14 b #90236
+// CHECK-NOFIX: 22e000: f8 0a 40 f9 ldr x24, [x23, #16]
+// CHECK-NEXT: 22e004: c0 03 5f d6 ret
.section .text.15, "ax", %progbits
.balign 4096
.globl t3_ff8_st1multiple
@@ -295,14 +295,14 @@ t3_ff8_st1multiple:
ldr x24, [x23, :lo12:dat3]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 3FFF8 in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 22FFF8 in unpatched output.
// CHECK: t4_ff8_ldr:
-// CHECK-NEXT: 3fff8: 00 01 00 b0 adrp x0, #135168
-// CHECK-NEXT: 3fffc: 21 00 40 f9 ldr x1, [x1]
-// CHECK-NEXT: 40000: 42 00 00 8b add x2, x2, x0
-// CHECK-FIX: 40004: 20 50 00 14 b #82048
-// CHECK-NOFIX: 40004: 02 00 40 f9 ldr x2, [x0]
-// CHECK-NEXT: 40008: c0 03 5f d6 ret
+// CHECK-NEXT: 22fff8: 00 01 00 b0 adrp x0, #135168
+// CHECK-NEXT: 22fffc: 21 00 40 f9 ldr x1, [x1]
+// CHECK-NEXT: 230000: 42 00 00 8b add x2, x2, x0
+// CHECK-FIX: 230004: 20 50 00 14 b #82048
+// CHECK-NOFIX: 230004: 02 00 40 f9 ldr x2, [x0]
+// CHECK-NEXT: 230008: c0 03 5f d6 ret
.section .text.16, "ax", %progbits
.balign 4096
.globl t4_ff8_ldr
@@ -315,14 +315,14 @@ t4_ff8_ldr:
ldr x2, [x0, :got_lo12:dat1]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 41FFC in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 231FFC in unpatched output.
// CHECK: t4_ffc_str:
-// CHECK-NEXT: 41ffc: fc 00 00 f0 adrp x28, #126976
-// CHECK-NEXT: 42000: 42 00 00 f9 str x2, [x2]
-// CHECK-NEXT: 42004: 20 00 02 cb sub x0, x1, x2
-// CHECK-FIX: 42008: 21 48 00 14 b #73860
-// CHECK-NOFIX: 42008: 9b 07 00 f9 str x27, [x28, #8]
-// CHECK-NEXT: 4200c: c0 03 5f d6 ret
+// CHECK-NEXT: 231ffc: fc 00 00 f0 adrp x28, #126976
+// CHECK-NEXT: 232000: 42 00 00 f9 str x2, [x2]
+// CHECK-NEXT: 232004: 20 00 02 cb sub x0, x1, x2
+// CHECK-FIX: 232008: 21 48 00 14 b #73860
+// CHECK-NOFIX: 232008: 9b 07 00 f9 str x27, [x28, #8]
+// CHECK-NEXT: 23200c: c0 03 5f d6 ret
.section .text.17, "ax", %progbits
.balign 4096
.globl t4_ffc_str
@@ -335,14 +335,14 @@ t4_ffc_str:
str x27, [x28, :got_lo12:dat2]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 43FF8 in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 233FF8 in unpatched output.
// CHECK: t4_ff8_stp:
-// CHECK-NEXT: 43ff8: f0 00 00 b0 adrp x16, #118784
-// CHECK-NEXT: 43ffc: 61 08 00 a9 stp x1, x2, [x3]
-// CHECK-NEXT: 44000: 03 7e 10 9b mul x3, x16, x16
-// CHECK-FIX: 44004: 24 40 00 14 b #65680
-// CHECK-NOFIX: 44004: 0e 0a 40 f9 ldr x14, [x16, #16]
-// CHECK-NEXT: 44008: c0 03 5f d6 ret
+// CHECK-NEXT: 233ff8: f0 00 00 b0 adrp x16, #118784
+// CHECK-NEXT: 233ffc: 61 08 00 a9 stp x1, x2, [x3]
+// CHECK-NEXT: 234000: 03 7e 10 9b mul x3, x16, x16
+// CHECK-FIX: 234004: 24 40 00 14 b #65680
+// CHECK-NOFIX: 234004: 0e 0a 40 f9 ldr x14, [x16, #16]
+// CHECK-NEXT: 234008: c0 03 5f d6 ret
.section .text.18, "ax", %progbits
.balign 4096
.globl t4_ff8_stp
@@ -355,14 +355,14 @@ t4_ff8_stp:
ldr x14, [x16, :got_lo12:dat3]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 45FF8 in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 235FF8 in unpatched output.
// CHECK: t4_ff8_stppre:
-// CHECK-NEXT: 45ff8: d0 00 00 f0 adrp x16, #110592
-// CHECK-NEXT: 45ffc: 61 08 81 a9 stp x1, x2, [x3, #16]!
-// CHECK-NEXT: 46000: 03 7e 10 9b mul x3, x16, x16
-// CHECK-FIX: 46004: 26 38 00 14 b #57496
-// CHECK-NOFIX: 46004: 0e 06 40 f9 ldr x14, [x16, #8]
-// CHECK-NEXT: 46008: c0 03 5f d6 ret
+// CHECK-NEXT: 235ff8: d0 00 00 f0 adrp x16, #110592
+// CHECK-NEXT: 235ffc: 61 08 81 a9 stp x1, x2, [x3, #16]!
+// CHECK-NEXT: 236000: 03 7e 10 9b mul x3, x16, x16
+// CHECK-FIX: 236004: 26 38 00 14 b #57496
+// CHECK-NOFIX: 236004: 0e 06 40 f9 ldr x14, [x16, #8]
+// CHECK-NEXT: 236008: c0 03 5f d6 ret
.section .text.19, "ax", %progbits
.balign 4096
.globl t4_ff8_stppre
@@ -375,14 +375,14 @@ t4_ff8_stppre:
ldr x14, [x16, #8]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 47FF8 in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 237FF8 in unpatched output.
// CHECK: t4_ff8_stppost:
-// CHECK-NEXT: 47ff8: d0 00 00 b0 adrp x16, #102400
-// CHECK-NEXT: 47ffc: 61 08 81 a8 stp x1, x2, [x3], #16
-// CHECK-NEXT: 48000: 03 7e 10 9b mul x3, x16, x16
-// CHECK-FIX: 48004: 28 30 00 14 b #49312
-// CHECK-NOFIX: 48004: 0e 06 40 f9 ldr x14, [x16, #8]
-// CHECK-NEXT: 48008: c0 03 5f d6 ret
+// CHECK-NEXT: 237ff8: d0 00 00 b0 adrp x16, #102400
+// CHECK-NEXT: 237ffc: 61 08 81 a8 stp x1, x2, [x3], #16
+// CHECK-NEXT: 238000: 03 7e 10 9b mul x3, x16, x16
+// CHECK-FIX: 238004: 28 30 00 14 b #49312
+// CHECK-NOFIX: 238004: 0e 06 40 f9 ldr x14, [x16, #8]
+// CHECK-NEXT: 238008: c0 03 5f d6 ret
.section .text.20, "ax", %progbits
.balign 4096
.globl t4_ff8_stppost
@@ -395,14 +395,14 @@ t4_ff8_stppost:
ldr x14, [x16, #8]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 49FFC in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 239FFC in unpatched output.
// CHECK: t4_ffc_stpsimd:
-// CHECK-NEXT: 49ffc: b0 00 00 f0 adrp x16, #94208
-// CHECK-NEXT: 4a000: 61 08 00 ad stp q1, q2, [x3]
-// CHECK-NEXT: 4a004: 03 7e 10 9b mul x3, x16, x16
-// CHECK-FIX: 4a008: 29 28 00 14 b #41124
-// CHECK-NOFIX: 4a008: 0e 06 40 f9 ldr x14, [x16, #8]
-// CHECK-NEXT: 4a00c: c0 03 5f d6 ret
+// CHECK-NEXT: 239ffc: b0 00 00 f0 adrp x16, #94208
+// CHECK-NEXT: 23a000: 61 08 00 ad stp q1, q2, [x3]
+// CHECK-NEXT: 23a004: 03 7e 10 9b mul x3, x16, x16
+// CHECK-FIX: 23a008: 29 28 00 14 b #41124
+// CHECK-NOFIX: 23a008: 0e 06 40 f9 ldr x14, [x16, #8]
+// CHECK-NEXT: 23a00c: c0 03 5f d6 ret
.section .text.21, "ax", %progbits
.balign 4096
.globl t4_ffc_stpsimd
@@ -415,14 +415,14 @@ t4_ffc_stpsimd:
ldr x14, [x16, #8]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 4BFFC in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 23BFFC in unpatched output.
// CHECK: t4_ffc_stnp:
-// CHECK-NEXT: 4bffc: a7 00 00 b0 adrp x7, #86016
-// CHECK-NEXT: 4c000: 61 08 00 a8 stnp x1, x2, [x3]
-// CHECK-NEXT: 4c004: 1f 20 03 d5 nop
-// CHECK-FIX: 4c008: 2b 20 00 14 b #32940
-// CHECK-NOFIX: 4c008: ea 00 40 f9 ldr x10, [x7]
-// CHECK-NEXT: 4c00c: c0 03 5f d6 ret
+// CHECK-NEXT: 23bffc: a7 00 00 b0 adrp x7, #86016
+// CHECK-NEXT: 23c000: 61 08 00 a8 stnp x1, x2, [x3]
+// CHECK-NEXT: 23c004: 1f 20 03 d5 nop
+// CHECK-FIX: 23c008: 2b 20 00 14 b #32940
+// CHECK-NOFIX: 23c008: ea 00 40 f9 ldr x10, [x7]
+// CHECK-NEXT: 23c00c: c0 03 5f d6 ret
.section .text.22, "ax", %progbits
.balign 4096
.globl t4_ffc_stnp
@@ -435,14 +435,14 @@ t4_ffc_stnp:
ldr x10, [x7, :got_lo12:dat1]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 4DFFC in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 23DFFC in unpatched output.
// CHECK: t4_ffc_st1:
-// CHECK-NEXT: 4dffc: 98 00 00 f0 adrp x24, #77824
-// CHECK-NEXT: 4e000: 20 80 00 4d st1 { v0.s }[2], [x1]
-// CHECK-NEXT: 4e004: f6 06 40 f9 ldr x22, [x23, #8]
-// CHECK-FIX: 4e008: 2d 18 00 14 b #24756
-// CHECK-NOFIX: 4e008: 18 ff 3f f9 str x24, [x24, #32760]
-// CHECK-NEXT: 4e00c: c0 03 5f d6 ret
+// CHECK-NEXT: 23dffc: 98 00 00 f0 adrp x24, #77824
+// CHECK-NEXT: 23e000: 20 80 00 4d st1 { v0.s }[2], [x1]
+// CHECK-NEXT: 23e004: f6 06 40 f9 ldr x22, [x23, #8]
+// CHECK-FIX: 23e008: 2d 18 00 14 b #24756
+// CHECK-NOFIX: 23e008: 18 ff 3f f9 str x24, [x24, #32760]
+// CHECK-NEXT: 23e00c: c0 03 5f d6 ret
.section .text.23, "ax", %progbits
.balign 4096
.globl t4_ffc_st1
@@ -455,14 +455,14 @@ t4_ffc_st1:
str x24, [x24, #32760]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 4FFF8 in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 23FFF8 in unpatched output.
// CHECK: t3_ff8_ldr_once:
-// CHECK-NEXT: 4fff8: 80 00 00 b0 adrp x0, #69632
-// CHECK-NEXT: 4fffc: 20 70 82 4c st1 { v0.16b }, [x1], x2
-// CHECK-FIX: 50000: 31 10 00 14 b #16580
-// CHECK-NOFIX: 50000: 01 08 40 f9 ldr x1, [x0, #16]
-// CHECK-NEXT: 50004: 02 08 40 f9 ldr x2, [x0, #16]
-// CHECK-NEXT: 50008: c0 03 5f d6 ret
+// CHECK-NEXT: 23fff8: 80 00 00 b0 adrp x0, #69632
+// CHECK-NEXT: 23fffc: 20 70 82 4c st1 { v0.16b }, [x1], x2
+// CHECK-FIX: 240000: 31 10 00 14 b #16580
+// CHECK-NOFIX: 240000: 01 08 40 f9 ldr x1, [x0, #16]
+// CHECK-NEXT: 240004: 02 08 40 f9 ldr x2, [x0, #16]
+// CHECK-NEXT: 240008: c0 03 5f d6 ret
.section .text.24, "ax", %progbits
.balign 4096
.globl t3_ff8_ldr_once
@@ -475,14 +475,14 @@ t3_ff8_ldr_once:
ldr x2, [x0, #16]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 51FF8 in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 241FF8 in unpatched output.
// CHECK: t3_ff8_ldxr:
-// CHECK-NEXT: 51ff8: 60 00 00 f0 adrp x0, #61440
-// CHECK-NEXT: 51ffc: 03 7c 5f c8 ldxr x3, [x0]
-// CHECK-FIX: 52000: 33 08 00 14 b #8396
-// CHECK-NOFIX: 52000: 01 08 40 f9 ldr x1, [x0, #16]
-// CHECK: 52004: 02 08 40 f9 ldr x2, [x0, #16]
-// CHECK-NEXT: 52008: c0 03 5f d6 ret
+// CHECK-NEXT: 241ff8: 60 00 00 f0 adrp x0, #61440
+// CHECK-NEXT: 241ffc: 03 7c 5f c8 ldxr x3, [x0]
+// CHECK-FIX: 242000: 33 08 00 14 b #8396
+// CHECK-NOFIX: 242000: 01 08 40 f9 ldr x1, [x0, #16]
+// CHECK: 242004: 02 08 40 f9 ldr x2, [x0, #16]
+// CHECK-NEXT: 242008: c0 03 5f d6 ret
.section .text.25, "ax", %progbits
.balign 4096
.globl t3_ff8_ldxr
@@ -495,14 +495,14 @@ t3_ff8_ldxr:
ldr x2, [x0, #16]
ret
-// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 53FF8 in unpatched output.
+// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 243FF8 in unpatched output.
// CHECK: t3_ff8_stxr:
-// CHECK-NEXT: 53ff8: 60 00 00 b0 adrp x0, #53248
-// CHECK-NEXT: 53ffc: 03 7c 04 c8 stxr w4, x3, [x0]
-// CHECK-FIX: 54000: 35 00 00 14 b #212
-// CHECK-NOFIX: 54000: 01 08 40 f9 ldr x1, [x0, #16]
-// CHECK: 54004: 02 08 40 f9 ldr x2, [x0, #16]
-// CHECK-NEXT: 54008: c0 03 5f d6 ret
+// CHECK-NEXT: 243ff8: 60 00 00 b0 adrp x0, #53248
+// CHECK-NEXT: 243ffc: 03 7c 04 c8 stxr w4, x3, [x0]
+// CHECK-FIX: 244000: 35 00 00 14 b #212
+// CHECK-NOFIX: 244000: 01 08 40 f9 ldr x1, [x0, #16]
+// CHECK: 244004: 02 08 40 f9 ldr x2, [x0, #16]
+// CHECK-NEXT: 244008: c0 03 5f d6 ret
.section .text.26, "ax", %progbits
.balign 4096
.globl t3_ff8_stxr
@@ -521,84 +521,84 @@ t3_ff8_stxr:
_start:
ret
-// CHECK-FIX: __CortexA53843419_22000:
-// CHECK-FIX-NEXT: 5400c: 00 00 40 f9 ldr x0, [x0]
-// CHECK-FIX-NEXT: 54010: fd 37 ff 17 b #-204812
-// CHECK-FIX: __CortexA53843419_24000:
-// CHECK-FIX-NEXT: 54014: 02 04 40 f9 ldr x2, [x0, #8]
-// CHECK-FIX-NEXT: 54018: fb 3f ff 17 b #-196628
-// CHECK-FIX: __CortexA53843419_26004:
-// CHECK-FIX-NEXT: 5401c: 03 08 40 f9 ldr x3, [x0, #16]
-// CHECK-FIX-NEXT: 54020: fa 47 ff 17 b #-188440
-// CHECK-FIX: __CortexA53843419_28000:
-// CHECK-FIX-NEXT: 54024: 02 00 40 f9 ldr x2, [x0]
-// CHECK-FIX-NEXT: 54028: f7 4f ff 17 b #-180260
-// CHECK-FIX: __CortexA53843419_2A004:
-// CHECK-FIX-NEXT: 5402c: 9c 07 00 f9 str x28, [x28, #8]
-// CHECK-FIX-NEXT: 54030: f6 57 ff 17 b #-172072
-// CHECK-FIX: __CortexA53843419_2C004:
-// CHECK-FIX-NEXT: 54034: 84 0b 00 f9 str x4, [x28, #16]
-// CHECK-FIX-NEXT: 54038: f4 5f ff 17 b #-163888
-// CHECK-FIX: __CortexA53843419_2E000:
-// CHECK-FIX-NEXT: 5403c: bd 03 40 f9 ldr x29, [x29]
-// CHECK-FIX-NEXT: 54040: f1 67 ff 17 b #-155708
-// CHECK-FIX: __CortexA53843419_30004:
-// CHECK-FIX-NEXT: 54044: bd 07 40 f9 ldr x29, [x29, #8]
-// CHECK-FIX-NEXT: 54048: f0 6f ff 17 b #-147520
-// CHECK-FIX: __CortexA53843419_32004:
-// CHECK-FIX-NEXT: 5404c: 41 0a 40 f9 ldr x1, [x18, #16]
-// CHECK-FIX-NEXT: 54050: ee 77 ff 17 b #-139336
-// CHECK-FIX: __CortexA53843419_34000:
-// CHECK-FIX-NEXT: 54054: 52 02 40 f9 ldr x18, [x18]
-// CHECK-FIX-NEXT: 54058: eb 7f ff 17 b #-131156
-// CHECK-FIX: __CortexA53843419_36004:
-// CHECK-FIX-NEXT: 5405c: ea 05 40 f9 ldr x10, [x15, #8]
-// CHECK-FIX-NEXT: 54060: ea 87 ff 17 b #-122968
-// CHECK-FIX: __CortexA53843419_38000:
-// CHECK-FIX-NEXT: 54064: 0d 0a 40 f9 ldr x13, [x16, #16]
-// CHECK-FIX-NEXT: 54068: e7 8f ff 17 b #-114788
-// CHECK-FIX: __CortexA53843419_3A004:
-// CHECK-FIX-NEXT: 5406c: e9 00 40 f9 ldr x9, [x7]
-// CHECK-FIX-NEXT: 54070: e6 97 ff 17 b #-106600
-// CHECK-FIX: __CortexA53843419_3C004:
-// CHECK-FIX-NEXT: 54074: f6 06 40 f9 ldr x22, [x23, #8]
-// CHECK-FIX-NEXT: 54078: e4 9f ff 17 b #-98416
-// CHECK-FIX: __CortexA53843419_3E000:
-// CHECK-FIX-NEXT: 5407c: f8 0a 40 f9 ldr x24, [x23, #16]
-// CHECK-FIX-NEXT: 54080: e1 a7 ff 17 b #-90236
-// CHECK-FIX: __CortexA53843419_40004:
-// CHECK-FIX-NEXT: 54084: 02 00 40 f9 ldr x2, [x0]
-// CHECK-FIX-NEXT: 54088: e0 af ff 17 b #-82048
-// CHECK-FIX: __CortexA53843419_42008:
-// CHECK-FIX-NEXT: 5408c: 9b 07 00 f9 str x27, [x28, #8]
-// CHECK-FIX-NEXT: 54090: df b7 ff 17 b #-73860
-// CHECK-FIX: __CortexA53843419_44004:
-// CHECK-FIX-NEXT: 54094: 0e 0a 40 f9 ldr x14, [x16, #16]
-// CHECK-FIX-NEXT: 54098: dc bf ff 17 b #-65680
-// CHECK-FIX: __CortexA53843419_46004:
-// CHECK-FIX-NEXT: 5409c: 0e 06 40 f9 ldr x14, [x16, #8]
-// CHECK-FIX-NEXT: 540a0: da c7 ff 17 b #-57496
-// CHECK-FIX: __CortexA53843419_48004:
-// CHECK-FIX-NEXT: 540a4: 0e 06 40 f9 ldr x14, [x16, #8]
-// CHECK-FIX-NEXT: 540a8: d8 cf ff 17 b #-49312
-// CHECK-FIX: __CortexA53843419_4A008:
-// CHECK-FIX-NEXT: 540ac: 0e 06 40 f9 ldr x14, [x16, #8]
-// CHECK-FIX-NEXT: 540b0: d7 d7 ff 17 b #-41124
-// CHECK-FIX: __CortexA53843419_4C008:
-// CHECK-FIX-NEXT: 540b4: ea 00 40 f9 ldr x10, [x7]
-// CHECK-FIX-NEXT: 540b8: d5 df ff 17 b #-32940
-// CHECK-FIX: __CortexA53843419_4E008:
-// CHECK-FIX-NEXT: 540bc: 18 ff 3f f9 str x24, [x24, #32760]
-// CHECK-FIX-NEXT: 540c0: d3 e7 ff 17 b #-24756
-// CHECK-FIX: __CortexA53843419_50000:
-// CHECK-FIX-NEXT: 540c4: 01 08 40 f9 ldr x1, [x0, #16]
-// CHECK-FIX-NEXT: 540c8: cf ef ff 17 b #-16580
-// CHECK-FIX: __CortexA53843419_52000:
-// CHECK-FIX-NEXT: 540cc: 01 08 40 f9 ldr x1, [x0, #16]
-// CHECK-FIX-NEXT: 540d0: cd f7 ff 17 b #-8396
-// CHECK-FIX: __CortexA53843419_54000:
-// CHECK-FIX-NEXT: 540d4: 01 08 40 f9 ldr x1, [x0, #16]
-// CHECK-FIX-NEXT: 540d8: cb ff ff 17 b #-212
+// CHECK-FIX: __CortexA53843419_212000:
+// CHECK-FIX-NEXT: 24400c: 00 00 40 f9 ldr x0, [x0]
+// CHECK-FIX-NEXT: 244010: fd 37 ff 17 b #-204812
+// CHECK-FIX: __CortexA53843419_214000:
+// CHECK-FIX-NEXT: 244014: 02 04 40 f9 ldr x2, [x0, #8]
+// CHECK-FIX-NEXT: 244018: fb 3f ff 17 b #-196628
+// CHECK-FIX: __CortexA53843419_216004:
+// CHECK-FIX-NEXT: 24401c: 03 08 40 f9 ldr x3, [x0, #16]
+// CHECK-FIX-NEXT: 244020: fa 47 ff 17 b #-188440
+// CHECK-FIX: __CortexA53843419_218000:
+// CHECK-FIX-NEXT: 244024: 02 00 40 f9 ldr x2, [x0]
+// CHECK-FIX-NEXT: 244028: f7 4f ff 17 b #-180260
+// CHECK-FIX: __CortexA53843419_21A004:
+// CHECK-FIX-NEXT: 24402c: 9c 07 00 f9 str x28, [x28, #8]
+// CHECK-FIX-NEXT: 244030: f6 57 ff 17 b #-172072
+// CHECK-FIX: __CortexA53843419_21C004:
+// CHECK-FIX-NEXT: 244034: 84 0b 00 f9 str x4, [x28, #16]
+// CHECK-FIX-NEXT: 244038: f4 5f ff 17 b #-163888
+// CHECK-FIX: __CortexA53843419_21E000:
+// CHECK-FIX-NEXT: 24403c: bd 03 40 f9 ldr x29, [x29]
+// CHECK-FIX-NEXT: 244040: f1 67 ff 17 b #-155708
+// CHECK-FIX: __CortexA53843419_220004:
+// CHECK-FIX-NEXT: 244044: bd 07 40 f9 ldr x29, [x29, #8]
+// CHECK-FIX-NEXT: 244048: f0 6f ff 17 b #-147520
+// CHECK-FIX: __CortexA53843419_222004:
+// CHECK-FIX-NEXT: 24404c: 41 0a 40 f9 ldr x1, [x18, #16]
+// CHECK-FIX-NEXT: 244050: ee 77 ff 17 b #-139336
+// CHECK-FIX: __CortexA53843419_224000:
+// CHECK-FIX-NEXT: 244054: 52 02 40 f9 ldr x18, [x18]
+// CHECK-FIX-NEXT: 244058: eb 7f ff 17 b #-131156
+// CHECK-FIX: __CortexA53843419_226004:
+// CHECK-FIX-NEXT: 24405c: ea 05 40 f9 ldr x10, [x15, #8]
+// CHECK-FIX-NEXT: 244060: ea 87 ff 17 b #-122968
+// CHECK-FIX: __CortexA53843419_228000:
+// CHECK-FIX-NEXT: 244064: 0d 0a 40 f9 ldr x13, [x16, #16]
+// CHECK-FIX-NEXT: 244068: e7 8f ff 17 b #-114788
+// CHECK-FIX: __CortexA53843419_22A004:
+// CHECK-FIX-NEXT: 24406c: e9 00 40 f9 ldr x9, [x7]
+// CHECK-FIX-NEXT: 244070: e6 97 ff 17 b #-106600
+// CHECK-FIX: __CortexA53843419_22C004:
+// CHECK-FIX-NEXT: 244074: f6 06 40 f9 ldr x22, [x23, #8]
+// CHECK-FIX-NEXT: 244078: e4 9f ff 17 b #-98416
+// CHECK-FIX: __CortexA53843419_22E000:
+// CHECK-FIX-NEXT: 24407c: f8 0a 40 f9 ldr x24, [x23, #16]
+// CHECK-FIX-NEXT: 244080: e1 a7 ff 17 b #-90236
+// CHECK-FIX: __CortexA53843419_230004:
+// CHECK-FIX-NEXT: 244084: 02 00 40 f9 ldr x2, [x0]
+// CHECK-FIX-NEXT: 244088: e0 af ff 17 b #-82048
+// CHECK-FIX: __CortexA53843419_232008:
+// CHECK-FIX-NEXT: 24408c: 9b 07 00 f9 str x27, [x28, #8]
+// CHECK-FIX-NEXT: 244090: df b7 ff 17 b #-73860
+// CHECK-FIX: __CortexA53843419_234004:
+// CHECK-FIX-NEXT: 244094: 0e 0a 40 f9 ldr x14, [x16, #16]
+// CHECK-FIX-NEXT: 244098: dc bf ff 17 b #-65680
+// CHECK-FIX: __CortexA53843419_236004:
+// CHECK-FIX-NEXT: 24409c: 0e 06 40 f9 ldr x14, [x16, #8]
+// CHECK-FIX-NEXT: 2440a0: da c7 ff 17 b #-57496
+// CHECK-FIX: __CortexA53843419_238004:
+// CHECK-FIX-NEXT: 2440a4: 0e 06 40 f9 ldr x14, [x16, #8]
+// CHECK-FIX-NEXT: 2440a8: d8 cf ff 17 b #-49312
+// CHECK-FIX: __CortexA53843419_23A008:
+// CHECK-FIX-NEXT: 2440ac: 0e 06 40 f9 ldr x14, [x16, #8]
+// CHECK-FIX-NEXT: 2440b0: d7 d7 ff 17 b #-41124
+// CHECK-FIX: __CortexA53843419_23C008:
+// CHECK-FIX-NEXT: 2440b4: ea 00 40 f9 ldr x10, [x7]
+// CHECK-FIX-NEXT: 2440b8: d5 df ff 17 b #-32940
+// CHECK-FIX: __CortexA53843419_23E008:
+// CHECK-FIX-NEXT: 2440bc: 18 ff 3f f9 str x24, [x24, #32760]
+// CHECK-FIX-NEXT: 2440c0: d3 e7 ff 17 b #-24756
+// CHECK-FIX: __CortexA53843419_240000:
+// CHECK-FIX-NEXT: 2440c4: 01 08 40 f9 ldr x1, [x0, #16]
+// CHECK-FIX-NEXT: 2440c8: cf ef ff 17 b #-16580
+// CHECK-FIX: __CortexA53843419_242000:
+// CHECK-FIX-NEXT: 2440cc: 01 08 40 f9 ldr x1, [x0, #16]
+// CHECK-FIX-NEXT: 2440d0: cd f7 ff 17 b #-8396
+// CHECK-FIX: __CortexA53843419_244000:
+// CHECK-FIX-NEXT: 2440d4: 01 08 40 f9 ldr x1, [x0, #16]
+// CHECK-FIX-NEXT: 2440d8: cb ff ff 17 b #-212
.data
.globl dat
.globl dat2
diff --git a/test/ELF/aarch64-cortex-a53-843419-tlsrelax.s b/test/ELF/aarch64-cortex-a53-843419-tlsrelax.s
new file mode 100644
index 000000000000..2db5c7e36bbc
--- /dev/null
+++ b/test/ELF/aarch64-cortex-a53-843419-tlsrelax.s
@@ -0,0 +1,38 @@
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux %s -o %t.o
+// RUN: ld.lld -fix-cortex-a53-843419 %t.o -o %t2
+// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 | FileCheck %s
+
+// The following code sequence is covered by the TLS IE to LE relaxation. It
+// transforms the ADRP, LDR to MOVZ, MOVK. The former can trigger a
+// cortex-a53-843419 patch, whereas the latter can not. As both
+// relaxation and patching transform instructions very late in the
+// link there is a possibility of them both being simultaneously
+// applied. In this case the relaxed sequence is immune from the erratum so we
+// prefer to keep it.
+ .text
+ .balign 4096
+ .space 4096 - 8
+ .globl _start
+ .type _start,@function
+_start:
+ mrs x1, tpidr_el0
+ adrp x0, :gottprel:v
+ ldr x1, [x0, #:gottprel_lo12:v]
+ adrp x0, :gottprel:v
+ ldr x1, [x0, #:gottprel_lo12:v]
+ ret
+
+// CHECK: _start:
+// CHECK-NEXT: 210ff8: 41 d0 3b d5 mrs x1, TPIDR_EL0
+// CHECK-NEXT: 210ffc: 00 00 a0 d2 movz x0, #0, lsl #16
+// CHECK-NEXT: 211000: 01 08 80 f2 movk x1, #64
+// CHECK-NEXT: 211004: 00 00 a0 d2 movz x0, #0, lsl #16
+// CHECK-NEXT: 211008: 01 08 80 f2 movk x1, #64
+// CHECK-NEXT: 21100c: c0 03 5f d6 ret
+
+ .type v,@object
+ .section .tbss,"awT",@nobits
+ .globl v
+v:
+ .word 0
diff --git a/test/ELF/aarch64-data-relocs.s b/test/ELF/aarch64-data-relocs.s
index d32871543bf6..c2769758c6e5 100644
--- a/test/ELF/aarch64-data-relocs.s
+++ b/test/ELF/aarch64-data-relocs.s
@@ -12,7 +12,7 @@ _start:
// S = 0x100, A = 0x24
// S + A = 0x124
// CHECK: Contents of section .R_AARCH64_ABS64:
-// CHECK-NEXT: 20000 24010000 00000000
+// CHECK-NEXT: 210000 24010000 00000000
.section .R_AARCH64_PREL64, "ax",@progbits
.xword foo - . + 0x24
@@ -20,4 +20,4 @@ _start:
// S = 0x100, A = 0x24, P = 0x20008
// S + A - P = 0xfffffffffffe011c
// CHECK: Contents of section .R_AARCH64_PREL64:
-// CHECK-NEXT: 20008 1c01feff ffffffff
+// CHECK-NEXT: 210008 1c01dfff ffffffff
diff --git a/test/ELF/aarch64-gnu-ifunc-address.s b/test/ELF/aarch64-gnu-ifunc-address.s
new file mode 100644
index 000000000000..9321fe35e536
--- /dev/null
+++ b/test/ELF/aarch64-gnu-ifunc-address.s
@@ -0,0 +1,40 @@
+# REQUIRES: aarch64
+# RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-gnu %s -o %t.o
+# RUN: ld.lld -shared %t.o -o %tout
+# RUN: llvm-objdump -D %tout | FileCheck %s
+# RUN: llvm-readobj -r %tout | FileCheck %s --check-prefix=CHECK-RELOCS
+
+# Test that when we take the address of a preemptible ifunc in a shared object
+# we get R_AARCH64_GLOB_DAT to the symbol as it could be defined in another
+# link unit and preempt our definition.
+.text
+.globl myfunc
+.type myfunc,@gnu_indirect_function
+myfunc:
+ ret
+
+.text
+.globl main
+.type main,@function
+main:
+ adrp x8, :got:myfunc
+ ldr x8, [x8, :got_lo12:myfunc]
+ ret
+# CHECK: 0000000000010004 main:
+# x8 = 0x30000
+# CHECK-NEXT: 10004: 08 01 00 90 adrp x8, #131072
+# x8 = 0x300e0 = .got entry for myfunc with R_AARCH64_GLOB_DAT
+# CHECK-NEXT: 10008: 08 71 40 f9 ldr x8, [x8, #224]
+# CHECK-NEXT: 1000c: c0 03 5f d6 ret
+
+# CHECK: Disassembly of section .got:
+# CHECK-NEXT: 00000000000300e0 .got:
+
+# CHECK-RELOCS: Relocations [
+# CHECK-RELOCS-NEXT: Section {{.*}} .rela.dyn {
+# CHECK-RELOCS-NEXT: 0x300E0 R_AARCH64_GLOB_DAT myfunc 0x0
+# CHECK-RELOCS-NEXT: }
+# CHECK-RELOCS-NEXT: Section {{.*}} .rela.plt {
+# CHECK-RELOCS-NEXT: 0x20018 R_AARCH64_JUMP_SLOT myfunc 0x0
+# CHECK-RELOCS-NEXT: }
+# CHECK-RELOCS-NEXT: ]
diff --git a/test/ELF/aarch64-gnu-ifunc-plt.s b/test/ELF/aarch64-gnu-ifunc-plt.s
index ca30316c7afe..381bcf7cd142 100644
--- a/test/ELF/aarch64-gnu-ifunc-plt.s
+++ b/test/ELF/aarch64-gnu-ifunc-plt.s
@@ -10,19 +10,19 @@
// Check that the IRELATIVE relocations are after the JUMP_SLOT in the plt
// CHECK: Relocations [
// CHECK-NEXT: Section (4) .rela.plt {
-// CHECK: 0x30018 R_AARCH64_JUMP_SLOT bar2 0x0
-// CHECK-NEXT: 0x30020 R_AARCH64_JUMP_SLOT zed2 0x0
-// CHECK-NEXT: 0x30028 R_AARCH64_IRELATIVE - 0x20000
-// CHECK-NEXT: 0x30030 R_AARCH64_IRELATIVE - 0x20004
+// CHECK: 0x220018 R_AARCH64_JUMP_SLOT bar2 0x0
+// CHECK-NEXT: 0x220020 R_AARCH64_JUMP_SLOT zed2 0x0
+// CHECK-NEXT: 0x220028 R_AARCH64_IRELATIVE - 0x210000
+// CHECK-NEXT: 0x220030 R_AARCH64_IRELATIVE - 0x210004
// CHECK-NEXT: }
// CHECK-NEXT: ]
// Check that .got.plt entries point back to PLT header
// GOTPLT: Contents of section .got.plt:
-// GOTPLT-NEXT: 30000 00000000 00000000 00000000 00000000
-// GOTPLT-NEXT: 30010 00000000 00000000 20000200 00000000
-// GOTPLT-NEXT: 30020 20000200 00000000 20000200 00000000
-// GOTPLT-NEXT: 30030 20000200 00000000
+// GOTPLT-NEXT: 220000 00000000 00000000 00000000 00000000
+// GOTPLT-NEXT: 220010 00000000 00000000 20002100 00000000
+// GOTPLT-NEXT: 220020 20002100 00000000 20002100 00000000
+// GOTPLT-NEXT: 220030 20002100 00000000
// Check that the PLTRELSZ tag includes the IRELATIVE relocations
// CHECK: DynamicSection [
@@ -31,40 +31,44 @@
// Check that a PLT header is written and the ifunc entries appear last
// DISASM: Disassembly of section .text:
// DISASM-NEXT: foo:
-// DISASM-NEXT: 20000: {{.*}} ret
+// DISASM-NEXT: 210000: {{.*}} ret
// DISASM: bar:
-// DISASM-NEXT: 20004: {{.*}} ret
+// DISASM-NEXT: 210004: {{.*}} ret
// DISASM: _start:
-// DISASM-NEXT: 20008: {{.*}} bl #88
-// DISASM-NEXT: 2000c: {{.*}} bl #100
-// DISASM-NEXT: 20010: {{.*}} bl #48
-// DISASM-NEXT: 20014: {{.*}} bl #60
+// DISASM-NEXT: 210008: {{.*}} bl #88
+// DISASM-NEXT: 21000c: {{.*}} bl #100
+// DISASM-NEXT: 210010: {{.*}} bl #48
+// DISASM-NEXT: 210014: {{.*}} bl #60
// DISASM-NEXT: Disassembly of section .plt:
// DISASM-NEXT: .plt:
-// DISASM-NEXT: 20020: {{.*}} stp x16, x30, [sp, #-16]!
-// DISASM-NEXT: 20024: {{.*}} adrp x16, #65536
-// DISASM-NEXT: 20028: {{.*}} ldr x17, [x16, #16]
-// DISASM-NEXT: 2002c: {{.*}} add x16, x16, #16
-// DISASM-NEXT: 20030: {{.*}} br x17
-// DISASM-NEXT: 20034: {{.*}} nop
-// DISASM-NEXT: 20038: {{.*}} nop
-// DISASM-NEXT: 2003c: {{.*}} nop
-// DISASM-NEXT: 20040: {{.*}} adrp x16, #65536
-// DISASM-NEXT: 20044: {{.*}} ldr x17, [x16, #24]
-// DISASM-NEXT: 20048: {{.*}} add x16, x16, #24
-// DISASM-NEXT: 2004c: {{.*}} br x17
-// DISASM-NEXT: 20050: {{.*}} adrp x16, #65536
-// DISASM-NEXT: 20054: {{.*}} ldr x17, [x16, #32]
-// DISASM-NEXT: 20058: {{.*}} add x16, x16, #32
-// DISASM-NEXT: 2005c: {{.*}} br x17
-// DISASM-NEXT: 20060: {{.*}} adrp x16, #65536
-// DISASM-NEXT: 20064: {{.*}} ldr x17, [x16, #40]
-// DISASM-NEXT: 20068: {{.*}} add x16, x16, #40
-// DISASM-NEXT: 2006c: {{.*}} br x17
-// DISASM-NEXT: 20070: {{.*}} adrp x16, #65536
-// DISASM-NEXT: 20074: {{.*}} ldr x17, [x16, #48]
-// DISASM-NEXT: 20078: {{.*}} add x16, x16, #48
-// DISASM-NEXT: 2007c: {{.*}} br x17
+// DISASM-NEXT: 210020: {{.*}} stp x16, x30, [sp, #-16]!
+// DISASM-NEXT: 210024: {{.*}} adrp x16, #65536
+// DISASM-NEXT: 210028: {{.*}} ldr x17, [x16, #16]
+// DISASM-NEXT: 21002c: {{.*}} add x16, x16, #16
+// DISASM-NEXT: 210030: {{.*}} br x17
+// DISASM-NEXT: 210034: {{.*}} nop
+// DISASM-NEXT: 210038: {{.*}} nop
+// DISASM-NEXT: 21003c: {{.*}} nop
+// DISASM-EMPTY:
+// DISASM-NEXT: bar2@plt:
+// DISASM-NEXT: 210040: {{.*}} adrp x16, #65536
+// DISASM-NEXT: 210044: {{.*}} ldr x17, [x16, #24]
+// DISASM-NEXT: 210048: {{.*}} add x16, x16, #24
+// DISASM-NEXT: 21004c: {{.*}} br x17
+// DISASM-EMPTY:
+// DISASM-NEXT: zed2@plt:
+// DISASM-NEXT: 210050: {{.*}} adrp x16, #65536
+// DISASM-NEXT: 210054: {{.*}} ldr x17, [x16, #32]
+// DISASM-NEXT: 210058: {{.*}} add x16, x16, #32
+// DISASM-NEXT: 21005c: {{.*}} br x17
+// DISASM-NEXT: 210060: {{.*}} adrp x16, #65536
+// DISASM-NEXT: 210064: {{.*}} ldr x17, [x16, #40]
+// DISASM-NEXT: 210068: {{.*}} add x16, x16, #40
+// DISASM-NEXT: 21006c: {{.*}} br x17
+// DISASM-NEXT: 210070: {{.*}} adrp x16, #65536
+// DISASM-NEXT: 210074: {{.*}} ldr x17, [x16, #48]
+// DISASM-NEXT: 210078: {{.*}} add x16, x16, #48
+// DISASM-NEXT: 21007c: {{.*}} br x17
.text
.type foo STT_GNU_IFUNC
diff --git a/test/ELF/aarch64-gnu-ifunc.s b/test/ELF/aarch64-gnu-ifunc.s
index b3c1571b7604..9a15f1341d3d 100644
--- a/test/ELF/aarch64-gnu-ifunc.s
+++ b/test/ELF/aarch64-gnu-ifunc.s
@@ -16,14 +16,14 @@
// CHECK-NEXT: Offset: 0x158
// CHECK-NEXT: Size: 48
// CHECK-NEXT: Link: 0
-// CHECK-NEXT: Info: 0
+// CHECK-NEXT: Info: 4
// CHECK-NEXT: AddressAlignment: 8
// CHECK-NEXT: EntrySize: 24
// CHECK-NEXT: }
// CHECK: Relocations [
// CHECK-NEXT: Section ({{.*}}) .rela.plt {
-// CHECK-NEXT: 0x30000 R_AARCH64_IRELATIVE
-// CHECK-NEXT: 0x30008 R_AARCH64_IRELATIVE
+// CHECK-NEXT: 0x220000 R_AARCH64_IRELATIVE
+// CHECK-NEXT: 0x220008 R_AARCH64_IRELATIVE
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK: Symbols [
@@ -38,7 +38,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: $x.0
-// CHECK-NEXT: Value: 0x20000
+// CHECK-NEXT: Value: 0x210000
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local
// CHECK-NEXT: Type: None
@@ -47,7 +47,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: __rela_iplt_end
-// CHECK-NEXT: Value: 0x10188
+// CHECK-NEXT: Value: 0x200188
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local
// CHECK-NEXT: Type: None
@@ -58,7 +58,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: __rela_iplt_start
-// CHECK-NEXT: Value: 0x10158
+// CHECK-NEXT: Value: 0x200158
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local
// CHECK-NEXT: Type: None
@@ -69,7 +69,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: _start
-// CHECK-NEXT: Value: 0x20008
+// CHECK-NEXT: Value: 0x210008
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: None
@@ -78,7 +78,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: bar
-// CHECK-NEXT: Value: 0x20004
+// CHECK-NEXT: Value: 0x210004
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: GNU_IFunc
@@ -87,7 +87,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: foo
-// CHECK-NEXT: Value: 0x20000
+// CHECK-NEXT: Value: 0x210000
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: GNU_IFunc
@@ -101,24 +101,24 @@
// DISASM: Disassembly of section .text:
// DISASM-NEXT: foo:
-// DISASM-NEXT: 20000: c0 03 5f d6 ret
+// DISASM-NEXT: 210000: c0 03 5f d6 ret
// DISASM: bar:
-// DISASM-NEXT: 20004: c0 03 5f d6 ret
+// DISASM-NEXT: 210004: c0 03 5f d6 ret
// DISASM: _start:
-// DISASM-NEXT: 20008: 06 00 00 94 bl #24
-// DISASM-NEXT: 2000c: 09 00 00 94 bl #36
-// DISASM-NEXT: 20010: 42 60 05 91 add x2, x2, #344
-// DISASM-NEXT: 20014: 42 20 06 91 add x2, x2, #392
+// DISASM-NEXT: 210008: 06 00 00 94 bl #24
+// DISASM-NEXT: 21000c: 09 00 00 94 bl #36
+// DISASM-NEXT: 210010: 42 60 05 91 add x2, x2, #344
+// DISASM-NEXT: 210014: 42 20 06 91 add x2, x2, #392
// DISASM-NEXT: Disassembly of section .plt:
// DISASM-NEXT: .plt:
-// DISASM-NEXT: 20020: 90 00 00 90 adrp x16, #65536
-// DISASM-NEXT: 20024: 11 02 40 f9 ldr x17, [x16]
-// DISASM-NEXT: 20028: 10 02 00 91 add x16, x16, #0
-// DISASM-NEXT: 2002c: 20 02 1f d6 br x17
-// DISASM-NEXT: 20030: 90 00 00 90 adrp x16, #65536
-// DISASM-NEXT: 20034: 11 06 40 f9 ldr x17, [x16, #8]
-// DISASM-NEXT: 20038: 10 22 00 91 add x16, x16, #8
-// DISASM-NEXT: 2003c: 20 02 1f d6 br x17
+// DISASM-NEXT: 210020: 90 00 00 90 adrp x16, #65536
+// DISASM-NEXT: 210024: 11 02 40 f9 ldr x17, [x16]
+// DISASM-NEXT: 210028: 10 02 00 91 add x16, x16, #0
+// DISASM-NEXT: 21002c: 20 02 1f d6 br x17
+// DISASM-NEXT: 210030: 90 00 00 90 adrp x16, #65536
+// DISASM-NEXT: 210034: 11 06 40 f9 ldr x17, [x16, #8]
+// DISASM-NEXT: 210038: 10 22 00 91 add x16, x16, #8
+// DISASM-NEXT: 21003c: 20 02 1f d6 br x17
.text
.type foo STT_GNU_IFUNC
diff --git a/test/ELF/aarch64-gnu-ifunc2.s b/test/ELF/aarch64-gnu-ifunc2.s
new file mode 100644
index 000000000000..2caff3f14586
--- /dev/null
+++ b/test/ELF/aarch64-gnu-ifunc2.s
@@ -0,0 +1,52 @@
+# REQUIRES: aarch64
+# RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-gnu %s -o %t.o
+# RUN: ld.lld -static %t.o -o %tout
+# RUN: llvm-objdump -D %tout | FileCheck %s
+# RUN: llvm-readobj -r %tout | FileCheck %s --check-prefix=RELOC
+
+# CHECK: Disassembly of section .text:
+# CHECK-NEXT: myfunc:
+# CHECK-NEXT: 210000:
+
+# CHECK: main:
+# adrp x8, 0x230000, 0x230000 == address in .got
+# CHECK-NEXT: 210004: {{.*}} adrp x8, #131072
+# CHECK-NEXT: 210008: {{.*}} ldr x8, [x8]
+# CHECK-NEXT: 21000c: {{.*}} ret
+
+# CHECK: Disassembly of section .plt:
+# CHECK-NEXT: .plt:
+# adrp x16, 0x220000, 0x220000 == address in .got.plt
+# CHECK-NEXT: 210010: {{.*}} adrp x16, #65536
+# CHECK-NEXT: 210014: {{.*}} ldr x17, [x16]
+# CHECK-NEXT: 210018: {{.*}} add x16, x16, #0
+# CHECK-NEXT: 21001c: {{.*}} br x17
+
+# CHECK: Disassembly of section .got.plt:
+# CHECK-NEXT: .got.plt:
+# CHECK-NEXT: 220000:
+
+# CHECK: Disassembly of section .got:
+# CHECK-NEXT: .got:
+# 0x210010 == address in .plt
+# CHECK-NEXT: 230000: 10 00 21 00
+
+# RELOC: Relocations [
+# RELOC-NEXT: Section {{.*}} .rela.plt {
+# RELOC-NEXT: 0x220000 R_AARCH64_IRELATIVE - 0x210000
+# RELOC-NEXT: }
+# RELOC-NEXT: ]
+
+.text
+.globl myfunc
+.type myfunc,@gnu_indirect_function
+myfunc:
+ ret
+
+.text
+.globl main
+.type main,@function
+main:
+ adrp x8, :got:myfunc
+ ldr x8, [x8, :got_lo12:myfunc]
+ ret
diff --git a/test/ELF/aarch64-gnu-ifunc3.s b/test/ELF/aarch64-gnu-ifunc3.s
new file mode 100644
index 000000000000..11d5631b8578
--- /dev/null
+++ b/test/ELF/aarch64-gnu-ifunc3.s
@@ -0,0 +1,49 @@
+# REQUIRES: aarch64
+# RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-gnu %s -o %t.o
+# RUN: ld.lld -static %t.o -o %tout
+# RUN: llvm-objdump -D %tout | FileCheck %s
+# RUN: llvm-readobj -r %tout | FileCheck %s --check-prefix=RELOC
+
+# The address of myfunc is the address of the PLT entry for myfunc.
+# The adrp to myfunc should generate a PLT entry and a got entry with an
+# irelative relocation.
+.text
+.globl myfunc
+.type myfunc,@gnu_indirect_function
+myfunc:
+ ret
+
+.text
+.globl _start
+.type _start,@function
+_start:
+ adrp x8, myfunc
+ add x8, x8, :lo12:myfunc
+ ret
+
+# CHECK: Disassembly of section .text:
+# CHECK-NEXT: myfunc:
+# CHECK-NEXT: 210000: c0 03 5f d6 ret
+# CHECK: _start:
+# adrp x8, 0x210000 + 0x10 from add == .plt entry
+# CHECK-NEXT: 210004: 08 00 00 90 adrp x8, #0
+# CHECK-NEXT: 210008: 08 41 00 91 add x8, x8, #16
+# CHECK-NEXT: 21000c: c0 03 5f d6 ret
+# CHECK-NEXT: Disassembly of section .plt:
+# CHECK-NEXT: .plt:
+# adrp x16, 0x220000, 0x220000 == address in .got.plt
+# CHECK-NEXT: 210010: 90 00 00 90 adrp x16, #65536
+# CHECK-NEXT: 210014: 11 02 40 f9 ldr x17, [x16]
+# CHECK-NEXT: 210018: 10 02 00 91 add x16, x16, #0
+# CHECK-NEXT: 21001c: 20 02 1f d6 br x17
+# CHECK-NEXT: Disassembly of section .got.plt:
+# CHECK-NEXT: .got.plt:
+# 0x210010 == address in .plt
+# CHECK-NEXT: 220000: 10 00 21 00
+# CHECK-NEXT: 220004: 00 00 00 00
+
+# RELOC: Relocations [
+# RELOC-NEXT: Section (1) .rela.plt {
+# RELOC-NEXT: 0x220000 R_AARCH64_IRELATIVE - 0x210000
+# RELOC-NEXT: }
+# RELOC-NEXT: ]
diff --git a/test/ELF/aarch64-jump26-thunk.s b/test/ELF/aarch64-jump26-thunk.s
index 13c084a0c78e..a381c701eca1 100644
--- a/test/ELF/aarch64-jump26-thunk.s
+++ b/test/ELF/aarch64-jump26-thunk.s
@@ -11,10 +11,10 @@ _start:
// CHECK: Disassembly of section .text:
// CHECK-NEXT: _start:
-// CHECK-NEXT: 20000: 02 00 00 14 b #8
+// CHECK-NEXT: 210000: 02 00 00 14 b #8
// CHECK: __AArch64AbsLongThunk_big:
-// CHECK-NEXT: 20008: 50 00 00 58 ldr x16, #8
-// CHECK-NEXT: 2000c: 00 02 1f d6 br x16
+// CHECK-NEXT: 210008: 50 00 00 58 ldr x16, #8
+// CHECK-NEXT: 21000c: 00 02 1f d6 br x16
// CHECK: $d:
-// CHECK-NEXT: 20010: 00 00 00 00 .word 0x00000000
-// CHECK-NEXT: 20014: 10 00 00 00 .word 0x00000010
+// CHECK-NEXT: 210010: 00 00 00 00 .word 0x00000000
+// CHECK-NEXT: 210014: 10 00 00 00 .word 0x00000010
diff --git a/test/ELF/aarch64-lo12-alignment.s b/test/ELF/aarch64-lo12-alignment.s
index 7edecd4494f5..a7ed99751490 100644
--- a/test/ELF/aarch64-lo12-alignment.s
+++ b/test/ELF/aarch64-lo12-alignment.s
@@ -39,7 +39,7 @@ foo4:
foo8:
.space 8
-// CHECK: improper alignment for relocation R_AARCH64_LDST16_ABS_LO12_NC: 0x30001 is not aligned to 2 bytes
-// CHECK-NEXT: improper alignment for relocation R_AARCH64_LDST32_ABS_LO12_NC: 0x30002 is not aligned to 4 bytes
-// CHECK-NEXT: improper alignment for relocation R_AARCH64_LDST64_ABS_LO12_NC: 0x30004 is not aligned to 8 bytes
-// CHECK-NEXT: improper alignment for relocation R_AARCH64_LDST128_ABS_LO12_NC: 0x30008 is not aligned to 16 bytes
+// CHECK: improper alignment for relocation R_AARCH64_LDST16_ABS_LO12_NC: 0x220001 is not aligned to 2 bytes
+// CHECK-NEXT: improper alignment for relocation R_AARCH64_LDST32_ABS_LO12_NC: 0x220002 is not aligned to 4 bytes
+// CHECK-NEXT: improper alignment for relocation R_AARCH64_LDST64_ABS_LO12_NC: 0x220004 is not aligned to 8 bytes
+// CHECK-NEXT: improper alignment for relocation R_AARCH64_LDST128_ABS_LO12_NC: 0x220008 is not aligned to 16 bytes
diff --git a/test/ELF/aarch64-prel16.s b/test/ELF/aarch64-prel16.s
index fc34f010853c..18a594c319a1 100644
--- a/test/ELF/aarch64-prel16.s
+++ b/test/ELF/aarch64-prel16.s
@@ -7,8 +7,8 @@
.globl _start
_start:
.data
- .hword foo - . + 0x20eff
- .hword foo - . + 0x8f02
+ .hword foo - . + 0x210eff
+ .hword foo - . + 0x1f8f02
// Note: If this test fails, it probably happens because of
// the change of the address of the .data section.
@@ -18,14 +18,14 @@ _start:
// RUN: llvm-objdump -s -section=.data %t2 | FileCheck %s
// CHECK: Contents of section .data:
-// 11000: S = 0x100, A = 0x20eff, P = 0x11000
-// S + A - P = 0xffff
-// 11002: S = 0x100, A = 0x8f02, P = 0x11002
-// S + A - P = 0x8000
-// CHECK-NEXT: 11000 ffff0080
+// 201000: S = 0x100, A = 0x210eff, P = 0x201000
+// S + A - P = 0xffff
+// 201002: S = 0x100, A = 0x1f8f02, P = 0x201002
+// S + A - P = 0x8000
+// CHECK-NEXT: 201000 ffff0080
-// RUN: not ld.lld %t.o %t255.o -o %t2
-// | FileCheck %s --check-prefix=OVERFLOW
-// RUN: not ld.lld %t.o %t257.o -o %t2
-// | FileCheck %s --check-prefix=OVERFLOW
-// OVERFLOW: Relocation R_AARCH64_PREL16 out of range: -94209 is not in [-32768, 65535]
+// RUN: not ld.lld -z max-page-size=4096 %t.o %t255.o -o %t2 2>&1 | FileCheck %s --check-prefix=OVERFLOW1
+// OVERFLOW1: relocation R_AARCH64_PREL16 out of range: -32769 is not in [-32768, 32767]
+
+// RUN: not ld.lld -z max-page-size=4096 %t.o %t257.o -o %t2 2>&1 | FileCheck %s --check-prefix=OVERFLOW2
+// OVERFLOW2: relocation R_AARCH64_PREL16 out of range: 65536 is not in [-32768, 32767]
diff --git a/test/ELF/aarch64-prel32.s b/test/ELF/aarch64-prel32.s
index 7aa290382c53..16c8bb3c2019 100644
--- a/test/ELF/aarch64-prel32.s
+++ b/test/ELF/aarch64-prel32.s
@@ -7,8 +7,8 @@
.globl _start
_start:
.data
- .word foo - . + 0x100010eff
- .word foo - . - 0x7ffef0fc
+ .word foo - . + 0x100200eff
+ .word foo - . - 0x7fdff0fc
// Note: If this test fails, it probably happens because of
// the change of the address of the .data section.
@@ -18,14 +18,14 @@ _start:
// RUN: llvm-objdump -s -section=.data %t2 | FileCheck %s
// CHECK: Contents of section .data:
-// 11000: S = 0x100, A = 0x100010eff, P = 0x11000
-// S + A - P = 0xffffffff
-// 11004: S = 0x100, A = -0x7ffef0fc, P = 0x11004
-// S + A - P = 0x80000000
-// CHECK-NEXT: 11000 ffffffff 00000080
+// 201000: S = 0x100, A = 0x100200eff, P = 0x201000
+// S + A - P = 0xffffffff
+// 201004: S = 0x100, A = -0x7fdff0fc, P = 0x201004
+// S + A - P = 0x80000000
+// CHECK-NEXT: 201000 ffffffff 00000080
-// RUN: not ld.lld %t.o %t255.o -o %t2
-// | FileCheck %s --check-prefix=OVERFLOW
-// RUN: not ld.lld %t.o %t257.o -o %t2
-// | FileCheck %s --check-prefix=OVERFLOW
-// OVERFLOW: Relocation R_AARCH64_PREL32 out of range: 18446744071562006527 is not in [-2147483648, 4294967295]
+// RUN: not ld.lld -z max-page-size=4096 %t.o %t255.o -o %t2 2>&1 | FileCheck %s --check-prefix=OVERFLOW1
+// OVERFLOW1: relocation R_AARCH64_PREL32 out of range: -2147483649 is not in [-2147483648, 2147483647]
+
+// RUN: not ld.lld -z max-page-size=4096 %t.o %t257.o -o %t2 2>&1 | FileCheck %s --check-prefix=OVERFLOW2
+// OVERFLOW2: relocation R_AARCH64_PREL32 out of range: 4294967296 is not in [-2147483648, 2147483647]
diff --git a/test/ELF/aarch64-relocs.s b/test/ELF/aarch64-relocs.s
index 79caabcb6bb5..93a67c00c6ec 100644
--- a/test/ELF/aarch64-relocs.s
+++ b/test/ELF/aarch64-relocs.s
@@ -24,13 +24,13 @@ mystr:
.asciz "blah"
.size mystr, 4
-# S = 0x20012, A = 0x4, P = 0x20012
-# PAGE(S + A) = 0x11000
-# PAGE(P) = 0x11000
+# S = 0x210012, A = 0x4, P = 0x210012
+# PAGE(S + A) = 0x210000
+# PAGE(P) = 0x210000
#
# CHECK: Disassembly of section .R_AARCH64_ADR_PREL_PG_H121:
# CHECK-NEXT: $x.2:
-# CHECK-NEXT: 20012: 01 00 00 90 adrp x1, #0
+# CHECK-NEXT: 210012: 01 00 00 90 adrp x1, #0
.section .R_AARCH64_ADD_ABS_LO12_NC,"ax",@progbits
add x0, x0, :lo12:.L.str
@@ -38,13 +38,13 @@ mystr:
.asciz "blah"
.size mystr, 4
-# S = 0x2001b, A = 0x4
+# S = 0x21001b, A = 0x4
# R = (S + A) & 0xFFF = 0x1f
# R << 10 = 0x7c00
#
# CHECK: Disassembly of section .R_AARCH64_ADD_ABS_LO12_NC:
# CHECK-NEXT: $x.4:
-# CHECK-NEXT: 2001b: 00 7c 00 91 add x0, x0, #31
+# CHECK-NEXT: 21001b: 00 7c 00 91 add x0, x0, #31
.section .R_AARCH64_LDST64_ABS_LO12_NC,"ax",@progbits
ldr x28, [x27, :lo12:foo]
@@ -52,12 +52,12 @@ foo:
.asciz "foo"
.size mystr, 3
-# S = 0x20024, A = 0x4
+# S = 0x210024, A = 0x4
# R = ((S + A) & 0xFFF) << 7 = 0x00001400
# 0x00001400 | 0xf940177c = 0xf940177c
# CHECK: Disassembly of section .R_AARCH64_LDST64_ABS_LO12_NC:
# CHECK-NEXT: $x.6:
-# CHECK-NEXT: 20024: 7c 17 40 f9 ldr x28, [x27, #40]
+# CHECK-NEXT: 210024: 7c 17 40 f9 ldr x28, [x27, #40]
.section .SUB,"ax",@progbits
nop
@@ -66,33 +66,33 @@ sub:
# CHECK: Disassembly of section .SUB:
# CHECK-NEXT: $x.8:
-# CHECK-NEXT: 2002c: 1f 20 03 d5 nop
+# CHECK-NEXT: 21002c: 1f 20 03 d5 nop
# CHECK: sub:
-# CHECK-NEXT: 20030: 1f 20 03 d5 nop
+# CHECK-NEXT: 210030: 1f 20 03 d5 nop
.section .R_AARCH64_CALL26,"ax",@progbits
call26:
bl sub
-# S = 0x2002c, A = 0x4, P = 0x20034
+# S = 0x21002c, A = 0x4, P = 0x210034
# R = S + A - P = -0x4 = 0xfffffffc
# (R & 0x0ffffffc) >> 2 = 0x03ffffff
# 0x94000000 | 0x03ffffff = 0x97ffffff
# CHECK: Disassembly of section .R_AARCH64_CALL26:
# CHECK-NEXT: call26:
-# CHECK-NEXT: 20034: ff ff ff 97 bl #-4
+# CHECK-NEXT: 210034: ff ff ff 97 bl #-4
.section .R_AARCH64_JUMP26,"ax",@progbits
jump26:
b sub
-# S = 0x2002c, A = 0x4, P = 0x20038
+# S = 0x21002c, A = 0x4, P = 0x210038
# R = S + A - P = -0x8 = 0xfffffff8
# (R & 0x0ffffffc) >> 2 = 0x03fffffe
# 0x14000000 | 0x03fffffe = 0x17fffffe
# CHECK: Disassembly of section .R_AARCH64_JUMP26:
# CHECK-NEXT: jump26:
-# CHECK-NEXT: 20038: fe ff ff 17 b #-8
+# CHECK-NEXT: 210038: fe ff ff 17 b #-8
.section .R_AARCH64_LDST32_ABS_LO12_NC,"ax",@progbits
ldst32:
@@ -101,12 +101,12 @@ foo32:
.asciz "foo"
.size mystr, 3
-# S = 0x2003c, A = 0x4
+# S = 0x21003c, A = 0x4
# R = ((S + A) & 0xFFC) << 8 = 0x00004000
# 0x00004000 | 0xbd4000a4 = 0xbd4040a4
# CHECK: Disassembly of section .R_AARCH64_LDST32_ABS_LO12_NC:
# CHECK-NEXT: ldst32:
-# CHECK-NEXT: 2003c: a4 40 40 bd ldr s4, [x5, #64]
+# CHECK-NEXT: 21003c: a4 40 40 bd ldr s4, [x5, #64]
.section .R_AARCH64_LDST8_ABS_LO12_NC,"ax",@progbits
ldst8:
@@ -115,12 +115,12 @@ foo8:
.asciz "foo"
.size mystr, 3
-# S = 0x20044, A = 0x4
+# S = 0x210044, A = 0x4
# R = ((S + A) & 0xFFF) << 10 = 0x00012000
# 0x00012000 | 0x398001ab = 0x398121ab
# CHECK: Disassembly of section .R_AARCH64_LDST8_ABS_LO12_NC:
# CHECK-NEXT: ldst8:
-# CHECK-NEXT: 20044: ab 21 81 39 ldrsb x11, [x13, #72]
+# CHECK-NEXT: 210044: ab 21 81 39 ldrsb x11, [x13, #72]
.section .R_AARCH64_LDST128_ABS_LO12_NC,"ax",@progbits
ldst128:
@@ -129,14 +129,14 @@ foo128:
.asciz "foo"
.size mystr, 3
-# S = 0x2004c, A = 0x4
+# S = 0x21004c, A = 0x4
# R = ((S + A) & 0xFF8) << 6 = 0x00001400
# 0x00001400 | 0x3dc00274 = 0x3dc01674
# CHECK: Disassembly of section .R_AARCH64_LDST128_ABS_LO12_NC:
# CHECK: ldst128:
-# CHECK: 2004c: 74 16 c0 3d ldr q20, [x19, #80]
+# CHECK: 21004c: 74 16 c0 3d ldr q20, [x19, #80]
#foo128:
-# 20050: 66 6f 6f 00 .word
+# 210050: 66 6f 6f 00 .word
.section .R_AARCH64_LDST16_ABS_LO12_NC,"ax",@progbits
ldst16:
@@ -147,14 +147,14 @@ foo16:
.asciz "foo"
.size mystr, 4
-# S = 0x20054, A = 0x4
+# S = 0x210054, A = 0x4
# R = ((S + A) & 0x0FFC) << 9 = 0xb000
# 0xb000 | 0x7d400271 = 0x7d40b271
# CHECK: Disassembly of section .R_AARCH64_LDST16_ABS_LO12_NC:
# CHECK-NEXT: ldst16:
-# CHECK-NEXT: 20054: 71 c2 40 7d ldr h17, [x19, #96]
-# CHECK-NEXT: 20058: 61 c2 40 79 ldrh w1, [x19, #96]
-# CHECK-NEXT: 2005c: 62 c6 40 79 ldrh w2, [x19, #98]
+# CHECK-NEXT: 210054: 71 c2 40 7d ldr h17, [x19, #96]
+# CHECK-NEXT: 210058: 61 c2 40 79 ldrh w1, [x19, #96]
+# CHECK-NEXT: 21005c: 62 c6 40 79 ldrh w2, [x19, #98]
.section .R_AARCH64_MOVW_UABS,"ax",@progbits
movz1:
diff --git a/test/ELF/aarch64-thunk-pi.s b/test/ELF/aarch64-thunk-pi.s
index d5d956c669b5..345e6ee91f58 100644
--- a/test/ELF/aarch64-thunk-pi.s
+++ b/test/ELF/aarch64-thunk-pi.s
@@ -81,10 +81,14 @@ high_target2:
// CHECK-NEXT: 10000034: 1f 20 03 d5 nop
// CHECK-NEXT: 10000038: 1f 20 03 d5 nop
// CHECK-NEXT: 1000003c: 1f 20 03 d5 nop
+// CHECK-EMPTY:
+// CHECK-NEXT: high_target@plt:
// CHECK-NEXT: 10000040: 10 00 00 90 adrp x16, #0
// CHECK-NEXT: 10000044: 11 3e 40 f9 ldr x17, [x16, #120]
// CHECK-NEXT: 10000048: 10 e2 01 91 add x16, x16, #120
// CHECK-NEXT: 1000004c: 20 02 1f d6 br x17
+// CHECK-EMPTY:
+// CHECK-NEXT: low_target@plt:
// CHECK-NEXT: 10000050: 10 00 00 90 adrp x16, #0
// CHECK-NEXT: 10000054: 11 42 40 f9 ldr x17, [x16, #128]
// CHECK-NEXT: 10000058: 10 02 02 91 add x16, x16, #128
diff --git a/test/ELF/aarch64-thunk-section-location.s b/test/ELF/aarch64-thunk-section-location.s
index 606c6941579e..36ba33835eda 100644
--- a/test/ELF/aarch64-thunk-section-location.s
+++ b/test/ELF/aarch64-thunk-section-location.s
@@ -1,7 +1,7 @@
// REQUIRES: aarch64
// RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %s -o %t
// RUN: ld.lld %t -o %t2 2>&1
-// RUN: llvm-objdump -d -start-address=134086664 -stop-address=134086676 -triple=aarch64-linux-gnu %t2 | FileCheck %s
+// RUN: llvm-objdump -d -start-address=136118280 -stop-address=136118292 -triple=aarch64-linux-gnu %t2 | FileCheck %s
// Check that the range extension thunks are dumped close to the aarch64 branch
// range of 128 MiB
.section .text.1, "ax", %progbits
@@ -35,7 +35,7 @@ high_target:
ret
// CHECK: __AArch64AbsLongThunk_high_target:
-// CHECK-NEXT: 7fe0008: 50 00 00 58 ldr x16, #8
-// CHECK-NEXT: 7fe000c: 00 02 1f d6 br x16
+// CHECK-NEXT: 81d0008: 50 00 00 58 ldr x16, #8
+// CHECK-NEXT: 81d000c: 00 02 1f d6 br x16
// CHECK: $d:
-// CHECK-NEXT: 7fe0010: 00 10 02 08 .word 0x08021000
+// CHECK-NEXT: 81d0010: 00 10 21 08 .word 0x08211000
diff --git a/test/ELF/aarch64-tls-gdie.s b/test/ELF/aarch64-tls-gdie.s
index ab7461ac2973..3b795f60e0d8 100644
--- a/test/ELF/aarch64-tls-gdie.s
+++ b/test/ELF/aarch64-tls-gdie.s
@@ -21,14 +21,14 @@ _start:
// SEC-NEXT: SHF_ALLOC
// SEC-NEXT: SHF_WRITE
// SEC-NEXT: ]
-// SEC-NEXT: Address: 0x300B0
+// SEC-NEXT: Address: 0x2200B0
-// page(0x300B0) - page(0x20004) = 65536
+// page(0x2200B0) - page(0x20004) = 65536
// 0x0B0 = 176
// CHECK: _start:
-// CHECK-NEXT: 20000: {{.*}} nop
-// CHECK-NEXT: 20004: {{.*}} adrp x0, #65536
-// CHECK-NEXT: 20008: {{.*}} ldr x0, [x0, #176]
-// CHECK-NEXT: 2000c: {{.*}} nop
-// CHECK-NEXT: 20010: {{.*}} nop
+// CHECK-NEXT: 210000: {{.*}} nop
+// CHECK-NEXT: 210004: {{.*}} adrp x0, #65536
+// CHECK-NEXT: 210008: {{.*}} ldr x0, [x0, #176]
+// CHECK-NEXT: 21000c: {{.*}} nop
+// CHECK-NEXT: 210010: {{.*}} nop
diff --git a/test/ELF/aarch64-tls-gdle.s b/test/ELF/aarch64-tls-gdle.s
index 6763c50838da..882ec8c1ae17 100644
--- a/test/ELF/aarch64-tls-gdle.s
+++ b/test/ELF/aarch64-tls-gdle.s
@@ -5,17 +5,17 @@
# RUN: llvm-objdump -d %tout | FileCheck %s
# RUN: llvm-readobj -s -r %tout | FileCheck -check-prefix=RELOC %s
-#Local-Dynamic to Initial-Exec relax creates no
+#Local-Dynamic to Local-Exec relax creates no
#RELOC: Relocations [
#RELOC-NEXT: ]
-# TCB size = 0x16 and foo is first element from TLS register.
+# TCB size = 64 and foo is first element from TLS register.
# CHECK: Disassembly of section .text:
# CHECK: _start:
-# CHECK: 20000: 00 00 a0 d2 movz x0, #0, lsl #16
-# CHECK: 20004: 00 02 80 f2 movk x0, #16
-# CHECK: 20008: 1f 20 03 d5 nop
-# CHECK: 2000c: 1f 20 03 d5 nop
+# CHECK: 210000: 00 00 a0 d2 movz x0, #0, lsl #16
+# CHECK: 210004: 00 08 80 f2 movk x0, #64
+# CHECK: 210008: 1f 20 03 d5 nop
+# CHECK: 21000c: 1f 20 03 d5 nop
.globl _start
_start:
diff --git a/test/ELF/aarch64-tls-ie.s b/test/ELF/aarch64-tls-ie.s
index fba7cd8af51f..5786fe3a0a97 100644
--- a/test/ELF/aarch64-tls-ie.s
+++ b/test/ELF/aarch64-tls-ie.s
@@ -15,7 +15,7 @@
#RELOC-NEXT: SHF_ALLOC
#RELOC-NEXT: SHF_WRITE
#RELOC-NEXT: ]
-#RELOC-NEXT: Address: 0x300B0
+#RELOC-NEXT: Address: 0x2200B0
#RELOC-NEXT: Offset: 0x200B0
#RELOC-NEXT: Size: 16
#RELOC-NEXT: Link: 0
@@ -25,21 +25,21 @@
#RELOC-NEXT: }
#RELOC: Relocations [
#RELOC-NEXT: Section ({{.*}}) .rela.dyn {
-#RELOC-NEXT: 0x300B8 R_AARCH64_TLS_TPREL64 bar 0x0
-#RELOC-NEXT: 0x300B0 R_AARCH64_TLS_TPREL64 foo 0x0
+#RELOC-NEXT: 0x2200B8 R_AARCH64_TLS_TPREL64 bar 0x0
+#RELOC-NEXT: 0x2200B0 R_AARCH64_TLS_TPREL64 foo 0x0
#RELOC-NEXT: }
#RELOC-NEXT:]
-# Page(0x300B0) - Page(0x20000) = 0x10000 = 65536
-# 0x300B0 & 0xff8 = 0xB0 = 176
-# Page(0x300B8) - Page(0x20000) = 0x10000 = 65536
-# 0x300B8 & 0xff8 = 0xB8 = 184
+# Page(0x2200B0) - Page(0x210000) = 0x10000 = 65536
+# 0x2200B0 & 0xff8 = 0xB0 = 176
+# Page(0x2200B8) - Page(0x210000) = 0x10000 = 65536
+# 0x2200B8 & 0xff8 = 0xB8 = 184
#CHECK: Disassembly of section .text:
#CHECK: _start:
-#CHECK: 20000: 80 00 00 90 adrp x0, #65536
-#CHECK: 20004: 00 58 40 f9 ldr x0, [x0, #176]
-#CHECK: 20008: 80 00 00 90 adrp x0, #65536
-#CHECK: 2000c: 00 5c 40 f9 ldr x0, [x0, #184]
+#CHECK: 210000: 80 00 00 90 adrp x0, #65536
+#CHECK: 210004: 00 58 40 f9 ldr x0, [x0, #176]
+#CHECK: 210008: 80 00 00 90 adrp x0, #65536
+#CHECK: 21000c: 00 5c 40 f9 ldr x0, [x0, #184]
.globl _start
_start:
diff --git a/test/ELF/aarch64-tls-iele.s b/test/ELF/aarch64-tls-iele.s
index c97a578f8dc2..0229d6676cd5 100644
--- a/test/ELF/aarch64-tls-iele.s
+++ b/test/ELF/aarch64-tls-iele.s
@@ -9,13 +9,13 @@
# RELOC: Relocations [
# RELOC-NEXT: ]
-# TCB size = 0x16 and foo is first element from TLS register.
+# TCB size = 64 and foo is first element from TLS register.
# CHECK: Disassembly of section .text:
# CHECK: _start:
-# CHECK-NEXT: 20000: 00 00 a0 d2 movz x0, #0, lsl #16
-# CHECK-NEXT: 20004: 80 02 80 f2 movk x0, #20
-# CHECK-NEXT: 20008: 00 00 a0 d2 movz x0, #0, lsl #16
-# CHECK-NEXT: 2000c: 00 02 80 f2 movk x0, #16
+# CHECK-NEXT: 210000: 00 00 a0 d2 movz x0, #0, lsl #16
+# CHECK-NEXT: 210004: 80 08 80 f2 movk x0, #68
+# CHECK-NEXT: 210008: 00 00 a0 d2 movz x0, #0, lsl #16
+# CHECK-NEXT: 21000c: 00 08 80 f2 movk x0, #64
.section .tdata
.align 2
diff --git a/test/ELF/aarch64-tls-le.s b/test/ELF/aarch64-tls-le.s
index e5b1c208a185..49c322facb12 100644
--- a/test/ELF/aarch64-tls-le.s
+++ b/test/ELF/aarch64-tls-le.s
@@ -4,7 +4,7 @@
# RUN: llvm-objdump -d %tout | FileCheck %s
# RUN: llvm-readobj -s -r %tout | FileCheck -check-prefix=RELOC %s
-#Local-Dynamic to Initial-Exec relax creates no
+#Local-Dynamic to Local-Exec relax creates no
#RELOC: Relocations [
#RELOC-NEXT: ]
@@ -13,19 +13,36 @@ _start:
mrs x0, TPIDR_EL0
add x0, x0, :tprel_hi12:v1
add x0, x0, :tprel_lo12_nc:v1
+ mrs x0, TPIDR_EL0
+ add x0, x0, :tprel_hi12:v2
+ add x0, x0, :tprel_lo12_nc:v2
-# TCB size = 0x16 and foo is first element from TLS register.
+# TCB size = 64 and foo is first element from TLS register.
#CHECK: Disassembly of section .text:
#CHECK: _start:
-#CHECK: 20000: 40 d0 3b d5 mrs x0, TPIDR_EL0
-#CHECK: 20004: 00 00 40 91 add x0, x0, #0, lsl #12
-#CHECK: 20008: 00 40 00 91 add x0, x0, #16
+#CHECK: 210000: 40 d0 3b d5 mrs x0, TPIDR_EL0
+#CHECK: 210004: 00 00 40 91 add x0, x0, #0, lsl #12
+#CHECK: 210008: 00 00 01 91 add x0, x0, #64
+#CHECK: 21000c: 40 d0 3b d5 mrs x0, TPIDR_EL0
+#CHECK: 210010: 00 fc 7f 91 add x0, x0, #4095, lsl #12
+#CHECK: 210014: 00 e0 3f 91 add x0, x0, #4088
-.type v1,@object
.section .tbss,"awT",@nobits
+
+.type v1,@object
.globl v1
.p2align 2
v1:
.word 0
.size v1, 4
+# The current offset from the thread pointer is 68. Raise it to just below the
+# 24-bit limit.
+.space (0xfffff8 - 68)
+
+.type v2,@object
+.globl v2
+.p2align 2
+v2:
+.word 0
+.size v2, 4
diff --git a/test/ELF/aarch64-tlsld-ldst.s b/test/ELF/aarch64-tlsld-ldst.s
index 9de3a38044d9..8ebdc2f152a6 100644
--- a/test/ELF/aarch64-tlsld-ldst.s
+++ b/test/ELF/aarch64-tlsld-ldst.s
@@ -25,28 +25,28 @@ _start: mrs x8, TPIDR_EL0
ldrb w0, [x8, :tprel_lo12_nc:var4]
// CHECK: _start:
-// CHECK-NEXT: 20000: 48 d0 3b d5 mrs x8, TPIDR_EL0
-// 0x0 + c10 = 0xc10 = tcb (16-bytes) + var0
-// CHECK-NEXT: 20004: 08 01 40 91 add x8, x8, #0, lsl #12
-// CHECK-NEXT: 20008: 14 05 c3 3d ldr q20, [x8, #3088]
-// 0x1000 + 0x820 = 0x1820 = tcb + var1
-// CHECK-NEXT: 2000c: 08 05 40 91 add x8, x8, #1, lsl #12
-// CHECK-NEXT: 20010: 00 11 44 f9 ldr x0, [x8, #2080]
-// 0x2000 + 0x428 = 0x2428 = tcb + var2
-// CHECK-NEXT: 20014: 08 09 40 91 add x8, x8, #2, lsl #12
-// CHECK-NEXT: 20018: 00 29 44 b9 ldr w0, [x8, #1064]
-// 0x3000 + 0x2c = 0x302c = tcb + var3
-// CHECK-NEXT: 2001c: 08 0d 40 91 add x8, x8, #3, lsl #12
-// CHECK-NEXT: 20020: 00 59 40 79 ldrh w0, [x8, #44]
-// 0x3000 + 0xc2e = 0x32ce = tcb + var4
-// CHECK-NEXT: 20024: 08 0d 40 91 add x8, x8, #3, lsl #12
-// CHECK-NEXT: 20028: 00 b9 70 39 ldrb w0, [x8, #3118]
+// CHECK-NEXT: 210000: 48 d0 3b d5 mrs x8, TPIDR_EL0
+// 0x0 + c40 = 0xc40 = tcb (64-bytes) + var0
+// CHECK-NEXT: 210004: 08 01 40 91 add x8, x8, #0, lsl #12
+// CHECK-NEXT: 210008: 14 11 c3 3d ldr q20, [x8, #3136]
+// 0x1000 + 0x850 = 0x1850 = tcb + var1
+// CHECK-NEXT: 21000c: 08 05 40 91 add x8, x8, #1, lsl #12
+// CHECK-NEXT: 210010: 00 29 44 f9 ldr x0, [x8, #2128]
+// 0x2000 + 0x458 = 0x2458 = tcb + var2
+// CHECK-NEXT: 210014: 08 09 40 91 add x8, x8, #2, lsl #12
+// CHECK-NEXT: 210018: 00 59 44 b9 ldr w0, [x8, #1112]
+// 0x3000 + 0x5c = 0x305c = tcb + var3
+// CHECK-NEXT: 21001c: 08 0d 40 91 add x8, x8, #3, lsl #12
+// CHECK-NEXT: 210020: 00 b9 40 79 ldrh w0, [x8, #92]
+// 0x3000 + 0xc5e = 0x3c5e = tcb + var4
+// CHECK-NEXT: 210024: 08 0d 40 91 add x8, x8, #3, lsl #12
+// CHECK-NEXT: 210028: 00 79 71 39 ldrb w0, [x8, #3166]
-// CHECK-SYMS: 0000000000000c00 0 TLS GLOBAL DEFAULT 2 var0
-// CHECK-SYMS-NEXT: 0000000000001810 4 TLS GLOBAL DEFAULT 2 var1
-// CHECK-SYMS-NEXT: 0000000000002418 2 TLS GLOBAL DEFAULT 2 var2
-// CHECK-SYMS-NEXT: 000000000000301c 1 TLS GLOBAL DEFAULT 2 var3
-// CHECK-SYMS-NEXT: 0000000000003c1e 0 TLS GLOBAL DEFAULT 2 var4
+// CHECK-SYMS: 0000000000000c00 16 TLS GLOBAL DEFAULT 2 var0
+// CHECK-SYMS-NEXT: 0000000000001810 8 TLS GLOBAL DEFAULT 2 var1
+// CHECK-SYMS-NEXT: 0000000000002418 4 TLS GLOBAL DEFAULT 2 var2
+// CHECK-SYMS-NEXT: 000000000000301c 2 TLS GLOBAL DEFAULT 2 var3
+// CHECK-SYMS-NEXT: 0000000000003c1e 1 TLS GLOBAL DEFAULT 2 var4
.globl var0
.globl var1
@@ -59,12 +59,12 @@ _start: mrs x8, TPIDR_EL0
.type var3,@object
.section .tbss,"awT",@nobits
- .balign 16
+ .balign 64
.space 1024 * 3
var0:
.quad 0
.quad 0
- .size var1, 16
+ .size var0, 16
.space 1024 * 3
var1:
.quad 0
@@ -72,14 +72,14 @@ var1:
.space 1024 * 3
var2:
.word 0
- .size var1, 4
+ .size var2, 4
.space 1024 * 3
var3:
.hword 0
- .size var2, 2
+ .size var3, 2
.space 1024 * 3
var4:
.byte 0
- .size var3, 1
+ .size var4, 1
.space 1024 * 3
diff --git a/test/ELF/aarch64-tstbr14-reloc.s b/test/ELF/aarch64-tstbr14-reloc.s
index 779ca6b808a8..9e9d969d9bb6 100644
--- a/test/ELF/aarch64-tstbr14-reloc.s
+++ b/test/ELF/aarch64-tstbr14-reloc.s
@@ -13,19 +13,19 @@
# 0x11028 - 24 = 0x20010
# CHECK: Disassembly of section .text:
# CHECK-NEXT: _foo:
-# CHECK-NEXT: 20000: {{.*}} nop
-# CHECK-NEXT: 20004: {{.*}} nop
-# CHECK-NEXT: 20008: {{.*}} nop
-# CHECK-NEXT: 2000c: {{.*}} nop
+# CHECK-NEXT: 210000: {{.*}} nop
+# CHECK-NEXT: 210004: {{.*}} nop
+# CHECK-NEXT: 210008: {{.*}} nop
+# CHECK-NEXT: 21000c: {{.*}} nop
# CHECK: _bar:
-# CHECK-NEXT: 20010: {{.*}} nop
-# CHECK-NEXT: 20014: {{.*}} nop
-# CHECK-NEXT: 20018: {{.*}} nop
+# CHECK-NEXT: 210010: {{.*}} nop
+# CHECK-NEXT: 210014: {{.*}} nop
+# CHECK-NEXT: 210018: {{.*}} nop
# CHECK: _start:
-# CHECK-NEXT: 2001c: {{.*}} tbnz w3, #15, #-28
-# CHECK-NEXT: 20020: {{.*}} tbnz w3, #15, #-16
-# CHECK-NEXT: 20024: {{.*}} tbz x6, #45, #-36
-# CHECK-NEXT: 20028: {{.*}} tbz x6, #45, #-24
+# CHECK-NEXT: 21001c: {{.*}} tbnz w3, #15, #-28
+# CHECK-NEXT: 210020: {{.*}} tbnz w3, #15, #-16
+# CHECK-NEXT: 210024: {{.*}} tbz x6, #45, #-36
+# CHECK-NEXT: 210028: {{.*}} tbz x6, #45, #-24
#DSOREL: Section {
#DSOREL: Index:
@@ -79,10 +79,14 @@
#DSO-NEXT: 10044: {{.*}} nop
#DSO-NEXT: 10048: {{.*}} nop
#DSO-NEXT: 1004c: {{.*}} nop
+#DSO-EMPTY:
+#DSO-NEXT: _foo@plt:
#DSO-NEXT: 10050: {{.*}} adrp x16, #65536
#DSO-NEXT: 10054: {{.*}} ldr x17, [x16, #24]
#DSO-NEXT: 10058: {{.*}} add x16, x16, #24
#DSO-NEXT: 1005c: {{.*}} br x17
+#DSO-EMPTY:
+#DSO-NEXT: _bar@plt:
#DSO-NEXT: 10060: {{.*}} adrp x16, #65536
#DSO-NEXT: 10064: {{.*}} ldr x17, [x16, #32]
#DSO-NEXT: 10068: {{.*}} add x16, x16, #32
diff --git a/test/ELF/aarch64-undefined-weak.s b/test/ELF/aarch64-undefined-weak.s
index e2316acf36a0..ef14bfc237ab 100644
--- a/test/ELF/aarch64-undefined-weak.s
+++ b/test/ELF/aarch64-undefined-weak.s
@@ -34,16 +34,16 @@ _start:
ldr x8, target
// CHECK: Disassembly of section .text:
-// 131072 = 0x20000
-// CHECK: 20000: {{.*}} b #4
-// CHECK-NEXT: 20004: {{.*}} bl #4
-// CHECK-NEXT: 20008: {{.*}} b.eq #4
-// CHECK-NEXT: 2000c: {{.*}} cbz x1, #4
-// CHECK-NEXT: 20010: {{.*}} adr x0, #0
-// CHECK-NEXT: 20014: {{.*}} adrp x0, #-131072
-// CHECK: 20018: {{.*}} .word 0x00000000
-// CHECK-NEXT: 2001c: {{.*}} .word 0x00000000
-// CHECK-NEXT: 20020: {{.*}} .word 0x00000000
-// CHECK-NEXT: 20024: {{.*}} .short 0x0000
+// 2162688 = 0x210000
+// CHECK: 210000: {{.*}} b #4
+// CHECK-NEXT: 210004: {{.*}} bl #4
+// CHECK-NEXT: 210008: {{.*}} b.eq #4
+// CHECK-NEXT: 21000c: {{.*}} cbz x1, #4
+// CHECK-NEXT: 210010: {{.*}} adr x0, #0
+// CHECK-NEXT: 210014: {{.*}} adrp x0, #0
+// CHECK: 210018: {{.*}} .word 0x00000000
+// CHECK-NEXT: 21001c: {{.*}} .word 0x00000000
+// CHECK-NEXT: 210020: {{.*}} .word 0x00000000
+// CHECK-NEXT: 210024: {{.*}} .short 0x0000
// CHECK: $x.2:
-// CHECK-NEXT: 20026: {{.*}} ldr x8, #0
+// CHECK-NEXT: 210026: {{.*}} ldr x8, #0
diff --git a/test/ELF/amdgpu-elf-flags-err.s b/test/ELF/amdgpu-elf-flags-err.s
index b5619352fb04..ae68afa6586d 100644
--- a/test/ELF/amdgpu-elf-flags-err.s
+++ b/test/ELF/amdgpu-elf-flags-err.s
@@ -1,6 +1,6 @@
# REQUIRES: amdgpu
-# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx802 -filetype=obj %S/Inputs/amdgpu-kernel-0.s -o %t-0.o
-# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx803 -filetype=obj %S/Inputs/amdgpu-kernel-1.s -o %t-1.o
+# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx802 -mattr=-code-object-v3 -filetype=obj %S/Inputs/amdgpu-kernel-0.s -o %t-0.o
+# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx803 -mattr=-code-object-v3 -filetype=obj %S/Inputs/amdgpu-kernel-1.s -o %t-1.o
# RUN: not ld.lld -shared %t-0.o %t-1.o -o /dev/null 2>&1 | FileCheck %s
# CHECK: error: incompatible e_flags: {{.*}}-1.o
diff --git a/test/ELF/amdgpu-elf-flags.s b/test/ELF/amdgpu-elf-flags.s
index d062dac748ea..c96913cf31d3 100644
--- a/test/ELF/amdgpu-elf-flags.s
+++ b/test/ELF/amdgpu-elf-flags.s
@@ -1,6 +1,6 @@
# REQUIRES: amdgpu
-# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx803 -filetype=obj %S/Inputs/amdgpu-kernel-0.s -o %t-0.o
-# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx803 -filetype=obj %S/Inputs/amdgpu-kernel-1.s -o %t-1.o
+# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx803 -mattr=-code-object-v3 -filetype=obj %S/Inputs/amdgpu-kernel-0.s -o %t-0.o
+# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx803 -mattr=-code-object-v3 -filetype=obj %S/Inputs/amdgpu-kernel-1.s -o %t-1.o
# RUN: ld.lld -shared %t-0.o %t-1.o -o %t.so
# RUN: llvm-readobj -file-headers %t.so | FileCheck %s
diff --git a/test/ELF/amdgpu-kernels.s b/test/ELF/amdgpu-kernels.s
index 01b1ef2757fb..5888201acf37 100644
--- a/test/ELF/amdgpu-kernels.s
+++ b/test/ELF/amdgpu-kernels.s
@@ -1,5 +1,5 @@
# REQUIRES: amdgpu
-# RUN: llvm-mc -filetype=obj -triple amdgcn--amdhsa -mcpu=kaveri %s -o %t.o
+# RUN: llvm-mc -filetype=obj -triple amdgcn--amdhsa -mcpu=kaveri -mattr=-code-object-v3 %s -o %t.o
# RUN: ld.lld -shared %t.o -o %t
# RUN: llvm-readobj -sections -symbols -program-headers %t | FileCheck %s
diff --git a/test/ELF/archive-fetch.s b/test/ELF/archive-fetch.s
new file mode 100644
index 000000000000..201218f4cc26
--- /dev/null
+++ b/test/ELF/archive-fetch.s
@@ -0,0 +1,15 @@
+# REQUIRES: x86
+
+# We have a code in LLD that prevents fetching the same object from archive file twice.
+# This test triggers that code, without it we would fail to link output.
+
+# RUN: echo '.globl foo, bar; foo:' | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %tfoo.o
+# RUN: echo '.globl foo, bar; bar:' | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %tbar.o
+# RUN: rm -f %t.a
+# RUN: llvm-ar rcs %t.a %tfoo.o %tbar.o
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld %t.a %t.o -o /dev/null
+
+_start:
+callq foo
diff --git a/test/ELF/arm-bl-v6-inrange.s b/test/ELF/arm-bl-v6-inrange.s
new file mode 100644
index 000000000000..0e186c53f3c3
--- /dev/null
+++ b/test/ELF/arm-bl-v6-inrange.s
@@ -0,0 +1,47 @@
+// REQUIRES: arm
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv6-none-linux-gnueabi %s -o %t
+// RUN: echo "SECTIONS { \
+// RUN: .callee1 0x100004 : { *(.callee_low) } \
+// RUN: .caller 0x500000 : { *(.text) } \
+// RUN: .callee2 0x900004 : { *(.callee_high) } } " > %t.script
+// RUN: ld.lld %t --script %t.script -o %t2 2>&1
+// RUN: llvm-objdump -d -triple=thumbv6-none-linux-gnueabi %t2 | FileCheck -check-prefix=CHECK-THUMB %s
+// RUN: llvm-objdump -d -triple=armv6-none-linux-gnueabi %t2 | FileCheck -check-prefix=CHECK-ARM %s
+
+// On older Arm Architectures such as v5 and v6 the Thumb BL and BLX relocation
+// uses a slightly different encoding that has a lower range. These relocations
+// are at the extreme range of what is permitted.
+ .thumb
+ .text
+ .syntax unified
+ .cpu arm1176jzf-s
+ .globl _start
+ .type _start,%function
+_start:
+ bl thumbfunc
+ bl armfunc
+ bx lr
+
+ .section .callee_low, "ax", %progbits
+ .globl thumbfunc
+ .type thumbfunc, %function
+thumbfunc:
+ bx lr
+// CHECK-THUMB: Disassembly of section .callee1:
+// CHECK-THUMB-NEXT: thumbfunc:
+// CHECK-THUMB-NEXT: 100004: 70 47 bx lr
+// CHECK-THUMB-NEXT: Disassembly of section .caller:
+// CHECK-THUMB-NEXT: _start:
+// CHECK-THUMB-NEXT: 500000: 00 f4 00 f8 bl #-4194304
+// CHECK-THUMB-NEXT: 500004: ff f3 fe ef blx #4194300
+// CHECK-THUMB-NEXT: 500008: 70 47 bx lr
+
+ .arm
+ .section .callee_high, "ax", %progbits
+ .globl armfunc
+ .type armfunc, %function
+armfunc:
+ bx lr
+// CHECK-ARM: Disassembly of section .callee2:
+// CHECK-ARM-NEXT: armfunc:
+// CHECK-ARM-NEXT: 900004: 1e ff 2f e1 bx lr
diff --git a/test/ELF/arm-bl-v6.s b/test/ELF/arm-bl-v6.s
index c27a99e6b9e7..13be7694120d 100644
--- a/test/ELF/arm-bl-v6.s
+++ b/test/ELF/arm-bl-v6.s
@@ -1,22 +1,23 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=arm-none-linux-gnueabi %s -o %t
-// RUN: ld.lld %t -o /dev/null 2>&1 | FileCheck %s
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv6-none-linux-gnueabi %s -o %t
+// RUN: ld.lld %t -o %t2 2>&1
+// RUN: llvm-objdump -d -triple=armv6-none-linux-gnueabi -start-address=69632 -stop-address=69640 %t2 | FileCheck -check-prefix=CHECK-ARM1 %s
+// RUN: llvm-objdump -d -triple=thumbv6-none-linux-gnueabi %t2 -start-address=69640 -stop-address=69644 | FileCheck -check-prefix=CHECK-THUMB1 %s
+// RUN: llvm-objdump -d -triple=armv6-none-linux-gnueabi -start-address=2166796 -stop-address=2166804 %t2 | FileCheck -check-prefix=CHECK-ARM2 %s
+// RUN: llvm-objdump -d -triple=thumbv6-none-linux-gnueabi %t2 -start-address=6365184 -stop-address=6365186 | FileCheck -check-prefix=CHECK-THUMB2 %s
// On Arm v6 the range of a Thumb BL instruction is only 4 megabytes as the
// extended range encoding is not supported. The following example has a Thumb
// BL that is out of range on ARM v6 and requires a range extension thunk.
// As v6 does not support MOVT or MOVW instructions the Thunk must not
-// use these instructions either. At present we don't support v6 so we give a
-// warning for unsupported features.
+// use these instructions either.
+
-// CHECK: warning: lld uses extended branch encoding, no object with architecture supporting feature detected.
-// CHECK-NEXT: warning: lld may use movt/movw, no object with architecture supporting feature detected.
// ARM v6 supports blx so we shouldn't see the blx not supported warning.
// CHECK-NOT: warning: lld uses blx instruction, no object with architecture supporting feature detected.
.text
.syntax unified
.cpu arm1176jzf-s
- .eabi_attribute 6, 6 @ Tag_CPU_arch
.globl _start
.type _start,%function
.balign 0x1000
@@ -24,6 +25,10 @@ _start:
bl thumbfunc
bx lr
+// CHECK-ARM1: Disassembly of section .text:
+// CHECK-ARM1-NEXT: _start:
+// CHECK-ARM1-NEXT: 11000: 00 00 00 fa blx #0 <thumbfunc>
+// CHECK-ARM1-NEXT: 11004: 1e ff 2f e1 bx lr
.thumb
.section .text.2, "ax", %progbits
.globl thumbfunc
@@ -31,11 +36,17 @@ _start:
thumbfunc:
bl farthumbfunc
-// 6 Megabytes, enough to make farthumbfunc out of range of caller on a v6
-// Arm, but not on a v7 Arm.
+// CHECK-THUMB1: thumbfunc:
+// CHECK-THUMB1-NEXT: 11008: 00 f2 00 e8 blx #2097152
+// 6 Megabytes, enough to make farthumbfunc out of range of caller
+// on a v6 Arm, but not on a v7 Arm.
+
.section .text.3, "ax", %progbits
.space 0x200000
-
+// CHECK-ARM2: __ARMv5ABSLongThunk_farthumbfunc:
+// CHECK-ARM2-NEXT: 21100c: 04 f0 1f e5 ldr pc, [pc, #-4]
+// CHECK-ARM2: $d:
+// CHECK-ARM2-NEXT: 211010: 01 20 61 00 .word 0x00612001
.section .text.4, "ax", %progbits
.space 0x200000
@@ -49,3 +60,5 @@ thumbfunc:
.type farthumbfunc,%function
farthumbfunc:
bx lr
+// CHECK-THUMB2: farthumbfunc:
+// CHECK-THUMB2-NEXT: 612000: 70 47 bx lr
diff --git a/test/ELF/arm-blx-v4t.s b/test/ELF/arm-blx-v4t.s
index f526b3b01f4a..6c2b69885a10 100644
--- a/test/ELF/arm-blx-v4t.s
+++ b/test/ELF/arm-blx-v4t.s
@@ -1,19 +1,16 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=arm-none-linux-gnueabi %s -o %t
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=arm-none-linux-gnueabi %s -o %t
// RUN: ld.lld %t -o /dev/null 2>&1 | FileCheck %s
// On Arm v4t there is no blx instruction so all interworking must go via
// a thunk. At present we don't support v4t so we give a warning for unsupported
// features.
-// CHECK: warning: lld uses blx instruction, no object with architecture supporting feature detected.
-// CHECK-NEXT: warning: lld uses extended branch encoding, no object with architecture supporting feature detected.
-// CHECK-NEXT: warning: lld may use movt/movw, no object with architecture supporting feature detected.
+// CHECK: warning: lld uses blx instruction, no object with architecture supporting feature detected
.text
.syntax unified
.cpu arm7tdmi
- .eabi_attribute 6, 2 @ Tag_CPU_arch
.arm
.globl _start
.type _start,%function
diff --git a/test/ELF/arm-branch-rangethunk.s b/test/ELF/arm-branch-rangethunk.s
index 739a7707dbec..7d83c8735cb0 100644
--- a/test/ELF/arm-branch-rangethunk.s
+++ b/test/ELF/arm-branch-rangethunk.s
@@ -1,9 +1,9 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
-// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %S/Inputs/far-arm-abs.s -o %tfar
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-none-linux-gnueabi %S/Inputs/far-arm-abs.s -o %tfar
// RUN: ld.lld %t %tfar -o %t2 2>&1
// RUN: llvm-objdump -d -triple=armv7a-none-linux-gnueabi %t2 | FileCheck --check-prefix=SHORT %s
-// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %S/Inputs/far-long-arm-abs.s -o %tfarlong
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-none-linux-gnueabi %S/Inputs/far-long-arm-abs.s -o %tfarlong
// RUN: ld.lld %t %tfarlong -o %t3 2>&1
// RUN: llvm-objdump -d -triple=armv7a-none-linux-gnueabi %t3 | FileCheck --check-prefix=LONG %s
.syntax unified
diff --git a/test/ELF/arm-branch-undef-weak-plt-thunk.s b/test/ELF/arm-branch-undef-weak-plt-thunk.s
index f47ed61ca5a6..919d4f5bdc33 100644
--- a/test/ELF/arm-branch-undef-weak-plt-thunk.s
+++ b/test/ELF/arm-branch-undef-weak-plt-thunk.s
@@ -1,7 +1,7 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %S/Inputs/arm-shared.s -o %t
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-none-linux-gnueabi %S/Inputs/arm-shared.s -o %t
// RUN: ld.lld %t --shared -o %t.so
-// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t2
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t2
// RUN: ld.lld %t2 %t.so -o %t3
// RUN: llvm-objdump -d -triple=armv7a-none-linux-gnueabi -start-address=69632 -stop-address=69664 %t3 | FileCheck %s
diff --git a/test/ELF/arm-combined-dynrel-ifunc.s b/test/ELF/arm-combined-dynrel-ifunc.s
new file mode 100644
index 000000000000..2761357fd98d
--- /dev/null
+++ b/test/ELF/arm-combined-dynrel-ifunc.s
@@ -0,0 +1,49 @@
+// REQUIRES: arm
+// RUN: llvm-mc -filetype=obj -arm-add-build-attributes -triple=armv7a-linux-gnueabihf %p/Inputs/arm-shared.s -o %t-lib.o
+// RUN: llvm-mc -filetype=obj -arm-add-build-attributes -triple=armv7a-linux-gnueabihf %s -o %t.o
+// RUN: ld.lld %t-lib.o --shared -o %t.so
+// RUN: echo "SECTIONS { \
+// RUN: .text : { *(.text) } \
+// RUN: .rela.dyn : { *(.rel.dyn) *(.rel.plt) } \
+// RUN: } " > %t.script
+// RUN: ld.lld %t.o -o %t.axf %t.so --script %t.script
+// RUN: llvm-readobj --section-headers --dynamic-table %t.axf | FileCheck %s
+
+// The linker script above combines the .rela.dyn and .rela.plt into a single
+// table. ELF is clear that the DT_PLTRELSZ should match the subset of
+// relocations that is associated with the PLT. It is less clear about what
+// the value of DT_RELASZ should be. ELF implies that it should be the size
+// of the single table so that DT_RELASZ includes DT_PLTRELSZ. The loader in
+// glibc permits this as long as .rela.plt comes after .rela.dyn in the
+// combined table. In the ARM case irelative relocations do not count as PLT
+// relocs.
+
+.text
+.globl indirect
+.type indirect,%gnu_indirect_function
+indirect:
+ bx lr
+
+.globl bar2 // from Inputs/arm-shared.s
+
+.text
+.globl _start
+.type _start,%function
+main:
+ bl indirect
+ bl bar2
+ .word indirect(got)
+ .word bar2(got)
+ bx lr
+
+// CHECK: Name: .rela.dyn
+// CHECK-NEXT: Type: SHT_REL
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: SHF_ALLOC
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address:
+// CHECK-NEXT: Offset:
+// CHECK-NEXT: Size: 24
+
+// CHECK: 0x00000012 RELSZ 24 (bytes)
+// CHECK: 0x00000002 PLTRELSZ 8 (bytes)
diff --git a/test/ELF/arm-extreme-range-pi-thunk.s b/test/ELF/arm-extreme-range-pi-thunk.s
new file mode 100644
index 000000000000..5daf38807ba1
--- /dev/null
+++ b/test/ELF/arm-extreme-range-pi-thunk.s
@@ -0,0 +1,82 @@
+// REQUIRES: arm
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
+// RUN: echo "SECTIONS {" > %t.script
+// RUN: echo " .text_low 0x130 : { *(.text) }" >> %t.script
+// RUN: echo " .text_high 0xf0000000 : AT(0x1000) { *(.text_high) }" >> %t.script
+// RUN: echo " } " >> %t.script
+// RUN: ld.lld --script %t.script --pie --static %t -o %t2 2>&1
+// RUN: llvm-objdump -d -triple=armv7a-none-linux-gnueabi %t2 | FileCheck %s
+
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t3
+// RUN: ld.lld --script %t.script --pie %t3 -o %t4 2>&1
+// RUN: llvm-objdump -d -triple=thumbv7a-none-linux-gnueabi %t4 | FileCheck -check-prefix=CHECK-THUMB %s
+
+// Check that we can create Arm and Thumb v7a Position Independent Thunks that
+// can span the address space without triggering overflow errors. We use an
+// AT(0x1000) for .text_high to avoid creating an almost 4Gb size file.
+ .syntax unified
+ .text
+ .global _start
+ .type _start, %function
+_start:
+ bl high
+ bx lr
+
+ .section .text_high, "ax", %progbits
+ .global high
+ .type high, %function
+high:
+ bl _start
+ bx lr
+
+// ARMv7a instructions and relocations.
+
+// CHECK: Disassembly of section .text_low:
+// CHECK-NEXT: _start:
+// CHECK-NEXT: 130: 00 00 00 eb bl #0 <__ARMV7PILongThunk_high>
+// CHECK-NEXT: 134: 1e ff 2f e1 bx lr
+
+// CHECK: __ARMV7PILongThunk_high:
+// CHECK-NEXT: 138: b8 ce 0f e3 movw r12, #65208
+// CHECK-NEXT: 13c: ff cf 4e e3 movt r12, #61439
+// 0x140 + 0xEFFF0000 + 0x0000FEB8 + 8 = 0xf0000000 = high
+// CHECK-NEXT: 140: 0f c0 8c e0 add r12, r12, pc
+// CHECK-NEXT: 144: 1c ff 2f e1 bx r12
+
+// CHECK: Disassembly of section .text_high:
+// CHECK-NEXT: high:
+// CHECK-NEXT: f0000000: 00 00 00 eb bl #0 <__ARMV7PILongThunk__start>
+// CHECK-NEXT: f0000004: 1e ff 2f e1 bx lr
+
+// CHECK: __ARMV7PILongThunk__start:
+// CHECK-NEXT: f0000008: 18 c1 00 e3 movw r12, #280
+// CHECK-NEXT: f000000c: 00 c0 41 e3 movt r12, #4096
+// 0xf0000010 + 0x10000000 + 0x0000118 + 8 = bits32(0x100000130),0x130 = _start
+// CHECK-NEXT: f0000010: 0f c0 8c e0 add r12, r12, pc
+// CHECK-NEXT: f0000014: 1c ff 2f e1 bx r12
+
+// Thumbv7a instructions and relocations
+// CHECK-THUMB: Disassembly of section .text_low:
+// CHECK-THUMB-NEXT: _start:
+// CHECK-THUMB-NEXT: 130: 00 f0 02 f8 bl #4
+// CHECK-THUMB-NEXT: 134: 70 47 bx lr
+// CHECK-THUMB-NEXT: 136: d4 d4 bmi #-88
+
+// CHECK-THUMB: __ThumbV7PILongThunk_high:
+// CHECK-THUMB-NEXT: 138: 4f f6 bd 6c movw r12, #65213
+// CHECK-THUMB-NEXT: 13c: ce f6 ff 7c movt r12, #61439
+// 0x140 + 0xEFFF0000 + 0x0000FEBD + 4 = 0xf0000001 = high
+// CHECK-THUMB-NEXT: 140: fc 44 add r12, pc
+// CHECK-THUMB-NEXT: 142: 60 47 bx r12
+
+// CHECK-THUMB: Disassembly of section .text_high:
+// CHECK-THUMB-NEXT: high:
+// CHECK-THUMB-NEXT: f0000000: 00 f0 02 f8 bl #4
+// CHECK-THUMB-NEXT: f0000004: 70 47 bx lr
+
+// CHECK-THUMB: __ThumbV7PILongThunk__start:
+// CHECK-THUMB-NEXT: f0000008: 40 f2 1d 1c movw r12, #285
+// CHECK-THUMB-NEXT: f000000c: c1 f2 00 0c movt r12, #4096
+// 0xf0000010 + 0x10000000 + 0x000011d +4 = bits32(0x100000131),0x131 = _start
+// CHECK-THUMB-NEXT: f0000010: fc 44 add r12, pc
+// CHECK-THUMB-NEXT: f0000012: 60 47 bx r12
diff --git a/test/ELF/arm-long-thunk-converge.s b/test/ELF/arm-long-thunk-converge.s
index dadc7e5fc9a9..f241a585676d 100644
--- a/test/ELF/arm-long-thunk-converge.s
+++ b/test/ELF/arm-long-thunk-converge.s
@@ -1,5 +1,5 @@
// REQUIRES: arm
-// RUN: llvm-mc -triple armv7-unknown-gnu -filetype=obj -o %t %s
+// RUN: llvm-mc -triple armv7-unknown-gnu -arm-add-build-attributes -filetype=obj -o %t %s
// RUN: ld.lld %t %S/Inputs/arm-long-thunk-converge.lds -o %t2
// RUN: llvm-objdump -d -start-address=0x00000000 -stop-address=0x00000010 -triple=armv7a-linux-gnueabihf %t2 | FileCheck --check-prefix=CHECK1 %s
// RUN: llvm-objdump -d -start-address=0x02000000 -stop-address=0x02000010 -triple=armv7a-linux-gnueabihf %t2 | FileCheck --check-prefix=CHECK2 %s
diff --git a/test/ELF/arm-thumb-branch-rangethunk.s b/test/ELF/arm-thumb-branch-rangethunk.s
index 4bbd69214e93..31a239dcdd88 100644
--- a/test/ELF/arm-thumb-branch-rangethunk.s
+++ b/test/ELF/arm-thumb-branch-rangethunk.s
@@ -1,6 +1,6 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
-// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %S/Inputs/far-arm-thumb-abs.s -o %tfar
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-none-linux-gnueabi %S/Inputs/far-arm-thumb-abs.s -o %tfar
// RUN: ld.lld %t %tfar -o %t2 2>&1
// RUN: llvm-objdump -d -triple=thumbv7a-none-linux-gnueabi %t2
.syntax unified
diff --git a/test/ELF/arm-thumb-branch.s b/test/ELF/arm-thumb-branch.s
index 89c081a69b88..043db4b08f97 100644
--- a/test/ELF/arm-thumb-branch.s
+++ b/test/ELF/arm-thumb-branch.s
@@ -1,6 +1,6 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
-// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %S/Inputs/far-arm-thumb-abs.s -o %tfar
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-none-linux-gnueabi %S/Inputs/far-arm-thumb-abs.s -o %tfar
// RUN: echo "SECTIONS { \
// RUN: . = 0xb4; \
// RUN: .callee1 : { *(.callee_low) } \
diff --git a/test/ELF/arm-thumb-condbranch-thunk.s b/test/ELF/arm-thumb-condbranch-thunk.s
index c9365efb73a7..8a5e9c85f510 100644
--- a/test/ELF/arm-thumb-condbranch-thunk.s
+++ b/test/ELF/arm-thumb-condbranch-thunk.s
@@ -1,5 +1,5 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
// RUN: ld.lld %t -o %t2 2>&1
// The output file is large, most of it zeroes. We dissassemble only the
// parts we need to speed up the test and avoid a large output file
diff --git a/test/ELF/arm-thumb-interwork-shared.s b/test/ELF/arm-thumb-interwork-shared.s
index 030ac29854b2..5c847367e09b 100644
--- a/test/ELF/arm-thumb-interwork-shared.s
+++ b/test/ELF/arm-thumb-interwork-shared.s
@@ -1,5 +1,5 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
// RUN: ld.lld %t --shared -o %t.so
// RUN: llvm-objdump -d -triple=thumbv7a-none-linux-gnueabi %t.so | FileCheck %s
// RUN: llvm-objdump -d -triple=armv7a-none-linux-gnueabi %t.so | FileCheck %s -check-prefix=PLT
diff --git a/test/ELF/arm-thumb-interwork-thunk-range.s b/test/ELF/arm-thumb-interwork-thunk-range.s
index d59ee1159920..3c013183791b 100644
--- a/test/ELF/arm-thumb-interwork-thunk-range.s
+++ b/test/ELF/arm-thumb-interwork-thunk-range.s
@@ -1,5 +1,5 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o
// RUN: ld.lld %t.o -o /dev/null -image-base=0x80000000
// Test that when the thunk is at a high address we don't get confused with it
diff --git a/test/ELF/arm-thumb-interwork-thunk-v5.s b/test/ELF/arm-thumb-interwork-thunk-v5.s
new file mode 100644
index 000000000000..90aa76e4a3e3
--- /dev/null
+++ b/test/ELF/arm-thumb-interwork-thunk-v5.s
@@ -0,0 +1,66 @@
+// REQUIRES: arm
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv5-none-linux-gnueabi %s -o %t
+// RUN: ld.lld %t -o %t2
+// RUN: llvm-objdump -d %t2 -triple=armv5-none-linux-gnueabi | FileCheck -check-prefix=CHECK-ARM %s
+// RUN: llvm-objdump -d %t2 -triple=thumbv5-none-linux-gnueabi | FileCheck -check-prefix=CHECK-THUMB %s
+// RUN: ld.lld %t -o %t3 --shared
+// RUN: llvm-objdump -d %t3 -triple=armv5-none-linux-gnueabi | FileCheck -check-prefix=CHECK-ARM-PI %s
+// RUN: llvm-objdump -d %t3 -triple=thumbv5-none-linux-gnueabi | FileCheck -check-prefix=CHECK-THUMB-PI %s
+
+// Test ARM Thumb Interworking on older Arm architectures using Thunks that do
+// not use MOVT/MOVW instructions.
+// For pure interworking (not considering range extension) there is only the
+// case of an Arm B to a Thumb Symbol to consider as in older Arm architectures
+// there is no Thumb B.w that we can intercept with a Thunk and we still assume
+// support for the blx instruction for Thumb BL and BLX to an Arm symbol.
+ .arm
+ .text
+ .syntax unified
+ .cpu arm10tdmi
+
+ .text
+ .globl _start
+ .type _start, %function
+ .balign 0x1000
+_start:
+ b thumb_func
+ bl thumb_func
+ blx thumb_func
+ bx lr
+
+// CHECK-ARM: _start:
+// CHECK-ARM-NEXT: 11000: 03 00 00 ea b #12 <__ARMv5ABSLongThunk_thumb_func>
+// CHECK-ARM-NEXT: 11004: 01 00 00 fa blx #4 <thumb_func>
+// CHECK-ARM-NEXT: 11008: 00 00 00 fa blx #0 <thumb_func>
+// CHECK-ARM-NEXT: 1100c: 1e ff 2f e1 bx lr
+
+// CHECK-THUMB: thumb_func:
+// CHECK-THUMB-NEXT: 11010: 70 47 bx lr
+
+// CHECK-ARM: __ARMv5ABSLongThunk_thumb_func:
+// CHECK-ARM-NEXT: 11014: 04 f0 1f e5 ldr pc, [pc, #-4]
+// CHECK-ARM: $d:
+// CHECK-ARM-NEXT: 11018: 11 10 01 00 .word 0x00011011
+
+// CHECK-ARM-PI: _start:
+// CHECK-ARM-PI-NEXT: 1000: 03 00 00 ea b #12 <__ARMV5PILongThunk_thumb_func>
+// CHECK-ARM-PI-NEXT: 1004: 01 00 00 fa blx #4 <thumb_func>
+// CHECK-ARM-PI-NEXT: 1008: 00 00 00 fa blx #0 <thumb_func>
+// CHECK-ARM-PI-NEXT: 100c: 1e ff 2f e1 bx lr
+
+// CHECK-THUMB-PI: thumb_func:
+// CHECK-THUMB-PI-NEXT: 1010: 70 47 bx lr
+
+// CHECK-ARM-PI: __ARMV5PILongThunk_thumb_func:
+// CHECK-ARM-PI-NEXT: 1014: 04 c0 9f e5 ldr r12, [pc, #4]
+// CHECK-ARM-PI-NEXT: 1018: 0c c0 8f e0 add r12, pc, r12
+// CHECK-ARM-PI-NEXT: 101c: 1c ff 2f e1 bx r12
+// CHECK-ARM-PI: $d:
+// CHECK-ARM-PI-NEXT: 1020: f1 ff ff ff .word 0xfffffff1
+
+ .section .text.1, "ax", %progbits
+ .thumb
+ .hidden thumb_func
+ .type thumb_func, %function
+thumb_func:
+ bx lr
diff --git a/test/ELF/arm-thumb-interwork-thunk.s b/test/ELF/arm-thumb-interwork-thunk.s
index df5d6c6b7401..4ff08e0112b7 100644
--- a/test/ELF/arm-thumb-interwork-thunk.s
+++ b/test/ELF/arm-thumb-interwork-thunk.s
@@ -1,5 +1,5 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
// RUN: echo "SECTIONS { \
// RUN: . = SIZEOF_HEADERS; \
// RUN: .R_ARM_JUMP24_callee_1 : { *(.R_ARM_JUMP24_callee_low) } \
diff --git a/test/ELF/arm-thumb-mix-range-thunk-os.s b/test/ELF/arm-thumb-mix-range-thunk-os.s
index b5db2565f2c9..7be56648e965 100644
--- a/test/ELF/arm-thumb-mix-range-thunk-os.s
+++ b/test/ELF/arm-thumb-mix-range-thunk-os.s
@@ -1,5 +1,5 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
// RUN: ld.lld %t -o %t2 2>&1
// The output file is large, most of it zeroes. We dissassemble only the
// parts we need to speed up the test and avoid a large output file
diff --git a/test/ELF/arm-thumb-plt-range-thunk-os.s b/test/ELF/arm-thumb-plt-range-thunk-os.s
index 080160bb2474..08907510be88 100644
--- a/test/ELF/arm-thumb-plt-range-thunk-os.s
+++ b/test/ELF/arm-thumb-plt-range-thunk-os.s
@@ -1,5 +1,5 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
// RUN: ld.lld %t --shared --icf=all -o %t.so
// The output file is large, most of it zeroes. We dissassemble only the
// parts we need to speed up the test and avoid a large output file
diff --git a/test/ELF/arm-thumb-range-thunk-os.s b/test/ELF/arm-thumb-range-thunk-os.s
index 182b18d79cae..281e79a4eb1c 100644
--- a/test/ELF/arm-thumb-range-thunk-os.s
+++ b/test/ELF/arm-thumb-range-thunk-os.s
@@ -1,5 +1,5 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
// RUN: ld.lld %t -o %t2 2>&1
// The output file is large, most of it zeroes. We dissassemble only the
// parts we need to speed up the test and avoid a large output file
diff --git a/test/ELF/arm-thumb-thunk-empty-pass.s b/test/ELF/arm-thumb-thunk-empty-pass.s
index ab9da1b8a2c2..6e81b508492f 100644
--- a/test/ELF/arm-thumb-thunk-empty-pass.s
+++ b/test/ELF/arm-thumb-thunk-empty-pass.s
@@ -1,5 +1,5 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
// RUN: ld.lld %t -o %t2 2>&1
// RUN: llvm-objdump -d %t2 -start-address=69632 -stop-address=69646 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK1 %s
// RUN: llvm-objdump -d %t2 -start-address=16846856 -stop-address=16846874 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK2 %s
diff --git a/test/ELF/arm-thumb-thunk-symbols.s b/test/ELF/arm-thumb-thunk-symbols.s
index 457d460997aa..ad6e79db3625 100644
--- a/test/ELF/arm-thumb-thunk-symbols.s
+++ b/test/ELF/arm-thumb-thunk-symbols.s
@@ -1,5 +1,5 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
// RUN: ld.lld %t -o %t2 2>&1
// RUN: llvm-readobj --symbols %t2 | FileCheck %s
// RUN: ld.lld --shared %t -o %t3 2>&1
diff --git a/test/ELF/arm-thumb-thunk-v6m.s b/test/ELF/arm-thumb-thunk-v6m.s
new file mode 100644
index 000000000000..bf5afd5edfee
--- /dev/null
+++ b/test/ELF/arm-thumb-thunk-v6m.s
@@ -0,0 +1,61 @@
+// REQUIRES: arm
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv6m-none-eabi %s -o %t
+// RUN: echo "SECTIONS { \
+// RUN: . = SIZEOF_HEADERS; \
+// RUN: .text_low : { *(.text_low) *(.text_low2) } \
+// RUN: .text_high 0x2000000 : { *(.text_high) *(.text_high2) } \
+// RUN: } " > %t.script
+// RUN: ld.lld --script %t.script %t -o %t2
+// RUN: llvm-objdump -d %t2 -triple=armv6m-none-eabi | FileCheck %s
+// RUN: ld.lld --script %t.script %t -o %t3 --pie
+// RUN: llvm-objdump -d %t3 -triple=armv6m-none-eabi | FileCheck -check-prefix=CHECK-PI %s
+
+// Range extension thunks for Arm Architecture v6m. Only Thumb instructions
+// are permitted which limits the access to instructions that can access the
+// high registers (r8 - r15), this means that the thunks have to spill
+// low registers (r0 - r7) in order to perform the transfer of control.
+
+ .syntax unified
+ .section .text_low, "ax", %progbits
+ .thumb
+ .type _start, %function
+ .balign 4
+ .globl _start
+_start:
+ bl far
+
+ .section .text_high, "ax", %progbits
+ .globl far
+ .type far, %function
+far:
+ bx lr
+
+// CHECK: Disassembly of section .text_low:
+// CHECK-NEXT: _start:
+// CHECK-NEXT: 94: 00 f0 00 f8 bl #0
+// CHECK: __Thumbv6MABSLongThunk_far:
+// CHECK-NEXT: 98: 03 b4 push {r0, r1}
+// CHECK-NEXT: 9a: 01 48 ldr r0, [pc, #4]
+// CHECK-NEXT: 9c: 01 90 str r0, [sp, #4]
+// CHECK-NEXT: 9e: 01 bd pop {r0, pc}
+// CHECK: a0: 01 00 00 02 .word 0x02000001
+// CHECK: Disassembly of section .text_high:
+// CHECK-NEXT: far:
+// CHECK-NEXT: 2000000: 70 47 bx lr
+
+// CHECK-PI: Disassembly of section .text_low:
+// CHECK-PI-NEXT: _start:
+// CHECK-PI-NEXT: 130: 00 f0 00 f8 bl #0
+// CHECK-PI: __Thumbv6MPILongThunk_far:
+// CHECK-PI-NEXT: 134: 01 b4 push {r0}
+// CHECK-PI-NEXT: 136: 02 48 ldr r0, [pc, #8]
+// CHECK-PI-NEXT: 138: 84 46 mov r12, r0
+// CHECK-PI-NEXT: 13a: 01 bc pop {r0}
+// pc = pc (0x13c + 4) + r12 (1fffec1) = 0x2000001 = .far
+// CHECK-PI-NEXT: 13c: e7 44 add pc, r12
+// CHECK-PI-NEXT: 13e: c0 46 mov r8, r8
+// CHECK-PI: 140: c1 fe ff 01 .word 0x01fffec1
+
+// CHECK-PI: Disassembly of section .text_high:
+// CHECK-PI-NEXT: far:
+// CHECK-PI-NEXT: 2000000: 70 47 bx lr
diff --git a/test/ELF/arm-thumb-undefined-weak-narrow.test b/test/ELF/arm-thumb-undefined-weak-narrow.test
new file mode 100644
index 000000000000..15f428e019b0
--- /dev/null
+++ b/test/ELF/arm-thumb-undefined-weak-narrow.test
@@ -0,0 +1,50 @@
+# REQUIRES: arm
+# RUN: yaml2obj %s -o %t.o
+# RUN: ld.lld %t.o -o %t
+# RUN: llvm-objdump -triple=thumbv7a-linux-gnueabi -d %t | FileCheck %s
+
+# CHECK: Disassembly of section .text:
+# CHECK-NEXT:_start:
+# CHECK-NEXT: 11000: ff e7 b #-2
+
+# Test the R_ARM_THM_JUMP11 relocation (102) to an undefined weak reference
+# It should resolve to the next instruction, which is an offset of -2 which
+# when added to the Thumb PC-bias of 4 is +2. We can't use llvm-mc to construct
+# the object as it relaxes b.n to b.w (R_ARM_JUMP24).
+
+!ELF
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_ARM
+Sections:
+ - Type: SHT_PROGBITS
+ Name: .text
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ Content: "fee7"
+ - Type: SHT_REL
+ Name: .rel.text
+ Link: .symtab
+ Info: .text
+ Relocations:
+ - Offset: 0
+ Symbol: undefined_weak
+ Type: R_ARM_THM_JUMP11
+
+Symbols:
+ Global:
+ - Type: STT_FUNC
+ Name: _start
+ Value: 1
+ Section: .text
+ Local:
+ - Type: STT_NOTYPE
+ Name: "$t"
+ Section: .text
+ Value: 0
+ Weak:
+ - Type: STT_NOTYPE
+ Name: undefined_weak
+ Value: 0
+
diff --git a/test/ELF/arm-thunk-edgecase.s b/test/ELF/arm-thunk-edgecase.s
index 81837c7b3284..356687668399 100644
--- a/test/ELF/arm-thunk-edgecase.s
+++ b/test/ELF/arm-thunk-edgecase.s
@@ -1,5 +1,5 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o
// RUN: echo "SECTIONS { \
// RUN: .text_armfunc 0x1000 : { *(.text_armfunc) } \
// RUN: .text_thumbfunc 0x11010 : { *(.text_thumbfunc) } \
diff --git a/test/ELF/arm-thunk-largesection.s b/test/ELF/arm-thunk-largesection.s
index d68cd0c76141..940888f185d4 100644
--- a/test/ELF/arm-thunk-largesection.s
+++ b/test/ELF/arm-thunk-largesection.s
@@ -1,5 +1,5 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
// RUN: ld.lld %t -o %t2 2>&1
// RUN: llvm-objdump -d -triple=thumbv7a-none-linux-gnueabi -start-address=69632 -stop-address=69636 %t2 | FileCheck -check-prefix=CHECK1 %s
// RUN: llvm-objdump -d -triple=thumbv7a-none-linux-gnueabi -start-address=73732 -stop-address=73742 %t2 | FileCheck -check-prefix=CHECK2 %s
@@ -16,9 +16,12 @@ _start:
bx lr
.space 0x1000
// CHECK1: Disassembly of section .text:
-// CHECK1-NEXT: _start:
-// CHECK1-NEXT: 11000: 70 47 bx lr
-// CHECK1-NEXT: 11002: 00 00 movs r0, r0
+// CHECK1-NEXT:_start:
+// CHECK1-NEXT: 11000: 70 47 bx lr
+// CHECK1-EMPTY:
+// CHECK-NEXT:$d.1:
+// CHECK-NEXT: 11002: 00 00 .short 0x0000
+
// CHECK2: __Thumbv7ABSLongThunk__start:
// CHECK2-NEXT: 12004: fe f7 fc bf b.w #-4104 <_start>
diff --git a/test/ELF/arm-thunk-linkerscript-dotexpr.s b/test/ELF/arm-thunk-linkerscript-dotexpr.s
index ea741708bc90..4b68ad813bff 100644
--- a/test/ELF/arm-thunk-linkerscript-dotexpr.s
+++ b/test/ELF/arm-thunk-linkerscript-dotexpr.s
@@ -1,5 +1,5 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
// RUN: echo "SECTIONS { \
// RUN: . = SIZEOF_HEADERS; \
// RUN: .text_low : { *(.text_low) *(.text_low2) . = . + 0x2000000 ; *(.text_high) *(.text_high2) } \
diff --git a/test/ELF/arm-thunk-linkerscript-large.s b/test/ELF/arm-thunk-linkerscript-large.s
index 839d7716c278..1b9ec0bc86ff 100644
--- a/test/ELF/arm-thunk-linkerscript-large.s
+++ b/test/ELF/arm-thunk-linkerscript-large.s
@@ -1,5 +1,5 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
// RUN: echo "SECTIONS { \
// RUN: .text 0x100000 : { *(.text) } \
// RUN: .textl : { *(.text_l0*) *(.text_l1*) *(.text_l2*) *(.text_l3*) } \
@@ -21,7 +21,8 @@
// per OutputSection basis
.syntax unified
-// Define a function that we can match with .text_l* aligned on a megabyte // boundary
+// Define a function that we can match with .text_l* aligned on a megabyte
+// boundary
.macro FUNCTIONL suff
.section .text_l\suff\(), "ax", %progbits
.thumb
diff --git a/test/ELF/arm-thunk-linkerscript-orphan.s b/test/ELF/arm-thunk-linkerscript-orphan.s
index f05cc0de9069..556e67be3165 100644
--- a/test/ELF/arm-thunk-linkerscript-orphan.s
+++ b/test/ELF/arm-thunk-linkerscript-orphan.s
@@ -1,5 +1,5 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
// RUN: echo "SECTIONS { \
// RUN: .text_low 0x100000 : { *(.text_low) } \
// RUN: .text_high 0x2000000 : { *(.text_high) } \
diff --git a/test/ELF/arm-thunk-linkerscript-sort.s b/test/ELF/arm-thunk-linkerscript-sort.s
index 62ea41363f41..8e2a117b5bb6 100644
--- a/test/ELF/arm-thunk-linkerscript-sort.s
+++ b/test/ELF/arm-thunk-linkerscript-sort.s
@@ -1,5 +1,5 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
// RUN: echo "SECTIONS { \
// RUN: .text 0x100000 : { *(SORT_BY_NAME(.text.*)) } \
// RUN: }" > %t.script
diff --git a/test/ELF/arm-thunk-linkerscript.s b/test/ELF/arm-thunk-linkerscript.s
index 7728ddf76a97..6e476a21b43f 100644
--- a/test/ELF/arm-thunk-linkerscript.s
+++ b/test/ELF/arm-thunk-linkerscript.s
@@ -1,5 +1,5 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
// RUN: echo "SECTIONS { \
// RUN: . = SIZEOF_HEADERS; \
// RUN: .text_low : { *(.text_low) *(.text_low2) } \
diff --git a/test/ELF/arm-thunk-multipass.s b/test/ELF/arm-thunk-multipass.s
index b353bb148ff6..33578b1da51d 100644
--- a/test/ELF/arm-thunk-multipass.s
+++ b/test/ELF/arm-thunk-multipass.s
@@ -1,5 +1,5 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
// RUN: ld.lld %t -o %t2 2>&1
// The output file is large, most of it zeroes. We dissassemble only the
// parts we need to speed up the test and avoid a large output file
diff --git a/test/ELF/arm-thunk-nosuitable.s b/test/ELF/arm-thunk-nosuitable.s
index cde790665c42..0e08f3f941d2 100644
--- a/test/ELF/arm-thunk-nosuitable.s
+++ b/test/ELF/arm-thunk-nosuitable.s
@@ -1,4 +1,4 @@
-// REQUIRES: ARM
+// REQUIRES: arm
// RUN: llvm-mc %s --arm-add-build-attributes --triple=armv7a-linux-gnueabihf --filetype=obj -o %t.o
// RUN: ld.lld %t.o -o %t
// RUN: llvm-objdump -triple=thumbv7a-linux-gnueabihf -d -start-address=2166784 -stop-address=2166794 %t | FileCheck %s
@@ -23,8 +23,7 @@ _start:
// CHECK-NEXT: 211000: 00 f0 00 80 beq.w #0
// CHECK: __Thumbv7ABSLongThunk_target:
// CHECK-NEXT: 211004: 00 f0 01 90 b.w #12582914
-// CHECK: $t.1:
-// CHECK-NEXT: 211008: 70 47 bx lr
+// CHECK: 211008: 70 47 bx lr
.section .text.2, "ax", %progbits
.space 12 * 1024 * 1024
diff --git a/test/ELF/arm-thunk-re-add.s b/test/ELF/arm-thunk-re-add.s
index 760e18f57313..9e8feb381829 100644
--- a/test/ELF/arm-thunk-re-add.s
+++ b/test/ELF/arm-thunk-re-add.s
@@ -1,5 +1,5 @@
// REQUIRES: arm
-// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
+// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
// RUN: ld.lld %t --shared -o %t.so
// The output file is large, most of it zeroes. We dissassemble only the
// parts we need to speed up the test and avoid a large output file
diff --git a/test/ELF/arm-thunk-section-too-large.s b/test/ELF/arm-thunk-section-too-large.s
index 9174093380f7..62b59de51a0d 100644
--- a/test/ELF/arm-thunk-section-too-large.s
+++ b/test/ELF/arm-thunk-section-too-large.s
@@ -1,4 +1,4 @@
-// REQUIRES: ARM
+// REQUIRES: arm
// RUN: llvm-mc %s -triple=armv7a-linux-gnueabihf -arm-add-build-attributes -filetype=obj -o %t.o
// RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
diff --git a/test/ELF/arm-tls-le32.s b/test/ELF/arm-tls-le32.s
index 7834dedf1be0..f9a5fa9b2fc9 100644
--- a/test/ELF/arm-tls-le32.s
+++ b/test/ELF/arm-tls-le32.s
@@ -69,9 +69,9 @@ x:
// CHECK: Disassembly of section .text:
// CHECK-NEXT: _start:
-// offset of x from Thread pointer = (TcbSize + 0x0 = 0x8)
-// CHECK-NEXT: 11000: 08 00 00 00
-// offset of z from Thread pointer = (TcbSize + 0x8 = 0x10)
-// CHECK-NEXT: 11004: 10 00 00 00
-// offset of y from Thread pointer = (TcbSize + 0x4 = 0xc)
-// CHECK-NEXT: 11008: 0c 00 00 00
+// offset of x from Thread pointer = (TcbSize + 0x0 = 0x20)
+// CHECK-NEXT: 11000: 20 00 00 00
+// offset of z from Thread pointer = (TcbSize + 0x8 = 0x28)
+// CHECK-NEXT: 11004: 28 00 00 00
+// offset of y from Thread pointer = (TcbSize + 0x4 = 0x24)
+// CHECK-NEXT: 11008: 24 00 00 00
diff --git a/test/ELF/arm-tls-norelax-ie-le.s b/test/ELF/arm-tls-norelax-ie-le.s
index be8af9760481..11c3e4f5dc1a 100644
--- a/test/ELF/arm-tls-norelax-ie-le.s
+++ b/test/ELF/arm-tls-norelax-ie-le.s
@@ -37,5 +37,5 @@ x2:
.type x2, %object
// CHECK: Contents of section .got:
-// x1 at offset 8 from TP, x2 at offset c from TP. Offsets include TCB size of 8
-// CHECK-NEXT: 13064 08000000 0c000000
+// x1 at offset 0x20 from TP, x2 at offset 0x24 from TP. Offsets include TCB size of 0x20
+// CHECK-NEXT: 13064 20000000 24000000
diff --git a/test/ELF/arm-v4bx.test b/test/ELF/arm-v4bx.test
new file mode 100644
index 000000000000..1b39a431417b
--- /dev/null
+++ b/test/ELF/arm-v4bx.test
@@ -0,0 +1,40 @@
+# REQUIRES: arm
+# RUN: yaml2obj %s -o %t.o
+# RUN: ld.lld %t.o -o %t
+# RUN: llvm-readelf -sections %t | FileCheck %s
+# RUN: ld.lld -shared %t.o -o %t
+# RUN: llvm-readelf -sections %t | FileCheck %s
+
+# CHECK: .text
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_ARM
+ Flags: [ EF_ARM_EABI_VER5 ]
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000004
+ Content: 1EFF2F01
+ - Name: .rel.text
+ Type: SHT_REL
+ Link: .symtab
+ AddressAlign: 0x0000000000000004
+ Info: .text
+ Relocations:
+ - Offset: 0x0000000000000000
+ Symbol: ''
+ Type: R_ARM_V4BX
+Symbols:
+ Global:
+ - Name: _start
+ Section: .text
+ Local:
+ - Name: .text
+ Type: STT_SECTION
+ Section: .text
+DynamicSymbols:
diff --git a/test/ELF/arm-v5-reloc-error.s b/test/ELF/arm-v5-reloc-error.s
new file mode 100644
index 000000000000..90ea36d3df12
--- /dev/null
+++ b/test/ELF/arm-v5-reloc-error.s
@@ -0,0 +1,31 @@
+// REQUIRES: arm
+// RUN: llvm-mc -filetype=obj -triple=armv7a-linux-gnueabi %s -o %t
+// RUN: echo "SECTIONS { \
+// RUN: . = SIZEOF_HEADERS; \
+// RUN: .text_low : { *(.text_low) *(.text_low2) } \
+// RUN: .text_high 0x2000000 : { *(.text_high) *(.text_high2) } \
+// RUN: } " > %t.script
+// RUN: not ld.lld --script %t.script %t -o %t2 2>&1 | FileCheck %s
+
+// CHECK: error: relocation R_ARM_THM_JUMP24 to far not supported for Armv5 or Armv6 targets
+
+// Lie about our build attributes. Our triple is armv7a-linux-gnueabi but
+// we are claiming to be Armv5. This can also happen with llvm-mc when we
+// don't have any .eabi_attribute directives in the file or the
+// --arm-add-build-attributes command line isn't used to add them from the
+// triple.
+ .eabi_attribute 6, 5 // Tag_cpu_arch 5 = v5TEJ
+ .thumb
+ .syntax unified
+ .section .text_low, "ax", %progbits
+ .thumb
+ .globl _start
+ .type _start, %function
+_start:
+ b.w far // Will produce relocation not supported in Armv5.
+
+ .section .text_high, "ax", %progbits
+ .globl far
+ .type far, %function
+far:
+ bx lr
diff --git a/test/ELF/as-needed-in-regular.s b/test/ELF/as-needed-in-regular.s
new file mode 100644
index 000000000000..2ba646f85300
--- /dev/null
+++ b/test/ELF/as-needed-in-regular.s
@@ -0,0 +1,24 @@
+# REQUIRES: x86
+
+# RUN: echo '.globl a; .type a, @function; .type a, @function; a: ret' | \
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %ta.o
+# RUN: ld.lld %ta.o --shared --soname=a.so -o %ta.so
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: ld.lld %t.o --as-needed %ta.so -o %t
+# RUN: llvm-readelf -d %t | FileCheck %s
+# RUN: ld.lld %t.o --as-needed %ta.so --gc-sections -o %t
+# RUN: llvm-readelf -d %t | FileCheck %s
+
+# The order of %ta.so and %t.o does not matter.
+
+# RUN: ld.lld --as-needed %ta.so %t.o -o %t
+# RUN: llvm-readelf -d %t | FileCheck %s
+# RUN: ld.lld --as-needed %ta.so %t.o --gc-sections -o %t
+# RUN: llvm-readelf -d %t | FileCheck %s
+
+# CHECK: a.so
+
+.global _start
+_start:
+ jmp a@PLT
diff --git a/test/ELF/as-needed-not-in-regular.s b/test/ELF/as-needed-not-in-regular.s
new file mode 100644
index 000000000000..cd7efa6d2688
--- /dev/null
+++ b/test/ELF/as-needed-not-in-regular.s
@@ -0,0 +1,32 @@
+# REQUIRES: x86
+
+# RUN: echo '.globl a1, a2; .type a1, @function; .type a2, @function; a1: a2: ret' | \
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %ta.o
+# RUN: ld.lld %ta.o --shared --soname=a.so -o %ta.so
+
+# RUN: echo '.globl b; .type b, @function; b: jmp a1@PLT' | \
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %tb.o
+# RUN: ld.lld %tb.o %ta.so --shared --soname=b.so -o %tb.so
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: ld.lld %t.o %tb.so --as-needed %ta.so -o %t
+# RUN: llvm-readelf -d %t | FileCheck %s
+
+# RUN: ld.lld %t.o %tb.so --as-needed %ta.so --gc-sections -o %t
+# RUN: llvm-readelf -d %t | FileCheck %s
+
+# The symbol a1 (defined in a.so) is not referenced by a regular object,
+# the reference to a2 is weak, don't add a DT_NEEDED entry for a.so.
+# CHECK-NOT: a.so
+
+# RUN: ld.lld %t.o %tb.so --as-needed %ta.so --no-as-needed %ta.so -o %t
+# RUN: llvm-readelf -d %t | FileCheck %s -check-prefix=NEEDED
+
+# a.so is needed because one of its occurrences is needed.
+# NEEDED: a.so
+
+.global _start
+.weak a2
+_start:
+ jmp b@PLT
+ jmp a2
diff --git a/test/ELF/as-needed-weak.s b/test/ELF/as-needed-weak.s
index f009c72d6f48..a47399a600c3 100644
--- a/test/ELF/as-needed-weak.s
+++ b/test/ELF/as-needed-weak.s
@@ -12,7 +12,7 @@
# CHECK: Symbol table of .hash for image:
# CHECK-NEXT: Num Buc: Value Size Type Bind Vis Ndx Name
-# CHECK-NEXT: 1 1: 0000000000000000 0 FUNC WEAK DEFAULT UND foo@
+# CHECK-NEXT: 1 1: 0000000000000000 0 FUNC WEAK DEFAULT UND foo
.globl _start
.weak foo
diff --git a/test/ELF/bad-reloc-target.test b/test/ELF/bad-reloc-target.test
new file mode 100644
index 000000000000..fea8c5f0f396
--- /dev/null
+++ b/test/ELF/bad-reloc-target.test
@@ -0,0 +1,29 @@
+# RUN: yaml2obj %s -o %t1.o
+# RUN: not ld.lld %t1.o -o %t1 2>&1 | FileCheck %s
+# CHECK: error: {{.*}}.o: unsupported relocation reference
+
+# RUN: yaml2obj %S/Inputs/bad-reloc-target.test -o %t2.o
+# RUN: not ld.lld %t2.o -o %t2 2>&1 | FileCheck %s --check-prefix=ERR2
+# ERR2: error: {{.*}}.o: invalid relocated section index: 99
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ - Name: .rela.text
+ Type: SHT_RELA
+ Link: .symtab
+ Info: 0
+ Relocations:
+ - Offset: 0x0000000000000000
+ Symbol: foo
+ Type: R_X86_64_64
+Symbols:
+ Global:
+ - Name: foo \ No newline at end of file
diff --git a/test/ELF/basic-aarch64.s b/test/ELF/basic-aarch64.s
index efbe0080844f..151bf52cc3ee 100644
--- a/test/ELF/basic-aarch64.s
+++ b/test/ELF/basic-aarch64.s
@@ -59,7 +59,7 @@ _start:
# CHECK-NEXT: SHF_ALLOC (0x2)
# CHECK-NEXT: SHF_EXECINSTR (0x4)
# CHECK-NEXT: ]
-# CHECK-NEXT: Address: 0x20000
+# CHECK-NEXT: Address: 0x210000
# CHECK-NEXT: Offset: 0x10000
# CHECK-NEXT: Size: 12
# CHECK-NEXT: Link: 0
@@ -138,7 +138,7 @@ _start:
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: $x.0
-# CHECK-NEXT: Value: 0x20000
+# CHECK-NEXT: Value: 0x210000
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Local (0x0)
# CHECK-NEXT: Type: None (0x0)
@@ -159,8 +159,8 @@ _start:
# CHECK-NEXT: ProgramHeader {
# CHECK-NEXT: Type: PT_PHDR (0x6)
# CHECK-NEXT: Offset: 0x40
-# CHECK-NEXT: VirtualAddress: 0x10040
-# CHECK-NEXT: PhysicalAddress: 0x10040
+# CHECK-NEXT: VirtualAddress: 0x200040
+# CHECK-NEXT: PhysicalAddress: 0x200040
# CHECK-NEXT: FileSize: 224
# CHECK-NEXT: MemSize: 224
# CHECK-NEXT: Flags [ (0x4)
@@ -171,8 +171,8 @@ _start:
# CHECK-NEXT: ProgramHeader {
# CHECK-NEXT: Type: PT_LOAD (0x1)
# CHECK-NEXT: Offset: 0x0
-# CHECK-NEXT: VirtualAddress: 0x10000
-# CHECK-NEXT: PhysicalAddress: 0x10000
+# CHECK-NEXT: VirtualAddress: 0x200000
+# CHECK-NEXT: PhysicalAddress: 0x200000
# CHECK-NEXT: FileSize: 288
# CHECK-NEXT: MemSize: 288
# CHECK-NEXT: Flags [
@@ -183,8 +183,8 @@ _start:
# CHECK-NEXT: ProgramHeader {
# CHECK-NEXT: Type: PT_LOAD (0x1)
# CHECK-NEXT: Offset: 0x1000
-# CHECK-NEXT: VirtualAddress: 0x20000
-# CHECK-NEXT: PhysicalAddress: 0x20000
+# CHECK-NEXT: VirtualAddress: 0x210000
+# CHECK-NEXT: PhysicalAddress: 0x210000
# CHECK-NEXT: FileSize: 4096
# CHECK-NEXT: MemSize: 4096
# CHECK-NEXT: Flags [ (0x5)
diff --git a/test/ELF/basic-ppc64.s b/test/ELF/basic-ppc64.s
index f586d6320d16..624d8301cb63 100644
--- a/test/ELF/basic-ppc64.s
+++ b/test/ELF/basic-ppc64.s
@@ -28,7 +28,7 @@
// CHECK-NEXT: Version: 1
// CHECK-NEXT: Entry: 0x10000
// CHECK-NEXT: ProgramHeaderOffset: 0x40
-// CHECK-NEXT: SectionHeaderOffset:
+// CHECK-NEXT: SectionHeaderOffset: 0x200F8
// CHECK-NEXT: Flags [ (0x2)
// CHECK-NEXT: 0x2
// CHECK-NEXT: ]
@@ -36,8 +36,8 @@
// CHECK-NEXT: ProgramHeaderEntrySize: 56
// CHECK-NEXT: ProgramHeaderCount: 7
// CHECK-NEXT: SectionHeaderEntrySize: 64
-// CHECK-NEXT: SectionHeaderCount: 10
-// CHECK-NEXT: StringTableSectionIndex: 8
+// CHECK-NEXT: SectionHeaderCount: 11
+// CHECK-NEXT: StringTableSectionIndex: 9
// CHECK-NEXT:}
// CHECK-NEXT:Sections [
// CHECK-NEXT: Section {
@@ -156,7 +156,23 @@
// CHECK-NEXT: }
// CHECK-NEXT: Section {
// CHECK-NEXT: Index: 6
-// CHECK-NEXT: Name: .comment (38)
+// CHECK-NEXT: Name: .branch_lt (38)
+// CHECK-NEXT: Type: SHT_NOBITS (0x8)
+// CHECK-NEXT: Flags [ (0x3)
+// CHECK-NEXT: SHF_ALLOC (0x2)
+// CHECK-NEXT: SHF_WRITE (0x1)
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address: 0x30000
+// CHECK-NEXT: Offset: 0x20060
+// CHECK-NEXT: Size: 0
+// CHECK-NEXT: Link: 0
+// CHECK-NEXT: Info: 0
+// CHECK-NEXT: AddressAlignment: 8
+// CHECK-NEXT: EntrySize: 0
+// CHECK-NEXT: }
+// CHECK-NEXT: Section {
+// CHECK-NEXT: Index: 7
+// CHECK-NEXT: Name: .comment (49)
// CHECK-NEXT: Type: SHT_PROGBITS (0x1)
// CHECK-NEXT: Flags [ (0x30)
// CHECK-NEXT: SHF_MERGE (0x10)
@@ -174,15 +190,15 @@
// CHECK-NEXT: )
// CHECK-NEXT: }
// CHECK-NEXT: Section {
-// CHECK-NEXT: Index: 7
-// CHECK-NEXT: Name: .symtab (47)
+// CHECK-NEXT: Index: 8
+// CHECK-NEXT: Name: .symtab (58)
// CHECK-NEXT: Type: SHT_SYMTAB (0x2)
// CHECK-NEXT: Flags [ (0x0)
// CHECK-NEXT: ]
// CHECK-NEXT: Address: 0x0
// CHECK-NEXT: Offset: 0x20068
// CHECK-NEXT: Size: 48
-// CHECK-NEXT: Link: 9
+// CHECK-NEXT: Link: 10
// CHECK-NEXT: Info: 2
// CHECK-NEXT: AddressAlignment: 8
// CHECK-NEXT: EntrySize: 24
@@ -193,14 +209,14 @@
// CHECK-NEXT: )
// CHECK-NEXT: }
// CHECK-NEXT: Section {
-// CHECK-NEXT: Index: 8
-// CHECK-NEXT: Name: .shstrtab (55)
+// CHECK-NEXT: Index: 9
+// CHECK-NEXT: Name: .shstrtab (66)
// CHECK-NEXT: Type: SHT_STRTAB (0x3)
// CHECK-NEXT: Flags [ (0x0)
// CHECK-NEXT: ]
// CHECK-NEXT: Address: 0x0
// CHECK-NEXT: Offset: 0x20098
-// CHECK-NEXT: Size: 73
+// CHECK-NEXT: Size: 84
// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
// CHECK-NEXT: AddressAlignment: 1
@@ -208,19 +224,20 @@
// CHECK-NEXT: SectionData (
// CHECK-NEXT: 0000: 002E6479 6E73796D 002E6861 7368002E |..dynsym..hash..|
// CHECK-NEXT: 0010: 64796E73 7472002E 74657874 002E6479 |dynstr..text..dy|
-// CHECK-NEXT: 0020: 6E616D69 63002E63 6F6D6D65 6E74002E |namic..comment..|
-// CHECK-NEXT: 0030: 73796D74 6162002E 73687374 72746162 |symtab..shstrtab|
-// CHECK-NEXT: 0040: 002E7374 72746162 00 |..strtab.|
+// CHECK-NEXT: 0020: 6E616D69 63002E62 72616E63 685F6C74 |namic..branch_lt|
+// CHECK-NEXT: 0030: 002E636F 6D6D656E 74002E73 796D7461 |..comment..symta|
+// CHECK-NEXT: 0040: 62002E73 68737472 74616200 2E737472 |b..shstrtab..str|
+// CHECK-NEXT: 0050: 74616200 |tab.|
// CHECK-NEXT: )
// CHECK-NEXT: }
// CHECK-NEXT: Section {
-// CHECK-NEXT: Index: 9
-// CHECK-NEXT: Name: .strtab (65)
+// CHECK-NEXT: Index: 10
+// CHECK-NEXT: Name: .strtab (76)
// CHECK-NEXT: Type: SHT_STRTAB (0x3)
// CHECK-NEXT: Flags [ (0x0)
// CHECK-NEXT: ]
// CHECK-NEXT: Address: 0x0
-// CHECK-NEXT: Offset: 0x200E1
+// CHECK-NEXT: Offset: 0x200EC
// CHECK-NEXT: Size: 10
// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
@@ -275,7 +292,7 @@
// CHECK-NEXT: VirtualAddress: 0x20000
// CHECK-NEXT: PhysicalAddress: 0x20000
// CHECK-NEXT: FileSize: 96
-// CHECK-NEXT: MemSize: 96
+// CHECK-NEXT: MemSize: 65536
// CHECK-NEXT: Flags [ (0x6)
// CHECK-NEXT: PF_R (0x4)
// CHECK-NEXT: PF_W (0x2)
diff --git a/test/ELF/basic32.s b/test/ELF/basic32.s
index 72058dc6b168..38ef77959598 100644
--- a/test/ELF/basic32.s
+++ b/test/ELF/basic32.s
@@ -23,7 +23,7 @@ _start:
# CHECK-NEXT: Type: Executable (0x2)
# CHECK-NEXT: Machine: EM_386 (0x3)
# CHECK-NEXT: Version: 1
-# CHECK-NEXT: Entry: 0x11000
+# CHECK-NEXT: Entry: 0x401000
# CHECK-NEXT: ProgramHeaderOffset: 0x34
# CHECK-NEXT: SectionHeaderOffset: 0x205C
# CHECK-NEXT: Flags [ (0x0)
@@ -58,7 +58,7 @@ _start:
# CHECK-NEXT: SHF_ALLOC (0x2)
# CHECK-NEXT: SHF_EXECINSTR (0x4)
# CHECK-NEXT: ]
-# CHECK-NEXT: Address: 0x11000
+# CHECK-NEXT: Address: 0x401000
# CHECK-NEXT: Offset: 0x1000
# CHECK-NEXT: Size: 12
# CHECK-NEXT: Link: 0
@@ -129,8 +129,8 @@ _start:
# CHECK-NEXT: ProgramHeader {
# CHECK-NEXT: Type: PT_PHDR (0x6)
# CHECK-NEXT: Offset: 0x34
-# CHECK-NEXT: VirtualAddress: 0x10034
-# CHECK-NEXT: PhysicalAddress: 0x10034
+# CHECK-NEXT: VirtualAddress: 0x400034
+# CHECK-NEXT: PhysicalAddress: 0x400034
# CHECK-NEXT: FileSize: 128
# CHECK-NEXT: MemSize: 128
# CHECK-NEXT: Flags [ (0x4)
@@ -141,8 +141,8 @@ _start:
# CHECK-NEXT: ProgramHeader {
# CHECK-NEXT: Type: PT_LOAD (0x1)
# CHECK-NEXT: Offset: 0x0
-# CHECK-NEXT: VirtualAddress: 0x10000
-# CHECK-NEXT: PhysicalAddress: 0x10000
+# CHECK-NEXT: VirtualAddress: 0x400000
+# CHECK-NEXT: PhysicalAddress: 0x400000
# CHECK-NEXT: FileSize: 180
# CHECK-NEXT: MemSize: 180
# CHECK-NEXT: Flags [
@@ -153,8 +153,8 @@ _start:
# CHECK-NEXT: ProgramHeader {
# CHECK-NEXT: Type: PT_LOAD (0x1)
# CHECK-NEXT: Offset: 0x1000
-# CHECK-NEXT: VirtualAddress: 0x11000
-# CHECK-NEXT: PhysicalAddress: 0x11000
+# CHECK-NEXT: VirtualAddress: 0x401000
+# CHECK-NEXT: PhysicalAddress: 0x401000
# CHECK-NEXT: FileSize: 4096
# CHECK-NEXT: MemSize: 4096
# CHECK-NEXT: Flags [ (0x5)
diff --git a/test/ELF/basic64be.s b/test/ELF/basic64be.s
index 2bef1545153e..0add5b99bd57 100644
--- a/test/ELF/basic64be.s
+++ b/test/ELF/basic64be.s
@@ -23,7 +23,7 @@
# CHECK-NEXT: Version: 1
# CHECK-NEXT: Entry: 0x10010000
# CHECK-NEXT: ProgramHeaderOffset: 0x40
-# CHECK-NEXT: SectionHeaderOffset: 0x11050
+# CHECK-NEXT: SectionHeaderOffset: 0x20058
# CHECK-NEXT: Flags [ (0x2)
# CHECK-NEXT: 0x2
# CHECK-NEXT: ]
@@ -31,8 +31,8 @@
# CHECK-NEXT: ProgramHeaderEntrySize: 56
# CHECK-NEXT: ProgramHeaderCount: 4
# CHECK-NEXT: SectionHeaderEntrySize: 64
-# CHECK-NEXT: SectionHeaderCount: 6
-# CHECK-NEXT: StringTableSectionIndex: 4
+# CHECK-NEXT: SectionHeaderCount: 7
+# CHECK-NEXT: StringTableSectionIndex: 5
# CHECK-NEXT: }
# CHECK-NEXT: Sections [
# CHECK-NEXT: Section {
@@ -72,14 +72,32 @@
# CHECK-NEXT: }
# CHECK-NEXT: Section {
# CHECK-NEXT: Index: 2
-# CHECK-NEXT: Name: .comment (7)
+# CHECK-NEXT: Name: .branch_lt (7)
+# CHECK-NEXT: Type: SHT_PROGBITS (0x1)
+# CHECK-NEXT: Flags [ (0x3)
+# CHECK-NEXT: SHF_ALLOC (0x2)
+# CHECK-NEXT: SHF_WRITE (0x1)
+# CHECK-NEXT: ]
+# CHECK-NEXT: Address: 0x10020000
+# CHECK-NEXT: Offset: 0x20000
+# CHECK-NEXT: Size: 0
+# CHECK-NEXT: Link: 0
+# CHECK-NEXT: Info: 0
+# CHECK-NEXT: AddressAlignment: 8
+# CHECK-NEXT: EntrySize: 0
+# CHECK-NEXT: SectionData (
+# CHECK-NEXT: )
+# CHECK-NEXT: }
+# CHECK-NEXT: Section {
+# CHECK-NEXT: Index: 3
+# CHECK-NEXT: Name: .comment (18)
# CHECK-NEXT: Type: SHT_PROGBITS (0x1)
# CHECK-NEXT: Flags [ (0x30)
# CHECK-NEXT: SHF_MERGE (0x10)
# CHECK-NEXT: SHF_STRINGS (0x20)
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x0
-# CHECK-NEXT: Offset: 0x11000
+# CHECK-NEXT: Offset: 0x20000
# CHECK-NEXT: Size: 8
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
@@ -90,15 +108,15 @@
# CHECK-NEXT: )
# CHECK-NEXT: }
# CHECK-NEXT: Section {
-# CHECK-NEXT: Index: 3
-# CHECK-NEXT: Name: .symtab (16)
+# CHECK-NEXT: Index: 4
+# CHECK-NEXT: Name: .symtab (27)
# CHECK-NEXT: Type: SHT_SYMTAB (0x2)
# CHECK-NEXT: Flags [ (0x0)
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x0
-# CHECK-NEXT: Offset: 0x11008
+# CHECK-NEXT: Offset: 0x20008
# CHECK-NEXT: Size: 24
-# CHECK-NEXT: Link: 5
+# CHECK-NEXT: Link: 6
# CHECK-NEXT: Info: 1
# CHECK-NEXT: AddressAlignment: 8
# CHECK-NEXT: EntrySize: 24
@@ -108,32 +126,33 @@
# CHECK-NEXT: )
# CHECK-NEXT: }
# CHECK-NEXT: Section {
-# CHECK-NEXT: Index: 4
-# CHECK-NEXT: Name: .shstrtab (24)
+# CHECK-NEXT: Index: 5
+# CHECK-NEXT: Name: .shstrtab (35)
# CHECK-NEXT: Type: SHT_STRTAB (0x3)
# CHECK-NEXT: Flags [ (0x0)
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x0
-# CHECK-NEXT: Offset: 0x11020
-# CHECK-NEXT: Size: 42
+# CHECK-NEXT: Offset: 0x20020
+# CHECK-NEXT: Size: 53
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
# CHECK-NEXT: AddressAlignment: 1
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: SectionData (
-# CHECK-NEXT: 0000: 002E7465 7874002E 636F6D6D 656E7400 |..text..comment.|
-# CHECK-NEXT: 0010: 2E73796D 74616200 2E736873 74727461 |.symtab..shstrta|
-# CHECK-NEXT: 0020: 62002E73 74727461 6200 |b..strtab.|
+# CHECK-NEXT: 0000: 002E7465 7874002E 6272616E 63685F6C |..text..branch_l|
+# CHECK-NEXT: 0010: 74002E63 6F6D6D65 6E74002E 73796D74 |t..comment..symt|
+# CHECK-NEXT: 0020: 6162002E 73687374 72746162 002E7374 |ab..shstrtab..st|
+# CHECK-NEXT: 0030: 72746162 00 |rtab.|
# CHECK-NEXT: )
# CHECK-NEXT: }
# CHECK-NEXT: Section {
-# CHECK-NEXT: Index: 5
-# CHECK-NEXT: Name: .strtab (34)
+# CHECK-NEXT: Index: 6
+# CHECK-NEXT: Name: .strtab (45)
# CHECK-NEXT: Type: SHT_STRTAB (0x3)
# CHECK-NEXT: Flags [ (0x0)
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x0
-# CHECK-NEXT: Offset: 0x1104A
+# CHECK-NEXT: Offset: 0x20055
# CHECK-NEXT: Size: 1
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
@@ -150,8 +169,8 @@
# CHECK-NEXT: Offset: 0x40
# CHECK-NEXT: VirtualAddress: 0x10000040
# CHECK-NEXT: PhysicalAddress: 0x10000040
-# CHECK-NEXT: FileSize: 224
-# CHECK-NEXT: MemSize: 224
+# CHECK-NEXT: FileSize: 280
+# CHECK-NEXT: MemSize: 280
# CHECK-NEXT: Flags [ (0x4)
# CHECK-NEXT: PF_R (0x4)
# CHECK-NEXT: ]
@@ -162,8 +181,8 @@
# CHECK-NEXT: Offset: 0x0
# CHECK-NEXT: VirtualAddress: 0x10000000
# CHECK-NEXT: PhysicalAddress: 0x10000000
-# CHECK-NEXT: FileSize: 288
-# CHECK-NEXT: MemSize: 288
+# CHECK-NEXT: FileSize: 344
+# CHECK-NEXT: MemSize: 344
# CHECK-NEXT: Flags [ (0x4)
# CHECK-NEXT: PF_R (0x4)
# CHECK-NEXT: ]
diff --git a/test/ELF/bsymbolic-undef.s b/test/ELF/bsymbolic-undef.s
index 1269cb456228..97080273cf6c 100644
--- a/test/ELF/bsymbolic-undef.s
+++ b/test/ELF/bsymbolic-undef.s
@@ -5,7 +5,7 @@
# CHECK: DynamicSymbols [
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: @
+# CHECK-NEXT: Name:
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Local (0x0)
@@ -14,7 +14,7 @@
# CHECK-NEXT: Section: Undefined (0x0)
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: undef@
+# CHECK-NEXT: Name: undef
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Global (0x1)
diff --git a/test/ELF/cgprofile-obj.s b/test/ELF/cgprofile-obj.s
new file mode 100644
index 000000000000..4b7f465328cc
--- /dev/null
+++ b/test/ELF/cgprofile-obj.s
@@ -0,0 +1,44 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: ld.lld -e A %t.o -o %t
+# RUN: llvm-nm --no-sort %t | FileCheck %s
+# RUN: ld.lld --no-call-graph-profile-sort -e A %t.o -o %t
+# RUN: llvm-nm --no-sort %t | FileCheck %s --check-prefix=NO-CG
+
+ .section .text.D,"ax",@progbits
+D:
+ retq
+
+ .section .text.C,"ax",@progbits
+ .globl C
+C:
+ retq
+
+ .section .text.B,"ax",@progbits
+ .globl B
+B:
+ retq
+
+ .section .text.A,"ax",@progbits
+ .globl A
+A:
+Aa:
+ retq
+
+ .cg_profile A, B, 10
+ .cg_profile A, B, 10
+ .cg_profile Aa, B, 80
+ .cg_profile A, C, 40
+ .cg_profile B, C, 30
+ .cg_profile C, D, 90
+
+# CHECK: 0000000000201003 t D
+# CHECK: 0000000000201000 T A
+# CHECK: 0000000000201001 T B
+# CHECK: 0000000000201002 T C
+
+# NO-CG: 0000000000201000 t D
+# NO-CG: 0000000000201003 T A
+# NO-CG: 0000000000201002 T B
+# NO-CG: 0000000000201001 T C
diff --git a/test/ELF/cgprofile-shared-warn.s b/test/ELF/cgprofile-shared-warn.s
new file mode 100644
index 000000000000..86312770d1d7
--- /dev/null
+++ b/test/ELF/cgprofile-shared-warn.s
@@ -0,0 +1,21 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: ld.lld --shared %t.o -o /dev/null 2>&1 | count 0
+# RUN: ld.lld -e A --unresolved-symbols=ignore-all %t.o -o /dev/null 2>&1 | count 0
+
+# RUN: echo '.globl B; B: ret' | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %t1.o
+# RUN: ld.lld --shared %t1.o -o %t1.so
+# RUN: ld.lld -e A %t.o %t1.so -o /dev/null 2>&1 | count 0
+
+# RUN: ld.lld --gc-sections %t.o %t1.so -o /dev/null 2>&1 | count 0
+.globl _start
+_start:
+ ret
+
+.section .text.A,"ax",@progbits
+.globl A
+A:
+ callq B
+
+.cg_profile A, B, 10
diff --git a/test/ELF/cgprofile-txt2.s b/test/ELF/cgprofile-txt2.s
new file mode 100644
index 000000000000..e4f68524d2ac
--- /dev/null
+++ b/test/ELF/cgprofile-txt2.s
@@ -0,0 +1,38 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: echo "A B 5" > %t.call_graph
+# RUN: echo "B C 50" >> %t.call_graph
+# RUN: echo "C D 40" >> %t.call_graph
+# RUN: echo "D B 10" >> %t.call_graph
+# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph -o %t2
+# RUN: llvm-readobj -symbols %t2 | FileCheck %s
+
+# CHECK: Name: A
+# CHECK-NEXT: Value: 0x201003
+# CHECK: Name: B
+# CHECK-NEXT: Value: 0x201000
+# CHECK: Name: C
+# CHECK-NEXT: Value: 0x201001
+# CHECK: Name: D
+# CHECK-NEXT: Value: 0x201002
+
+.section .text.A,"ax",@progbits
+.globl A
+A:
+ nop
+
+.section .text.B,"ax",@progbits
+.globl B
+B:
+ nop
+
+.section .text.C,"ax",@progbits
+.globl C
+C:
+ nop
+
+.section .text.D,"ax",@progbits
+.globl D
+D:
+ nop
diff --git a/test/ELF/common-gc2.s b/test/ELF/common-gc2.s
index 165bf625394e..21bff88b6181 100644
--- a/test/ELF/common-gc2.s
+++ b/test/ELF/common-gc2.s
@@ -3,8 +3,8 @@
# RUN: ld.lld -gc-sections -export-dynamic %t -o %t1
# RUN: llvm-readobj --dyn-symbols %t1 | FileCheck %s
-# CHECK: Name: bar@
-# CHECK: Name: foo@
+# CHECK: Name: bar
+# CHECK: Name: foo
.comm foo,4,4
.comm bar,4,4
diff --git a/test/ELF/compressed-debug-input-err.s b/test/ELF/compressed-debug-input-err.s
index e32ba315b342..191075e7c7c7 100644
--- a/test/ELF/compressed-debug-input-err.s
+++ b/test/ELF/compressed-debug-input-err.s
@@ -3,8 +3,8 @@
# 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 we are able to report zlib decompressor errors.
-# CHECK: error: {{.*}}.o:(.zdebug_str): decompress failed: zlib error: Z_DATA_ERROR
+## Check we are able to report zlib uncompress errors.
+# CHECK: error: {{.*}}.o:(.debug_str): uncompress failed: zlib error: Z_DATA_ERROR
.section .zdebug_str,"MS",@progbits,1
.ascii "ZLIB"
diff --git a/test/ELF/conflict.s b/test/ELF/conflict.s
index cbe1b5b8845a..6cfb8f557ad3 100644
--- a/test/ELF/conflict.s
+++ b/test/ELF/conflict.s
@@ -26,6 +26,7 @@
# RUN: FileCheck -check-prefix=DEMANGLE %s
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/conflict.s -o %t2.o
+# RUN: rm -f %t3.a
# 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
diff --git a/test/ELF/copy-rel-tls.s b/test/ELF/copy-rel-tls.s
new file mode 100644
index 000000000000..265cce1bc7a0
--- /dev/null
+++ b/test/ELF/copy-rel-tls.s
@@ -0,0 +1,15 @@
+// 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/copy-rel-tls.s -o %t1.o
+// RUN: ld.lld %t1.o -shared -soname t1.so -o %t1.so
+// RUN: ld.lld %t.o %t1.so -o %t
+// RUN: llvm-nm %t1.so | FileCheck %s
+// RUN: llvm-nm %t | FileCheck --check-prefix=TLS %s
+// foo and tfoo have the same st_value but we should not copy tfoo.
+// CHECK: 2000 B foo
+// CHECK: 2000 B tfoo
+// TLS-NOT: tfoo
+
+.global _start
+_start:
+ leaq foo, %rax
diff --git a/test/ELF/debug-line-str.s b/test/ELF/debug-line-str.s
new file mode 100644
index 000000000000..e23b5c879291
--- /dev/null
+++ b/test/ELF/debug-line-str.s
@@ -0,0 +1,136 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux -dwarf-version=5 %s -o %t.o
+# RUN: not ld.lld %t.o -o %t1 2>&1 | FileCheck %s
+
+# Check we do not crash and able to report the source location.
+
+# CHECK: error: undefined symbol: foo()
+# CHECK-NEXT: >>> referenced by test.cpp:3
+# CHECK-NEXT: >>> {{.*}}.o:(.text+0x1)
+
+# The code below is the reduced version of the output
+# from the following invocation and source:
+#
+# // test.cpp:
+# int foo();
+# int main() {
+# return foo();
+# }
+#
+# clang -gdwarf-5 test.cpp -o test.s -S
+# clang version 8.0.0 (trunk 343487)
+
+.text
+.file "test.cpp"
+.globl main
+.type main,@function
+main:
+.Lfunc_begin0:
+ .file 0 "/home/path" "test.cpp" md5 0x8ed32099ab837bd13543fd3e8102739f
+ .file 1 "test.cpp" md5 0x8ed32099ab837bd13543fd3e8102739f
+ .loc 1 3 10 prologue_end
+ jmp _Z3foov
+.Lfunc_end0:
+
+.Lstr_offsets_base0:
+.section .debug_str,"MS",@progbits,1
+ .asciz "stub"
+
+.section .debug_str_offsets,"",@progbits
+ .long 0
+
+.section .debug_abbrev,"",@progbits
+ .byte 1 # Abbreviation Code
+ .byte 17 # DW_TAG_compile_unit
+ .byte 0 # DW_CHILDREN_yes
+ .byte 37 # DW_AT_producer
+ .byte 37 # DW_FORM_strx1
+ .byte 19 # DW_AT_language
+ .byte 5 # DW_FORM_data2
+ .byte 3 # DW_AT_name
+ .byte 37 # DW_FORM_strx1
+ .byte 114 # DW_AT_str_offsets_base
+ .byte 23 # DW_FORM_sec_offset
+ .byte 16 # DW_AT_stmt_list
+ .byte 23 # DW_FORM_sec_offset
+ .byte 27 # DW_AT_comp_dir
+ .byte 37 # DW_FORM_strx1
+ .byte 17 # DW_AT_low_pc
+ .byte 1 # DW_FORM_addr
+ .byte 18 # DW_AT_high_pc
+ .byte 6 # DW_FORM_data4
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+
+ .byte 2 # Abbreviation Code
+ .byte 46 # DW_TAG_subprogram
+ .byte 0 # DW_CHILDREN_no
+ .byte 17 # DW_AT_low_pc
+ .byte 1 # DW_FORM_addr
+ .byte 18 # DW_AT_high_pc
+ .byte 6 # DW_FORM_data4
+ .byte 64 # DW_AT_frame_base
+ .byte 24 # DW_FORM_exprloc
+ .byte 3 # DW_AT_name
+ .byte 37 # DW_FORM_strx1
+ .byte 58 # DW_AT_decl_file
+ .byte 11 # DW_FORM_data1
+ .byte 59 # DW_AT_decl_line
+ .byte 11 # DW_FORM_data1
+ .byte 73 # DW_AT_type
+ .byte 19 # DW_FORM_ref4
+ .byte 63 # DW_AT_external
+ .byte 25 # DW_FORM_flag_present
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+
+ .byte 3 # Abbreviation Code
+ .byte 36 # DW_TAG_base_type
+ .byte 0 # DW_CHILDREN_no
+ .byte 3 # DW_AT_name
+ .byte 37 # DW_FORM_strx1
+ .byte 62 # DW_AT_encoding
+ .byte 11 # DW_FORM_data1
+ .byte 11 # DW_AT_byte_size
+ .byte 11 # DW_FORM_data1
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 0 # EOM(3)
+
+.section .debug_info,"",@progbits
+.Lcu_begin0:
+ .long 61 # Length of Unit
+ .short 5 # DWARF version number
+ .byte 1 # DWARF Unit Type
+ .byte 8 # Address Size (in bytes)
+ .long .debug_abbrev # Offset Into Abbrev. Section
+
+ .byte 1 # Abbrev [1] 0xc:0x35 DW_TAG_compile_unit
+ .byte 0 # DW_AT_producer
+ .short 0 # DW_AT_language
+ .byte 0 # DW_AT_name
+ .long .Lstr_offsets_base0 # DW_AT_str_offsets_base
+ .long .Lline_table_start0 # DW_AT_stmt_list
+ .byte 0 # DW_AT_comp_dir
+ .quad .Lfunc_begin0 # DW_AT_low_pc
+ .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
+
+ .byte 2 # Abbrev [2] 0x26:0x16 DW_TAG_subprogram
+ .quad .Lfunc_begin0 # DW_AT_low_pc
+ .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
+ .byte 1 # DW_AT_frame_base
+ .byte 87
+ .byte 0 # DW_AT_name
+ .byte 1 # DW_AT_decl_file
+ .byte 2 # DW_AT_decl_line
+ .long 60 # DW_AT_type
+ # DW_AT_external
+
+ .byte 3 # Abbrev [3] 0x3c:0x4 DW_TAG_base_type
+ .byte 0 # DW_AT_name
+ .byte 5 # DW_AT_encoding
+ .byte 4 # DW_AT_byte_size
+ .byte 0 # End Of Children Mark
+
+.section .debug_line,"",@progbits
+.Lline_table_start0:
diff --git a/test/ELF/debug-relocation-none.test b/test/ELF/debug-relocation-none.test
new file mode 100644
index 000000000000..d22941db2220
--- /dev/null
+++ b/test/ELF/debug-relocation-none.test
@@ -0,0 +1,58 @@
+# REQUIRES: x86
+# RUN: yaml2obj %s -o %t.o
+# RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
+
+## Previously we would report an error saying the relocation in .debug_info
+## has an unsupported target.
+## Check we do not report debug information parsing errors when relocation
+## used is of type R_*_NONE, what actually means it should be ignored.
+
+# CHECK-NOT: error
+# CHECK: error: undefined symbol: bar
+# CHECK-NOT: error
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ Content: '0000000000000000'
+ - Name: .rela.text
+ Type: SHT_RELA
+ AddressAlign: 8
+ Link: .symtab
+ Info: .text
+ Relocations:
+ - Offset: 0x0000000000000000
+ Symbol: bar
+ Type: R_X86_64_64
+ - Name: .debug_line
+ Type: SHT_PROGBITS
+ Content: 3300000002001C0000000101FB0E0D000101010100000001000001006162632E7300000000000009020000000000000000140208000101
+ - Name: .rela.debug_line
+ AddressAlign: 8
+ Type: SHT_RELA
+ Link: .symtab
+ Info: .debug_line
+ Relocations:
+ - Offset: 0x0000000000000029
+ Type: R_X86_64_NONE
+ - Name: .debug_info
+ Type: SHT_PROGBITS
+ AddressAlign: 0x0000000000000001
+ Content: 0C000000040000000000080100000000
+ - Name: .debug_abbrev
+ Type: SHT_PROGBITS
+ AddressAlign: 0x0000000000000001
+ Content: '0111001017000000'
+
+Symbols:
+ Global:
+ - Name: _start
+ Section: .text
+ - Name: bar
diff --git a/test/ELF/defsym.s b/test/ELF/defsym.s
index 2abc08f99dfc..598ecd51681f 100644
--- a/test/ELF/defsym.s
+++ b/test/ELF/defsym.s
@@ -9,6 +9,12 @@
# RUN: llvm-readobj -t -s %t2 | FileCheck %s
# RUN: llvm-objdump -d -print-imm-hex %t2 | FileCheck %s --check-prefix=USE
+## Check we are reporting the error correctly and don't crash
+## when handling the second --defsym.
+# RUN: not ld.lld -o %t2 %t.o --defsym ERR+ \
+# --defsym foo2=foo1 2>&1 | FileCheck %s --check-prefix=ERR
+# ERR: error: -defsym: syntax error: ERR+
+
# CHECK: Symbol {
# CHECK: Name: foo1
# CHECK-NEXT: Value: 0x123
@@ -68,8 +74,17 @@
# EXPR-NEXT: Section: Absolute
# EXPR-NEXT: }
-# RUN: not ld.lld -o %t %t.o --defsym=foo2=und 2>&1 | FileCheck %s -check-prefix=ERR
-# ERR: error: -defsym:1: symbol not found: und
+# RUN: not ld.lld -o %t %t.o --defsym=foo2=und 2>&1 | FileCheck %s -check-prefix=ERR1
+# ERR1: error: -defsym:1: symbol not found: und
+
+# RUN: not ld.lld -o %t %t.o --defsym=xxx=yyy,zzz 2>&1 | FileCheck %s -check-prefix=ERR2
+# ERR2: -defsym:1: EOF expected, but got ,
+
+# RUN: not ld.lld -o %t %t.o --defsym=foo 2>&1 | FileCheck %s -check-prefix=ERR3
+# ERR3: error: -defsym: syntax error: foo
+
+# RUN: not ld.lld -o %t %t.o --defsym= 2>&1 | FileCheck %s -check-prefix=ERR4
+# ERR4: error: -defsym: syntax error:
.globl foo1
foo1 = 0x123
diff --git a/test/ELF/dont-export-hidden.s b/test/ELF/dont-export-hidden.s
index 161e342bea84..651c024a03fe 100644
--- a/test/ELF/dont-export-hidden.s
+++ b/test/ELF/dont-export-hidden.s
@@ -19,7 +19,7 @@ foo:
// CHECK: DynamicSymbols [
// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: @
+// CHECK-NEXT: Name:
// CHECK-NEXT: Value: 0x0
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local
diff --git a/test/ELF/driver-access.test b/test/ELF/driver-access.test
index 46b87c1f7e5d..da8fa6cd9de3 100644
--- a/test/ELF/driver-access.test
+++ b/test/ELF/driver-access.test
@@ -1,4 +1,4 @@
-# REQUIRES: x86, shell
+# REQUIRES: x86
# Make sure that LLD works even if the current directory is not writable.
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
diff --git a/test/ELF/driver.test b/test/ELF/driver.test
index 20bc79509725..585800a3b0b5 100644
--- a/test/ELF/driver.test
+++ b/test/ELF/driver.test
@@ -62,6 +62,9 @@
# RUN: not ld.lld %t -z foo 2>&1 | FileCheck -check-prefix=ERR10 %s
# ERR10: unknown -z value: foo
+## Check we report "unknown -z value" error even with -v.
+# RUN: not ld.lld %t -z foo -v 2>&1 | FileCheck -check-prefix=ERR10 %s
+
# RUN: not ld.lld %t -z max-page-size 2>&1 | FileCheck -check-prefix=ERR11 %s
# ERR11: unknown -z value: max-page-size
diff --git a/test/ELF/dt_flags.s b/test/ELF/dt_flags.s
index e160e0600378..5f6addd0780a 100644
--- a/test/ELF/dt_flags.s
+++ b/test/ELF/dt_flags.s
@@ -3,7 +3,8 @@
# 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 initfirst -z now -z nodelete -z nodlopen -z origin -Bsymbolic %t %t.so -o %t1
+# RUN: ld.lld -z global -z initfirst -z interpose -z now -z nodefaultlib \
+# RUN: -z nodelete -z nodlopen -z origin -Bsymbolic %t %t.so -o %t1
# RUN: llvm-readobj -dynamic-table %t1 | FileCheck -check-prefix=FLAGS %s
# RUN: ld.lld %t %t.so -o %t2
@@ -14,7 +15,7 @@
# FLAGS: DynamicSection [
# FLAGS: 0x000000000000001E FLAGS ORIGIN SYMBOLIC BIND_NOW
-# FLAGS: 0x000000006FFFFFFB FLAGS_1 NOW NODELETE INITFIRST NOOPEN ORIGIN
+# FLAGS: 0x000000006FFFFFFB FLAGS_1 NOW GLOBAL NODELETE INITFIRST NOOPEN ORIGIN INTERPOSE NODEFLIB
# FLAGS: ]
# CHECK: DynamicSection [
diff --git a/test/ELF/dynamic-list-locals.s b/test/ELF/dynamic-list-locals.s
new file mode 100644
index 000000000000..36ac849f514d
--- /dev/null
+++ b/test/ELF/dynamic-list-locals.s
@@ -0,0 +1,7 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: echo "{ local: *; };" > %t.list
+# RUN: not ld.lld -dynamic-list %t.list -shared %t.o -o %t.so 2>&1 | FileCheck %s
+
+# CHECK: error: {{.*}}:1: "local:" scope not supported in --dynamic-list
diff --git a/test/ELF/dynamic-list-preempt.s b/test/ELF/dynamic-list-preempt.s
index 2bb10a3ed0a6..daed27a08f09 100644
--- a/test/ELF/dynamic-list-preempt.s
+++ b/test/ELF/dynamic-list-preempt.s
@@ -16,7 +16,7 @@
# DYNSYMS: DynamicSymbols [
# DYNSYMS-NEXT: Symbol {
-# DYNSYMS-NEXT: Name: @ (0)
+# DYNSYMS-NEXT: Name:
# DYNSYMS-NEXT: Value: 0x0
# DYNSYMS-NEXT: Size: 0
# DYNSYMS-NEXT: Binding: Local
@@ -25,7 +25,7 @@
# DYNSYMS-NEXT: Section: Undefined
# DYNSYMS-NEXT: }
# DYNSYMS-NEXT: Symbol {
-# DYNSYMS-NEXT: Name: bar@
+# DYNSYMS-NEXT: Name: bar
# DYNSYMS-NEXT: Value:
# DYNSYMS-NEXT: Size:
# DYNSYMS-NEXT: Binding: Global
@@ -34,7 +34,7 @@
# DYNSYMS-NEXT: Section:
# DYNSYMS-NEXT: }
# DYNSYMS-NEXT: Symbol {
-# DYNSYMS-NEXT: Name: ext@
+# DYNSYMS-NEXT: Name: ext
# DYNSYMS-NEXT: Value:
# DYNSYMS-NEXT: Size:
# DYNSYMS-NEXT: Binding: Global
@@ -43,7 +43,7 @@
# DYNSYMS-NEXT: Section:
# DYNSYMS-NEXT: }
# DYNSYMS-NEXT: Symbol {
-# DYNSYMS-NEXT: Name: foo@
+# DYNSYMS-NEXT: Name: foo
# DYNSYMS-NEXT: Value:
# DYNSYMS-NEXT: Size:
# DYNSYMS-NEXT: Binding: Global
diff --git a/test/ELF/dynamic-list-unexpected-end.s b/test/ELF/dynamic-list-unexpected-end.s
new file mode 100644
index 000000000000..f485a662dbf9
--- /dev/null
+++ b/test/ELF/dynamic-list-unexpected-end.s
@@ -0,0 +1,7 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: echo "{ }; foo;" > %t.list
+# RUN: not ld.lld -dynamic-list %t.list -shared %t.o -o %t.so 2>&1 | FileCheck %s
+
+# CHECK: error: {{.*}}:1: EOF expected, but got foo
diff --git a/test/ELF/dynamic-list-wildcard.s b/test/ELF/dynamic-list-wildcard.s
index cd7ed71771ae..09a78af01a5a 100644
--- a/test/ELF/dynamic-list-wildcard.s
+++ b/test/ELF/dynamic-list-wildcard.s
@@ -8,7 +8,7 @@
# CHECK: DynamicSymbols [
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: @ (0)
+# CHECK-NEXT: Name:
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Local (0x0)
@@ -17,7 +17,7 @@
# CHECK-NEXT: Section: Undefined (0x0)
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: foo1@ (1)
+# CHECK-NEXT: Name: foo1
# CHECK-NEXT: Value: 0x1000
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Global (0x1)
@@ -26,7 +26,7 @@
# CHECK-NEXT: Section: .text (0x4)
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: foo11@ (6)
+# CHECK-NEXT: Name: foo11
# CHECK-NEXT: Value: 0x1001
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Global (0x1)
diff --git a/test/ELF/dynamic-list.s b/test/ELF/dynamic-list.s
index 888508e270a7..f6addcb9bf2e 100644
--- a/test/ELF/dynamic-list.s
+++ b/test/ELF/dynamic-list.s
@@ -23,7 +23,7 @@
# CHECK: DynamicSymbols [
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: @
+# CHECK-NEXT: Name:
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Local
@@ -32,7 +32,7 @@
# CHECK-NEXT: Section: Undefined
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: foo1@
+# CHECK-NEXT: Name: foo1
# CHECK-NEXT: Value: 0x201000
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Global (0x1)
@@ -54,7 +54,7 @@
# CHECK2: DynamicSymbols [
# CHECK2-NEXT: Symbol {
-# CHECK2-NEXT: Name: @
+# CHECK2-NEXT: Name:
# CHECK2-NEXT: Value: 0x0
# CHECK2-NEXT: Size: 0
# CHECK2-NEXT: Binding: Local
@@ -63,7 +63,7 @@
# CHECK2-NEXT: Section: Undefined
# CHECK2-NEXT: }
# CHECK2-NEXT: Symbol {
-# CHECK2-NEXT: Name: foo1@
+# CHECK2-NEXT: Name: foo1
# CHECK2-NEXT: Value: 0x201000
# CHECK2-NEXT: Size: 0
# CHECK2-NEXT: Binding: Global (0x1)
@@ -72,7 +72,7 @@
# CHECK2-NEXT: Section: .text (0x4)
# CHECK2-NEXT: }
# CHECK2-NEXT: Symbol {
-# CHECK2-NEXT: Name: foo2@
+# CHECK2-NEXT: Name: foo2
# CHECK2-NEXT: Value: 0x201001
# CHECK2-NEXT: Size: 0
# CHECK2-NEXT: Binding: Global (0x1)
@@ -81,7 +81,7 @@
# CHECK2-NEXT: Section: .text (0x4)
# CHECK2-NEXT: }
# CHECK2-NEXT: Symbol {
-# CHECK2-NEXT: Name: foo31@
+# CHECK2-NEXT: Name: foo31
# CHECK2-NEXT: Value: 0x201002
# CHECK2-NEXT: Size: 0
# CHECK2-NEXT: Binding: Global (0x1)
@@ -104,7 +104,7 @@
# CHECK3: DynamicSymbols [
# CHECK3-NEXT: Symbol {
-# CHECK3-NEXT: Name: @
+# CHECK3-NEXT: Name:
# CHECK3-NEXT: Value: 0x0
# CHECK3-NEXT: Size: 0
# CHECK3-NEXT: Binding: Local
@@ -113,7 +113,7 @@
# CHECK3-NEXT: Section: Undefined
# CHECK3-NEXT: }
# CHECK3-NEXT: Symbol {
-# CHECK3-NEXT: Name: _start@
+# CHECK3-NEXT: Name: _start
# CHECK3-NEXT: Value: 0x201003
# CHECK3-NEXT: Size: 0
# CHECK3-NEXT: Binding: Global (0x1)
@@ -122,7 +122,7 @@
# CHECK3-NEXT: Section: .text (0x4)
# CHECK3-NEXT: }
# CHECK3-NEXT: Symbol {
-# CHECK3-NEXT: Name: foo1@
+# CHECK3-NEXT: Name: foo1
# CHECK3-NEXT: Value: 0x201000
# CHECK3-NEXT: Size: 0
# CHECK3-NEXT: Binding: Global (0x1)
@@ -131,7 +131,7 @@
# CHECK3-NEXT: Section: .text (0x4)
# CHECK3-NEXT: }
# CHECK3-NEXT: Symbol {
-# CHECK3-NEXT: Name: foo2@
+# CHECK3-NEXT: Name: foo2
# CHECK3-NEXT: Value: 0x201001
# CHECK3-NEXT: Size: 0
# CHECK3-NEXT: Binding: Global (0x1)
@@ -140,7 +140,7 @@
# CHECK3-NEXT: Section: .text (0x4)
# CHECK3-NEXT: }
# CHECK3-NEXT: Symbol {
-# CHECK3-NEXT: Name: foo31@
+# CHECK3-NEXT: Name: foo31
# CHECK3-NEXT: Value: 0x201002
# CHECK3-NEXT: Size: 0
# CHECK3-NEXT: Binding: Global (0x1)
diff --git a/test/ELF/dynamic-reloc.s b/test/ELF/dynamic-reloc.s
index 3a957ac0d05e..ce6d21c1b1e5 100644
--- a/test/ELF/dynamic-reloc.s
+++ b/test/ELF/dynamic-reloc.s
@@ -18,7 +18,7 @@
// CHECK-NEXT: Offset:
// CHECK-NEXT: Size: [[RELASIZE:.*]]
// CHECK-NEXT: Link: 1
-// CHECK-NEXT: Info: 0
+// CHECK-NEXT: Info: 7
// CHECK-NEXT: AddressAlignment: 8
// CHECK-NEXT: EntrySize: 24
diff --git a/test/ELF/dynsym-no-rosegment.s b/test/ELF/dynsym-no-rosegment.s
index 947f526e0575..c378bbce4afe 100644
--- a/test/ELF/dynsym-no-rosegment.s
+++ b/test/ELF/dynsym-no-rosegment.s
@@ -5,7 +5,7 @@
# CHECK: DynamicSymbols [
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: @ (0)
+# CHECK-NEXT: Name:
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Local
@@ -14,7 +14,7 @@
# CHECK-NEXT: Section: Undefined
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: undef@
+# CHECK-NEXT: Name: undef
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Global
diff --git a/test/ELF/dynsym-pie.s b/test/ELF/dynsym-pie.s
index b162d27335ac..6a7f4f1f0f70 100644
--- a/test/ELF/dynsym-pie.s
+++ b/test/ELF/dynsym-pie.s
@@ -50,7 +50,7 @@
# CHECK: DynamicSymbols [
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: @
+# CHECK-NEXT: Name:
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Local
diff --git a/test/ELF/edata-etext.s b/test/ELF/edata-etext.s
index 52070cbc4ce3..6eef319f189e 100644
--- a/test/ELF/edata-etext.s
+++ b/test/ELF/edata-etext.s
@@ -18,7 +18,6 @@
# CHECK-NEXT: 2 .data 00000002 0000000000202000 DATA
# CHECK-NEXT: 3 .bss 00000006 0000000000202004 BSS
# CHECK: SYMBOL TABLE:
-# CHECK-NEXT: 0000000000000000 *UND* 00000000
# CHECK-NEXT: 0000000000202002 .data 00000000 _edata
# CHECK-NEXT: 000000000020200a .bss 00000000 _end
# CHECK-NEXT: 0000000000201001 .text 00000000 _etext
diff --git a/test/ELF/emit-relocs-icf1.s b/test/ELF/emit-relocs-icf1.s
new file mode 100644
index 000000000000..2f7e0cab27f6
--- /dev/null
+++ b/test/ELF/emit-relocs-icf1.s
@@ -0,0 +1,32 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: ld.lld --emit-relocs --icf=all %t.o -o %t
+# RUN: llvm-readobj -r %t | FileCheck %s
+
+# CHECK: Relocations [
+# CHECK-NEXT: Section (3) .rela.text {
+# CHECK-NEXT: 0x201000 R_X86_64_64 .text 0x11
+# CHECK-NEXT: 0x201008 R_X86_64_64 .text 0x11
+# CHECK-NEXT: 0x201011 R_X86_64_64 .rodata 0x0
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
+
+.rodata
+quux:
+.quad 0xfe
+
+.section .text.foo,"ax"
+foo:
+.quad quux
+
+.section .text.bar,"ax"
+bar:
+.quad quux
+
+.text
+.quad foo
+.quad bar
+
+.global _start
+_start:
+ nop
diff --git a/test/ELF/emit-relocs-icf2.s b/test/ELF/emit-relocs-icf2.s
new file mode 100644
index 000000000000..7c9ac229b733
--- /dev/null
+++ b/test/ELF/emit-relocs-icf2.s
@@ -0,0 +1,36 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: ld.lld --gc-sections --emit-relocs --icf=all %t.o -o %t
+# RUN: llvm-readobj -r %t | FileCheck %s
+
+# CHECK: Relocations [
+# CHECK-NEXT: Section (3) .rela.text {
+# CHECK-NEXT: 0x201000 R_X86_64_64 .text 0x11
+# CHECK-NEXT: 0x201008 R_X86_64_64 .text 0x11
+# CHECK-NEXT: 0x201011 R_X86_64_64 .rodata 0x0
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
+
+.rodata
+quux:
+.quad 0xfe
+
+.section .text.foo,"ax"
+foo:
+.quad quux
+
+.section .text.bar,"ax"
+bar:
+.quad quux
+
+.section .text.baz,"ax"
+baz:
+.quad quux
+
+.text
+.quad foo
+.quad bar
+
+.global _start
+_start:
+ nop
diff --git a/test/ELF/empty-pack-dyn-relocs.s b/test/ELF/empty-pack-dyn-relocs.s
new file mode 100644
index 000000000000..b74a89d66d46
--- /dev/null
+++ b/test/ELF/empty-pack-dyn-relocs.s
@@ -0,0 +1,11 @@
+// REQUIRES: x86
+
+// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+// RUN: ld.lld -pie --pack-dyn-relocs=relr %t.o -o %t
+// RUN: llvm-readobj -sections %t | FileCheck %s
+
+.global _start
+_start:
+ nop
+
+# CHECK-NOT: Name: .relr.dyn
diff --git a/test/ELF/empty-ver.s b/test/ELF/empty-ver.s
index 3412f3134737..d923607bfb01 100644
--- a/test/ELF/empty-ver.s
+++ b/test/ELF/empty-ver.s
@@ -29,7 +29,7 @@
// CHECK-NEXT: Symbols [
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Version: 0
-// CHECK-NEXT: Name: @
+// CHECK-NEXT: Name:
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Version: 2
diff --git a/test/ELF/empty-ver2.s b/test/ELF/empty-ver2.s
index 2aceee128ba3..f4b288eb512c 100644
--- a/test/ELF/empty-ver2.s
+++ b/test/ELF/empty-ver2.s
@@ -8,11 +8,11 @@
# CHECK: Symbols [
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Version: 0
-# CHECK-NEXT: Name: @
+# CHECK-NEXT: Name:
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Version: 1
-# CHECK-NEXT: Name: bar@@
+# CHECK-NEXT: Name: bar@
# CHECK-NEXT: }
# CHECK-NEXT: ]
diff --git a/test/ELF/emulation-aarch64.s b/test/ELF/emulation-aarch64.s
new file mode 100644
index 000000000000..b9a6428fa953
--- /dev/null
+++ b/test/ELF/emulation-aarch64.s
@@ -0,0 +1,34 @@
+# REQUIRES: aarch64
+# RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-linux %s -o %taarch64
+# RUN: ld.lld -m aarch64linux %taarch64 -o %t2aarch64
+# RUN: llvm-readobj -file-headers %t2aarch64 | FileCheck --check-prefix=AARCH64 %s
+# RUN: ld.lld -m aarch64elf %taarch64 -o %t3aarch64
+# RUN: llvm-readobj -file-headers %t3aarch64 | FileCheck --check-prefix=AARCH64 %s
+# RUN: ld.lld -m aarch64_elf64_le_vec %taarch64 -o %t4aarch64
+# RUN: llvm-readobj -file-headers %t4aarch64 | FileCheck --check-prefix=AARCH64 %s
+# RUN: ld.lld %taarch64 -o %t5aarch64
+# RUN: llvm-readobj -file-headers %t5aarch64 | FileCheck --check-prefix=AARCH64 %s
+# RUN: echo 'OUTPUT_FORMAT(elf64-littleaarch64)' > %t4aarch64.script
+# RUN: ld.lld %t4aarch64.script %taarch64 -o %t4aarch64
+# RUN: llvm-readobj -file-headers %t4aarch64 | FileCheck --check-prefix=AARCH64 %s
+# AARCH64: ElfHeader {
+# AARCH64-NEXT: Ident {
+# AARCH64-NEXT: Magic: (7F 45 4C 46)
+# AARCH64-NEXT: Class: 64-bit (0x2)
+# AARCH64-NEXT: DataEncoding: LittleEndian (0x1)
+# AARCH64-NEXT: FileVersion: 1
+# AARCH64-NEXT: OS/ABI: SystemV (0x0)
+# AARCH64-NEXT: ABIVersion: 0
+# AARCH64-NEXT: Unused: (00 00 00 00 00 00 00)
+# AARCH64-NEXT: }
+# AARCH64-NEXT: Type: Executable (0x2)
+# AARCH64-NEXT: Machine: EM_AARCH64 (0xB7)
+# AARCH64-NEXT: Version: 1
+# AARCH64-NEXT: Entry:
+# AARCH64-NEXT: ProgramHeaderOffset: 0x40
+# AARCH64-NEXT: SectionHeaderOffset:
+# AARCH64-NEXT: Flags [ (0x0)
+# AARCH64-NEXT: ]
+
+.globl _start
+_start:
diff --git a/test/ELF/emulation-arm.s b/test/ELF/emulation-arm.s
new file mode 100644
index 000000000000..53015e4701c8
--- /dev/null
+++ b/test/ELF/emulation-arm.s
@@ -0,0 +1,27 @@
+# REQUIRES: arm
+# RUN: llvm-mc -filetype=obj -triple=armv7-unknown-linux %s -o %tarm
+# RUN: ld.lld -m armelf %tarm -o %t2arm
+# RUN: llvm-readobj -file-headers %t2arm | FileCheck --check-prefix=ARM %s
+# RUN: ld.lld -m armelf_linux_eabi %tarm -o %t3arm
+# RUN: llvm-readobj -file-headers %t3arm | FileCheck --check-prefix=ARM %s
+# RUN: ld.lld %tarm -o %t4arm
+# RUN: llvm-readobj -file-headers %t4arm | FileCheck --check-prefix=ARM %s
+# RUN: echo 'OUTPUT_FORMAT(elf32-littlearm)' > %t5arm.script
+# RUN: ld.lld %t5arm.script %tarm -o %t5arm
+# RUN: llvm-readobj -file-headers %t5arm | FileCheck --check-prefix=ARM %s
+# ARM: ElfHeader {
+# ARM-NEXT: Ident {
+# ARM-NEXT: Magic: (7F 45 4C 46)
+# ARM-NEXT: Class: 32-bit (0x1)
+# ARM-NEXT: DataEncoding: LittleEndian (0x1)
+# ARM-NEXT: FileVersion: 1
+# ARM-NEXT: OS/ABI: SystemV (0x0)
+# ARM-NEXT: ABIVersion: 0
+# ARM-NEXT: Unused: (00 00 00 00 00 00 00)
+# ARM-NEXT: }
+# ARM-NEXT: Type: Executable (0x2)
+# ARM-NEXT: Machine: EM_ARM (0x28)
+# ARM-NEXT: Version: 1
+
+.globl _start
+_start:
diff --git a/test/ELF/emulation-mips.s b/test/ELF/emulation-mips.s
new file mode 100644
index 000000000000..42d0dd973eb3
--- /dev/null
+++ b/test/ELF/emulation-mips.s
@@ -0,0 +1,189 @@
+# REQUIRES: mips
+# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %tmips
+# RUN: ld.lld -m elf32btsmip -e _start %tmips -o %t2mips
+# RUN: llvm-readobj -file-headers %t2mips | FileCheck --check-prefix=MIPS %s
+# RUN: ld.lld %tmips -e _start -o %t3mips
+# RUN: llvm-readobj -file-headers %t3mips | FileCheck --check-prefix=MIPS %s
+# RUN: echo 'OUTPUT_FORMAT(elf32-tradbigmips)' > %tmips.script
+# RUN: ld.lld %tmips.script -e _start %tmips -o %t4mips
+# RUN: llvm-readobj -file-headers %t4mips | FileCheck --check-prefix=MIPS %s
+# MIPS: ElfHeader {
+# MIPS-NEXT: Ident {
+# MIPS-NEXT: Magic: (7F 45 4C 46)
+# MIPS-NEXT: Class: 32-bit (0x1)
+# MIPS-NEXT: DataEncoding: BigEndian (0x2)
+# MIPS-NEXT: FileVersion: 1
+# MIPS-NEXT: OS/ABI: SystemV (0x0)
+# MIPS-NEXT: ABIVersion: 1
+# MIPS-NEXT: Unused: (00 00 00 00 00 00 00)
+# MIPS-NEXT: }
+# MIPS-NEXT: Type: Executable (0x2)
+# MIPS-NEXT: Machine: EM_MIPS (0x8)
+# MIPS-NEXT: Version: 1
+# MIPS-NEXT: Entry:
+# MIPS-NEXT: ProgramHeaderOffset: 0x34
+# MIPS-NEXT: SectionHeaderOffset:
+# MIPS-NEXT: Flags [
+# MIPS-NEXT: EF_MIPS_ABI_O32
+# MIPS-NEXT: EF_MIPS_ARCH_32
+# MIPS-NEXT: EF_MIPS_CPIC
+# MIPS-NEXT: ]
+
+# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux %s -o %tmipsel
+# RUN: ld.lld -m elf32ltsmip -e _start %tmipsel -o %t2mipsel
+# RUN: llvm-readobj -file-headers %t2mipsel | FileCheck --check-prefix=MIPSEL %s
+# RUN: ld.lld -melf32ltsmip -e _start %tmipsel -o %t2mipsel
+# RUN: llvm-readobj -file-headers %t2mipsel | FileCheck --check-prefix=MIPSEL %s
+# RUN: ld.lld %tmipsel -e _start -o %t3mipsel
+# RUN: llvm-readobj -file-headers %t3mipsel | FileCheck --check-prefix=MIPSEL %s
+# RUN: echo 'OUTPUT_FORMAT(elf32-tradlittlemips)' > %tmipsel.script
+# RUN: ld.lld %tmipsel.script -e _start %tmipsel -o %t4mipsel
+# RUN: llvm-readobj -file-headers %t4mipsel | FileCheck --check-prefix=MIPSEL %s
+# MIPSEL: ElfHeader {
+# MIPSEL-NEXT: Ident {
+# MIPSEL-NEXT: Magic: (7F 45 4C 46)
+# MIPSEL-NEXT: Class: 32-bit (0x1)
+# MIPSEL-NEXT: DataEncoding: LittleEndian (0x1)
+# MIPSEL-NEXT: FileVersion: 1
+# MIPSEL-NEXT: OS/ABI: SystemV (0x0)
+# MIPSEL-NEXT: ABIVersion: 1
+# MIPSEL-NEXT: Unused: (00 00 00 00 00 00 00)
+# MIPSEL-NEXT: }
+# MIPSEL-NEXT: Type: Executable (0x2)
+# MIPSEL-NEXT: Machine: EM_MIPS (0x8)
+# MIPSEL-NEXT: Version: 1
+# MIPSEL-NEXT: Entry:
+# MIPSEL-NEXT: ProgramHeaderOffset: 0x34
+# MIPSEL-NEXT: SectionHeaderOffset:
+# MIPSEL-NEXT: Flags [
+# MIPSEL-NEXT: EF_MIPS_ABI_O32
+# MIPSEL-NEXT: EF_MIPS_ARCH_32
+# MIPSEL-NEXT: EF_MIPS_CPIC
+# MIPSEL-NEXT: ]
+
+# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux-gnuabin32 %s -o %tmipsn32
+# RUN: ld.lld -m elf32btsmipn32 -e _start %tmipsn32 -o %t2mipsn32
+# RUN: llvm-readobj -file-headers %t2mipsn32 | FileCheck --check-prefix=MIPSN32 %s
+# RUN: ld.lld %tmipsn32 -e _start -o %t3mipsn32
+# RUN: llvm-readobj -file-headers %t3mipsn32 | FileCheck --check-prefix=MIPSN32 %s
+# RUN: echo 'OUTPUT_FORMAT(elf32-ntradbigmips)' > %tmipsn32.script
+# RUN: ld.lld %tmipsn32.script -e _start %tmipsn32 -o %t4mipsn32
+# RUN: llvm-readobj -file-headers %t4mipsn32 | FileCheck --check-prefix=MIPSN32 %s
+# MIPSN32: ElfHeader {
+# MIPSN32-NEXT: Ident {
+# MIPSN32-NEXT: Magic: (7F 45 4C 46)
+# MIPSN32-NEXT: Class: 32-bit (0x1)
+# MIPSN32-NEXT: DataEncoding: BigEndian (0x2)
+# MIPSN32-NEXT: FileVersion: 1
+# MIPSN32-NEXT: OS/ABI: SystemV (0x0)
+# MIPSN32-NEXT: ABIVersion: 1
+# MIPSN32-NEXT: Unused: (00 00 00 00 00 00 00)
+# MIPSN32-NEXT: }
+# MIPSN32-NEXT: Type: Executable (0x2)
+# MIPSN32-NEXT: Machine: EM_MIPS (0x8)
+# MIPSN32-NEXT: Version: 1
+# MIPSN32-NEXT: Entry:
+# MIPSN32-NEXT: ProgramHeaderOffset: 0x34
+# MIPSN32-NEXT: SectionHeaderOffset:
+# MIPSN32-NEXT: Flags [
+# MIPSN32-NEXT: EF_MIPS_ABI2
+# MIPSN32-NEXT: EF_MIPS_ARCH_64
+# MIPSN32-NEXT: EF_MIPS_CPIC
+# MIPSN32-NEXT: ]
+
+# RUN: llvm-mc -filetype=obj -triple=mips64el-unknown-linux-gnuabin32 %s -o %tmipsn32el
+# RUN: ld.lld -m elf32ltsmipn32 -e _start %tmipsn32el -o %t2mipsn32el
+# RUN: llvm-readobj -file-headers %t2mipsn32el | FileCheck --check-prefix=MIPSN32EL %s
+# RUN: ld.lld -melf32ltsmipn32 -e _start %tmipsn32el -o %t2mipsn32el
+# RUN: llvm-readobj -file-headers %t2mipsn32el | FileCheck --check-prefix=MIPSN32EL %s
+# RUN: ld.lld %tmipsn32el -e _start -o %t3mipsn32el
+# RUN: llvm-readobj -file-headers %t3mipsn32el | FileCheck --check-prefix=MIPSN32EL %s
+# RUN: echo 'OUTPUT_FORMAT(elf32-ntradlittlemips)' > %tmipsn32el.script
+# RUN: ld.lld %tmipsn32el.script -e _start %tmipsn32el -o %t4mipsn32el
+# RUN: llvm-readobj -file-headers %t4mipsn32el | FileCheck --check-prefix=MIPSN32EL %s
+# MIPSN32EL: ElfHeader {
+# MIPSN32EL-NEXT: Ident {
+# MIPSN32EL-NEXT: Magic: (7F 45 4C 46)
+# MIPSN32EL-NEXT: Class: 32-bit (0x1)
+# MIPSN32EL-NEXT: DataEncoding: LittleEndian (0x1)
+# MIPSN32EL-NEXT: FileVersion: 1
+# MIPSN32EL-NEXT: OS/ABI: SystemV (0x0)
+# MIPSN32EL-NEXT: ABIVersion: 1
+# MIPSN32EL-NEXT: Unused: (00 00 00 00 00 00 00)
+# MIPSN32EL-NEXT: }
+# MIPSN32EL-NEXT: Type: Executable (0x2)
+# MIPSN32EL-NEXT: Machine: EM_MIPS (0x8)
+# MIPSN32EL-NEXT: Version: 1
+# MIPSN32EL-NEXT: Entry:
+# MIPSN32EL-NEXT: ProgramHeaderOffset: 0x34
+# MIPSN32EL-NEXT: SectionHeaderOffset:
+# MIPSN32EL-NEXT: Flags [
+# MIPSN32EL-NEXT: EF_MIPS_ABI2
+# MIPSN32EL-NEXT: EF_MIPS_ARCH_64
+# MIPSN32EL-NEXT: EF_MIPS_CPIC
+# MIPSN32EL-NEXT: ]
+
+# 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
+# RUN: llvm-readobj -file-headers %t3mips64 | FileCheck --check-prefix=MIPS64 %s
+# RUN: echo 'OUTPUT_FORMAT(elf64-tradbigmips)' > %tmips64.script
+# RUN: ld.lld %tmips64.script -e _start %tmips64 -o %t4mips64
+# RUN: llvm-readobj -file-headers %t4mips64 | FileCheck --check-prefix=MIPS64 %s
+# MIPS64: ElfHeader {
+# MIPS64-NEXT: Ident {
+# MIPS64-NEXT: Magic: (7F 45 4C 46)
+# MIPS64-NEXT: Class: 64-bit (0x2)
+# MIPS64-NEXT: DataEncoding: BigEndian (0x2)
+# MIPS64-NEXT: FileVersion: 1
+# MIPS64-NEXT: OS/ABI: SystemV (0x0)
+# MIPS64-NEXT: ABIVersion: 0
+# MIPS64-NEXT: Unused: (00 00 00 00 00 00 00)
+# MIPS64-NEXT: }
+# MIPS64-NEXT: Type: Executable (0x2)
+# MIPS64-NEXT: Machine: EM_MIPS (0x8)
+# MIPS64-NEXT: Version: 1
+# MIPS64-NEXT: Entry:
+# MIPS64-NEXT: ProgramHeaderOffset: 0x40
+# MIPS64-NEXT: SectionHeaderOffset:
+# MIPS64-NEXT: Flags [
+# MIPS64-NEXT: EF_MIPS_ARCH_64
+# MIPS64-NEXT: EF_MIPS_CPIC
+# MIPS64-NEXT: EF_MIPS_PIC
+# MIPS64-NEXT: ]
+
+# 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
+# RUN: llvm-readobj -file-headers %t3mips64el | FileCheck --check-prefix=MIPS64EL %s
+# RUN: echo 'OUTPUT_FORMAT(elf64-tradlittlemips)' > %tmips64el.script
+# RUN: ld.lld %tmips64el.script -e _start %tmips64el -o %t4mips64el
+# RUN: llvm-readobj -file-headers %t4mips64el | FileCheck --check-prefix=MIPS64EL %s
+# MIPS64EL: ElfHeader {
+# MIPS64EL-NEXT: Ident {
+# MIPS64EL-NEXT: Magic: (7F 45 4C 46)
+# MIPS64EL-NEXT: Class: 64-bit (0x2)
+# MIPS64EL-NEXT: DataEncoding: LittleEndian (0x1)
+# MIPS64EL-NEXT: FileVersion: 1
+# MIPS64EL-NEXT: OS/ABI: SystemV (0x0)
+# MIPS64EL-NEXT: ABIVersion: 0
+# MIPS64EL-NEXT: Unused: (00 00 00 00 00 00 00)
+# MIPS64EL-NEXT: }
+# MIPS64EL-NEXT: Type: Executable (0x2)
+# MIPS64EL-NEXT: Machine: EM_MIPS (0x8)
+# MIPS64EL-NEXT: Version: 1
+# MIPS64EL-NEXT: Entry:
+# MIPS64EL-NEXT: ProgramHeaderOffset: 0x40
+# MIPS64EL-NEXT: SectionHeaderOffset:
+# MIPS64EL-NEXT: Flags [
+# MIPS64EL-NEXT: EF_MIPS_ARCH_64
+# MIPS64EL-NEXT: EF_MIPS_CPIC
+# MIPS64EL-NEXT: EF_MIPS_PIC
+# MIPS64EL-NEXT: ]
+
+.globl _start
+_start:
diff --git a/test/ELF/emulation-ppc.s b/test/ELF/emulation-ppc.s
new file mode 100644
index 000000000000..12e84782252f
--- /dev/null
+++ b/test/ELF/emulation-ppc.s
@@ -0,0 +1,75 @@
+# REQUIRES: ppc
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %tppc64
+# RUN: ld.lld -m elf64ppc %tppc64 -o %t2ppc64
+# RUN: llvm-readobj -file-headers %t2ppc64 | FileCheck --check-prefix=PPC64 %s
+# RUN: ld.lld %tppc64 -o %t3ppc64
+# RUN: llvm-readobj -file-headers %t3ppc64 | FileCheck --check-prefix=PPC64 %s
+# RUN: echo 'OUTPUT_FORMAT(elf64-powerpc)' > %tppc64.script
+# RUN: ld.lld %tppc64.script %tppc64 -o %t4ppc64
+# RUN: llvm-readobj -file-headers %t4ppc64 | FileCheck --check-prefix=PPC64 %s
+
+# PPC64: ElfHeader {
+# PPC64-NEXT: Ident {
+# PPC64-NEXT: Magic: (7F 45 4C 46)
+# PPC64-NEXT: Class: 64-bit (0x2)
+# PPC64-NEXT: DataEncoding: BigEndian (0x2)
+# PPC64-NEXT: FileVersion: 1
+# PPC64-NEXT: OS/ABI: SystemV (0x0)
+# PPC64-NEXT: ABIVersion: 0
+# PPC64-NEXT: Unused: (00 00 00 00 00 00 00)
+# PPC64-NEXT: }
+# PPC64-NEXT: Type: Executable (0x2)
+# PPC64-NEXT: Machine: EM_PPC64 (0x15)
+# PPC64-NEXT: Version: 1
+# PPC64-NEXT: Entry:
+# PPC64-NEXT: ProgramHeaderOffset: 0x40
+# PPC64-NEXT: SectionHeaderOffset:
+# PPC64-NEXT: Flags [ (0x2)
+# PPC64-NEXT: 0x2
+# PPC64-NEXT: ]
+# PPC64-NEXT: HeaderSize: 64
+# PPC64-NEXT: ProgramHeaderEntrySize: 56
+# PPC64-NEXT: ProgramHeaderCount:
+# PPC64-NEXT: SectionHeaderEntrySize: 64
+# PPC64-NEXT: SectionHeaderCount:
+# PPC64-NEXT: StringTableSectionIndex:
+# PPC64-NEXT: }
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %tppc64le
+# RUN: ld.lld -m elf64lppc %tppc64le -o %t2ppc64le
+# RUN: llvm-readobj -file-headers %t2ppc64le | FileCheck --check-prefix=PPC64LE %s
+# RUN: ld.lld %tppc64le -o %t3ppc64le
+# RUN: llvm-readobj -file-headers %t3ppc64le | FileCheck --check-prefix=PPC64LE %s
+# RUN: echo 'OUTPUT_FORMAT(elf64-powerpcle)' > %tppc64le.script
+# RUN: ld.lld %tppc64le.script %tppc64le -o %t4ppc64le
+# RUN: llvm-readobj -file-headers %t4ppc64le | FileCheck --check-prefix=PPC64LE %s
+
+# PPC64LE: ElfHeader {
+# PPC64LE-NEXT: Ident {
+# PPC64LE-NEXT: Magic: (7F 45 4C 46)
+# PPC64LE-NEXT: Class: 64-bit (0x2)
+# PPC64LE-NEXT: DataEncoding: LittleEndian (0x1)
+# PPC64LE-NEXT: FileVersion: 1
+# PPC64LE-NEXT: OS/ABI: SystemV (0x0)
+# PPC64LE-NEXT: ABIVersion: 0
+# PPC64LE-NEXT: Unused: (00 00 00 00 00 00 00)
+# PPC64LE-NEXT: }
+# PPC64LE-NEXT: Type: Executable (0x2)
+# PPC64LE-NEXT: Machine: EM_PPC64 (0x15)
+# PPC64LE-NEXT: Version: 1
+# PPC64LE-NEXT: Entry:
+# PPC64LE-NEXT: ProgramHeaderOffset: 0x40
+# PPC64LE-NEXT: SectionHeaderOffset:
+# PPC64LE-NEXT: Flags [ (0x2)
+# PPC64LE-NEXT: 0x2
+# PPC64LE-NEXT: ]
+# PPC64LE-NEXT: HeaderSize: 64
+# PPC64LE-NEXT: ProgramHeaderEntrySize: 56
+# PPC64LE-NEXT: ProgramHeaderCount:
+# PPC64LE-NEXT: SectionHeaderEntrySize: 64
+# PPC64LE-NEXT: SectionHeaderCount:
+# PPC64LE-NEXT: StringTableSectionIndex:
+# PPC64LE-NEXT: }
+
+.globl _start
+_start:
diff --git a/test/ELF/emulation-x86.s b/test/ELF/emulation-x86.s
new file mode 100644
index 000000000000..65d807c67f2f
--- /dev/null
+++ b/test/ELF/emulation-x86.s
@@ -0,0 +1,205 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-freebsd %s -o %tx64
+# RUN: ld.lld -m elf_amd64_fbsd %tx64 -o %t2x64
+# RUN: llvm-readobj -file-headers %t2x64 | FileCheck --check-prefix=AMD64 %s
+# RUN: ld.lld %tx64 -o %t3x64
+# RUN: llvm-readobj -file-headers %t3x64 | FileCheck --check-prefix=AMD64 %s
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.sysv
+# RUN: ld.lld -m elf_amd64_fbsd %t.sysv -o %t.freebsd
+# RUN: llvm-readobj -file-headers %t.freebsd | FileCheck --check-prefix=AMD64 %s
+# AMD64: ElfHeader {
+# AMD64-NEXT: Ident {
+# AMD64-NEXT: Magic: (7F 45 4C 46)
+# AMD64-NEXT: Class: 64-bit (0x2)
+# AMD64-NEXT: DataEncoding: LittleEndian (0x1)
+# AMD64-NEXT: FileVersion: 1
+# AMD64-NEXT: OS/ABI: FreeBSD (0x9)
+# AMD64-NEXT: ABIVersion: 0
+# AMD64-NEXT: Unused: (00 00 00 00 00 00 00)
+# AMD64-NEXT: }
+# AMD64-NEXT: Type: Executable (0x2)
+# AMD64-NEXT: Machine: EM_X86_64 (0x3E)
+# AMD64-NEXT: Version: 1
+# AMD64-NEXT: Entry:
+# AMD64-NEXT: ProgramHeaderOffset: 0x40
+# AMD64-NEXT: SectionHeaderOffset:
+# AMD64-NEXT: Flags [ (0x0)
+# AMD64-NEXT: ]
+# AMD64-NEXT: HeaderSize: 64
+# AMD64-NEXT: ProgramHeaderEntrySize: 56
+# AMD64-NEXT: ProgramHeaderCount:
+# AMD64-NEXT: SectionHeaderEntrySize: 64
+# AMD64-NEXT: SectionHeaderCount:
+# AMD64-NEXT: StringTableSectionIndex:
+# AMD64-NEXT: }
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %tx64
+# RUN: ld.lld -m elf_x86_64 %tx64 -o %t2x64
+# RUN: llvm-readobj -file-headers %t2x64 | FileCheck --check-prefix=X86-64 %s
+# RUN: ld.lld %tx64 -o %t3x64
+# RUN: llvm-readobj -file-headers %t3x64 | FileCheck --check-prefix=X86-64 %s
+# RUN: echo 'OUTPUT_FORMAT(elf64-x86-64)' > %t4x64.script
+# RUN: ld.lld %t4x64.script %tx64 -o %t4x64
+# RUN: ld.lld %tx64 -o %t4x64 %t4x64.script
+# RUN: llvm-readobj -file-headers %t4x64 | FileCheck --check-prefix=X86-64 %s
+# X86-64: ElfHeader {
+# X86-64-NEXT: Ident {
+# X86-64-NEXT: Magic: (7F 45 4C 46)
+# X86-64-NEXT: Class: 64-bit (0x2)
+# X86-64-NEXT: DataEncoding: LittleEndian (0x1)
+# X86-64-NEXT: FileVersion: 1
+# X86-64-NEXT: OS/ABI: SystemV (0x0)
+# X86-64-NEXT: ABIVersion: 0
+# X86-64-NEXT: Unused: (00 00 00 00 00 00 00)
+# X86-64-NEXT: }
+# X86-64-NEXT: Type: Executable (0x2)
+# X86-64-NEXT: Machine: EM_X86_64 (0x3E)
+# X86-64-NEXT: Version: 1
+# X86-64-NEXT: Entry:
+# X86-64-NEXT: ProgramHeaderOffset: 0x40
+# X86-64-NEXT: SectionHeaderOffset:
+# X86-64-NEXT: Flags [ (0x0)
+# X86-64-NEXT: ]
+# X86-64-NEXT: HeaderSize: 64
+# X86-64-NEXT: ProgramHeaderEntrySize: 56
+# X86-64-NEXT: ProgramHeaderCount:
+# X86-64-NEXT: SectionHeaderEntrySize: 64
+# X86-64-NEXT: SectionHeaderCount:
+# X86-64-NEXT: StringTableSectionIndex:
+# X86-64-NEXT: }
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux-gnux32 %s -o %tx32
+# RUN: ld.lld -m elf32_x86_64 %tx32 -o %t2x32
+# RUN: llvm-readobj -file-headers %t2x32 | FileCheck --check-prefix=X32 %s
+# RUN: ld.lld %tx32 -o %t3x32
+# RUN: llvm-readobj -file-headers %t3x32 | FileCheck --check-prefix=X32 %s
+# RUN: echo 'OUTPUT_FORMAT(elf32-x86-64)' > %t4x32.script
+# RUN: ld.lld %t4x32.script %tx32 -o %t4x32
+# RUN: llvm-readobj -file-headers %t4x32 | FileCheck --check-prefix=X32 %s
+# X32: ElfHeader {
+# X32-NEXT: Ident {
+# X32-NEXT: Magic: (7F 45 4C 46)
+# X32-NEXT: Class: 32-bit (0x1)
+# X32-NEXT: DataEncoding: LittleEndian (0x1)
+# X32-NEXT: FileVersion: 1
+# X32-NEXT: OS/ABI: SystemV (0x0)
+# X32-NEXT: ABIVersion: 0
+# X32-NEXT: Unused: (00 00 00 00 00 00 00)
+# X32-NEXT: }
+# X32-NEXT: Type: Executable (0x2)
+# X32-NEXT: Machine: EM_X86_64 (0x3E)
+# X32-NEXT: Version: 1
+# X32-NEXT: Entry:
+# X32-NEXT: ProgramHeaderOffset: 0x34
+# X32-NEXT: SectionHeaderOffset:
+# X32-NEXT: Flags [ (0x0)
+# X32-NEXT: ]
+# X32-NEXT: HeaderSize: 52
+# X32-NEXT: ProgramHeaderEntrySize: 32
+# X32-NEXT: ProgramHeaderCount:
+# X32-NEXT: SectionHeaderEntrySize: 40
+# X32-NEXT: SectionHeaderCount:
+# X32-NEXT: StringTableSectionIndex:
+# X32-NEXT: }
+
+# RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %s -o %tx86
+# RUN: ld.lld -m elf_i386 %tx86 -o %t2x86
+# RUN: llvm-readobj -file-headers %t2x86 | FileCheck --check-prefix=X86 %s
+# RUN: ld.lld %tx86 -o %t3x86
+# RUN: llvm-readobj -file-headers %t3x86 | FileCheck --check-prefix=X86 %s
+# RUN: echo 'OUTPUT_FORMAT(elf32-i386)' > %t4x86.script
+# RUN: ld.lld %t4x86.script %tx86 -o %t4x86
+# RUN: llvm-readobj -file-headers %t4x86 | FileCheck --check-prefix=X86 %s
+# X86: ElfHeader {
+# X86-NEXT: Ident {
+# X86-NEXT: Magic: (7F 45 4C 46)
+# X86-NEXT: Class: 32-bit (0x1)
+# X86-NEXT: DataEncoding: LittleEndian (0x1)
+# X86-NEXT: FileVersion: 1
+# X86-NEXT: OS/ABI: SystemV (0x0)
+# X86-NEXT: ABIVersion: 0
+# X86-NEXT: Unused: (00 00 00 00 00 00 00)
+# X86-NEXT: }
+# X86-NEXT: Type: Executable (0x2)
+# X86-NEXT: Machine: EM_386 (0x3)
+# X86-NEXT: Version: 1
+# X86-NEXT: Entry:
+# X86-NEXT: ProgramHeaderOffset: 0x34
+# X86-NEXT: SectionHeaderOffset:
+# X86-NEXT: Flags [ (0x0)
+# X86-NEXT: ]
+# X86-NEXT: HeaderSize: 52
+# X86-NEXT: ProgramHeaderEntrySize: 32
+# X86-NEXT: ProgramHeaderCount:
+# X86-NEXT: SectionHeaderEntrySize: 40
+# X86-NEXT: SectionHeaderCount:
+# X86-NEXT: StringTableSectionIndex:
+# X86-NEXT: }
+
+# RUN: llvm-mc -filetype=obj -triple=i686-unknown-freebsd %s -o %tx86fbsd
+# RUN: ld.lld -m elf_i386_fbsd %tx86fbsd -o %t2x86_fbsd
+# RUN: llvm-readobj -file-headers %t2x86_fbsd | FileCheck --check-prefix=X86FBSD %s
+# RUN: ld.lld %tx86fbsd -o %t3x86fbsd
+# RUN: llvm-readobj -file-headers %t3x86fbsd | FileCheck --check-prefix=X86FBSD %s
+# X86FBSD: ElfHeader {
+# X86FBSD-NEXT: Ident {
+# X86FBSD-NEXT: Magic: (7F 45 4C 46)
+# X86FBSD-NEXT: Class: 32-bit (0x1)
+# X86FBSD-NEXT: DataEncoding: LittleEndian (0x1)
+# X86FBSD-NEXT: FileVersion: 1
+# X86FBSD-NEXT: OS/ABI: FreeBSD (0x9)
+# X86FBSD-NEXT: ABIVersion: 0
+# X86FBSD-NEXT: Unused: (00 00 00 00 00 00 00)
+# X86FBSD-NEXT: }
+# X86FBSD-NEXT: Type: Executable (0x2)
+# X86FBSD-NEXT: Machine: EM_386 (0x3)
+# X86FBSD-NEXT: Version: 1
+# X86FBSD-NEXT: Entry:
+# X86FBSD-NEXT: ProgramHeaderOffset: 0x34
+# X86FBSD-NEXT: SectionHeaderOffset:
+# X86FBSD-NEXT: Flags [ (0x0)
+# X86FBSD-NEXT: ]
+# X86FBSD-NEXT: HeaderSize: 52
+# X86FBSD-NEXT: ProgramHeaderEntrySize: 32
+# X86FBSD-NEXT: ProgramHeaderCount:
+# X86FBSD-NEXT: SectionHeaderEntrySize: 40
+# X86FBSD-NEXT: SectionHeaderCount:
+# X86FBSD-NEXT: StringTableSectionIndex:
+# X86FBSD-NEXT: }
+
+# RUN: llvm-mc -filetype=obj -triple=i586-intel-elfiamcu %s -o %tiamcu
+# RUN: ld.lld -m elf_iamcu %tiamcu -o %t2iamcu
+# RUN: llvm-readobj -file-headers %t2iamcu | FileCheck --check-prefix=IAMCU %s
+# RUN: ld.lld %tiamcu -o %t3iamcu
+# RUN: llvm-readobj -file-headers %t3iamcu | FileCheck --check-prefix=IAMCU %s
+# RUN: echo 'OUTPUT_FORMAT(elf32-iamcu)' > %t4iamcu.script
+# RUN: ld.lld %t4iamcu.script %tiamcu -o %t4iamcu
+# RUN: llvm-readobj -file-headers %t4iamcu | FileCheck --check-prefix=IAMCU %s
+# IAMCU: ElfHeader {
+# IAMCU-NEXT: Ident {
+# IAMCU-NEXT: Magic: (7F 45 4C 46)
+# IAMCU-NEXT: Class: 32-bit (0x1)
+# IAMCU-NEXT: DataEncoding: LittleEndian (0x1)
+# IAMCU-NEXT: FileVersion: 1
+# IAMCU-NEXT: OS/ABI: SystemV (0x0)
+# IAMCU-NEXT: ABIVersion: 0
+# IAMCU-NEXT: Unused: (00 00 00 00 00 00 00)
+# IAMCU-NEXT: }
+# IAMCU-NEXT: Type: Executable (0x2)
+# IAMCU-NEXT: Machine: EM_IAMCU (0x6)
+# IAMCU-NEXT: Version: 1
+# IAMCU-NEXT: Entry:
+# IAMCU-NEXT: ProgramHeaderOffset: 0x34
+# IAMCU-NEXT: SectionHeaderOffset:
+# IAMCU-NEXT: Flags [ (0x0)
+# IAMCU-NEXT: ]
+# IAMCU-NEXT: HeaderSize: 52
+# IAMCU-NEXT: ProgramHeaderEntrySize: 32
+# IAMCU-NEXT: ProgramHeaderCount:
+# IAMCU-NEXT: SectionHeaderEntrySize: 40
+# IAMCU-NEXT: SectionHeaderCount:
+# IAMCU-NEXT: StringTableSectionIndex:
+# IAMCU-NEXT: }
+
+.globl _start
+_start:
diff --git a/test/ELF/emulation.s b/test/ELF/emulation.s
deleted file mode 100644
index 98f78b8ec1df..000000000000
--- a/test/ELF/emulation.s
+++ /dev/null
@@ -1,396 +0,0 @@
-# REQUIRES: x86,ppc,mips,aarch64
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-freebsd %s -o %tx64
-# RUN: ld.lld -m elf_amd64_fbsd %tx64 -o %t2x64
-# RUN: llvm-readobj -file-headers %t2x64 | FileCheck --check-prefix=AMD64 %s
-# RUN: ld.lld %tx64 -o %t3x64
-# RUN: llvm-readobj -file-headers %t3x64 | FileCheck --check-prefix=AMD64 %s
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.sysv
-# RUN: ld.lld -m elf_amd64_fbsd %t.sysv -o %t.freebsd
-# RUN: llvm-readobj -file-headers %t.freebsd | FileCheck --check-prefix=AMD64 %s
-# AMD64: ElfHeader {
-# AMD64-NEXT: Ident {
-# AMD64-NEXT: Magic: (7F 45 4C 46)
-# AMD64-NEXT: Class: 64-bit (0x2)
-# AMD64-NEXT: DataEncoding: LittleEndian (0x1)
-# AMD64-NEXT: FileVersion: 1
-# AMD64-NEXT: OS/ABI: FreeBSD (0x9)
-# AMD64-NEXT: ABIVersion: 0
-# AMD64-NEXT: Unused: (00 00 00 00 00 00 00)
-# AMD64-NEXT: }
-# AMD64-NEXT: Type: Executable (0x2)
-# AMD64-NEXT: Machine: EM_X86_64 (0x3E)
-# AMD64-NEXT: Version: 1
-# AMD64-NEXT: Entry:
-# AMD64-NEXT: ProgramHeaderOffset: 0x40
-# AMD64-NEXT: SectionHeaderOffset:
-# AMD64-NEXT: Flags [ (0x0)
-# AMD64-NEXT: ]
-# AMD64-NEXT: HeaderSize: 64
-# AMD64-NEXT: ProgramHeaderEntrySize: 56
-# AMD64-NEXT: ProgramHeaderCount:
-# AMD64-NEXT: SectionHeaderEntrySize: 64
-# AMD64-NEXT: SectionHeaderCount:
-# AMD64-NEXT: StringTableSectionIndex:
-# AMD64-NEXT: }
-
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %tx64
-# RUN: ld.lld -m elf_x86_64 %tx64 -o %t2x64
-# RUN: llvm-readobj -file-headers %t2x64 | FileCheck --check-prefix=X86-64 %s
-# RUN: ld.lld %tx64 -o %t3x64
-# RUN: llvm-readobj -file-headers %t3x64 | FileCheck --check-prefix=X86-64 %s
-# X86-64: ElfHeader {
-# X86-64-NEXT: Ident {
-# X86-64-NEXT: Magic: (7F 45 4C 46)
-# X86-64-NEXT: Class: 64-bit (0x2)
-# X86-64-NEXT: DataEncoding: LittleEndian (0x1)
-# X86-64-NEXT: FileVersion: 1
-# X86-64-NEXT: OS/ABI: SystemV (0x0)
-# X86-64-NEXT: ABIVersion: 0
-# X86-64-NEXT: Unused: (00 00 00 00 00 00 00)
-# X86-64-NEXT: }
-# X86-64-NEXT: Type: Executable (0x2)
-# X86-64-NEXT: Machine: EM_X86_64 (0x3E)
-# X86-64-NEXT: Version: 1
-# X86-64-NEXT: Entry:
-# X86-64-NEXT: ProgramHeaderOffset: 0x40
-# X86-64-NEXT: SectionHeaderOffset:
-# X86-64-NEXT: Flags [ (0x0)
-# X86-64-NEXT: ]
-# X86-64-NEXT: HeaderSize: 64
-# X86-64-NEXT: ProgramHeaderEntrySize: 56
-# X86-64-NEXT: ProgramHeaderCount:
-# X86-64-NEXT: SectionHeaderEntrySize: 64
-# X86-64-NEXT: SectionHeaderCount:
-# X86-64-NEXT: StringTableSectionIndex:
-# X86-64-NEXT: }
-
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux-gnux32 %s -o %tx32
-# RUN: ld.lld -m elf32_x86_64 %tx32 -o %t2x32
-# RUN: llvm-readobj -file-headers %t2x32 | FileCheck --check-prefix=X32 %s
-# RUN: ld.lld %tx32 -o %t3x32
-# RUN: llvm-readobj -file-headers %t3x32 | FileCheck --check-prefix=X32 %s
-# X32: ElfHeader {
-# X32-NEXT: Ident {
-# X32-NEXT: Magic: (7F 45 4C 46)
-# X32-NEXT: Class: 32-bit (0x1)
-# X32-NEXT: DataEncoding: LittleEndian (0x1)
-# X32-NEXT: FileVersion: 1
-# X32-NEXT: OS/ABI: SystemV (0x0)
-# X32-NEXT: ABIVersion: 0
-# X32-NEXT: Unused: (00 00 00 00 00 00 00)
-# X32-NEXT: }
-# X32-NEXT: Type: Executable (0x2)
-# X32-NEXT: Machine: EM_X86_64 (0x3E)
-# X32-NEXT: Version: 1
-# X32-NEXT: Entry:
-# X32-NEXT: ProgramHeaderOffset: 0x34
-# X32-NEXT: SectionHeaderOffset:
-# X32-NEXT: Flags [ (0x0)
-# X32-NEXT: ]
-# X32-NEXT: HeaderSize: 52
-# X32-NEXT: ProgramHeaderEntrySize: 32
-# X32-NEXT: ProgramHeaderCount:
-# X32-NEXT: SectionHeaderEntrySize: 40
-# X32-NEXT: SectionHeaderCount:
-# X32-NEXT: StringTableSectionIndex:
-# X32-NEXT: }
-
-# RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %s -o %tx86
-# RUN: ld.lld -m elf_i386 %tx86 -o %t2x86
-# RUN: llvm-readobj -file-headers %t2x86 | FileCheck --check-prefix=X86 %s
-# RUN: ld.lld %tx86 -o %t3x86
-# RUN: llvm-readobj -file-headers %t3x86 | FileCheck --check-prefix=X86 %s
-# X86: ElfHeader {
-# X86-NEXT: Ident {
-# X86-NEXT: Magic: (7F 45 4C 46)
-# X86-NEXT: Class: 32-bit (0x1)
-# X86-NEXT: DataEncoding: LittleEndian (0x1)
-# X86-NEXT: FileVersion: 1
-# X86-NEXT: OS/ABI: SystemV (0x0)
-# X86-NEXT: ABIVersion: 0
-# X86-NEXT: Unused: (00 00 00 00 00 00 00)
-# X86-NEXT: }
-# X86-NEXT: Type: Executable (0x2)
-# X86-NEXT: Machine: EM_386 (0x3)
-# X86-NEXT: Version: 1
-# X86-NEXT: Entry:
-# X86-NEXT: ProgramHeaderOffset: 0x34
-# X86-NEXT: SectionHeaderOffset:
-# X86-NEXT: Flags [ (0x0)
-# X86-NEXT: ]
-# X86-NEXT: HeaderSize: 52
-# X86-NEXT: ProgramHeaderEntrySize: 32
-# X86-NEXT: ProgramHeaderCount:
-# X86-NEXT: SectionHeaderEntrySize: 40
-# X86-NEXT: SectionHeaderCount:
-# X86-NEXT: StringTableSectionIndex:
-# X86-NEXT: }
-
-# RUN: llvm-mc -filetype=obj -triple=i686-unknown-freebsd %s -o %tx86fbsd
-# RUN: ld.lld -m elf_i386_fbsd %tx86fbsd -o %t2x86_fbsd
-# RUN: llvm-readobj -file-headers %t2x86_fbsd | FileCheck --check-prefix=X86FBSD %s
-# RUN: ld.lld %tx86fbsd -o %t3x86fbsd
-# RUN: llvm-readobj -file-headers %t3x86fbsd | FileCheck --check-prefix=X86FBSD %s
-# X86FBSD: ElfHeader {
-# X86FBSD-NEXT: Ident {
-# X86FBSD-NEXT: Magic: (7F 45 4C 46)
-# X86FBSD-NEXT: Class: 32-bit (0x1)
-# X86FBSD-NEXT: DataEncoding: LittleEndian (0x1)
-# X86FBSD-NEXT: FileVersion: 1
-# X86FBSD-NEXT: OS/ABI: FreeBSD (0x9)
-# X86FBSD-NEXT: ABIVersion: 0
-# X86FBSD-NEXT: Unused: (00 00 00 00 00 00 00)
-# X86FBSD-NEXT: }
-# X86FBSD-NEXT: Type: Executable (0x2)
-# X86FBSD-NEXT: Machine: EM_386 (0x3)
-# X86FBSD-NEXT: Version: 1
-# X86FBSD-NEXT: Entry:
-# X86FBSD-NEXT: ProgramHeaderOffset: 0x34
-# X86FBSD-NEXT: SectionHeaderOffset:
-# X86FBSD-NEXT: Flags [ (0x0)
-# X86FBSD-NEXT: ]
-# X86FBSD-NEXT: HeaderSize: 52
-# X86FBSD-NEXT: ProgramHeaderEntrySize: 32
-# X86FBSD-NEXT: ProgramHeaderCount:
-# X86FBSD-NEXT: SectionHeaderEntrySize: 40
-# X86FBSD-NEXT: SectionHeaderCount:
-# X86FBSD-NEXT: StringTableSectionIndex:
-# X86FBSD-NEXT: }
-
-# RUN: llvm-mc -filetype=obj -triple=i586-intel-elfiamcu %s -o %tiamcu
-# RUN: ld.lld -m elf_iamcu %tiamcu -o %t2iamcu
-# RUN: llvm-readobj -file-headers %t2iamcu | FileCheck --check-prefix=IAMCU %s
-# RUN: ld.lld %tiamcu -o %t3iamcu
-# RUN: llvm-readobj -file-headers %t3iamcu | FileCheck --check-prefix=IAMCU %s
-# IAMCU: ElfHeader {
-# IAMCU-NEXT: Ident {
-# IAMCU-NEXT: Magic: (7F 45 4C 46)
-# IAMCU-NEXT: Class: 32-bit (0x1)
-# IAMCU-NEXT: DataEncoding: LittleEndian (0x1)
-# IAMCU-NEXT: FileVersion: 1
-# IAMCU-NEXT: OS/ABI: SystemV (0x0)
-# IAMCU-NEXT: ABIVersion: 0
-# IAMCU-NEXT: Unused: (00 00 00 00 00 00 00)
-# IAMCU-NEXT: }
-# IAMCU-NEXT: Type: Executable (0x2)
-# IAMCU-NEXT: Machine: EM_IAMCU (0x6)
-# IAMCU-NEXT: Version: 1
-# IAMCU-NEXT: Entry:
-# IAMCU-NEXT: ProgramHeaderOffset: 0x34
-# IAMCU-NEXT: SectionHeaderOffset:
-# IAMCU-NEXT: Flags [ (0x0)
-# IAMCU-NEXT: ]
-# IAMCU-NEXT: HeaderSize: 52
-# IAMCU-NEXT: ProgramHeaderEntrySize: 32
-# IAMCU-NEXT: ProgramHeaderCount:
-# IAMCU-NEXT: SectionHeaderEntrySize: 40
-# IAMCU-NEXT: SectionHeaderCount:
-# IAMCU-NEXT: StringTableSectionIndex:
-# IAMCU-NEXT: }
-
-# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %tppc64
-# RUN: ld.lld -m elf64ppc %tppc64 -o %t2ppc64
-# RUN: llvm-readobj -file-headers %t2ppc64 | FileCheck --check-prefix=PPC64 %s
-# RUN: ld.lld %tppc64 -o %t3ppc64
-# RUN: llvm-readobj -file-headers %t3ppc64 | FileCheck --check-prefix=PPC64 %s
-# PPC64: ElfHeader {
-# PPC64-NEXT: Ident {
-# PPC64-NEXT: Magic: (7F 45 4C 46)
-# PPC64-NEXT: Class: 64-bit (0x2)
-# PPC64-NEXT: DataEncoding: BigEndian (0x2)
-# PPC64-NEXT: FileVersion: 1
-# PPC64-NEXT: OS/ABI: SystemV (0x0)
-# PPC64-NEXT: ABIVersion: 0
-# PPC64-NEXT: Unused: (00 00 00 00 00 00 00)
-# PPC64-NEXT: }
-# PPC64-NEXT: Type: Executable (0x2)
-# PPC64-NEXT: Machine: EM_PPC64 (0x15)
-# PPC64-NEXT: Version: 1
-# PPC64-NEXT: Entry:
-# PPC64-NEXT: ProgramHeaderOffset: 0x40
-# PPC64-NEXT: SectionHeaderOffset:
-# PPC64-NEXT: Flags [ (0x2)
-# PPC64-NEXT: 0x2
-# PPC64-NEXT: ]
-# PPC64-NEXT: HeaderSize: 64
-# PPC64-NEXT: ProgramHeaderEntrySize: 56
-# PPC64-NEXT: ProgramHeaderCount:
-# PPC64-NEXT: SectionHeaderEntrySize: 64
-# PPC64-NEXT: SectionHeaderCount:
-# PPC64-NEXT: StringTableSectionIndex:
-# PPC64-NEXT: }
-
-# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %tppc64le
-# RUN: ld.lld -m elf64lppc %tppc64le -o %t2ppc64le
-# RUN: llvm-readobj -file-headers %t2ppc64le | FileCheck --check-prefix=PPC64LE %s
-# RUN: ld.lld %tppc64le -o %t3ppc64le
-# RUN: llvm-readobj -file-headers %t3ppc64le | FileCheck --check-prefix=PPC64LE %s
-# PPC64LE: ElfHeader {
-# PPC64LE-NEXT: Ident {
-# PPC64LE-NEXT: Magic: (7F 45 4C 46)
-# PPC64LE-NEXT: Class: 64-bit (0x2)
-# PPC64LE-NEXT: DataEncoding: LittleEndian (0x1)
-# PPC64LE-NEXT: FileVersion: 1
-# PPC64LE-NEXT: OS/ABI: SystemV (0x0)
-# PPC64LE-NEXT: ABIVersion: 0
-# PPC64LE-NEXT: Unused: (00 00 00 00 00 00 00)
-# PPC64LE-NEXT: }
-# PPC64LE-NEXT: Type: Executable (0x2)
-# PPC64LE-NEXT: Machine: EM_PPC64 (0x15)
-# PPC64LE-NEXT: Version: 1
-# PPC64LE-NEXT: Entry:
-# PPC64LE-NEXT: ProgramHeaderOffset: 0x40
-# PPC64LE-NEXT: SectionHeaderOffset:
-# PPC64LE-NEXT: Flags [ (0x2)
-# PPC64LE-NEXT: 0x2
-# PPC64LE-NEXT: ]
-# PPC64LE-NEXT: HeaderSize: 64
-# PPC64LE-NEXT: ProgramHeaderEntrySize: 56
-# PPC64LE-NEXT: ProgramHeaderCount:
-# PPC64LE-NEXT: SectionHeaderEntrySize: 64
-# PPC64LE-NEXT: SectionHeaderCount:
-# PPC64LE-NEXT: StringTableSectionIndex:
-# PPC64LE-NEXT: }
-
-# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %tmips
-# RUN: ld.lld -m elf32btsmip -e _start %tmips -o %t2mips
-# RUN: llvm-readobj -file-headers %t2mips | FileCheck --check-prefix=MIPS %s
-# RUN: ld.lld %tmips -e _start -o %t3mips
-# RUN: llvm-readobj -file-headers %t3mips | FileCheck --check-prefix=MIPS %s
-# MIPS: ElfHeader {
-# MIPS-NEXT: Ident {
-# MIPS-NEXT: Magic: (7F 45 4C 46)
-# MIPS-NEXT: Class: 32-bit (0x1)
-# MIPS-NEXT: DataEncoding: BigEndian (0x2)
-# MIPS-NEXT: FileVersion: 1
-# MIPS-NEXT: OS/ABI: SystemV (0x0)
-# MIPS-NEXT: ABIVersion: 1
-# MIPS-NEXT: Unused: (00 00 00 00 00 00 00)
-# MIPS-NEXT: }
-# MIPS-NEXT: Type: Executable (0x2)
-# MIPS-NEXT: Machine: EM_MIPS (0x8)
-# MIPS-NEXT: Version: 1
-# MIPS-NEXT: Entry:
-# MIPS-NEXT: ProgramHeaderOffset: 0x34
-# MIPS-NEXT: SectionHeaderOffset:
-# MIPS-NEXT: Flags [
-# MIPS-NEXT: EF_MIPS_ABI_O32
-# MIPS-NEXT: EF_MIPS_ARCH_32
-# MIPS-NEXT: EF_MIPS_CPIC
-# MIPS-NEXT: ]
-
-# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux %s -o %tmipsel
-# RUN: ld.lld -m elf32ltsmip -e _start %tmipsel -o %t2mipsel
-# RUN: llvm-readobj -file-headers %t2mipsel | FileCheck --check-prefix=MIPSEL %s
-# RUN: ld.lld -melf32ltsmip -e _start %tmipsel -o %t2mipsel
-# RUN: llvm-readobj -file-headers %t2mipsel | FileCheck --check-prefix=MIPSEL %s
-# RUN: ld.lld %tmipsel -e _start -o %t3mipsel
-# RUN: llvm-readobj -file-headers %t3mipsel | FileCheck --check-prefix=MIPSEL %s
-# MIPSEL: ElfHeader {
-# MIPSEL-NEXT: Ident {
-# MIPSEL-NEXT: Magic: (7F 45 4C 46)
-# MIPSEL-NEXT: Class: 32-bit (0x1)
-# MIPSEL-NEXT: DataEncoding: LittleEndian (0x1)
-# MIPSEL-NEXT: FileVersion: 1
-# MIPSEL-NEXT: OS/ABI: SystemV (0x0)
-# MIPSEL-NEXT: ABIVersion: 1
-# MIPSEL-NEXT: Unused: (00 00 00 00 00 00 00)
-# MIPSEL-NEXT: }
-# MIPSEL-NEXT: Type: Executable (0x2)
-# MIPSEL-NEXT: Machine: EM_MIPS (0x8)
-# MIPSEL-NEXT: Version: 1
-# MIPSEL-NEXT: Entry:
-# MIPSEL-NEXT: ProgramHeaderOffset: 0x34
-# MIPSEL-NEXT: SectionHeaderOffset:
-# MIPSEL-NEXT: Flags [
-# MIPSEL-NEXT: EF_MIPS_ABI_O32
-# MIPSEL-NEXT: EF_MIPS_ARCH_32
-# MIPSEL-NEXT: EF_MIPS_CPIC
-# MIPSEL-NEXT: ]
-
-# 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
-# RUN: llvm-readobj -file-headers %t3mips64 | FileCheck --check-prefix=MIPS64 %s
-# MIPS64: ElfHeader {
-# MIPS64-NEXT: Ident {
-# MIPS64-NEXT: Magic: (7F 45 4C 46)
-# MIPS64-NEXT: Class: 64-bit (0x2)
-# MIPS64-NEXT: DataEncoding: BigEndian (0x2)
-# MIPS64-NEXT: FileVersion: 1
-# MIPS64-NEXT: OS/ABI: SystemV (0x0)
-# MIPS64-NEXT: ABIVersion: 0
-# MIPS64-NEXT: Unused: (00 00 00 00 00 00 00)
-# MIPS64-NEXT: }
-# MIPS64-NEXT: Type: Executable (0x2)
-# MIPS64-NEXT: Machine: EM_MIPS (0x8)
-# MIPS64-NEXT: Version: 1
-# MIPS64-NEXT: Entry:
-# MIPS64-NEXT: ProgramHeaderOffset: 0x40
-# MIPS64-NEXT: SectionHeaderOffset:
-# MIPS64-NEXT: Flags [
-# MIPS64-NEXT: EF_MIPS_ARCH_64
-# MIPS64-NEXT: EF_MIPS_CPIC
-# MIPS64-NEXT: EF_MIPS_PIC
-# MIPS64-NEXT: ]
-
-# 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
-# RUN: llvm-readobj -file-headers %t3mips64el | FileCheck --check-prefix=MIPS64EL %s
-# MIPS64EL: ElfHeader {
-# MIPS64EL-NEXT: Ident {
-# MIPS64EL-NEXT: Magic: (7F 45 4C 46)
-# MIPS64EL-NEXT: Class: 64-bit (0x2)
-# MIPS64EL-NEXT: DataEncoding: LittleEndian (0x1)
-# MIPS64EL-NEXT: FileVersion: 1
-# MIPS64EL-NEXT: OS/ABI: SystemV (0x0)
-# MIPS64EL-NEXT: ABIVersion: 0
-# MIPS64EL-NEXT: Unused: (00 00 00 00 00 00 00)
-# MIPS64EL-NEXT: }
-# MIPS64EL-NEXT: Type: Executable (0x2)
-# MIPS64EL-NEXT: Machine: EM_MIPS (0x8)
-# MIPS64EL-NEXT: Version: 1
-# MIPS64EL-NEXT: Entry:
-# MIPS64EL-NEXT: ProgramHeaderOffset: 0x40
-# MIPS64EL-NEXT: SectionHeaderOffset:
-# MIPS64EL-NEXT: Flags [
-# MIPS64EL-NEXT: EF_MIPS_ARCH_64
-# MIPS64EL-NEXT: EF_MIPS_CPIC
-# MIPS64EL-NEXT: EF_MIPS_PIC
-# MIPS64EL-NEXT: ]
-
-# RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-linux %s -o %taarch64
-# RUN: ld.lld -m aarch64linux %taarch64 -o %t2aarch64
-# RUN: llvm-readobj -file-headers %t2aarch64 | FileCheck --check-prefix=AARCH64 %s
-# RUN: ld.lld -m aarch64elf %taarch64 -o %t3aarch64
-# RUN: llvm-readobj -file-headers %t3aarch64 | FileCheck --check-prefix=AARCH64 %s
-# RUN: ld.lld -m aarch64_elf64_le_vec %taarch64 -o %t4aarch64
-# RUN: llvm-readobj -file-headers %t4aarch64 | FileCheck --check-prefix=AARCH64 %s
-# RUN: ld.lld %taarch64 -o %t5aarch64
-# RUN: llvm-readobj -file-headers %t5aarch64 | FileCheck --check-prefix=AARCH64 %s
-# AARCH64: ElfHeader {
-# AARCH64-NEXT: Ident {
-# AARCH64-NEXT: Magic: (7F 45 4C 46)
-# AARCH64-NEXT: Class: 64-bit (0x2)
-# AARCH64-NEXT: DataEncoding: LittleEndian (0x1)
-# AARCH64-NEXT: FileVersion: 1
-# AARCH64-NEXT: OS/ABI: SystemV (0x0)
-# AARCH64-NEXT: ABIVersion: 0
-# AARCH64-NEXT: Unused: (00 00 00 00 00 00 00)
-# AARCH64-NEXT: }
-# AARCH64-NEXT: Type: Executable (0x2)
-# AARCH64-NEXT: Machine: EM_AARCH64 (0xB7)
-# AARCH64-NEXT: Version: 1
-# AARCH64-NEXT: Entry:
-# AARCH64-NEXT: ProgramHeaderOffset: 0x40
-# AARCH64-NEXT: SectionHeaderOffset:
-# AARCH64-NEXT: Flags [ (0x0)
-# AARCH64-NEXT: ]
-
-.globl _start
-_start:
diff --git a/test/ELF/execute-only-mixed-data.s b/test/ELF/execute-only-mixed-data.s
index 6ef62368123f..b57695493dd6 100644
--- a/test/ELF/execute-only-mixed-data.s
+++ b/test/ELF/execute-only-mixed-data.s
@@ -16,7 +16,7 @@
// RUN: }" > %t.lds
// RUN: ld.lld -T%t.lds %t.o -o %t -execute-only 2>&1
-// CHECK: -execute-only does not support intermingling data and code
+// CHECK: cannot place {{.*}}:(.rodata.foo) into .text: -execute-only does not support intermingling data and code
br lr
diff --git a/test/ELF/format-binary.test b/test/ELF/format-binary.test
index 94b9b51afe78..7c554bb60e43 100644
--- a/test/ELF/format-binary.test
+++ b/test/ELF/format-binary.test
@@ -55,3 +55,15 @@
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: Absolute
# CHECK-NEXT: }
+
+# RUN: echo 'OUTPUT_FORMAT(elf64-x86-64)' > %t.script
+# RUN: ld.lld -b binary %t.binary -T %t.script -o %t.out
+# RUN: llvm-readobj %t.out -sections -section-data -symbols | FileCheck -check-prefix=X86-64 %s
+
+# X86-64: Format: ELF64-x86-64
+
+# RUN: echo 'OUTPUT_FORMAT("elf64-x86-64")' > %t.script
+# RUN: ld.lld -b binary %t.binary -T %t.script -o %t.out
+# RUN: llvm-readobj %t.out -sections -section-data -symbols | FileCheck -check-prefix=X86-64-in-quotes %s
+
+# X86-64-in-quotes: Format: ELF64-x86-64
diff --git a/test/ELF/gc-sections-implicit-addend.s b/test/ELF/gc-sections-implicit-addend.s
index 1270affbcc0e..e3bdeaac1d7f 100644
--- a/test/ELF/gc-sections-implicit-addend.s
+++ b/test/ELF/gc-sections-implicit-addend.s
@@ -12,10 +12,10 @@
# CHECK-NEXT: SHF_MERGE
# CHECK-NEXT: SHF_STRINGS
# CHECK-NEXT: ]
-# CHECK-NEXT: Address: 0x100B4
+# CHECK-NEXT: Address: 0x4000B4
-# 0x100B4 == 65716
-# DISASM: leal 65716, %eax
+# 0x4000B4 == 4194484
+# DISASM: leal 4194484, %eax
.section .foo,"aMS",@progbits,1
.byte 0
diff --git a/test/ELF/gc-sections-linker-defined-symbol.s b/test/ELF/gc-sections-linker-defined-symbol.s
index 796f7b363559..e570116e31e1 100644
--- a/test/ELF/gc-sections-linker-defined-symbol.s
+++ b/test/ELF/gc-sections-linker-defined-symbol.s
@@ -4,7 +4,7 @@
# RUN: ld.lld %t.o -o %t.so --gc-sections -shared
# RUN: llvm-readobj --dyn-symbols %t.so | FileCheck %s
-# CHECK: Name: _end@
+# CHECK: Name: _end
# CHECK-NEXT: Value:
# CHECK-NEXT: Size:
# CHECK-NEXT: Binding: Global
diff --git a/test/ELF/gdb-index-base-addr.s b/test/ELF/gdb-index-base-addr.s
index 3871f8fc92e9..a16ea7b2c9dc 100644
--- a/test/ELF/gdb-index-base-addr.s
+++ b/test/ELF/gdb-index-base-addr.s
@@ -3,7 +3,7 @@
# RUN: ld.lld --gdb-index %t1.o -o %t
# RUN: llvm-dwarfdump -gdb-index %t | FileCheck %s
-# CHECK: .gnu_index contents:
+# CHECK: .gdb_index contents:
# CHECK: Address area offset = 0x28, has 2 entries:
# CHECK-NEXT: Low/High address = [0x201000, 0x201001) (Size: 0x1), CU id = 0
# CHECK-NEXT: Low/High address = [0x201003, 0x201006) (Size: 0x3), CU id = 0
diff --git a/test/ELF/gdb-index-dwarf5-low-high.s b/test/ELF/gdb-index-dwarf5-low-high.s
new file mode 100644
index 000000000000..94b713c6d216
--- /dev/null
+++ b/test/ELF/gdb-index-dwarf5-low-high.s
@@ -0,0 +1,49 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld --gdb-index %t.o -o %t
+# RUN: llvm-dwarfdump -gdb-index %t | FileCheck %s
+
+# CHECK: Address area offset = 0x28, has 1 entries:
+# CHECK-NEXT: Low/High address = [0x201000, 0x201001) (Size: 0x1), CU id = 0
+
+ .text
+ .globl main
+main: # @main
+.Lfunc_begin0:
+ retq
+.Lfunc_end0:
+ .section .debug_abbrev,"",@progbits
+ .byte 1 # Abbreviation Code
+ .byte 17 # DW_TAG_compile_unit
+ .byte 0 # DW_CHILDREN_no
+ .byte 115 # DW_AT_addr_base
+ .byte 23 # DW_FORM_sec_offset
+ .byte 17 # DW_AT_low_pc
+ .byte 27 # DW_FORM_addrx
+ .byte 18 # DW_AT_high_pc
+ .byte 6 # DW_FORM_data4
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 0 # EOM(3)
+
+ .section .debug_info,"",@progbits
+.Lcu_begin0:
+ .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
+.Ldebug_info_start0:
+ .short 5 # DWARF version number
+ .byte 1 # DWARF Unit Type
+ .byte 8 # Address Size (in bytes)
+ .long .debug_abbrev # Offset Into Abbrev. Section
+ .byte 1 # Abbrev [1] 0xc:0x2b DW_TAG_compile_unit
+ .long .Laddr_table_base0 # DW_AT_addr_base
+ .byte 0 # DW_AT_low_pc
+ .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
+.Ldebug_info_end0:
+
+ .section .debug_addr,"",@progbits
+ .long 12
+ .short 5
+ .byte 8
+ .byte 0
+.Laddr_table_base0:
+ .quad .Lfunc_begin0
diff --git a/test/ELF/gdb-index-invalid-ranges.s b/test/ELF/gdb-index-invalid-ranges.s
new file mode 100644
index 000000000000..1aac98d87cf6
--- /dev/null
+++ b/test/ELF/gdb-index-invalid-ranges.s
@@ -0,0 +1,42 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: not ld.lld --gdb-index -e main %t.o -o %t 2>&1 | FileCheck %s
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/gdb-index-invalid-ranges.obj.s -o %t2.o
+# RUN: llvm-ar rc %t.a %t.o
+# RUN: not ld.lld --gdb-index -e main %t2.o %t.a -o %t 2>&1 | FileCheck --check-prefix=ARCHIVE %s
+
+# CHECK: ld.lld: error: {{.*}}gdb-index-invalid-ranges.s.tmp.o:(.debug_info): decoding address ranges: invalid range list entry at offset 0x10
+# ARCHIVE: ld.lld: error: {{.*}}gdb-index-invalid-ranges.s.tmp.a(gdb-index-invalid-ranges.s.tmp.o):(.debug_info): decoding address ranges: invalid range list entry at offset 0x10
+
+.section .text.foo1,"ax",@progbits
+.globl f1
+.Lfunc_begin0:
+f1:
+ nop
+.Lfunc_end0:
+
+.section .debug_abbrev,"",@progbits
+.byte 1 # Abbreviation Code
+.byte 17 # DW_TAG_compile_unit
+.byte 0 # DW_CHILDREN_no
+.byte 85 # DW_AT_ranges
+.byte 23 # DW_FORM_sec_offset
+.byte 0 # EOM(1)
+.byte 0 # EOM(2)
+.byte 0 # EOM(3)
+
+.section .debug_info,"",@progbits
+.Lcu_begin0:
+.long .Lunit_end0-.Lunit_begin0 # Length of Unit
+.Lunit_begin0:
+.short 4 # DWARF version number
+.long .debug_abbrev # Offset Into Abbrev. Section
+.byte 8 # Address Size (in bytes)
+.byte 1 # Abbrev [1] 0xb:0x1f DW_TAG_compile_unit
+.long .Ldebug_ranges0 # DW_AT_ranges
+.Lunit_end0:
+
+.section .debug_ranges,"",@progbits
+.Ldebug_ranges0:
+.quad .Lfunc_begin0
+.quad .Lfunc_end0
diff --git a/test/ELF/gdb-index-multiple-cu-2.s b/test/ELF/gdb-index-multiple-cu-2.s
new file mode 100644
index 000000000000..9cf2a0c82693
--- /dev/null
+++ b/test/ELF/gdb-index-multiple-cu-2.s
@@ -0,0 +1,36 @@
+# REQUIRES: x86
+# 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/gdb-index-multiple-cu-2.s -o %t1.o
+# RUN: ld.lld --gdb-index %t.o %t1.o -o %t
+# RUN: llvm-dwarfdump -gdb-index %t | FileCheck %s
+
+# %t.o has 2 CUs while %t1 has 1, thus _start in %t1.o should have CuIndex 2.
+# Attributes << 24 | CuIndex = 48 << 24 | 2 = 0x30000002
+# CHECK: Constant pool
+# CHECK-NEXT: 0(0x0): 0x30000002
+
+.section .debug_abbrev,"",@progbits
+ .byte 1 # Abbreviation Code
+ .byte 17 # DW_TAG_compile_unit
+ .byte 0 # DW_CHILDREN_yes
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 0
+
+.section .debug_info,"",@progbits
+.Lcu_begin0:
+ .long .Lcu_end0 - .Lcu_begin0 - 4
+ .short 4 # DWARF version number
+ .long 0 # Offset Into Abbrev. Section
+ .byte 4 # Address Size
+ .byte 1 # Abbrev [1] DW_TAG_compile_unit
+ .byte 0
+.Lcu_end0:
+.Lcu_begin1:
+ .long .Lcu_end1 - .Lcu_begin1 - 4
+ .short 4 # DWARF version number
+ .long 0 # Offset Into Abbrev. Section
+ .byte 4 # Address Size
+ .byte 1 # Abbrev [1] DW_TAG_compile_unit
+ .byte 0
+.Lcu_end1:
diff --git a/test/ELF/gdb-index-multiple-cu.s b/test/ELF/gdb-index-multiple-cu.s
new file mode 100644
index 000000000000..9a8c2eae78d4
--- /dev/null
+++ b/test/ELF/gdb-index-multiple-cu.s
@@ -0,0 +1,88 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: ld.lld --gdb-index %t.o -o %t
+# RUN: llvm-dwarfdump -gdb-index %t | FileCheck %s
+
+# CuIndexAndAttrs of _start:
+# Attributes << 24 | CuIndex = 48 << 24 | 0 = 0x30000000
+# CuIndexAndAttrs of foo:
+# Attributes << 24 | CuIndex = 48 << 24 | 1 = 0x30000001
+# CHECK: Symbol table
+# CHECK-DAG: String name: _start, CU vector index: 0
+# CHECK-DAG: String name: foo, CU vector index: 1
+# CHECK: Constant pool
+# CHECK-NEXT: 0(0x0): 0x30000000
+# CHECK-NEXT: 1(0x8): 0x30000001
+
+.globl _start, foo
+_start:
+foo:
+
+.section .debug_abbrev,"",@progbits
+ .byte 1 # Abbreviation Code
+ .byte 17 # DW_TAG_compile_unit
+ .byte 1 # DW_CHILDREN_yes
+ .ascii "\264B" # DW_AT_GNU_pubnames
+ .byte 25 # DW_FORM_flag_present
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 2 # Abbreviation Code
+ .byte 46 # DW_TAG_subprogram
+ .byte 0 # DW_CHILDREN_no
+ .byte 3 # DW_AT_name
+ .byte 8 # DW_FORM_string
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 0
+
+.section .debug_info,"",@progbits
+.Lcu_begin0:
+ .long .Lcu_end0 - .Lcu_begin0 - 4
+ .short 4 # DWARF version number
+ .long 0 # Offset Into Abbrev. Section
+ .byte 4 # Address Size
+.Ldie0:
+ .byte 1 # Abbrev [1] DW_TAG_compile_unit
+ .byte 2 # Abbrev [2] DW_TAG_subprogram
+ .asciz "_start" # DW_AT_name
+ .byte 0
+ .byte 0
+.Lcu_end0:
+.Lcu_begin1:
+ .long .Lcu_end1 - .Lcu_begin1 - 4
+ .short 4 # DWARF version number
+ .long 0 # Offset Into Abbrev. Section
+ .byte 4 # Address Size
+.Ldie1:
+ .byte 1 # Abbrev [1] DW_TAG_compile_unit
+ .byte 2 # Abbrev [2] DW_TAG_subprogram
+ .asciz "foo" # DW_AT_name
+ .byte 0
+.Lcu_end1:
+
+# Swap sets to test the case where pubnames are in a
+# different order than the CUs they refer to.
+.section .debug_gnu_pubnames,"",@progbits
+ # CuIndex: 1
+ .long .LpubNames_end1 - .LpubNames_begin1
+.LpubNames_begin1:
+ .short 2 # Version
+ .long .Lcu_begin1 # CU Offset
+ .long .Lcu_end1 - .Lcu_begin1
+ .long .Ldie1 - .Lcu_begin1
+ .byte 48 # Attributes: FUNCTION, EXTERNAL
+ .asciz "foo" # External Name
+ .long 0
+.LpubNames_end1:
+
+ # CuIndex: 0
+ .long .LpubNames_end0 - .LpubNames_begin0
+.LpubNames_begin0:
+ .short 2 # Version
+ .long .Lcu_begin0 # CU Offset
+ .long .Lcu_end0 - .Lcu_begin0
+ .long .Ldie0 - .Lcu_begin0
+ .byte 48 # Attributes: FUNCTION, EXTERNAL
+ .asciz "_start" # External Name
+ .long 0
+.LpubNames_end0:
diff --git a/test/ELF/gdb-index-no-debug.s b/test/ELF/gdb-index-no-debug.s
new file mode 100644
index 000000000000..dba5fcf26385
--- /dev/null
+++ b/test/ELF/gdb-index-no-debug.s
@@ -0,0 +1,8 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld -o %t.exe -gdb-index %t.o
+# RUN: llvm-objdump --section-headers %t.exe | FileCheck %s
+# CHECK-NOT: .gdb_index
+
+.global _start
+_start:
diff --git a/test/ELF/gdb-index-ranges.s b/test/ELF/gdb-index-ranges.s
index c41be114f005..2190a2442f52 100644
--- a/test/ELF/gdb-index-ranges.s
+++ b/test/ELF/gdb-index-ranges.s
@@ -3,7 +3,7 @@
# RUN: ld.lld --gdb-index -e main %t.o -o %t
# RUN: llvm-dwarfdump -gdb-index %t | FileCheck %s
-# CHECK: .gnu_index contents:
+# CHECK: .gdb_index contents:
# CHECK: Address area offset = 0x28, has 2 entries:
# CHECK-NEXT: Low/High address = [0x201000, 0x201001) (Size: 0x1), CU id = 0
# CHECK-NEXT: Low/High address = [0x201001, 0x201003) (Size: 0x2), CU id = 0
diff --git a/test/ELF/gdb-index-rng-lists.s b/test/ELF/gdb-index-rng-lists.s
new file mode 100644
index 000000000000..d853d3bb6052
--- /dev/null
+++ b/test/ELF/gdb-index-rng-lists.s
@@ -0,0 +1,202 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o
+# RUN: ld.lld --gdb-index %t1.o -o %t
+# RUN: llvm-dwarfdump -gdb-index %t | FileCheck %s
+
+## The code contains DWARF v5 sections .debug_rnglists and .debug_addr.
+## Check we are able to build the correct address
+## area using address range lists.
+
+# CHECK: .gdb_index contents:
+# CHECK: Address area offset = 0x28, has 2 entries:
+# CHECK-NEXT: Low/High address = [0x201000, 0x201001) (Size: 0x1), CU id = 0
+# CHECK-NEXT: Low/High address = [0x201001, 0x201003) (Size: 0x2), CU id = 0
+
+.text
+.section .text._Z3zedv,"ax",@progbits
+.Lfunc_begin0:
+ retq
+.Lfunc_end0:
+
+.section .text.main,"ax",@progbits
+.Lfunc_begin1:
+ retq
+ retq
+.Lfunc_end1:
+
+.section .debug_str_offsets,"",@progbits
+.long 32
+.short 5
+.short 0
+.Lstr_offsets_base0:
+ .long .Linfo_string0
+ .long .Linfo_string0
+ .long .Linfo_string0
+ .long .Linfo_string0
+ .long .Linfo_string0
+ .long .Linfo_string0
+ .long .Linfo_string0
+
+.section .debug_str,"MS",@progbits,1
+.Linfo_string0:
+ .asciz "stub"
+
+.section .debug_abbrev,"",@progbits
+ .byte 1 # Abbreviation Code
+ .byte 17 # DW_TAG_compile_unit
+ .byte 1 # DW_CHILDREN_yes
+ .byte 37 # DW_AT_producer
+ .byte 37 # DW_FORM_strx1
+ .byte 19 # DW_AT_language
+ .byte 5 # DW_FORM_data2
+ .byte 3 # DW_AT_name
+ .byte 37 # DW_FORM_strx1
+ .byte 114 # DW_AT_str_offsets_base
+ .byte 23 # DW_FORM_sec_offset
+ .byte 16 # DW_AT_stmt_list
+ .byte 23 # DW_FORM_sec_offset
+ .byte 27 # DW_AT_comp_dir
+ .byte 37 # DW_FORM_strx1
+ .byte 115 # DW_AT_addr_base
+ .byte 23 # DW_FORM_sec_offset
+ .byte 17 # DW_AT_low_pc
+ .byte 1 # DW_FORM_addr
+ .byte 85 # DW_AT_ranges
+ .byte 35 # DW_FORM_rnglistx
+ .byte 116 # DW_AT_rnglists_base
+ .byte 23 # DW_FORM_sec_offset
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 2 # Abbreviation Code
+ .byte 46 # DW_TAG_subprogram
+ .byte 0 # DW_CHILDREN_no
+ .byte 17 # DW_AT_low_pc
+ .byte 27 # DW_FORM_addrx
+ .byte 18 # DW_AT_high_pc
+ .byte 6 # DW_FORM_data4
+ .byte 64 # DW_AT_frame_base
+ .byte 24 # DW_FORM_exprloc
+ .byte 110 # DW_AT_linkage_name
+ .byte 37 # DW_FORM_strx1
+ .byte 3 # DW_AT_name
+ .byte 37 # DW_FORM_strx1
+ .byte 58 # DW_AT_decl_file
+ .byte 11 # DW_FORM_data1
+ .byte 59 # DW_AT_decl_line
+ .byte 11 # DW_FORM_data1
+ .byte 73 # DW_AT_type
+ .byte 19 # DW_FORM_ref4
+ .byte 63 # DW_AT_external
+ .byte 25 # DW_FORM_flag_present
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 3 # Abbreviation Code
+ .byte 46 # DW_TAG_subprogram
+ .byte 0 # DW_CHILDREN_no
+ .byte 17 # DW_AT_low_pc
+ .byte 27 # DW_FORM_addrx
+ .byte 18 # DW_AT_high_pc
+ .byte 6 # DW_FORM_data4
+ .byte 64 # DW_AT_frame_base
+ .byte 24 # DW_FORM_exprloc
+ .byte 3 # DW_AT_name
+ .byte 37 # DW_FORM_strx1
+ .byte 58 # DW_AT_decl_file
+ .byte 11 # DW_FORM_data1
+ .byte 59 # DW_AT_decl_line
+ .byte 11 # DW_FORM_data1
+ .byte 73 # DW_AT_type
+ .byte 19 # DW_FORM_ref4
+ .byte 63 # DW_AT_external
+ .byte 25 # DW_FORM_flag_present
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 4 # Abbreviation Code
+ .byte 36 # DW_TAG_base_type
+ .byte 0 # DW_CHILDREN_no
+ .byte 3 # DW_AT_name
+ .byte 37 # DW_FORM_strx1
+ .byte 62 # DW_AT_encoding
+ .byte 11 # DW_FORM_data1
+ .byte 11 # DW_AT_byte_size
+ .byte 11 # DW_FORM_data1
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 0 # EOM(3)
+
+.section .debug_info,"",@progbits
+.Lcu_begin0:
+ .long 75 # Length of Unit
+ .short 5 # DWARF version number
+ .byte 1 # DWARF Unit Type
+ .byte 8 # Address Size (in bytes)
+ .long .debug_abbrev # Offset Into Abbrev. Section
+
+ .byte 1 # Abbrev [1] 0xc:0x43 DW_TAG_compile_unit
+ .byte 0 # DW_AT_producer
+ .short 4 # DW_AT_language
+ .byte 1 # DW_AT_name
+ .long .Lstr_offsets_base0 # DW_AT_str_offsets_base
+ .long 0 # DW_AT_stmt_list
+ .byte 2 # DW_AT_comp_dir
+ .long .Laddr_table_base0 # DW_AT_addr_base
+ .quad 0 # DW_AT_low_pc
+ .byte 0 # DW_AT_ranges
+ .long .Lrnglists_table_base0 # DW_AT_rnglists_base
+
+ .byte 2 # Abbrev [2] 0x2b:0x10 DW_TAG_subprogram
+ .byte 0 # DW_AT_low_pc
+ .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
+ .byte 1 # DW_AT_frame_base
+ .byte 86
+ .byte 3 # DW_AT_linkage_name
+ .byte 4 # DW_AT_name
+ .byte 1 # DW_AT_decl_file
+ .byte 1 # DW_AT_decl_line
+ .long 74 # DW_AT_type
+ # DW_AT_external
+
+ .byte 3 # Abbrev [3] 0x3b:0xf DW_TAG_subprogram
+ .byte 1 # DW_AT_low_pc
+ .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc
+ .byte 1 # DW_AT_frame_base
+ .byte 86
+ .byte 6 # DW_AT_name
+ .byte 1 # DW_AT_decl_file
+ .byte 5 # DW_AT_decl_line
+ .long 74 # DW_AT_type
+ # DW_AT_external
+
+ .byte 4 # Abbrev [4] 0x4a:0x4 DW_TAG_base_type
+ .byte 5 # DW_AT_name
+ .byte 5 # DW_AT_encoding
+ .byte 4 # DW_AT_byte_size
+ .byte 0 # End Of Children Mark
+
+.section .debug_rnglists,"",@progbits
+.long .Ldebug_rnglist_table_end0-.Ldebug_rnglist_table_start0 # Length
+.Ldebug_rnglist_table_start0:
+ .short 5 # Version
+ .byte 8 # Address size
+ .byte 0 # Segment selector size
+ .long 1 # Offset entry count
+.Lrnglists_table_base0:
+ .long .Ldebug_ranges0-.Lrnglists_table_base0
+.Ldebug_ranges0:
+ .byte 3 # DW_RLE_startx_length
+ .byte 0 # start index
+ .uleb128 .Lfunc_end0-.Lfunc_begin0 # length
+ .byte 3 # DW_RLE_startx_length
+ .byte 1 # start index
+ .uleb128 .Lfunc_end1-.Lfunc_begin1 # length
+ .byte 0 # DW_RLE_end_of_list
+.Ldebug_rnglist_table_end0:
+
+.section .debug_addr,"",@progbits
+ .long 20
+ .short 5
+ .byte 8
+ .byte 0
+.Laddr_table_base0:
+ .quad .Lfunc_begin0
+ .quad .Lfunc_begin1
diff --git a/test/ELF/gdb-index.s b/test/ELF/gdb-index.s
index e7f96066bd02..c9a02fd04d73 100644
--- a/test/ELF/gdb-index.s
+++ b/test/ELF/gdb-index.s
@@ -25,7 +25,7 @@
# DISASM-CHECK: 201004: 90 nop
# DISASM-CHECK: 201005: 90 nop
-# DWARF: .gnu_index contents:
+# DWARF: .gdb_index contents:
# DWARF-NEXT: Version = 7
# DWARF: CU list offset = 0x18, has 2 entries:
# DWARF-NEXT: 0: Offset = 0x0, Length = 0x34
diff --git a/test/ELF/global-offset-table-position-redef-err.s b/test/ELF/global-offset-table-position-redef-err.s
new file mode 100644
index 000000000000..fb2e506c1af6
--- /dev/null
+++ b/test/ELF/global-offset-table-position-redef-err.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 2>&1 | FileCheck %s
+
+# On some targets the location of the _GLOBAL_OFFSET_TABLE_ symbol table can
+# matter for the correctness of some relocations. Follow the example of ld.gold
+# and give a multiple definition error if input objects attempt to redefine it.
+
+# CHECK: ld.lld: error: {{.*o}} cannot redefine linker defined symbol '_GLOBAL_OFFSET_TABLE_'
+
+.data
+.global _GLOBAL_OFFSET_TABLE_
+_GLOBAL_OFFSET_TABLE_:
+.word 0
diff --git a/test/ELF/gnu-hash-table-copy.s b/test/ELF/gnu-hash-table-copy.s
index 9d91163258ea..cdd96e3dfd6a 100644
--- a/test/ELF/gnu-hash-table-copy.s
+++ b/test/ELF/gnu-hash-table-copy.s
@@ -13,10 +13,10 @@
# CHECK: Symbol table '.dynsym' contains 4 entries:
# CHECK-NEXT: Num: Value Size Type Bind Vis Ndx Name
-# CHECK-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND @
-# CHECK-NEXT: 1: 0000000000000000 0 OBJECT GLOBAL DEFAULT UND foo@
-# CHECK-DAG: : {{.*}} 4 OBJECT GLOBAL DEFAULT {{.*}} bar@
-# CHECK-DAG: : {{.*}} 0 FUNC GLOBAL DEFAULT UND zed@
+# CHECK-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
+# CHECK-NEXT: 1: 0000000000000000 0 OBJECT GLOBAL DEFAULT UND foo
+# CHECK-DAG: : {{.*}} 4 OBJECT GLOBAL DEFAULT {{.*}} bar
+# CHECK-DAG: : {{.*}} 0 FUNC GLOBAL DEFAULT UND zed
# CHECK: First Hashed Symbol Index: 2
diff --git a/test/ELF/gnu-hash-table-rwsegment.s b/test/ELF/gnu-hash-table-rwsegment.s
index b1a50fbde3a1..ab1b252bc5d4 100644
--- a/test/ELF/gnu-hash-table-rwsegment.s
+++ b/test/ELF/gnu-hash-table-rwsegment.s
@@ -8,8 +8,8 @@
# CHECK-NEXT: Num Buckets: 1
# CHECK-NEXT: First Hashed Symbol Index: 1
# CHECK-NEXT: Num Mask Words: 1
-# CHECK-NEXT: Shift Count: 6
-# CHECK-NEXT: Bloom Filter: [0x400000000004204]
+# CHECK-NEXT: Shift Count: 26
+# CHECK-NEXT: Bloom Filter: [0x400000000000204]
# CHECK-NEXT: Buckets: [1]
# CHECK-NEXT: Values: [0xB8860BA, 0xB887389]
# CHECK-NEXT: }
diff --git a/test/ELF/gnu-hash-table.s b/test/ELF/gnu-hash-table.s
index ffbf19fb5c6f..052a5bb20fbf 100644
--- a/test/ELF/gnu-hash-table.s
+++ b/test/ELF/gnu-hash-table.s
@@ -13,7 +13,7 @@
# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %t2.s -o %t2-ppc64le.o
# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %t2.s -o %t2-ppc64.o
-# RUN: rm -f %t2-i386.a %t2-x86_64.a %t2-ppc64.a
+# RUN: rm -f %t2-i386.a %t2-x86_64.a %t2-ppc64.a %t2-ppc64le.a
# RUN: llvm-ar rc %t2-i386.a %t2-i386.o
# RUN: llvm-ar rc %t2-x86_64.a %t2-x86_64.o
# RUN: llvm-ar rc %t2-ppc64le.a %t2-ppc64le.o
@@ -49,7 +49,7 @@
# EMPTY: DynamicSymbols [
# EMPTY: Symbol {
-# EMPTY: Name: foo@
+# EMPTY: Name: foo
# EMPTY-NEXT: Value: 0x0
# EMPTY-NEXT: Size: 0
# EMPTY-NEXT: Binding: Global
@@ -62,7 +62,7 @@
# EMPTY-NEXT: Num Buckets: 1
# EMPTY-NEXT: First Hashed Symbol Index: 2
# EMPTY-NEXT: Num Mask Words: 1
-# EMPTY-NEXT: Shift Count: 6
+# EMPTY-NEXT: Shift Count: 26
# EMPTY-NEXT: Bloom Filter: [0x0]
# EMPTY-NEXT: Buckets: [0]
# EMPTY-NEXT: Values: []
@@ -87,32 +87,32 @@
# I386: ]
# I386: DynamicSymbols [
# I386: Symbol {
-# I386: Name: @
+# I386: Name:
# I386: Binding: Local
# I386: Section: Undefined
# I386: }
# I386: Symbol {
-# I386: Name: baz@
+# I386: Name: baz
# I386: Binding: Global
# I386: Section: Undefined
# I386: }
# I386: Symbol {
-# I386: Name: xyz@
+# I386: Name: xyz
# I386: Binding: Global
# I386: Section: Undefined
# I386: }
# I386: Symbol {
-# I386: Name: zed@
+# I386: Name: zed
# I386: Binding: Weak
# I386: Section: Undefined
# I386: }
# I386: Symbol {
-# I386: Name: bar@
+# I386: Name: bar
# I386: Binding: Global
# I386: Section: .text
# I386: }
# I386: Symbol {
-# I386: Name: foo@
+# I386: Name: foo
# I386: Binding: Global
# I386: Section: .text
# I386: }
@@ -121,8 +121,8 @@
# I386-NEXT: Num Buckets: 1
# I386-NEXT: First Hashed Symbol Index: 4
# I386-NEXT: Num Mask Words: 1
-# I386-NEXT: Shift Count: 6
-# I386-NEXT: Bloom Filter: [0x4004204]
+# I386-NEXT: Shift Count: 26
+# I386-NEXT: Bloom Filter: [0x4000204]
# I386-NEXT: Buckets: [4]
# I386-NEXT: Values: [0xB8860BA, 0xB887389]
# I386-NEXT: }
@@ -147,32 +147,32 @@
# X86_64: ]
# X86_64: DynamicSymbols [
# X86_64: Symbol {
-# X86_64: Name: @
+# X86_64: Name:
# X86_64: Binding: Local
# X86_64: Section: Undefined
# X86_64: }
# X86_64: Symbol {
-# X86_64: Name: baz@
+# X86_64: Name: baz
# X86_64: Binding: Global
# X86_64: Section: Undefined
# X86_64: }
# X86_64: Symbol {
-# X86_64: Name: xyz@
+# X86_64: Name: xyz
# X86_64: Binding: Global
# X86_64: Section: Undefined
# X86_64: }
# X86_64: Symbol {
-# X86_64: Name: zed@
+# X86_64: Name: zed
# X86_64: Binding: Weak
# X86_64: Section: Undefined
# X86_64: }
# X86_64: Symbol {
-# X86_64: Name: bar@
+# X86_64: Name: bar
# X86_64: Binding: Global
# X86_64: Section: .text
# X86_64: }
# X86_64: Symbol {
-# X86_64: Name: foo@
+# X86_64: Name: foo
# X86_64: Binding: Global
# X86_64: Section: .text
# X86_64: }
@@ -181,8 +181,8 @@
# X86_64-NEXT: Num Buckets: 1
# X86_64-NEXT: First Hashed Symbol Index: 4
# X86_64-NEXT: Num Mask Words: 1
-# X86_64-NEXT: Shift Count: 6
-# X86_64-NEXT: Bloom Filter: [0x400000000004204]
+# X86_64-NEXT: Shift Count: 26
+# X86_64-NEXT: Bloom Filter: [0x400000000000204]
# X86_64-NEXT: Buckets: [4]
# X86_64-NEXT: Values: [0xB8860BA, 0xB887389]
# X86_64-NEXT: }
@@ -207,32 +207,32 @@
# PPC64: ]
# PPC64: DynamicSymbols [
# PPC64: Symbol {
-# PPC64: Name: @
+# PPC64: Name:
# PPC64: Binding: Local
# PPC64: Section: Undefined
# PPC64: }
# PPC64: Symbol {
-# PPC64: Name: baz@
+# PPC64: Name: baz
# PPC64: Binding: Global
# PPC64: Section: Undefined
# PPC64: }
# PPC64: Symbol {
-# PPC64: Name: xyz@
+# PPC64: Name: xyz
# PPC64: Binding: Global
# PPC64: Section: Undefined
# PPC64: }
# PPC64: Symbol {
-# PPC64: Name: zed@
+# PPC64: Name: zed
# PPC64: Binding: Weak
# PPC64: Section: Undefined
# PPC64: }
# PPC64: Symbol {
-# PPC64: Name: bar@
+# PPC64: Name: bar
# PPC64: Binding: Global
# PPC64: Section: .text
# PPC64: }
# PPC64: Symbol {
-# PPC64: Name: foo@
+# PPC64: Name: foo
# PPC64: Binding: Global
# PPC64: Section: .text
# PPC64: }
@@ -241,8 +241,8 @@
# PPC64-NEXT: Num Buckets: 1
# PPC64-NEXT: First Hashed Symbol Index: 4
# PPC64-NEXT: Num Mask Words: 1
-# PPC64-NEXT: Shift Count: 6
-# PPC64-NEXT: Bloom Filter: [0x400000000004204]
+# PPC64-NEXT: Shift Count: 26
+# PPC64-NEXT: Bloom Filter: [0x400000000000204]
# PPC64-NEXT: Buckets: [4]
# PPC64-NEXT: Values: [0xB8860BA, 0xB887389]
# PPC64-NEXT: }
diff --git a/test/ELF/gnu-ifunc-empty.s b/test/ELF/gnu-ifunc-empty.s
new file mode 100644
index 000000000000..90798532f973
--- /dev/null
+++ b/test/ELF/gnu-ifunc-empty.s
@@ -0,0 +1,16 @@
+// REQUIRES: x86
+
+// Verifies that .rela_iplt_{start,end} point to a dummy section
+// if .rela.iplt does not exist.
+
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: ld.lld -static %t.o -o %t.exe
+// RUN: llvm-objdump -syms %t.exe | FileCheck %s
+
+// CHECK: 0000000000200000 .text 00000000 .hidden __rela_iplt_end
+// CHECK: 0000000000200000 .text 00000000 .hidden __rela_iplt_start
+
+.globl _start
+_start:
+ movl $__rela_iplt_start, %edx
+ movl $__rela_iplt_end, %edx
diff --git a/test/ELF/gnu-ifunc-i386.s b/test/ELF/gnu-ifunc-i386.s
index f379bf1b28e8..bfc1587f0114 100644
--- a/test/ELF/gnu-ifunc-i386.s
+++ b/test/ELF/gnu-ifunc-i386.s
@@ -16,14 +16,14 @@
// CHECK-NEXT: Offset: 0xD4
// CHECK-NEXT: Size: 16
// CHECK-NEXT: Link: 0
-// CHECK-NEXT: Info: 0
+// CHECK-NEXT: Info: 4
// CHECK-NEXT: AddressAlignment: 4
// CHECK-NEXT: EntrySize: 8
// CHECK-NEXT: }
// CHECK: Relocations [
// CHECK-NEXT: Section ({{.*}}) .rel.plt {
-// CHECK-NEXT: 0x12000 R_386_IRELATIVE
-// CHECK-NEXT: 0x12004 R_386_IRELATIVE
+// CHECK-NEXT: 0x402000 R_386_IRELATIVE
+// CHECK-NEXT: 0x402004 R_386_IRELATIVE
// CHECK-NEXT: }
// CHECK-NEXT: ]
@@ -39,7 +39,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: __rel_iplt_end
-// CHECK-NEXT: Value: 0x100E4
+// CHECK-NEXT: Value: 0x4000E4
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local
// CHECK-NEXT: Type: None
@@ -61,7 +61,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: _start
-// CHECK-NEXT: Value: 0x11002
+// CHECK-NEXT: Value: 0x401002
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: None
@@ -70,7 +70,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: bar
-// CHECK-NEXT: Value: 0x11001
+// CHECK-NEXT: Value: 0x401001
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: GNU_IFunc
@@ -79,7 +79,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: foo
-// CHECK-NEXT: Value: 0x11000
+// CHECK-NEXT: Value: 0x401000
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: GNU_IFunc
@@ -90,22 +90,22 @@
// DISASM: Disassembly of section .text:
// DISASM-NEXT: foo:
-// DISASM-NEXT: 11000: c3 retl
+// DISASM-NEXT: 401000: c3 retl
// DISASM: bar:
-// DISASM-NEXT: 11001: c3 retl
+// DISASM-NEXT: 401001: c3 retl
// DISASM: _start:
-// DISASM-NEXT: 11002: e8 19 00 00 00 calll 25
-// DISASM-NEXT: 11007: e8 24 00 00 00 calll 36
-// DISASM-NEXT: 1100c: ba d4 00 01 00 movl $65748, %edx
-// DISASM-NEXT: 11011: ba e4 00 01 00 movl $65764, %edx
+// DISASM-NEXT: 401002: e8 19 00 00 00 calll 25
+// DISASM-NEXT: 401007: e8 24 00 00 00 calll 36
+// DISASM-NEXT: 40100c: ba d4 00 40 00 movl $4194516, %edx
+// DISASM-NEXT: 401011: ba e4 00 40 00 movl $4194532, %edx
// DISASM-NEXT: Disassembly of section .plt:
// DISASM-NEXT: .plt:
-// DISASM-NEXT: 11020: ff 25 00 20 01 00 jmpl *73728
-// DISASM-NEXT: 11026: 68 10 00 00 00 pushl $16
-// DISASM-NEXT: 1102b: e9 e0 ff ff ff jmp -32 <_start+0xe>
-// DISASM-NEXT: 11030: ff 25 04 20 01 00 jmpl *73732
-// DISASM-NEXT: 11036: 68 18 00 00 00 pushl $24
-// DISASM-NEXT: 1103b: e9 d0 ff ff ff jmp -48 <_start+0xe>
+// DISASM-NEXT: 401020: ff 25 00 20 40 00 jmpl *4202496
+// DISASM-NEXT: 401026: 68 10 00 00 00 pushl $16
+// DISASM-NEXT: 40102b: e9 e0 ff ff ff jmp -32 <_start+0xe>
+// DISASM-NEXT: 401030: ff 25 04 20 40 00 jmpl *4202500
+// DISASM-NEXT: 401036: 68 18 00 00 00 pushl $24
+// DISASM-NEXT: 40103b: e9 d0 ff ff ff jmp -48 <_start+0xe>
.text
.type foo STT_GNU_IFUNC
diff --git a/test/ELF/gnu-ifunc-plt-i386.s b/test/ELF/gnu-ifunc-plt-i386.s
index 14369bf6388b..3ed4e7616f57 100644
--- a/test/ELF/gnu-ifunc-plt-i386.s
+++ b/test/ELF/gnu-ifunc-plt-i386.s
@@ -10,16 +10,16 @@
// Check that the IRELATIVE relocations are after the JUMP_SLOT in the plt
// CHECK: Relocations [
// CHECK-NEXT: Section (4) .rel.plt {
-// CHECK-NEXT: 0x1200C R_386_JUMP_SLOT bar2
-// CHECK-NEXT: 0x12010 R_386_JUMP_SLOT zed2
-// CHECK-NEXT: 0x12014 R_386_IRELATIVE
-// CHECK-NEXT: 0x12018 R_386_IRELATIVE
+// CHECK-NEXT: 0x40200C R_386_JUMP_SLOT bar2
+// CHECK-NEXT: 0x402010 R_386_JUMP_SLOT zed2
+// CHECK-NEXT: 0x402014 R_386_IRELATIVE
+// CHECK-NEXT: 0x402018 R_386_IRELATIVE
// Check that IRELATIVE .got.plt entries point to ifunc resolver and not
// back to the plt entry + 6.
// GOTPLT: Contents of section .got.plt:
-// GOTPLT: 12000 00300100 00000000 00000000 36100100
-// GOTPLT-NEXT: 12010 46100100 00100100 01100100
+// GOTPLT: 402000 00304000 00000000 00000000 36104000
+// GOTPLT-NEXT: 402010 46104000 00104000 01104000
// Check that the PLTRELSZ tag includes the IRELATIVE relocations
// CHECK: DynamicSection [
@@ -28,34 +28,38 @@
// Check that a PLT header is written and the ifunc entries appear last
// DISASM: Disassembly of section .text:
// DISASM-NEXT: foo:
-// DISASM-NEXT: 11000: c3 retl
+// DISASM-NEXT: 401000: c3 retl
// DISASM: bar:
-// DISASM-NEXT: 11001: c3 retl
+// DISASM-NEXT: 401001: c3 retl
// DISASM: _start:
-// DISASM-NEXT: 11002: e8 49 00 00 00 calll 73
-// DISASM-NEXT: 11007: e8 54 00 00 00 calll 84
-// DISASM-NEXT: 1100c: e8 1f 00 00 00 calll 31
-// DISASM-NEXT: 11011: e8 2a 00 00 00 calll 42
+// DISASM-NEXT: 401002: e8 49 00 00 00 calll 73
+// DISASM-NEXT: 401007: e8 54 00 00 00 calll 84
+// DISASM-NEXT: 40100c: e8 1f 00 00 00 calll 31
+// DISASM-NEXT: 401011: e8 2a 00 00 00 calll 42
// DISASM-NEXT: Disassembly of section .plt:
// DISASM-NEXT: .plt:
-// DISASM-NEXT: 11020: ff 35 04 20 01 00 pushl 73732
-// DISASM-NEXT: 11026: ff 25 08 20 01 00 jmpl *73736
-// DISASM-NEXT: 1102c: 90 nop
-// DISASM-NEXT: 1102d: 90 nop
-// DISASM-NEXT: 1102e: 90 nop
-// DISASM-NEXT: 1102f: 90 nop
-// DISASM-NEXT: 11030: ff 25 0c 20 01 00 jmpl *73740
-// DISASM-NEXT: 11036: 68 00 00 00 00 pushl $0
-// DISASM-NEXT: 1103b: e9 e0 ff ff ff jmp -32 <.plt>
-// DISASM-NEXT: 11040: ff 25 10 20 01 00 jmpl *73744
-// DISASM-NEXT: 11046: 68 08 00 00 00 pushl $8
-// DISASM-NEXT: 1104b: e9 d0 ff ff ff jmp -48 <.plt>
-// DISASM-NEXT: 11050: ff 25 14 20 01 00 jmpl *73748
-// DISASM-NEXT: 11056: 68 30 00 00 00 pushl $48
-// DISASM-NEXT: 1105b: e9 e0 ff ff ff jmp -32 <.plt+0x20>
-// DISASM-NEXT: 11060: ff 25 18 20 01 00 jmpl *73752
-// DISASM-NEXT: 11066: 68 38 00 00 00 pushl $56
-// DISASM-NEXT: 1106b: e9 d0 ff ff ff jmp -48 <.plt+0x20>
+// DISASM-NEXT: 401020: ff 35 04 20 40 00 pushl 4202500
+// DISASM-NEXT: 401026: ff 25 08 20 40 00 jmpl *4202504
+// DISASM-NEXT: 40102c: 90 nop
+// DISASM-NEXT: 40102d: 90 nop
+// DISASM-NEXT: 40102e: 90 nop
+// DISASM-NEXT: 40102f: 90 nop
+// DISASM-EMPTY:
+// DISASM-NEXT: bar2@plt:
+// DISASM-NEXT: 401030: ff 25 0c 20 40 00 jmpl *4202508
+// DISASM-NEXT: 401036: 68 00 00 00 00 pushl $0
+// DISASM-NEXT: 40103b: e9 e0 ff ff ff jmp -32 <.plt>
+// DISASM-EMPTY:
+// DISASM-NEXT: zed2@plt:
+// DISASM-NEXT: 401040: ff 25 10 20 40 00 jmpl *4202512
+// DISASM-NEXT: 401046: 68 08 00 00 00 pushl $8
+// DISASM-NEXT: 40104b: e9 d0 ff ff ff jmp -48 <.plt>
+// DISASM-NEXT: 401050: ff 25 14 20 40 00 jmpl *4202516
+// DISASM-NEXT: 401056: 68 30 00 00 00 pushl $48
+// DISASM-NEXT: 40105b: e9 e0 ff ff ff jmp -32 <zed2@plt>
+// DISASM-NEXT: 401060: ff 25 18 20 40 00 jmpl *4202520
+// DISASM-NEXT: 401066: 68 38 00 00 00 pushl $56
+// DISASM-NEXT: 40106b: e9 d0 ff ff ff jmp -48 <zed2@plt>
.text
.type foo STT_GNU_IFUNC
diff --git a/test/ELF/gnu-ifunc-plt.s b/test/ELF/gnu-ifunc-plt.s
index b88f32cb7306..aa1c3c72f593 100644
--- a/test/ELF/gnu-ifunc-plt.s
+++ b/test/ELF/gnu-ifunc-plt.s
@@ -42,18 +42,22 @@
// DISASM-NEXT: 201020: ff 35 e2 0f 00 00 pushq 4066(%rip)
// DISASM-NEXT: 201026: ff 25 e4 0f 00 00 jmpq *4068(%rip)
// DISASM-NEXT: 20102c: 0f 1f 40 00 nopl (%rax)
+// DISASM-EMPTY:
+// DISASM-NEXT: bar2@plt:
// DISASM-NEXT: 201030: ff 25 e2 0f 00 00 jmpq *4066(%rip)
// DISASM-NEXT: 201036: 68 00 00 00 00 pushq $0
// DISASM-NEXT: 20103b: e9 e0 ff ff ff jmp -32 <.plt>
+// DISASM-EMPTY:
+// DISASM-NEXT: zed2@plt:
// DISASM-NEXT: 201040: ff 25 da 0f 00 00 jmpq *4058(%rip)
// DISASM-NEXT: 201046: 68 01 00 00 00 pushq $1
// DISASM-NEXT: 20104b: e9 d0 ff ff ff jmp -48 <.plt>
// DISASM-NEXT: 201050: ff 25 d2 0f 00 00 jmpq *4050(%rip)
// DISASM-NEXT: 201056: 68 00 00 00 00 pushq $0
-// DISASM-NEXT: 20105b: e9 e0 ff ff ff jmp -32 <.plt+0x20>
+// DISASM-NEXT: 20105b: e9 e0 ff ff ff jmp -32 <zed2@plt>
// DISASM-NEXT: 201060: ff 25 ca 0f 00 00 jmpq *4042(%rip)
// DISASM-NEXT: 201066: 68 01 00 00 00 pushq $1
-// DISASM-NEXT: 20106b: e9 d0 ff ff ff jmp -48 <.plt+0x20>
+// DISASM-NEXT: 20106b: e9 d0 ff ff ff jmp -48 <zed2@plt>
.text
.type foo STT_GNU_IFUNC
diff --git a/test/ELF/gnu-ifunc-relative.s b/test/ELF/gnu-ifunc-relative.s
index d797301d03ad..65750ec46f61 100644
--- a/test/ELF/gnu-ifunc-relative.s
+++ b/test/ELF/gnu-ifunc-relative.s
@@ -1,7 +1,9 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-// RUN: ld.lld -static %t.o -o %tout
-// RUN: llvm-readobj -r -t %tout | FileCheck %s
+// RUN: ld.lld --strip-all %t.o -o %t
+// RUN: llvm-readobj -r %t | FileCheck %s
+// RUN: ld.lld %t.o -o %t
+// RUN: llvm-readobj -r -t %t | FileCheck %s --check-prefixes=CHECK,SYM
.type foo STT_GNU_IFUNC
.globl foo
@@ -16,8 +18,8 @@ _start:
// CHECK-NEXT: R_X86_64_IRELATIVE - 0x[[ADDR:.*]]
// CHECK-NEXT: }
-// CHECK: Name: foo
-// CHECK-NEXT: Value: 0x[[ADDR]]
-// CHECK-NEXT: Size: 0
-// CHECK-NEXT: Binding: Global
-// CHECK-NEXT: Type: GNU_IFunc
+// SYM: Name: foo
+// SYM-NEXT: Value: 0x[[ADDR]]
+// SYM-NEXT: Size: 0
+// SYM-NEXT: Binding: Global
+// SYM-NEXT: Type: GNU_IFunc
diff --git a/test/ELF/gnu-ifunc-shared.s b/test/ELF/gnu-ifunc-shared.s
index bde6807e4b43..bc91ff9e5b32 100644
--- a/test/ELF/gnu-ifunc-shared.s
+++ b/test/ELF/gnu-ifunc-shared.s
@@ -23,15 +23,19 @@
// DISASM-NEXT: 1020: ff 35 e2 0f 00 00 pushq 4066(%rip)
// DISASM-NEXT: 1026: ff 25 e4 0f 00 00 jmpq *4068(%rip)
// DISASM-NEXT: 102c: 0f 1f 40 00 nopl (%rax)
+// DISASM-EMPTY:
+// DISASM-NEXT: fct2@plt:
// DISASM-NEXT: 1030: ff 25 e2 0f 00 00 jmpq *4066(%rip)
// DISASM-NEXT: 1036: 68 00 00 00 00 pushq $0
// DISASM-NEXT: 103b: e9 e0 ff ff ff jmp -32 <.plt>
+// DISASM-EMPTY:
+// DISASM-NEXT: f2@plt:
// DISASM-NEXT: 1040: ff 25 da 0f 00 00 jmpq *4058(%rip)
// DISASM-NEXT: 1046: 68 01 00 00 00 pushq $1
// DISASM-NEXT: 104b: e9 d0 ff ff ff jmp -48 <.plt>
// DISASM-NEXT: 1050: ff 25 d2 0f 00 00 jmpq *4050(%rip)
// DISASM-NEXT: 1056: 68 00 00 00 00 pushq $0
-// DISASM-NEXT: 105b: e9 e0 ff ff ff jmp -32 <.plt+0x20>
+// DISASM-NEXT: 105b: e9 e0 ff ff ff jmp -32 <f2@plt>
// CHECK: Relocations [
// CHECK-NEXT: Section (4) .rela.plt {
diff --git a/test/ELF/gnu-ifunc.s b/test/ELF/gnu-ifunc.s
index faf51b4b6216..25c71b033e20 100644
--- a/test/ELF/gnu-ifunc.s
+++ b/test/ELF/gnu-ifunc.s
@@ -16,10 +16,12 @@
// CHECK-NEXT: Offset: 0x158
// CHECK-NEXT: Size: 48
// CHECK-NEXT: Link: 0
-// CHECK-NEXT: Info: 0
+// CHECK-NEXT: Info: [[GOTPLT:.*]]
// CHECK-NEXT: AddressAlignment: 8
// CHECK-NEXT: EntrySize: 24
// CHECK-NEXT: }
+// CHECK: Index: [[GOTPLT]]
+// CHECK-NEXT: Name: .got.plt
// CHECK: Relocations [
// CHECK-NEXT: Section ({{.*}}) .rela.plt {
// CHECK-NEXT: 0x202000 R_X86_64_IRELATIVE
diff --git a/test/ELF/gnu-unique.s b/test/ELF/gnu-unique.s
index 06f370434cd8..83f0f233f4f3 100644
--- a/test/ELF/gnu-unique.s
+++ b/test/ELF/gnu-unique.s
@@ -20,7 +20,7 @@ _start:
.type symb, @gnu_unique_object
symb:
-# GNU: Name: symb@
+# GNU: Name: symb
# GNU-NEXT: Value:
# GNU-NEXT: Size: 0
# GNU-NEXT: Binding: Unique
@@ -29,7 +29,7 @@ symb:
# GNU-NEXT: Section: .data
# GNU-NEXT: }
-# NO: Name: symb@
+# NO: Name: symb
# NO-NEXT: Value:
# NO-NEXT: Size: 0
# NO-NEXT: Binding: Global
diff --git a/test/ELF/got-i386.s b/test/ELF/got-i386.s
index 7fb87e0dadbd..3b2ef1a31c2c 100644
--- a/test/ELF/got-i386.s
+++ b/test/ELF/got-i386.s
@@ -10,7 +10,7 @@
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: SHF_WRITE
// CHECK-NEXT: ]
-// CHECK-NEXT: Address: 0x12000
+// CHECK-NEXT: Address: 0x402000
// CHECK-NEXT: Offset:
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Link:
@@ -19,7 +19,7 @@
// CHECK: Symbol {
// CHECK: Name: bar
-// CHECK-NEXT: Value: 0x12000
+// CHECK-NEXT: Value: 0x402000
// CHECK-NEXT: Size: 10
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: Object
@@ -28,7 +28,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: obj
-// CHECK-NEXT: Value: 0x1200A
+// CHECK-NEXT: Value: 0x40200A
// CHECK-NEXT: Size: 10
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: Object
@@ -36,14 +36,14 @@
// CHECK-NEXT: Section: .bss
// CHECK-NEXT: }
-// 0x12000 - 0 = addr(.got) = 0x12000
-// 0x1200A - 10 = addr(.got) = 0x12000
-// 0x1200A + 5 - 15 = addr(.got) = 0x12000
+// 0x402000 - 0 = addr(.got) = 0x402000
+// 0x40200A - 10 = addr(.got) = 0x402000
+// 0x40200A + 5 - 15 = addr(.got) = 0x402000
// DISASM: Disassembly of section .text:
// DISASM-NEXT: _start:
-// DISASM-NEXT: 11000: c7 81 00 00 00 00 01 00 00 00 movl $1, (%ecx)
-// DISASM-NEXT: 1100a: c7 81 0a 00 00 00 02 00 00 00 movl $2, 10(%ecx)
-// DISASM-NEXT: 11014: c7 81 0f 00 00 00 03 00 00 00 movl $3, 15(%ecx)
+// DISASM-NEXT: 401000: c7 81 00 00 00 00 01 00 00 00 movl $1, (%ecx)
+// DISASM-NEXT: 40100a: c7 81 0a 00 00 00 02 00 00 00 movl $2, 10(%ecx)
+// DISASM-NEXT: 401014: c7 81 0f 00 00 00 03 00 00 00 movl $3, 15(%ecx)
.global _start
_start:
diff --git a/test/ELF/got32-i386-pie-rw.s b/test/ELF/got32-i386-pie-rw.s
index 45d2ec154675..180ba864fbfd 100644
--- a/test/ELF/got32-i386-pie-rw.s
+++ b/test/ELF/got32-i386-pie-rw.s
@@ -1,7 +1,7 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o
# RUN: ld.lld %t.o -o %t -pie
-# RUN: llvm-readelf -r -s %t | FileCheck %s
+# RUN: llvm-readelf -r -S %t | FileCheck %s
# Unlike bfd and gold we accept this.
diff --git a/test/ELF/got32-i386.s b/test/ELF/got32-i386.s
index dce50d0afc2e..ff67a4bbe0ef 100644
--- a/test/ELF/got32-i386.s
+++ b/test/ELF/got32-i386.s
@@ -14,10 +14,10 @@ _start:
## 73728 == 0x12000 == ADDR(.got)
# CHECK: _start:
-# CHECK-NEXT: 11001: 8b 1d {{.*}} movl 73728, %ebx
+# CHECK-NEXT: 401001: 8b 1d {{.*}} movl 4202496, %ebx
# CHECK: Sections:
# CHECK: Name Size Address
-# CHECK: .got 00000004 0000000000012000
+# CHECK: .got 00000004 0000000000402000
# RUN: not ld.lld %t.o -o %t -pie 2>&1 | FileCheck %s --check-prefix=ERR
# ERR: error: can't create dynamic relocation R_386_GOT32 against symbol: foo in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
diff --git a/test/ELF/got32x-i386.s b/test/ELF/got32x-i386.s
index 610051e8a962..88e7e31ee561 100644
--- a/test/ELF/got32x-i386.s
+++ b/test/ELF/got32x-i386.s
@@ -33,13 +33,13 @@
## 73728 == 0x12000 == ADDR(.got)
# CHECK: _start:
-# CHECK-NEXT: 11001: 8b 05 {{.*}} movl 77824, %eax
-# CHECK-NEXT: 11007: 8b 1d {{.*}} movl 77824, %ebx
-# CHECK-NEXT: 1100d: 8b 80 {{.*}} movl -4(%eax), %eax
-# CHECK-NEXT: 11013: 8b 83 {{.*}} movl -4(%ebx), %eax
+# CHECK-NEXT: 401001: 8b 05 {{.*}} movl 4206592, %eax
+# CHECK-NEXT: 401007: 8b 1d {{.*}} movl 4206592, %ebx
+# CHECK-NEXT: 40100d: 8b 80 {{.*}} movl -4(%eax), %eax
+# CHECK-NEXT: 401013: 8b 83 {{.*}} movl -4(%ebx), %eax
# CHECK: Sections:
# CHECK: Name Size Address
-# CHECK: .got 00000004 0000000000013000
+# CHECK: .got 00000004 0000000000403000
# RUN: not ld.lld %S/Inputs/i386-got32x-baseless.elf -o %t1 -pie 2>&1 | \
# RUN: FileCheck %s --check-prefix=ERR
diff --git a/test/ELF/hexagon-eflag.s b/test/ELF/hexagon-eflag.s
new file mode 100644
index 000000000000..01cb5e5b0f29
--- /dev/null
+++ b/test/ELF/hexagon-eflag.s
@@ -0,0 +1,7 @@
+# REQUIRES: hexagon
+# RUN: llvm-mc -filetype=obj -mv62 -triple=hexagon-unknown-elf %s -o %t
+# RUN: llvm-mc -filetype=obj -mv60 -triple=hexagon-unknown-elf %S/Inputs/hexagon.s -o %t2
+# RUN: ld.lld %t2 %t -o %t3
+# RUN: llvm-readelf -h %t3 | FileCheck %s
+# Verify that the largest arch in the input list is selected.
+# CHECK: Flags: 0x62
diff --git a/test/ELF/hexagon-shared.s b/test/ELF/hexagon-shared.s
new file mode 100644
index 000000000000..97f8e84f9257
--- /dev/null
+++ b/test/ELF/hexagon-shared.s
@@ -0,0 +1,46 @@
+# REQUIRES: hexagon
+# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %s -o %t
+# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %S/Inputs/hexagon-shared.s -o %t2.o
+# RUN: ld.lld -shared %t2.o -soname %t3.so -o %t3.so
+# RUN: ld.lld -shared %t %t3.so -soname %t4.so -o %t4.so
+# RUN: llvm-objdump -d -j .plt %t4.so | FileCheck --check-prefix=PLT %s
+# RUN: llvm-objdump -d -j .text %t4.so | FileCheck --check-prefix=TEXT %s
+# RUN: llvm-objdump -D -j .got %t4.so | FileCheck --check-prefix=GOT %s
+
+.global foo
+foo:
+
+# _HEX_32_PCREL
+.word _DYNAMIC - .
+call ##bar
+
+# R_HEX_PLT_B22_PCREL
+call bar@PLT
+
+# R_HEX_GOT_11_X and R_HEX_GOT_32_6_X
+r2=add(pc,##_GLOBAL_OFFSET_TABLE_@PCREL)
+r0 = memw (r2+##bar@GOT)
+jumpr r0
+
+# R_HEX_GOT_16_X
+r0 = add(r1,##bar@GOT)
+
+# PLT: { immext(#65472
+# PLT: r28 = add(pc,##65488) }
+# PLT: { r14 -= add(r28,#16)
+# PLT: r15 = memw(r28+#8)
+# PLT: r28 = memw(r28+#4) }
+# PLT: { r14 = asr(r14,#2)
+# PLT: jumpr r28 }
+# PLT: { trap0(#219) }
+# PLT: immext(#65472)
+# PLT: r14 = add(pc,##65472) }
+# PLT: r28 = memw(r14+#0) }
+# PLT: jumpr r28 }
+
+# TEXT: 10000: 00 00 02 00 00020000
+# TEXT: { call 0x10050 }
+# TEXT: r0 = add(r1,##65664) }
+
+# GOT: .got:
+# GOT: 30080: 00 00 00 00 00000000 <unknown>
diff --git a/test/ELF/hexagon.s b/test/ELF/hexagon.s
index 1b3273374c67..c8dd271815e8 100644
--- a/test/ELF/hexagon.s
+++ b/test/ELF/hexagon.s
@@ -4,28 +4,220 @@
# RUN: ld.lld %t2 %t -o %t3
# RUN: llvm-objdump -d %t3 | FileCheck %s
-# Note: 69632 == 0x11000
+# Note: 131072 == 0x20000
# R_HEX_32_6_X
# R_HEX_12_X
if (p0) r0 = ##_start
-# CHECK: immext(#69632)
-# CHECK: if (p0) r0 = ##69632
+# CHECK: immext(#131072)
+# CHECK: if (p0) r0 = ##131072
# R_HEX_B15_PCREL
if (p0) jump:nt #_start
-# CHECK: if (p0) jump:nt 0x11000
+# CHECK: if (p0) jump:nt 0x20000
# R_HEX_B32_PCREL_X
# R_HEX_B15_PCREL_X
if (p0) jump:nt ##_start
-# CHECK: if (p0) jump:nt 0x11000
+# CHECK: if (p0) jump:nt 0x20000
# R_HEX_B22_PCREL
call #_start
-# CHECK: call 0x11000
+# CHECK: call 0x20000
# R_HEX_B32_PCREL_X
# R_HEX_B22_PCREL_X
call ##_start
# CHECK: immext(#4294967232)
-# CHECK: call 0x11000
+# CHECK: call 0x20000
+
+# R_HEX_6_X tests:
+# One test for each mask in the lookup table.
+
+#0x38000000
+if (!P0) memw(r0+#8)=##_start
+# CHECK: 38c0c100 if (!p0) memw(r0+#8) = ##131072 }
+
+#0x39000000
+{ p0 = p1
+ if (!P0.new) memw(r0+#0)=##_start }
+# CHECK: 39c0c000 if (!p0.new) memw(r0+#0) = ##131072 }
+
+#0x3e000000
+memw(r0+##_start)+=r1
+# CHECK: 3e40c001 memw(r0+##131072) += r1 }
+
+#0x3f000000
+memw(r0+##_start)+=#4
+# CHECK: 3f40c004 memw(r0+##131072) += #4 }
+
+#0x40000000
+{ r0 = r1
+ if (p0) memb(r0+##_start)=r0.new }
+# CHECK: 40a0c200 if (p0) memb(r0+##131072) = r0.new }
+
+#0x41000000
+if (p0) r0=memb(r1+##_start)
+# CHECK: 4101c000 if (p0) r0 = memb(r1+##131072) }
+
+#0x42000000
+{ r0 = r1
+ p0 = p1
+ if (p0.new) memb(r0+##_start)=r0.new }
+# CHECK: 42a0c200 if (p0.new) memb(r0+##131072) = r0.new }
+
+#0x43000000
+{ p0 = p1
+ if (P0.new) r0=memb(r0+##_start) }
+# CHECK: 4300c000 if (p0.new) r0 = memb(r0+##131072) }
+
+#0x44000000
+if (!p0) memb(r0+##_start)=r1
+# CHECK: 4400c100 if (!p0) memb(r0+##131072) = r1 }
+
+#0x45000000
+if (!p0) r0=memb(r1+##_start)
+# CHECK: 4501c000 if (!p0) r0 = memb(r1+##131072) }
+
+#0x46000000
+{ p0 = p1
+ if (!p0.new) memb(r0+##_start)=r1 }
+# CHECK: 4600c100 if (!p0.new) memb(r0+##131072) = r1 }
+
+#0x47000000
+{ p0 = p1
+ if (!p0.new) r0=memb(r1+##_start) }
+# CHECK: 4701c000 if (!p0.new) r0 = memb(r1+##131072) }
+
+#0x6a000000 -- Note 4294967132 == -0xa4 the distance between
+# here and _start, so this will change if
+# tests are added between here and _start
+r0=add(pc,##_start@pcrel)
+# CHECK: 6a49ce00 r0 = add(pc,##4294967132) }
+
+#0x7c000000
+r1:0=combine(#8,##_start)
+# CHECK: 7c80c100 r1:0 = combine(#8,##131072) }
+
+#0x9a000000
+r1:0=memb_fifo(r2=##_start)
+# CHECK: 9a82d000 r1:0 = memb_fifo(r2=##131072) }
+
+#0x9b000000
+r0=memb(r1=##_start)
+# CHECK: 9b01d000 r0 = memb(r1=##131072) }
+
+#0x9c000000
+r1:0=memb_fifo(r2<<#2+##_start)
+# CHECK: 9c82f000 r1:0 = memb_fifo(r2<<#2+##131072) }
+
+#0x9d000000
+r0=memb(r1<<#2+##_start)
+# CHECK: 9d01f000 r0 = memb(r1<<#2+##131072) }
+
+#0x9f000000
+if (!p0) r0=memb(##_start)
+# CHECK: 9f00e880 if (!p0) r0 = memb(##131072) }
+
+#0xab000000
+memb(r0=##_start)=r1
+# CHECK: ab00c180 memb(r0=##131072) = r1 }
+
+#0xad000000
+memb(r0<<#2+##_start)=r1
+# CHECK: ad00e180 memb(r0<<#2+##131072) = r1 }
+
+#0xaf000000
+if (!p0) memb(##_start)=r1
+# CHECK: af00c184 if (!p0) memb(##131072) = r1 }
+
+#0xd7000000
+r0=add(##_start,mpyi(r1,r2))
+# CHECK: d701c200 r0 = add(##131072,mpyi(r1,r2)) }
+
+#0xd8000000
+R0=add(##_start,mpyi(r0,#2))
+# CHECK: d800c002 r0 = add(##131072,mpyi(r0,#2)) }
+
+#0xdb000000
+r0=add(r1,add(r2,##_start))
+# CHECK: db01c002 r0 = add(r1,add(r2,##131072)) }
+
+#0xdf000000
+r0=add(r1,mpyi(r2,##_start))
+# CHECK: df82c001 r0 = add(r1,mpyi(r2,##131072)) }
+
+# Duplex form of R_HEX_6_X
+# R_HEX_32_6_X
+# R_HEX_6_X
+{ r0 = ##_start; r2 = r16 }
+# CHECK: 28003082 r0 = ##131072; r2 = r16 }
+
+# R_HEX_HI16
+r0.h = #HI(_start)
+# CHECK: r0.h = #2
+
+# R_HEX_LO16
+r0.l = #LO(_start)
+# CHECK: r0.l = #0
+
+# R_HEX_8_X has 3 relocation mask variations
+#0xde000000
+r0=sub(##_start, asl(r0, #1))
+# CHECK: de00c106 r0 = sub(##131072,asl(r0,#1)) }
+
+#0x3c000000
+memw(r0+#0) = ##_start
+# CHECK: 3c40c000 memw(r0+#0) = ##131072 }
+
+# The rest:
+r1:0=combine(r2,##_start);
+# CHECK: 7302e000 r1:0 = combine(r2,##131072) }
+
+# R_HEX_32:
+r_hex_32:
+.word _start
+# CHECK: 00020000
+
+# R_HEX_16_X has 4 relocation mask variations
+# 0x48000000
+memw(##_start) = r0
+# CHECK: 4880c000 memw(##131072) = r0 }
+
+# 0x49000000
+r0 = memw(##_start)
+# CHECK: 4980c000 r0 = memw(##131072)
+
+# 0x78000000
+r0 = ##_start
+# CHECK: 7800c000 r0 = ##131072 }
+
+# 0xb0000000
+r0 = add(r1, ##_start)
+# CHECK: b001c000 r0 = add(r1,##131072) }
+
+# R_HEX_B9_PCREL:
+{r0=#1 ; jump #_start}
+# CHECK: jump 0x20000
+
+# R_HEX_B9_PCREL_X:
+{r0=#1 ; jump ##_start}
+# CHECK: jump 0x20000
+
+# R_HEX_B13_PCREL
+if (r0 == #0) jump:t #_start
+# CHECK: if (r0==#0) jump:t 0x20000
+
+# R_HEX_9_X
+p0 = !cmp.gtu(r0, ##_start)
+# CHECK: p0 = !cmp.gtu(r0,##131072)
+
+# R_HEX_10_X
+p0 = !cmp.gt(r0, ##_start)
+# CHECK: p0 = !cmp.gt(r0,##131072)
+
+# R_HEX_11_X
+r0 = memw(r1+##_start)
+# CHECK: r0 = memw(r1+##131072)
+
+memw(r0+##_start) = r1
+# CHECK: memw(r0+##131072) = r1
diff --git a/test/ELF/i386-linkonce.s b/test/ELF/i386-linkonce.s
new file mode 100644
index 000000000000..c06b042c7638
--- /dev/null
+++ b/test/ELF/i386-linkonce.s
@@ -0,0 +1,9 @@
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -triple=i386-linux-gnu %s -o %t.o
+// RUN: llvm-mc -filetype=obj -triple=i386-linux-gnu %p/Inputs/i386-linkonce.s -o %t2.o
+// RUN: llvm-ar rcs %t2.a %t2.o
+// RUN: ld.lld %t.o %t2.a -o %t
+
+ .globl _start
+_start:
+ call _strchr1
diff --git a/test/ELF/i386-pc8-pc16-addend.s b/test/ELF/i386-pc8-pc16-addend.s
index fc648b035509..8dad18fb2e65 100644
--- a/test/ELF/i386-pc8-pc16-addend.s
+++ b/test/ELF/i386-pc8-pc16-addend.s
@@ -4,11 +4,11 @@
# 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-NEXT: 401000 020000
+## 0x401003 - 0x401000 + addend(-1) = 0x02
+## 0x401003 - 0x401001 + addend(-2) = 0x0000
# CHECK: SYMBOL TABLE:
-# CHECK: 00011003 .und
+# CHECK: 00401003 .und
.byte und-.-1
.short und-.-2
diff --git a/test/ELF/i386-retpoline-nopic.s b/test/ELF/i386-retpoline-nopic.s
index 79dd5a63cd69..6d0a699cf306 100644
--- a/test/ELF/i386-retpoline-nopic.s
+++ b/test/ELF/i386-retpoline-nopic.s
@@ -8,56 +8,56 @@
// CHECK: Disassembly of section .plt:
// CHECK-NEXT: .plt:
-// CHECK-NEXT: 11010: ff 35 04 20 01 00 pushl 73732
-// CHECK-NEXT: 11016: 50 pushl %eax
-// CHECK-NEXT: 11017: a1 08 20 01 00 movl 73736, %eax
-// CHECK-NEXT: 1101c: e8 0f 00 00 00 calll 15 <.plt+0x20>
-// CHECK-NEXT: 11021: f3 90 pause
-// CHECK-NEXT: 11023: 0f ae e8 lfence
-// CHECK-NEXT: 11026: eb f9 jmp -7 <.plt+0x11>
-// CHECK-NEXT: 11028: cc int3
-// CHECK-NEXT: 11029: cc int3
-// CHECK-NEXT: 1102a: cc int3
-// CHECK-NEXT: 1102b: cc int3
-// CHECK-NEXT: 1102c: cc int3
-// CHECK-NEXT: 1102d: cc int3
-// CHECK-NEXT: 1102e: cc int3
-// CHECK-NEXT: 1102f: cc int3
-// CHECK-NEXT: 11030: 89 0c 24 movl %ecx, (%esp)
-// CHECK-NEXT: 11033: 8b 4c 24 04 movl 4(%esp), %ecx
-// CHECK-NEXT: 11037: 89 44 24 04 movl %eax, 4(%esp)
-// CHECK-NEXT: 1103b: 89 c8 movl %ecx, %eax
-// CHECK-NEXT: 1103d: 59 popl %ecx
-// CHECK-NEXT: 1103e: c3 retl
-// CHECK-NEXT: 1103f: cc int3
-// CHECK-NEXT: 11040: 50 pushl %eax
-// CHECK-NEXT: 11041: a1 0c 20 01 00 movl 73740, %eax
-// CHECK-NEXT: 11046: e8 e5 ff ff ff calll -27 <.plt+0x20>
-// CHECK-NEXT: 1104b: e9 d1 ff ff ff jmp -47 <.plt+0x11>
-// CHECK-NEXT: 11050: 68 00 00 00 00 pushl $0
-// CHECK-NEXT: 11055: e9 b6 ff ff ff jmp -74 <.plt>
-// CHECK-NEXT: 1105a: cc int3
-// CHECK-NEXT: 1105b: cc int3
-// CHECK-NEXT: 1105c: cc int3
-// CHECK-NEXT: 1105d: cc int3
-// CHECK-NEXT: 1105e: cc int3
-// CHECK-NEXT: 1105f: cc int3
-// CHECK-NEXT: 11060: 50 pushl %eax
-// CHECK-NEXT: 11061: a1 10 20 01 00 movl 73744, %eax
-// CHECK-NEXT: 11066: e8 c5 ff ff ff calll -59 <.plt+0x20>
-// CHECK-NEXT: 1106b: e9 b1 ff ff ff jmp -79 <.plt+0x11>
-// CHECK-NEXT: 11070: 68 08 00 00 00 pushl $8
-// CHECK-NEXT: 11075: e9 96 ff ff ff jmp -106 <.plt>
-// CHECK-NEXT: 1107a: cc int3
-// CHECK-NEXT: 1107b: cc int3
-// CHECK-NEXT: 1107c: cc int3
-// CHECK-NEXT: 1107d: cc int3
-// CHECK-NEXT: 1107e: cc int3
-// CHECK-NEXT: 1107f: cc int3
+// CHECK-NEXT: 401010: ff 35 04 20 40 00 pushl 4202500
+// CHECK-NEXT: 401016: 50 pushl %eax
+// CHECK-NEXT: 401017: a1 08 20 40 00 movl 4202504, %eax
+// CHECK-NEXT: 40101c: e8 0f 00 00 00 calll 15 <.plt+0x20>
+// CHECK-NEXT: 401021: f3 90 pause
+// CHECK-NEXT: 401023: 0f ae e8 lfence
+// CHECK-NEXT: 401026: eb f9 jmp -7 <.plt+0x11>
+// CHECK-NEXT: 401028: cc int3
+// CHECK-NEXT: 401029: cc int3
+// CHECK-NEXT: 40102a: cc int3
+// CHECK-NEXT: 40102b: cc int3
+// CHECK-NEXT: 40102c: cc int3
+// CHECK-NEXT: 40102d: cc int3
+// CHECK-NEXT: 40102e: cc int3
+// CHECK-NEXT: 40102f: cc int3
+// CHECK-NEXT: 401030: 89 0c 24 movl %ecx, (%esp)
+// CHECK-NEXT: 401033: 8b 4c 24 04 movl 4(%esp), %ecx
+// CHECK-NEXT: 401037: 89 44 24 04 movl %eax, 4(%esp)
+// CHECK-NEXT: 40103b: 89 c8 movl %ecx, %eax
+// CHECK-NEXT: 40103d: 59 popl %ecx
+// CHECK-NEXT: 40103e: c3 retl
+// CHECK-NEXT: 40103f: cc int3
+// CHECK-NEXT: 401040: 50 pushl %eax
+// CHECK-NEXT: 401041: a1 0c 20 40 00 movl 4202508, %eax
+// CHECK-NEXT: 401046: e8 e5 ff ff ff calll -27 <.plt+0x20>
+// CHECK-NEXT: 40104b: e9 d1 ff ff ff jmp -47 <.plt+0x11>
+// CHECK-NEXT: 401050: 68 00 00 00 00 pushl $0
+// CHECK-NEXT: 401055: e9 b6 ff ff ff jmp -74 <.plt>
+// CHECK-NEXT: 40105a: cc int3
+// CHECK-NEXT: 40105b: cc int3
+// CHECK-NEXT: 40105c: cc int3
+// CHECK-NEXT: 40105d: cc int3
+// CHECK-NEXT: 40105e: cc int3
+// CHECK-NEXT: 40105f: cc int3
+// CHECK-NEXT: 401060: 50 pushl %eax
+// CHECK-NEXT: 401061: a1 10 20 40 00 movl 4202512, %eax
+// CHECK-NEXT: 401066: e8 c5 ff ff ff calll -59 <.plt+0x20>
+// CHECK-NEXT: 40106b: e9 b1 ff ff ff jmp -79 <.plt+0x11>
+// CHECK-NEXT: 401070: 68 08 00 00 00 pushl $8
+// CHECK-NEXT: 401075: e9 96 ff ff ff jmp -106 <.plt>
+// CHECK-NEXT: 40107a: cc int3
+// CHECK-NEXT: 40107b: cc int3
+// CHECK-NEXT: 40107c: cc int3
+// CHECK-NEXT: 40107d: cc int3
+// CHECK-NEXT: 40107e: cc int3
+// CHECK-NEXT: 40107f: cc int3
// CHECK: Contents of section .got.plt:
-// CHECK-NEXT: 00300100 00000000 00000000 50100100
-// CHECK-NEXT: 70100100
+// CHECK-NEXT: 00304000 00000000 00000000 50104000
+// CHECK-NEXT: 70104000
.global _start
_start:
diff --git a/test/ELF/icf13.s b/test/ELF/icf13.s
index 2fe707f11c76..c0d4935cca40 100644
--- a/test/ELF/icf13.s
+++ b/test/ELF/icf13.s
@@ -1,3 +1,4 @@
+# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1
# RUN: ld.lld -shared -z notext %t1 -o /dev/null --icf=all --print-icf-sections 2>&1 | FileCheck -allow-empty %s
diff --git a/test/ELF/icf15.s b/test/ELF/icf15.s
index 57c1735e1518..5c651fbd65ff 100644
--- a/test/ELF/icf15.s
+++ b/test/ELF/icf15.s
@@ -1,3 +1,4 @@
+# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1
# RUN: ld.lld %t1 -o /dev/null --icf=all --print-icf-sections 2>&1 | FileCheck -allow-empty %s
diff --git a/test/ELF/icf16.s b/test/ELF/icf16.s
index e7650af37c3b..13cb8ecd2994 100644
--- a/test/ELF/icf16.s
+++ b/test/ELF/icf16.s
@@ -1,3 +1,4 @@
+# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1
# RUN: ld.lld -shared -z notext %t1 -o /dev/null --icf=all --print-icf-sections 2>&1 | FileCheck -allow-empty %s
diff --git a/test/ELF/icf17.s b/test/ELF/icf17.s
index 5d28aeb869c1..cab5c12d214e 100644
--- a/test/ELF/icf17.s
+++ b/test/ELF/icf17.s
@@ -1,3 +1,4 @@
+# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1
# RUN: ld.lld %t1 -o /dev/null --icf=all --print-icf-sections 2>&1 | FileCheck -allow-empty %s
diff --git a/test/ELF/image-base.s b/test/ELF/image-base.s
index eb79acdced81..8866708c4001 100644
--- a/test/ELF/image-base.s
+++ b/test/ELF/image-base.s
@@ -3,6 +3,9 @@
# RUN: ld.lld -image-base=0x1000000 %t -o %t1
# RUN: llvm-readobj -program-headers %t1 | FileCheck %s
+# RUN: not ld.lld -image-base=ABC %t -o %t1 2>&1 | FileCheck --check-prefix=ERR %s
+# ERR: error: -image-base: number expected, but got ABC
+
# RUN: ld.lld -image-base=0x1000 -z max-page-size=0x2000 %t -o %t1 2>&1 | FileCheck --check-prefix=WARN %s
# WARN: warning: -image-base: address isn't multiple of page size: 0x1000
diff --git a/test/ELF/incompatible-ar-first.s b/test/ELF/incompatible-ar-first.s
index fbbe9de761ec..e49171939513 100644
--- a/test/ELF/incompatible-ar-first.s
+++ b/test/ELF/incompatible-ar-first.s
@@ -1,5 +1,6 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/archive.s -o %ta.o
+// RUN: rm -f %t.a
// RUN: llvm-ar rc %t.a %ta.o
// RUN: llvm-mc -filetype=obj -triple=i686-linux %s -o %tb.o
// RUN: not ld.lld %t.a %tb.o -o /dev/null 2>&1 | FileCheck %s
diff --git a/test/ELF/incompatible.s b/test/ELF/incompatible.s
index 44c5b4bfcbf7..283146a7ee4f 100644
--- a/test/ELF/incompatible.s
+++ b/test/ELF/incompatible.s
@@ -48,6 +48,7 @@
// We used to fail to identify this incompatibility and crash trying to
// read a 64 bit file as a 32 bit one.
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/archive2.s -o %ta.o
+// RUN: rm -f %t.a
// RUN: llvm-ar rc %t.a %ta.o
// RUN: llvm-mc -filetype=obj -triple=i686-linux %s -o %tb.o
// RUN: not ld.lld %t.a %tb.o 2>&1 -o %t | FileCheck --check-prefix=ARCHIVE %s
diff --git a/test/ELF/invalid-linkerscript.test b/test/ELF/invalid-linkerscript.test
index f9fb8478251f..e635ae4f2af9 100644
--- a/test/ELF/invalid-linkerscript.test
+++ b/test/ELF/invalid-linkerscript.test
@@ -50,5 +50,11 @@
# RUN: echo "OUTPUT_FORMAT(x y z)" > %t8
# RUN: not ld.lld %t8 no-such-file 2>&1 | FileCheck -check-prefix=ERR8 %s
-# ERR8: , expected, but got y
+# RUN: not ld.lld -m elf_amd64 %t8 no-such-file 2>&1 | FileCheck -check-prefix=ERR8 %s
+# ERR8: unknown output format name: x
# ERR8: cannot open no-such-file:
+
+# RUN: echo "OUTPUT_FORMAT(elf64-x86-64 y z)" > %t9
+# RUN: not ld.lld %t9 no-such-file 2>&1 | FileCheck -check-prefix=ERR9 %s
+# ERR9: , expected, but got y
+# ERR9: cannot open no-such-file:
diff --git a/test/ELF/invalid/Inputs/shentsize-zero.elf b/test/ELF/invalid/Inputs/shentsize-zero.elf
deleted file mode 100644
index 5fa7df245619..000000000000
--- a/test/ELF/invalid/Inputs/shentsize-zero.elf
+++ /dev/null
Binary files differ
diff --git a/test/ELF/invalid/Inputs/sht-group.elf b/test/ELF/invalid/Inputs/sht-group.elf
deleted file mode 100644
index 5cb033628418..000000000000
--- a/test/ELF/invalid/Inputs/sht-group.elf
+++ /dev/null
Binary files differ
diff --git a/test/ELF/invalid/Inputs/undefined-local-symbol-in-dso.so b/test/ELF/invalid/Inputs/undefined-local-symbol-in-dso.so
new file mode 100755
index 000000000000..b88427351197
--- /dev/null
+++ b/test/ELF/invalid/Inputs/undefined-local-symbol-in-dso.so
Binary files differ
diff --git a/test/ELF/invalid/comdat-broken.test b/test/ELF/invalid/comdat-broken.test
new file mode 100644
index 000000000000..9ff8eca476a5
--- /dev/null
+++ b/test/ELF/invalid/comdat-broken.test
@@ -0,0 +1,25 @@
+# REQUIRES: x86
+
+# RUN: yaml2obj %s -o %t.o
+# RUN: not ld.lld %t.o -o %t.exe 2>&1 | FileCheck %s
+# RUN: not ld.lld %t.o %t.o -o %t.exe 2>&1 | FileCheck %s
+
+# CHECK: error: {{.*}}.o: unsupported SHT_GROUP format
+
+--- !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: 0xFF
+ - SectionOrType: 3
+Symbols:
+ Global:
+ - Name: foo
diff --git a/test/ELF/invalid/ehframe-broken-relocation.test b/test/ELF/invalid/ehframe-broken-relocation.test
new file mode 100644
index 000000000000..1333a6d0a868
--- /dev/null
+++ b/test/ELF/invalid/ehframe-broken-relocation.test
@@ -0,0 +1,31 @@
+# RUN: yaml2obj %s -o %t.o
+# RUN: not ld.lld --icf=all %t.o -o /dev/null 2>&1 | FileCheck %s
+# CHECK: .eh_frame: relocation is not in any piece
+
+!ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ OSABI: ELFOSABI_FREEBSD
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .eh_frame
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC]
+ Content: "1400000000000000017a5200017810011b0c070890010000140000001c00000000000000000000000000000000000000"
+ - Name: .rela.eh_frame
+ Type: SHT_RELA
+ Link: .symtab
+ Info: .eh_frame
+ Relocations:
+ - Offset: 0x99999999
+ Symbol: zed
+ Type: R_X86_64_64
+Symbols:
+ Global:
+ - Name: zed
+ Type: STT_FUNC
+ Section: .eh_frame
+ Value: 0x0
+ Size: 8
diff --git a/test/ELF/invalid/invalid-soname.test b/test/ELF/invalid/invalid-soname.test
new file mode 100644
index 000000000000..8641465acd50
--- /dev/null
+++ b/test/ELF/invalid/invalid-soname.test
@@ -0,0 +1,18 @@
+# REQUIRES: x86
+# RUN: yaml2obj %s -o %t.so
+# RUN: not ld.lld %t.so -o %t.exe 2>&1 | FileCheck %s
+
+# CHECK: error: {{.*}}.so: invalid DT_SONAME entry
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_DYN
+ Machine: EM_X86_64
+Sections:
+ - Name: .test
+ Type: SHT_DYNAMIC
+ Flags: [ SHF_ALLOC ]
+ Content: "0e000000000000000000000000000001"
+ Link: .strtab
diff --git a/test/ELF/invalid/linkorder-invalid-sec.test b/test/ELF/invalid/linkorder-invalid-sec.test
new file mode 100644
index 000000000000..d4aa376639c3
--- /dev/null
+++ b/test/ELF/invalid/linkorder-invalid-sec.test
@@ -0,0 +1,16 @@
+# REQUIRES: x86
+# RUN: yaml2obj %s -o %t.o
+# RUN: not ld.lld %t.o -o %t.exe 2>&1 | FileCheck %s
+# CHECK: invalid sh_link index: 12345
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .linkorder
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR, SHF_LINK_ORDER ]
+ Link: 12345
diff --git a/test/ELF/invalid/linkorder-invalid-sec2.test b/test/ELF/invalid/linkorder-invalid-sec2.test
new file mode 100644
index 000000000000..f78df3fb0896
--- /dev/null
+++ b/test/ELF/invalid/linkorder-invalid-sec2.test
@@ -0,0 +1,16 @@
+# REQUIRES: x86
+# RUN: yaml2obj %s -o %t.o
+# RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
+# CHECK: invalid sh_link index: 0
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .linkorder
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR, SHF_LINK_ORDER ]
+ Link: 0
diff --git a/test/ELF/invalid/merge-invalid-size.s b/test/ELF/invalid/merge-invalid-size.s
index cc2566d0ee87..b16889a538a5 100644
--- a/test/ELF/invalid/merge-invalid-size.s
+++ b/test/ELF/invalid/merge-invalid-size.s
@@ -3,8 +3,5 @@
// RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
// CHECK: SHF_MERGE section size must be a multiple of sh_entsize
-// Test that we accept a zero sh_entsize.
-// RUN: ld.lld %p/Inputs/shentsize-zero.elf -o /dev/null
-
.section .foo,"aM",@progbits,4
.short 42
diff --git a/test/ELF/invalid/merge-zero-size.test b/test/ELF/invalid/merge-zero-size.test
new file mode 100644
index 000000000000..564ed44068ef
--- /dev/null
+++ b/test/ELF/invalid/merge-zero-size.test
@@ -0,0 +1,21 @@
+# REQUIRES: x86
+
+# RUN: yaml2obj %s -o %t.o
+
+# Test that we accept a zero sh_entsize for SHF_MERGE section.
+# RUN: ld.lld %t.o -o %t.exe
+
+!ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ OSABI: ELFOSABI_FREEBSD
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Type: SHT_PROGBITS
+ Name: .strings
+ Flags: [ SHF_ALLOC, SHF_MERGE, SHF_STRINGS ]
+ AddressAlign: 0x04
+ Content: "FFFFFFFFFFFFFFFF"
+ EntSize: 0x0
diff --git a/test/ELF/invalid/non-terminated-string.test b/test/ELF/invalid/non-terminated-string.test
new file mode 100644
index 000000000000..82e94fe1457c
--- /dev/null
+++ b/test/ELF/invalid/non-terminated-string.test
@@ -0,0 +1,19 @@
+# RUN: yaml2obj %s -o %t
+# RUN: not ld.lld %t -o %tout 2>&1 | FileCheck %s
+
+# CHECK: {{.*}}:(.merge): string is not null terminated
+
+!ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ OSABI: ELFOSABI_FREEBSD
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Type: SHT_PROGBITS
+ Name: .merge
+ Flags: [ SHF_ALLOC, SHF_MERGE, SHF_STRINGS ]
+ AddressAlign: 0x04
+ Content: "AABB"
+ EntSize: 0x2
diff --git a/test/ELF/invalid/sht-group-wrong-section.test b/test/ELF/invalid/sht-group-wrong-section.test
new file mode 100644
index 000000000000..d431dcbc2d24
--- /dev/null
+++ b/test/ELF/invalid/sht-group-wrong-section.test
@@ -0,0 +1,22 @@
+# REQUIRES: x86
+# RUN: yaml2obj %s -o %t.o
+# RUN: not ld.lld %t.o %t.o -o %t.exe 2>&1 | FileCheck %s
+# CHECK: error: {{.*}}.o: invalid section index in group: 12345
+
+--- !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: 12345
+Symbols:
+ Global:
+ - Name: foo
diff --git a/test/ELF/invalid/sht-group.s b/test/ELF/invalid/sht-group.s
deleted file mode 100644
index a4b684c83fd3..000000000000
--- a/test/ELF/invalid/sht-group.s
+++ /dev/null
@@ -1,3 +0,0 @@
-## sht-group.elf contains SHT_GROUP section with invalid sh_info.
-# RUN: not ld.lld %p/Inputs/sht-group.elf -o /dev/null 2>&1 | FileCheck %s
-# CHECK: invalid symbol index
diff --git a/test/ELF/invalid/sht-group.test b/test/ELF/invalid/sht-group.test
new file mode 100644
index 000000000000..c91e649e2643
--- /dev/null
+++ b/test/ELF/invalid/sht-group.test
@@ -0,0 +1,18 @@
+# REQUIRES: x86
+# RUN: yaml2obj %s -o %t.o
+# RUN: not ld.lld %t.o -o %t.exe 2>&1 | FileCheck %s
+# CHECK: invalid symbol index
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .group
+ Type: SHT_GROUP
+ Link: .symtab
+ Info: 12345
+ Members:
+ - SectionOrType: GRP_COMDAT
diff --git a/test/ELF/invalid/undefined-local-symbol-in-dso.test b/test/ELF/invalid/undefined-local-symbol-in-dso.test
new file mode 100644
index 000000000000..a9c30f30db6f
--- /dev/null
+++ b/test/ELF/invalid/undefined-local-symbol-in-dso.test
@@ -0,0 +1,66 @@
+# REQUIRES: x86
+
+# LLD used to crash when linking against a DSO with an undefined STB_LOCAL
+# symbol in the global part of the dynamic symbol table (i.e. an STB_LOCAL
+# symbol with an index >= the sh_info of the dynamic symbol table section). Such
+# a DSO is very broken, because local symbols should precede all global symbols
+# in the symbol table, and because having a symbol that's both undefined and
+# STB_LOCAL is a nonsensical combination. Nevertheless, we should warn on such
+# input files instead of crashing.
+
+# We've found actual broken DSOs of this sort in the wild, but for this test, we
+# created a reduced broken input file. There are no tools capable of producing a
+# broken DSO of this nature, so instead we created a valid DSO with an undefined
+# global symbol in the dynamic symbol table and then manually edited the binary
+# to make that symbol local. The valid DSO was created as follows:
+
+```
+% cat undef.s
+.hidden bar
+bar:
+ movq foo@GOT, %rax
+
+% llvm-mc -triple=x86_64-linux-gnu -filetype=obj -o undef.o undef.s
+% ld.lld --no-rosegment -shared -o undefined-local-symbol-in-dso.so undef.o
+% strip undef.so
+```
+
+# (--no-rosegment and stripping are unnecessary; they just produce a smaller
+# binary)
+
+# This DSO should only have a single dynamic symbol table entry for foo, and
+# then we can use a small C program to modify that symbol table entry to be
+# STB_LOCAL instead of STB_GLOBAL.
+
+```
+#include <elf.h>
+#include <stdio.h>
+
+int main(int argc, char *argv[]) {
+ FILE *F = fopen(argv[1], "rb+");
+
+ Elf64_Ehdr Ehdr;
+ fread(&Ehdr, sizeof(Ehdr), 1, F);
+ fseek(F, Ehdr.e_shoff, SEEK_SET);
+
+ Elf64_Shdr Shdr;
+ do {
+ fread(&Shdr, sizeof(Shdr), 1, F);
+ } while (Shdr.sh_type != SHT_DYNSYM);
+
+ Elf64_Sym Sym;
+ fseek(F, Shdr.sh_offset + sizeof(Elf64_Sym), SEEK_SET);
+ fread(&Sym, sizeof(Sym), 1, F);
+ Sym.st_info = STB_LOCAL << 4 | ELF64_ST_TYPE(Sym.st_info);
+ fseek(F, Shdr.sh_offset + sizeof(Elf64_Sym), SEEK_SET);
+ fwrite(&Sym, sizeof(Sym), 1, F);
+ fclose(F);
+}
+```
+
+# (the C program just takes its input DSO and modifies the binding of the first
+# dynamic symbol table entry to be STB_LOCAL instead of STB_GLOBAL)
+
+# RUN: ld.lld %p/Inputs/undefined-local-symbol-in-dso.so -o %t 2>&1 | \
+# RUN: FileCheck -check-prefix=WARN %s
+# WARN: found local symbol 'foo' in global part of symbol table in file {{.*}}undefined-local-symbol-in-dso.so
diff --git a/test/ELF/lazy-arch-conflict.s b/test/ELF/lazy-arch-conflict.s
new file mode 100644
index 000000000000..e17c301798f1
--- /dev/null
+++ b/test/ELF/lazy-arch-conflict.s
@@ -0,0 +1,7 @@
+# REQUIRES: x86
+
+# RUN: echo '.globl foo; .weak foo; .quad foo;' | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %t64.o
+# RUN: echo '.globl foo; foo:' | llvm-mc -filetype=obj -triple=i686-pc-linux - -o %t32.o
+# RUN: not ld.lld %t64.o --start-lib %t32.o --end-lib -o /dev/null 2>&1 | FileCheck %s
+
+# CHECK: error: incompatible file: {{.*}}32.o
diff --git a/test/ELF/linkerscript/Inputs/at6.s b/test/ELF/linkerscript/Inputs/at6.s
new file mode 100644
index 000000000000..2d22d4d342dd
--- /dev/null
+++ b/test/ELF/linkerscript/Inputs/at6.s
@@ -0,0 +1,11 @@
+.global _start
+.text
+_start:
+nop
+
+.section .sec1,"aw",@progbits
+.long 1
+
+.section .sec2,"aw",@progbits
+.long 2
+
diff --git a/test/ELF/linkerscript/Inputs/at7.s b/test/ELF/linkerscript/Inputs/at7.s
new file mode 100644
index 000000000000..29d29635963b
--- /dev/null
+++ b/test/ELF/linkerscript/Inputs/at7.s
@@ -0,0 +1,7 @@
+.global _start
+.text
+_start:
+nop
+
+.section .sec, "aw"
+.word 4
diff --git a/test/ELF/linkerscript/Inputs/at8.s b/test/ELF/linkerscript/Inputs/at8.s
new file mode 100644
index 000000000000..e15e4cd3b77f
--- /dev/null
+++ b/test/ELF/linkerscript/Inputs/at8.s
@@ -0,0 +1,8 @@
+.section .sec1,"aw",@progbits
+.quad 1
+
+.section .sec2,"aw",@progbits
+.quad 2
+
+.section .sec3,"aw",@progbits
+.quad 3
diff --git a/test/ELF/linkerscript/align-r.test b/test/ELF/linkerscript/align-r.test
index 684ac1e92328..5bde8950974f 100644
--- a/test/ELF/linkerscript/align-r.test
+++ b/test/ELF/linkerscript/align-r.test
@@ -4,7 +4,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/align.s -o %t1.o
# RUN: ld.lld -r -o %t2.o --script %s %t1.o
-# RUN: llvm-readelf -s %t2.o | FileCheck %s
+# RUN: llvm-readelf -S %t2.o | FileCheck %s
# CHECK: Section Headers:
# CHECK-NEXT: Name Type Address Off Size ES Flg Lk Inf Al
diff --git a/test/ELF/linkerscript/align4.test b/test/ELF/linkerscript/align4.test
index 9440d60f6385..834e843da82b 100644
--- a/test/ELF/linkerscript/align4.test
+++ b/test/ELF/linkerscript/align4.test
@@ -4,7 +4,6 @@
# RUN: llvm-objdump -t %t | FileCheck %s
# CHECK-LABEL: SYMBOL TABLE:
-# CHECK-NEXT: 0000000000000000 *UND* 00000000
# CHECK-NEXT: 0000000000014008 .text 00000000 _start
# CHECK-NEXT: 0000000000010000 *ABS* 00000000 __code_base__
# CHECK-NEXT: 0000000000001000 *ABS* 00000000 VAR
diff --git a/test/ELF/linkerscript/at6.test b/test/ELF/linkerscript/at6.test
new file mode 100644
index 000000000000..498c0ef14f34
--- /dev/null
+++ b/test/ELF/linkerscript/at6.test
@@ -0,0 +1,30 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/at6.s -o %t.o
+# RUN: ld.lld %t.o --script %s -o %t
+# RUN: llvm-readelf -sections -program-headers %t | FileCheck %s
+
+MEMORY {
+ FLASH : ORIGIN = 0x08000000, LENGTH = 0x100
+ RAM : ORIGIN = 0x20000000, LENGTH = 0x200
+}
+
+SECTIONS {
+ .text : { *(.text) } > FLASH
+ .sec1 : { *(.sec1) } > RAM
+ .sec2 : { *(.sec2) } > RAM AT > FLASH
+}
+
+# Make sure we create a separate PT_LOAD entry for .sec2. Previously,
+# it was added to the PT_LOAD entry of .sec1
+
+# CHECK: Name Type Address Off
+# CHECK: .text PROGBITS 0000000008000000 001000
+# CHECK: .sec1 PROGBITS 0000000020000000 002000
+# CHECK: .sec2 PROGBITS 0000000020000004 002004
+
+# CHECK: Program Headers:
+# CHECK: Type Offset VirtAddr PhysAddr
+# CHECK-NEXT: LOAD 0x001000 0x0000000008000000 0x0000000008000000
+# CHECK-NEXT: LOAD 0x002000 0x0000000020000000 0x0000000020000000
+# CHECK-NEXT: LOAD 0x002004 0x0000000020000004 0x0000000008000001
+# CHECK-NOT: LOAD
diff --git a/test/ELF/linkerscript/at7.test b/test/ELF/linkerscript/at7.test
new file mode 100644
index 000000000000..1f67df29fdcd
--- /dev/null
+++ b/test/ELF/linkerscript/at7.test
@@ -0,0 +1,28 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/at7.s -o %t.o
+# RUN: ld.lld %t.o --script %s -o %t
+# RUN: llvm-readelf -sections -program-headers %t | FileCheck %s
+
+MEMORY {
+ RAM : ORIGIN = 0x20000000, LENGTH = 0x200
+}
+
+SECTIONS {
+ .text : { *(.text) } > RAM AT> RAM
+ .sec : { *(.sec) } > RAM
+}
+
+# Make sure the memory for the .text section is only reserved once.
+# Previously, the location counter for both MemRegion and LMARegion
+# was increased unconditionally.
+
+
+# CHECK: Name Type Address Off
+# CHECK: .text PROGBITS 0000000020000000 001000
+# CHECK: .sec PROGBITS 0000000020000001 001001
+
+# CHECK: Program Headers:
+# CHECK: Type Offset VirtAddr PhysAddr
+# CHECK-NEXT: LOAD 0x001000 0x0000000020000000 0x0000000020000000
+# CHECK-NEXT: LOAD 0x001001 0x0000000020000001 0x0000000020000001
+# CHECK-NOT: LOAD
diff --git a/test/ELF/linkerscript/at8.test b/test/ELF/linkerscript/at8.test
new file mode 100644
index 000000000000..48c0d4581422
--- /dev/null
+++ b/test/ELF/linkerscript/at8.test
@@ -0,0 +1,31 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/at8.s -o %t.o
+# RUN: ld.lld %t.o --script %s -o %t
+# RUN: llvm-readelf -sections -program-headers %t | FileCheck %s
+
+MEMORY {
+ FLASH : ORIGIN = 0x08000000, LENGTH = 0x100
+ RAM : ORIGIN = 0x20000000, LENGTH = 0x200
+}
+
+SECTIONS {
+ .text : { *(.text) } > FLASH
+ .sec1 : { *(.sec1) } > RAM AT > FLASH
+ .sec2 : { *(.sec2) } > RAM
+ .sec3 : { *(.sec3) } > RAM AT > FLASH
+}
+
+# Make sure we do not issue a load-address overlap error
+# Previously, .sec3 would overwrite the LMAOffset in the
+# PT_LOAD header.
+
+# CHECK: Name Type Address Off
+# CHECK: .text PROGBITS 0000000008000000 001000
+# CHECK: .sec1 PROGBITS 0000000020000000 001000
+# CHECK: .sec2 PROGBITS 0000000020000008 001008
+# CHECK: .sec3 PROGBITS 0000000020000010 001010
+
+# CHECK: Program Headers:
+# CHECK: Type Offset VirtAddr PhysAddr
+# CHECK-NEXT: LOAD 0x001000 0x0000000020000000 0x0000000008000000
+# CHECK-NOT: LOAD
diff --git a/test/ELF/linkerscript/discard-section-err.s b/test/ELF/linkerscript/discard-section-err.s
index f1d3b96691ba..bb77dbb087da 100644
--- a/test/ELF/linkerscript/discard-section-err.s
+++ b/test/ELF/linkerscript/discard-section-err.s
@@ -7,25 +7,17 @@
# RUN: FileCheck -check-prefix=SHSTRTAB %s
# SHSTRTAB: discarding .shstrtab section is not allowed
+## We allow discarding .dynamic, check we don't crash.
# RUN: echo "SECTIONS { /DISCARD/ : { *(.dynamic) } }" > %t.script
-# RUN: not ld.lld -pie -o %t --script %t.script %t.o 2>&1 | \
-# RUN: FileCheck -check-prefix=DYNAMIC %s
-# DYNAMIC: discarding .dynamic section is not allowed
+# RUN: ld.lld -pie -o %t --script %t.script %t.o
+## We allow discarding .dynsym, check we don't crash.
# RUN: echo "SECTIONS { /DISCARD/ : { *(.dynsym) } }" > %t.script
-# RUN: not ld.lld -pie -o %t --script %t.script %t.o 2>&1 | \
-# RUN: FileCheck -check-prefix=DYNSYM %s
-# DYNSYM: discarding .dynsym section is not allowed
+# RUN: ld.lld -pie -o %t --script %t.script %t.o
+## We allow discarding .dynstr, check we don't crash.
# RUN: echo "SECTIONS { /DISCARD/ : { *(.dynstr) } }" > %t.script
-# RUN: not ld.lld -pie -o %t --script %t.script %t.o 2>&1 | \
-# RUN: FileCheck -check-prefix=DYNSTR %s
-# DYNSTR: discarding .dynstr section is not allowed
-
-# RUN: echo "SECTIONS { /DISCARD/ : { *(.rela.plt) } }" > %t.script
-# RUN: not ld.lld -pie -o %t --script %t.script %t.o 2>&1 | \
-# RUN: FileCheck -check-prefix=RELAPLT %s
-# RELAPLT: discarding .rela.plt section is not allowed
+# RUN: ld.lld -pie -o %t --script %t.script %t.o
# RUN: echo "SECTIONS { /DISCARD/ : { *(.rela.dyn) } }" > %t.script
# RUN: not ld.lld -pie -o %t --script %t.script %t.o 2>&1 | \
diff --git a/test/ELF/linkerscript/filename-spec.s b/test/ELF/linkerscript/filename-spec.s
index 66fd4178387c..8a1f6605e2a9 100644
--- a/test/ELF/linkerscript/filename-spec.s
+++ b/test/ELF/linkerscript/filename-spec.s
@@ -43,6 +43,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.testdir1/filename-spec1.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
# RUN: %p/Inputs/filename-spec.s -o %t.testdir2/filename-spec2.o
+# RUN: rm -f %t.testdir1/lib1.a %t.testdir2/lib2.a
# RUN: llvm-ar rsc %t.testdir1/lib1.a %t.testdir1/filename-spec1.o
# RUN: llvm-ar rsc %t.testdir2/lib2.a %t.testdir2/filename-spec2.o
diff --git a/test/ELF/linkerscript/icf.s b/test/ELF/linkerscript/icf.s
new file mode 100644
index 000000000000..7c74458232aa
--- /dev/null
+++ b/test/ELF/linkerscript/icf.s
@@ -0,0 +1,11 @@
+# REQUIRES: x86
+
+# RUN: echo "foo = 1; bar = 2;" > %t.script
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld %t.o %t.script -o %t --icf=all --print-icf-sections | count 0
+
+.section .text.foo,"ax",@progbits
+jmp foo
+
+.section .text.bar,"ax",@progbits
+jmp bar
diff --git a/test/ELF/linkerscript/info-section-type.s b/test/ELF/linkerscript/info-section-type.s
index b718e828ab7d..16e663fc5d0f 100644
--- a/test/ELF/linkerscript/info-section-type.s
+++ b/test/ELF/linkerscript/info-section-type.s
@@ -29,5 +29,14 @@
# RUN: ld.lld -o %t --script %t.script %t.o
# RUN: llvm-readobj -sections %t | FileCheck %s --check-prefix=NONALLOC
+# RUN: echo "SECTIONS { .bar 0x20000 (INFO) : { *(.foo) } };" > %t.script
+# RUN: ld.lld -o %t --script %t.script %t.o
+# RUN: llvm-readobj -sections %t | FileCheck %s --check-prefix=NONALLOC
+
+# RUN: echo "SECTIONS { .bar 0x20000 (BAR) : { *(.foo) } };" > %t.script
+# RUN: not ld.lld -o %t --script %t.script %t.o 2>&1 |\
+# RUN: FileCheck %s --check-prefix=UNKNOWN
+# UNKNOWN: unknown section directive: BAR
+
.section .foo,"a",@progbits
.zero 1
diff --git a/test/ELF/linkerscript/lazy-symbols.test b/test/ELF/linkerscript/lazy-symbols.test
index 579df9323865..f409b839c4dd 100644
--- a/test/ELF/linkerscript/lazy-symbols.test
+++ b/test/ELF/linkerscript/lazy-symbols.test
@@ -1,5 +1,6 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/lazy-symbols.s -o %t1
+# RUN: rm -f %tar
# RUN: llvm-ar rcs %tar %t1
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux /dev/null -o %t2
# RUN: ld.lld %t2 %tar --script %s -o %tout
diff --git a/test/ELF/linkerscript/map-file.test b/test/ELF/linkerscript/map-file.test
index 540b8d494887..6ec8bafc42b1 100644
--- a/test/ELF/linkerscript/map-file.test
+++ b/test/ELF/linkerscript/map-file.test
@@ -44,10 +44,10 @@ SECTIONS {
# CHECK-NEXT: 2017 2017 246 1 . += 0x123 * ( 1 + 1 )
# CHECK-NEXT: 225d 225d 0 1 foo = .
# CHECK-NEXT: 225d 225d 0 1 bar = 0x42 - 0x26
-# CHECK-NEXT: 225d 0 0 1 sym1 = .
-# CHECK-NEXT: 225d 0 500 1 . += 0x500
-# CHECK-NEXT: 275d 0 0 1 sym2 = .
-# CHECK-NEXT: 275d 0 0 1 PROVIDE ( sym3 = 42 )
+# CHECK-NEXT: 225d 225d 0 1 sym1 = .
+# CHECK-NEXT: 225d 225d 500 1 . += 0x500
+# CHECK-NEXT: 275d 275d 0 1 sym2 = .
+# CHECK-NEXT: 275d 275d 0 1 PROVIDE ( sym3 = 42 )
# CHECK-NEXT: 2760 2760 10 4 .text
# CHECK-NEXT: 2760 2760 10 4 {{.*}}{{/|\\}}map-file.test.tmp.o:(.text)
# CHECK-NEXT: 0 0 8 1 .comment
diff --git a/test/ELF/linkerscript/map-file2.test b/test/ELF/linkerscript/map-file2.test
index d9ed339e228d..535043282249 100644
--- a/test/ELF/linkerscript/map-file2.test
+++ b/test/ELF/linkerscript/map-file2.test
@@ -8,6 +8,7 @@ SECTIONS {
.aaa : { *(.aaa.*) }
.bbb : AT(0x2000) { *(.bbb.*) }
.ccc : AT(0x3000) { *(.ccc.*) }
+ . += 0x100;
.ddd : {
BYTE(0x11)
. += 0x100;
@@ -24,16 +25,17 @@ SECTIONS {
# CHECK-NEXT: 1008 2000 8 1 {{.*}}{{/|\\}}map-file2.test.tmp.o:(.bbb)
# CHECK-NEXT: 1010 3000 8 1 .ccc
# CHECK-NEXT: 1010 3000 8 1 {{.*}}{{/|\\}}map-file2.test.tmp.o:(.ccc)
-# CHECK-NEXT: 1018 3008 109 1 .ddd
-# CHECK-NEXT: 1018 3008 1 1 BYTE ( 0x11 )
-# CHECK-NEXT: 1019 3009 100 1 . += 0x100
-# CHECK-NEXT: 1119 3109 8 1 {{.*}}{{/|\\}}map-file2.test.tmp.o:(.ddd)
-# CHECK-NEXT: 1128 3118 34 8 .eh_frame
-# CHECK-NEXT: 1128 3118 30 1 {{.*}}{{/|\\}}map-file2.test.tmp.o:(.eh_frame+0x0)
-# CHECK-NEXT: 115c 314c 1 4 .text
-# CHECK-NEXT: 115c 314c 1 4 {{.*}}{{/|\\}}map-file2.test.tmp.o:(.text)
-# CHECK-NEXT: 115c 314c 0 1 f(int)
-# CHECK-NEXT: 115c 314c 0 1 _start
+# CHECK-NEXT: 1018 3008 100 1 . += 0x100
+# CHECK-NEXT: 1118 3108 109 1 .ddd
+# CHECK-NEXT: 1118 3108 1 1 BYTE ( 0x11 )
+# CHECK-NEXT: 1119 3109 100 1 . += 0x100
+# CHECK-NEXT: 1219 3209 8 1 {{.*}}{{/|\\}}map-file2.test.tmp.o:(.ddd)
+# CHECK-NEXT: 1228 3218 34 8 .eh_frame
+# CHECK-NEXT: 1228 3218 30 1 {{.*}}{{/|\\}}map-file2.test.tmp.o:(.eh_frame+0x0)
+# CHECK-NEXT: 125c 324c 1 4 .text
+# CHECK-NEXT: 125c 324c 1 4 {{.*}}{{/|\\}}map-file2.test.tmp.o:(.text)
+# CHECK-NEXT: 125c 324c 0 1 f(int)
+# CHECK-NEXT: 125c 324c 0 1 _start
# CHECK-NEXT: 0 0 8 1 .comment
# CHECK-NEXT: 0 0 8 1 <internal>:(.comment)
# CHECK-NEXT: 0 0 48 8 .symtab
diff --git a/test/ELF/linkerscript/memory-include.test b/test/ELF/linkerscript/memory-include.test
new file mode 100644
index 000000000000..340328225bde
--- /dev/null
+++ b/test/ELF/linkerscript/memory-include.test
@@ -0,0 +1,23 @@
+# REQUIRES: x86
+
+# RUN: echo '.section .text,"ax"; .global _start; nop' > %t.s
+# RUN: echo '.section .data,"aw"; .quad 0' >> %t.s
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t.s -o %t.o
+
+# RUN: echo "RAM2 (rwx): ORIGIN = 0x3000, LENGTH = 0x100" > %t.inc
+# RUN: ld.lld -o %t.elf --script %s %t.o -L %T
+# RUN: llvm-objdump -section-headers %t.elf | FileCheck %s
+# CHECK: .data 00000008 0000000000002000 DATA
+# CHECK: .data2 00000008 0000000000003000 DATA
+
+MEMORY {
+ ROM (rwx): ORIGIN = 0x1000, LENGTH = 0x100
+ RAM (rwx): ORIGIN = 0x2000, LENGTH = 0x100
+ INCLUDE "memory-include.test.tmp.inc"
+}
+
+SECTIONS {
+ .text : { *(.text*) } > ROM
+ .data : { *(.data*) } > RAM
+ .data2 : { QUAD(0) } > RAM2
+}
diff --git a/test/ELF/linkerscript/merge-nonalloc.s b/test/ELF/linkerscript/merge-nonalloc.s
new file mode 100644
index 000000000000..7c48d3bc6cd0
--- /dev/null
+++ b/test/ELF/linkerscript/merge-nonalloc.s
@@ -0,0 +1,14 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: echo "SECTIONS { .text : { *(.text) *(.nonalloc) } }" > %t.script
+# RUN: ld.lld -shared -o %t.exe %t.script %t.o
+# RUN: llvm-objdump -syms %t.exe | FileCheck %s
+
+# CHECK: .text 00000000 nonalloc_start
+
+_start:
+ nop
+
+.section .nonalloc,"",@progbits
+nonalloc_start:
+ .long 0xcafe
diff --git a/test/ELF/linkerscript/no-filename-spec.s b/test/ELF/linkerscript/no-filename-spec.s
new file mode 100644
index 000000000000..aec03958da7d
--- /dev/null
+++ b/test/ELF/linkerscript/no-filename-spec.s
@@ -0,0 +1,17 @@
+# REQUIRES: x86
+# RUN: echo '.section .bar, "a"; .quad 1;' | \
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %tfile1.o
+# RUN: echo '.section .zed, "a"; .quad 2;' | \
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %tfile2.o
+
+## We have a file name and no input sections description. In that case, all
+## sections from the file specified should be included. Check that.
+# RUN: ld.lld -o %t --script %s %tfile1.o %tfile2.o
+# RUN: llvm-objdump -s %t | FileCheck %s
+
+# CHECK: Contents of section .foo:
+# CHECK-NEXT: 01000000 00000000 02000000 00000000
+
+SECTIONS {
+ .foo : { *file1.o *file2.o }
+}
diff --git a/test/ELF/linkerscript/non-alloc-segment.s b/test/ELF/linkerscript/non-alloc-segment.s
index d9984b3867d4..143cac1e2b12 100644
--- a/test/ELF/linkerscript/non-alloc-segment.s
+++ b/test/ELF/linkerscript/non-alloc-segment.s
@@ -16,7 +16,7 @@
# RUN: .foo : {*(.foo)} :foo \
# RUN: }" > %t.script
# RUN: ld.lld -o %t --script %t.script %t.o
-# RUN: llvm-readelf -s -l %t | FileCheck %s
+# RUN: llvm-readelf -S -l %t | FileCheck %s
# RUN: llvm-readobj -l %t | FileCheck --check-prefix=PHDR %s
# CHECK: Program Headers:
diff --git a/test/ELF/linkerscript/non-alloc.s b/test/ELF/linkerscript/non-alloc.s
index 87f9afff8091..e6fb84d17d41 100644
--- a/test/ELF/linkerscript/non-alloc.s
+++ b/test/ELF/linkerscript/non-alloc.s
@@ -3,7 +3,7 @@
# RUN: echo "SECTIONS { .foo 0 : {*(foo)} }" > %t.script
# RUN: ld.lld --hash-style=sysv -o %t --script %t.script %t.o -shared
-# RUN: llvm-readelf -s -l %t | FileCheck %s
+# RUN: llvm-readelf -S -l %t | FileCheck %s
# Test that we create all necessary PT_LOAD. We use to stop at the first
# non-alloc, causing us to not create PT_LOAD for linker generated sections.
diff --git a/test/ELF/linkerscript/orphan-discard.s b/test/ELF/linkerscript/orphan-discard.s
index 6fd6fafcd7f4..4549c3bc2b9e 100644
--- a/test/ELF/linkerscript/orphan-discard.s
+++ b/test/ELF/linkerscript/orphan-discard.s
@@ -10,7 +10,7 @@
# RUN: /DISCARD/ : { *(.comment) } \
# RUN: }" > %t.script
# RUN: ld.lld -o %t --script %t.script %t.o
-# RUN: llvm-readelf -s -symbols %t | FileCheck %s
+# RUN: llvm-readelf -S -symbols %t | FileCheck %s
# CHECK: .bss NOBITS ffffffff80002000 002008 000002 00 WA 0 0 4096
# CHECK: ffffffff80003000 0 NOTYPE GLOBAL DEFAULT 3 _end
diff --git a/test/ELF/linkerscript/orphan-phdrs.s b/test/ELF/linkerscript/orphan-phdrs.s
index f9d1467b532a..c889562d0fcc 100644
--- a/test/ELF/linkerscript/orphan-phdrs.s
+++ b/test/ELF/linkerscript/orphan-phdrs.s
@@ -10,7 +10,7 @@
# RUN: .rw : { *(.rw) } \
# RUN: }" > %t.script
# RUN: ld.lld -o %t --script %t.script %t.o
-# RUN: llvm-readelf -s -l %t | FileCheck %s
+# RUN: llvm-readelf -S -l %t | FileCheck %s
## Check that the orphan section is placed correctly and belongs to
## the correct segment.
diff --git a/test/ELF/linkerscript/ouputformat.s b/test/ELF/linkerscript/ouputformat.s
deleted file mode 100644
index 7d4402a557a0..000000000000
--- a/test/ELF/linkerscript/ouputformat.s
+++ /dev/null
@@ -1,9 +0,0 @@
-# REQUIRES: x86
-# RUN: echo "OUTPUT_FORMAT(x, y, z)" > %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_FORMAT(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
diff --git a/test/ELF/linkerscript/output-section-include.test b/test/ELF/linkerscript/output-section-include.test
new file mode 100644
index 000000000000..b18a7ee037a3
--- /dev/null
+++ b/test/ELF/linkerscript/output-section-include.test
@@ -0,0 +1,30 @@
+# REQUIRES: x86
+
+# RUN: echo '.section .text,"ax"; .global _start; nop' > %t.s
+# RUN: echo '.section .data,"aw"; .quad 0' >> %t.s
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t.s -o %t.o
+
+## Empty include file.
+# RUN: echo "" > %t.inc
+# RUN: ld.lld -o %t.elf --script %s %t.o -L %T
+# RUN: llvm-objdump -section-headers %t.elf | FileCheck %s --check-prefix=CHECK1
+# CHECK1: .data 00000008 0000000000002000 DATA
+
+## Non-empty include file.
+# RUN: echo "QUAD(0)" > %t.inc
+# RUN: ld.lld -o %t.elf --script %s %t.o -L %T
+# RUN: llvm-objdump -section-headers %t.elf | FileCheck %s --check-prefix=CHECK2
+# CHECK2: .data 00000010 0000000000002000 DATA
+
+MEMORY {
+ ROM (rwx): ORIGIN = 0x1000, LENGTH = 0x100
+ RAM (rwx): ORIGIN = 0x2000, LENGTH = 0x100
+}
+
+SECTIONS {
+ .text : { *(.text*) } > ROM
+ .data : {
+ *(.data*)
+ INCLUDE "output-section-include.test.tmp.inc"
+ } > RAM
+}
diff --git a/test/ELF/linkerscript/output-too-large.s b/test/ELF/linkerscript/output-too-large.s
index ca85465036fe..a5130d27a070 100644
--- a/test/ELF/linkerscript/output-too-large.s
+++ b/test/ELF/linkerscript/output-too-large.s
@@ -1,7 +1,13 @@
# REQUIRES: x86
+
# 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 --no-check-sections --script %t.script %t.o -o /dev/null 2>&1 | FileCheck %s
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: echo "SECTIONS { .text : { . = 0x8fffffffffffffff; *(.text*); } }" > %t.script
+# RUN: not ld.lld --no-check-sections --script %t.script %t.o -o /dev/null 2>&1 | FileCheck %s
+
# CHECK: error: output file too large
.global _start
diff --git a/test/ELF/linkerscript/phdrs.s b/test/ELF/linkerscript/phdrs.s
index b65015994533..c688bef5282c 100644
--- a/test/ELF/linkerscript/phdrs.s
+++ b/test/ELF/linkerscript/phdrs.s
@@ -130,6 +130,14 @@
# BADHDR: {{.*}}.script:1: section header 'bar' is not listed in PHDRS
+# RUN: echo "PHDRS { text PT_LOAD FOOHDR; }" > %t1.script
+# RUN: not ld.lld -o /dev/null --script %t1.script %t 2>&1 | FileCheck --check-prefix=FOOHDR %s
+# FOOHDR: error: {{.*}}.script:1: unexpected header attribute: FOOHDR
+
+# RUN: echo "PHDRS { text PT_FOO FOOHDR; }" > %t1.script
+# RUN: not ld.lld -o /dev/null --script %t1.script %t 2>&1 | FileCheck --check-prefix=PTFOO %s
+# PTFOO: invalid program header type: PT_FOO
+
.global _start
_start:
nop
diff --git a/test/ELF/linkerscript/provide-shared2.s b/test/ELF/linkerscript/provide-shared2.s
index 8a3200b6f545..1a7b213d8e54 100644
--- a/test/ELF/linkerscript/provide-shared2.s
+++ b/test/ELF/linkerscript/provide-shared2.s
@@ -6,7 +6,7 @@
# RUN: ld.lld -o %t --script %t.script %t.o %t2.so
# RUN: llvm-readelf --dyn-symbols %t | FileCheck %s
-# CHECK: 1 1: 000000000000002a 0 NOTYPE GLOBAL DEFAULT ABS foo@
+# CHECK: 1 1: 000000000000002a 0 NOTYPE GLOBAL DEFAULT ABS foo
.global _start
_start:
diff --git a/test/ELF/linkerscript/relocatable-discard.s b/test/ELF/linkerscript/relocatable-discard.s
new file mode 100644
index 000000000000..d4f5826b72d9
--- /dev/null
+++ b/test/ELF/linkerscript/relocatable-discard.s
@@ -0,0 +1,21 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: echo "SECTIONS { /DISCARD/ : { *(.discard.*) }}" > %t.script
+# RUN: ld.lld -o %t --script %t.script -r %t.o
+# RUN: llvm-readobj -sections %t | FileCheck %s
+
+## Test shows that we do not crash after discarding the .discard.foo with -r.
+## Previously it happened because of 2 reasons:
+## 1) .rela.discard.foo was not handled properly and was not discarded.
+## Remaining reference was invalid and caused the crash.
+## 2) Third-party section .debug_info referencing discarded section
+## did not handle this case properly and tried to apply the
+## relocation instead of ignoring it.
+
+# CHECK-NOT: .discard
+
+.section .discard.foo,"ax"
+callq fn@PLT
+
+.section .debug_info,"",@progbits
+.long .discard.foo
diff --git a/test/ELF/linkerscript/section-include.test b/test/ELF/linkerscript/section-include.test
new file mode 100644
index 000000000000..9b6dfa0dcc4e
--- /dev/null
+++ b/test/ELF/linkerscript/section-include.test
@@ -0,0 +1,32 @@
+# REQUIRES: x86
+
+# RUN: echo '.section .text,"ax"; .global _start; nop' > %t.s
+# RUN: echo '.section .data,"aw"; .quad 0' >> %t.s
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t.s -o %t.o
+
+## Empty include file.
+# RUN: echo "" > %t.inc
+# RUN: ld.lld -o %t.elf --script %s %t.o -L %T
+# RUN: llvm-objdump -section-headers %t.elf | FileCheck %s --check-prefix=CHECK1
+# CHECK1: .data 00000008 0000000000002000 DATA
+# CHECK1-NEXT: .data3 00000008 0000000000002008 DATA
+
+## Non-empty include file.
+# RUN: echo ".data2 : { QUAD(0) } > RAM" > %t.inc
+# RUN: ld.lld -o %t.elf --script %s %t.o -L %T
+# RUN: llvm-objdump -section-headers %t.elf | FileCheck %s --check-prefix=CHECK2
+# CHECK2: .data 00000008 0000000000002000 DATA
+# CHECK2-NEXT: .data2 00000008 0000000000002008 DATA
+# CHECK2-NEXT: .data3 00000008 0000000000002010 DATA
+
+MEMORY {
+ ROM (rwx): ORIGIN = 0x1000, LENGTH = 0x100
+ RAM (rwx): ORIGIN = 0x2000, LENGTH = 0x100
+}
+
+SECTIONS {
+ .text : { *(.text*) } > ROM
+ .data : { *(.data*) } > RAM
+ INCLUDE "section-include.test.tmp.inc"
+ .data3 : { QUAD(0) } > RAM
+}
diff --git a/test/ELF/linkerscript/sections-va-overflow.test b/test/ELF/linkerscript/sections-va-overflow.test
index 7ede6ecc3de8..142d2e5ef2d7 100644
--- a/test/ELF/linkerscript/sections-va-overflow.test
+++ b/test/ELF/linkerscript/sections-va-overflow.test
@@ -7,7 +7,7 @@ PHDRS {
ph_text PT_LOAD FILEHDR PHDRS FLAGS (0x1 | 0x4);
}
-SECTIONS {
+SECTIONS {
. = 0xffffffff20000000;
.text : { *(.text*) } : ph_text
.test 0x1000 : { BYTE(0) }
@@ -18,5 +18,5 @@ SECTIONS {
## with VA 0xffffffff20000000. That might be technically correct, but most probably
## is a result of a broken script file and causes file offset calculation overflow.
## It seems we do not have to support it, so we don't and we report an error in this case.
-# ERR: error: unable to place section .text at file offset [0xFFFFFFFF20000000, 0xFFFFFFFE40000000]; check your linker script for overflows
+# ERR: error: unable to place section .text at file offset [0xFFFFFFFF20000000, 0xFFFFFFFF20000000]; check your linker script for overflows
# ERR-NOT: unable to place section .bss
diff --git a/test/ELF/linkerscript/segment-none.s b/test/ELF/linkerscript/segment-none.s
index 06566525caf7..36d09e776478 100644
--- a/test/ELF/linkerscript/segment-none.s
+++ b/test/ELF/linkerscript/segment-none.s
@@ -9,7 +9,7 @@
# RUN: .foo : {*(.foo)} :NONE \
# RUN: }" > %t.script
# RUN: ld.lld -o %t --script %t.script %t.o
-# RUN: llvm-readelf -s -l %t | FileCheck %s
+# RUN: llvm-readelf -S -l %t | FileCheck %s
## Test that section .foo is placed in segment NONE when assigned to segment
## NONE in the linker script and segment NONE is defined.
@@ -19,7 +19,7 @@
# RUN: .foo : {*(.foo)} :NONE \
# RUN: }" > %t.script
# RUN: ld.lld -o %t --script %t.script %t.o
-# RUN: llvm-readelf -s -l %t | FileCheck --check-prefix=DEFINED %s
+# RUN: llvm-readelf -S -l %t | FileCheck --check-prefix=DEFINED %s
# CHECK: Section to Segment mapping:
# CHECK-NEXT: Segment Sections...
diff --git a/test/ELF/linkerscript/sizeof.s b/test/ELF/linkerscript/sizeof.s
index 4618f79d3db6..0d7106fc8956 100644
--- a/test/ELF/linkerscript/sizeof.s
+++ b/test/ELF/linkerscript/sizeof.s
@@ -18,7 +18,6 @@
# CHECK-NEXT: 2 .bbb 00000010
# CHECK-NEXT: 3 .ccc 00000018
# CHECK: SYMBOL TABLE:
-# CHECK-NEXT: 0000000000000000 *UND* 00000000
# CHECK-NEXT: .text 00000000 _start
# CHECK-NEXT: 0000000000000008 *ABS* 00000000 _aaa
# CHECK-NEXT: 0000000000000010 *ABS* 00000000 _bbb
diff --git a/test/ELF/linkerscript/sizeofheaders.s b/test/ELF/linkerscript/sizeofheaders.s
index 3cc70747280c..6a82442bc938 100644
--- a/test/ELF/linkerscript/sizeofheaders.s
+++ b/test/ELF/linkerscript/sizeofheaders.s
@@ -9,7 +9,6 @@
# RUN: llvm-objdump -t %t1 | FileCheck %s
#CHECK: SYMBOL TABLE:
-#CHECK-NEXT: 0000000000000000 *UND* 00000000
#CHECK-NEXT: 00000000000000e8 .text 00000000 _start
#CHECK-NEXT: 00000000000000e8 *ABS* 00000000 _size
diff --git a/test/ELF/linkerscript/sort-init.s b/test/ELF/linkerscript/sort-init.s
index 894b8ae882b7..dd030ace2efb 100644
--- a/test/ELF/linkerscript/sort-init.s
+++ b/test/ELF/linkerscript/sort-init.s
@@ -1,16 +1,18 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
-# RUN: echo "SECTIONS { .init_array : { *(SORT_BY_INIT_PRIORITY(.init_array.*)) } }" > %t1.script
+# RUN: echo "SECTIONS { .init_array : { *(SORT_BY_INIT_PRIORITY(.init_array.* foo*)) } }" > %t1.script
# RUN: ld.lld --script %t1.script %t1.o -o %t2
# RUN: llvm-objdump -s %t2 | FileCheck %s
# CHECK: Contents of section .init_array:
-# CHECK-NEXT: 03020000 00000000 010405
+# CHECK-NEXT: 03020000 00060000 010405
.globl _start
_start:
nop
+.section foo, "aw", @init_array
+ .byte 6
.section .init_array, "aw", @init_array
.align 8
.byte 1
diff --git a/test/ELF/linkerscript/sort-non-script.s b/test/ELF/linkerscript/sort-non-script.s
index 2477c835e134..7207e90d4d76 100644
--- a/test/ELF/linkerscript/sort-non-script.s
+++ b/test/ELF/linkerscript/sort-non-script.s
@@ -3,7 +3,7 @@
# RUN: echo "SECTIONS { foo : {*(foo)} }" > %t.script
# RUN: ld.lld --hash-style=sysv -o %t --script %t.script %t.o -shared
-# RUN: llvm-readelf -s %t | FileCheck %s
+# RUN: llvm-readelf -S %t | FileCheck %s
# CHECK: .dynsym {{.*}} A
# CHECK-NEXT: .hash {{.*}} A
diff --git a/test/ELF/linkerscript/symbol-assignexpr.s b/test/ELF/linkerscript/symbol-assignexpr.s
index 3be7d05931fe..56e0827caf11 100644
--- a/test/ELF/linkerscript/symbol-assignexpr.s
+++ b/test/ELF/linkerscript/symbol-assignexpr.s
@@ -25,7 +25,6 @@
# RUN: llvm-objdump -t %t1 | FileCheck %s
# CHECK: SYMBOL TABLE:
-# CHECK-NEXT: 0000000000000000 *UND* 00000000
# CHECK-NEXT: 0000000000000000 .text 00000000 _start
# CHECK-NEXT: 0000000000005678 *ABS* 00000000 bar
# CHECK-NEXT: 0000000000009abc *ABS* 00000000 baz
diff --git a/test/ELF/linkerscript/symbol-location.s b/test/ELF/linkerscript/symbol-location.s
new file mode 100644
index 000000000000..323d237e1533
--- /dev/null
+++ b/test/ELF/linkerscript/symbol-location.s
@@ -0,0 +1,15 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: echo "foo = 1;" > %t.script
+# RUN: not ld.lld -pie -o %t --script %t.script %t.o 2>&1 | FileCheck %s
+
+## Here we check that symbol 'foo' location is reported properly.
+
+# CHECK: error: relocation R_X86_64_PLT32 cannot refer to absolute symbol: foo
+# CHECK: >>> defined in {{.*}}.script:1
+# CHECK: >>> referenced by {{.*}}.o:(.text+0x1)
+
+.text
+.globl _start
+_start:
+ call foo@PLT
diff --git a/test/ELF/linkerscript/symbol-memoryexpr.s b/test/ELF/linkerscript/symbol-memoryexpr.s
index cdd821dc585a..9214ba83ea51 100644
--- a/test/ELF/linkerscript/symbol-memoryexpr.s
+++ b/test/ELF/linkerscript/symbol-memoryexpr.s
@@ -13,7 +13,6 @@
# RUN: llvm-objdump -t %t1 | FileCheck %s
# CHECK: SYMBOL TABLE:
-# CHECK-NEXT: 0000000000000000 *UND* 00000000
# CHECK-NEXT: 0000000000008000 .text 00000000 _start
# CHECK-NEXT: 0000000000008000 *ABS* 00000000 origin
# CHECK-NEXT: 0000000000040000 *ABS* 00000000 length
diff --git a/test/ELF/linkerscript/target.s b/test/ELF/linkerscript/target.s
new file mode 100644
index 000000000000..32db5b7866c2
--- /dev/null
+++ b/test/ELF/linkerscript/target.s
@@ -0,0 +1,18 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: echo "TARGET(binary) INPUT(\"%t.o\") TARGET(elf64-x86-64) INPUT(\"%t.o\")" > %t.script
+# RUN: ld.lld --script %t.script -o %t.exe
+# RUN: llvm-readelf -symbols %t.exe | FileCheck %s
+
+# CHECK: _binary_
+# CHECK: foobar
+
+# RUN: echo "TARGET(foo)" > %t2.script
+# RUN: not ld.lld --script %t2.script -o /dev/null 2>&1 | FileCheck -check-prefix=ERR %s
+
+# ERR: unknown target: foo
+
+.global foobar
+foobar:
+ nop
diff --git a/test/ELF/linkerscript/unused-synthetic.s b/test/ELF/linkerscript/unused-synthetic.s
index 6ddbf505ccbb..de494fa4975f 100644
--- a/test/ELF/linkerscript/unused-synthetic.s
+++ b/test/ELF/linkerscript/unused-synthetic.s
@@ -7,7 +7,7 @@
# RUN: }" > %t.script
# RUN: ld.lld -shared -o %t.so --script %t.script %t.o
-# RUN: llvm-readelf -s %t.so | FileCheck %s
+# RUN: llvm-readelf -S %t.so | FileCheck %s
# CHECK-NOT: .got
# CHECK-NOT: .plt
# CHECK: .dynsym
diff --git a/test/ELF/linkerscript/version-script.s b/test/ELF/linkerscript/version-script.s
index df666e1b39ea..67a0fd68ca7c 100644
--- a/test/ELF/linkerscript/version-script.s
+++ b/test/ELF/linkerscript/version-script.s
@@ -14,11 +14,11 @@
# CHECK: Symbols [
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Version: 0
-# CHECK-NEXT: Name: @
+# CHECK-NEXT: Name:
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Version: 0
-# CHECK-NEXT: Name: und@
+# CHECK-NEXT: Name: und
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Version: 2
@@ -41,7 +41,7 @@
# UNDEF: Symbols [
# UNDEF-NEXT: Symbol {
# UNDEF-NEXT: Version: 0
-# UNDEF-NEXT: Name: @
+# UNDEF-NEXT: Name:
# UNDEF-NEXT: }
# UNDEF-NEXT: Symbol {
# UNDEF-NEXT: Version: 2
diff --git a/test/ELF/local-dynamic.s b/test/ELF/local-dynamic.s
index c122074fd7d9..0adad2bf41d9 100644
--- a/test/ELF/local-dynamic.s
+++ b/test/ELF/local-dynamic.s
@@ -65,7 +65,7 @@
// CHECK: DynamicSymbols [
// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: @
+// CHECK-NEXT: Name:
// CHECK-NEXT: Value: 0x0
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local
@@ -74,7 +74,7 @@
// CHECK-NEXT: Section: Undefined
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: _start@
+// CHECK-NEXT: Name: _start
// CHECK-NEXT: Value:
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
diff --git a/test/ELF/local-ver-preemptible.s b/test/ELF/local-ver-preemptible.s
new file mode 100644
index 000000000000..80d78c4a8d86
--- /dev/null
+++ b/test/ELF/local-ver-preemptible.s
@@ -0,0 +1,22 @@
+# REQUIRES: x86
+# RUN: echo '.global foo; .type foo, @function; foo:' | \
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %t.so.o
+# RUN: ld.lld %t.so.o -o %t.so -shared
+
+# RUN: echo "{ global: main; local: *; };" > %t.script
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: ld.lld %t.o %t.so -o %t -version-script %t.script
+# RUN: llvm-readelf -r --symbols %t | FileCheck %s
+
+# CHECK: Relocation section '.rela.plt' at offset {{.*}} contains 1 entries:
+# CHECK: R_X86_64_JUMP_SLOT 0000000000201020 foo + 0
+
+# CHECK: Symbol table '.dynsym' contains 2 entries:
+# CHECK-NEXT: Num: Value Size Type Bind Vis Ndx Name
+# CHECK-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
+# CHECK-NEXT: 1: 0000000000201020 0 FUNC GLOBAL DEFAULT UND foo
+
+.globl _start
+_start:
+ movl $foo - ., %eax
diff --git a/test/ELF/lto-plugin-ignore.s b/test/ELF/lto-plugin-ignore.s
index 65230f1567e7..0370d458626b 100644
--- a/test/ELF/lto-plugin-ignore.s
+++ b/test/ELF/lto-plugin-ignore.s
@@ -6,5 +6,5 @@
# RUN: -plugin-opt=-data-sections -plugin-opt=thinlto -o /dev/null
# RUN: not ld.lld %t -plugin-opt=-abc -plugin-opt=-xyz 2>&1 | FileCheck %s
-# CHECK: error: --plugin-opt: ld.lld{{.*}}: Unknown command line argument '-abc'
-# CHECK: error: --plugin-opt: ld.lld{{.*}}: Unknown command line argument '-xyz'
+# CHECK: ld.lld: error: --plugin-opt: ld.lld{{.*}}: Unknown command line argument '-abc'
+# CHECK: ld.lld: error: --plugin-opt: ld.lld{{.*}}: Unknown command line argument '-xyz'
diff --git a/test/ELF/lto/Inputs/libcall-archive.s b/test/ELF/lto/Inputs/libcall-archive.s
new file mode 100644
index 000000000000..6ca6e5fa821e
--- /dev/null
+++ b/test/ELF/lto/Inputs/libcall-archive.s
@@ -0,0 +1,2 @@
+.globl __sync_val_compare_and_swap_8
+__sync_val_compare_and_swap_8:
diff --git a/test/ELF/lto/amdgcn.ll b/test/ELF/lto/amdgcn.ll
new file mode 100644
index 000000000000..4281e209fd97
--- /dev/null
+++ b/test/ELF/lto/amdgcn.ll
@@ -0,0 +1,12 @@
+; REQUIRES: amdgpu
+; RUN: llvm-as %s -o %t.o
+; RUN: ld.lld %t.o -o %t
+
+; Make sure the amdgcn triple is handled
+
+target triple = "amdgcn-amd-amdhsa"
+target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
+
+define void @_start() {
+ ret void
+}
diff --git a/test/ELF/lto/cache.ll b/test/ELF/lto/cache.ll
index 3f2bea9f2cdf..fe123989f22d 100644
--- a/test/ELF/lto/cache.ll
+++ b/test/ELF/lto/cache.ll
@@ -1,4 +1,6 @@
; REQUIRES: x86
+; NetBSD: noatime mounts currently inhibit 'touch' from updating atime
+; UNSUPPORTED: system-netbsd
; RUN: opt -module-hash -module-summary %s -o %t.o
; RUN: opt -module-hash -module-summary %p/Inputs/cache.ll -o %t2.o
@@ -13,12 +15,16 @@
; RUN: ls %t.cache | count 4
; Create a file of size 64KB.
-; RUN: "%python" -c "print(' ' * 65536)" > %t.cache/llvmcache-foo
+; RUN: %python -c "print(' ' * 65536)" > %t.cache/llvmcache-foo
; This should leave the file in place.
; RUN: ld.lld --thinlto-cache-dir=%t.cache --thinlto-cache-policy cache_size_bytes=128k:prune_interval=0s -o %t3 %t2.o %t.o
; RUN: ls %t.cache | count 5
+; Increase the age of llvmcache-foo, which will give it the oldest time stamp
+; so that it is processed and removed first.
+; RUN: %python -c 'import os,sys,time; t=time.time()-120; os.utime(sys.argv[1],(t,t))' %t.cache/llvmcache-foo
+
; This should remove it.
; RUN: ld.lld --thinlto-cache-dir=%t.cache --thinlto-cache-policy cache_size_bytes=32k:prune_interval=0s -o %t3 %t2.o %t.o
; RUN: ls %t.cache | count 4
@@ -31,6 +37,20 @@
; RUN: ld.lld --thinlto-cache-dir=%t.cache --thinlto-cache-policy prune_after=0s:cache_size=0%:cache_size_files=1:prune_interval=0s -o %t3 %t2.o %t.o
; RUN: ls %t.cache | count 3
+; Check that we remove the least recently used file first.
+; RUN: rm -fr %t.cache
+; RUN: mkdir %t.cache
+; RUN: echo xyz > %t.cache/llvmcache-old
+; RUN: touch -t 198002011200 %t.cache/llvmcache-old
+; RUN: echo xyz > %t.cache/llvmcache-newer
+; RUN: touch -t 198002021200 %t.cache/llvmcache-newer
+; RUN: ld.lld --thinlto-cache-dir=%t.cache --thinlto-cache-policy prune_after=0s:cache_size=0%:cache_size_files=3:prune_interval=0s -o %t3 %t2.o %t.o
+; RUN: ls %t.cache | FileCheck %s
+
+; CHECK-NOT: llvmcache-old
+; CHECK: llvmcache-newer
+; CHECK-NOT: llvmcache-old
+
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
diff --git a/test/ELF/lto/data-ordering-lto.s b/test/ELF/lto/data-ordering-lto.s
index bdacccc35400..f3cd52bd02b5 100644
--- a/test/ELF/lto/data-ordering-lto.s
+++ b/test/ELF/lto/data-ordering-lto.s
@@ -8,7 +8,7 @@
# RUN: echo "pat " >> %t_order_lto.txt
# RUN: ld.lld --symbol-ordering-file %t_order_lto.txt %t.o %t.bc -o %t2.out
-# RUN: llvm-readelf -t %t2.out| FileCheck %s
+# RUN: llvm-readelf --symbols %t2.out| FileCheck %s
# Check that the order is tin -> dipsy -> pat.
diff --git a/test/ELF/lto/defsym.ll b/test/ELF/lto/defsym.ll
index e5f0a4875f59..671f589da18d 100644
--- a/test/ELF/lto/defsym.ll
+++ b/test/ELF/lto/defsym.ll
@@ -3,14 +3,14 @@
; RUN: llvm-as %s -o %t.o
; RUN: llvm-as %S/Inputs/defsym-bar.ll -o %t1.o
; RUN: ld.lld %t.o %t1.o -shared -o %t.so -defsym=bar2=bar3 -save-temps
-; RUN: llvm-readelf -t %t.so.lto.o | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-readelf --symbols %t.so.lto.o | FileCheck --check-prefix=OBJ %s
; RUN: llvm-objdump -d %t.so | FileCheck %s
; ThinLTO
; RUN: opt -module-summary %s -o %t.o
; RUN: opt -module-summary %S/Inputs/defsym-bar.ll -o %t1.o
; RUN: ld.lld %t.o %t1.o -shared -o %t2.so -defsym=bar2=bar3 -save-temps
-; RUN: llvm-readelf -t %t2.so1.lto.o | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-readelf --symbols %t2.so1.lto.o | FileCheck --check-prefix=OBJ %s
; RUN: llvm-objdump -d %t2.so | FileCheck %s --check-prefix=THIN
; OBJ: UND bar2
diff --git a/test/ELF/lto/dynamic-list.ll b/test/ELF/lto/dynamic-list.ll
index c5473d833380..84b667b0eb0c 100644
--- a/test/ELF/lto/dynamic-list.ll
+++ b/test/ELF/lto/dynamic-list.ll
@@ -4,7 +4,7 @@
; RUN: ld.lld -o %t --dynamic-list %t.list -pie %t.o
; RUN: llvm-readobj -dyn-symbols %t | FileCheck %s
-; CHECK: Name: foo@
+; CHECK: Name: foo
; CHECK-NEXT: Value: 0x1010
; CHECK-NEXT: Size: 1
; CHECK-NEXT: Binding: Global (0x1)
diff --git a/test/ELF/lto/emit-llvm.ll b/test/ELF/lto/emit-llvm.ll
new file mode 100644
index 000000000000..bf38c982f02e
--- /dev/null
+++ b/test/ELF/lto/emit-llvm.ll
@@ -0,0 +1,14 @@
+; REQUIRES: x86
+
+; RUN: opt -module-hash -module-summary %s -o %t.o
+; RUN: ld.lld --plugin-opt=emit-llvm -o %t.out.o %t.o
+; RUN: llvm-dis < %t.out.o -o - | FileCheck %s
+
+; CHECK: define internal void @main()
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @main() {
+ ret void
+}
diff --git a/test/ELF/lto/libcall-archive.ll b/test/ELF/lto/libcall-archive.ll
index 731e25938bd3..7e8ac183317d 100644
--- a/test/ELF/lto/libcall-archive.ll
+++ b/test/ELF/lto/libcall-archive.ll
@@ -1,10 +1,15 @@
+; REQUIRES: x86
; RUN: rm -f %t.a
; RUN: llvm-as -o %t.o %s
; RUN: llvm-as -o %t2.o %S/Inputs/libcall-archive.ll
-; RUN: llvm-ar rcs %t.a %t2.o
+; RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux -o %t3.o %S/Inputs/libcall-archive.s
+; RUN: llvm-ar rcs %t.a %t2.o %t3.o
; RUN: ld.lld -o %t %t.o %t.a
; RUN: llvm-nm %t | FileCheck %s
+; RUN: ld.lld -o %t2 %t.o --start-lib %t2.o %t3.o --end-lib
+; RUN: llvm-nm %t2 | FileCheck %s
+; CHECK-NOT: T __sync_val_compare_and_swap_8
; CHECK: T _start
; CHECK: T memcpy
diff --git a/test/ELF/lto/ltopasses-custom.ll b/test/ELF/lto/ltopasses-custom.ll
index a75000d5cfd3..23f15642682a 100644
--- a/test/ELF/lto/ltopasses-custom.ll
+++ b/test/ELF/lto/ltopasses-custom.ll
@@ -27,11 +27,11 @@ define void @barrier() {
; RUN: not ld.lld -m elf_x86_64 %t.o -o %t2.so \
; RUN: --lto-newpm-passes=iamnotapass -shared 2>&1 | \
; RUN: FileCheck %s --check-prefix=INVALID
-; INVALID: unable to parse pass pipeline description: iamnotapass
+; INVALID: unable to parse pass pipeline description 'iamnotapass': unknown pass name 'iamnotapass'
; Check that invalid AA pipelines are rejected gracefully.
; RUN: not ld.lld -m elf_x86_64 %t.o -o %t2.so \
; RUN: --lto-newpm-passes=globaldce --lto-aa-pipeline=patatino \
; RUN: -shared 2>&1 | \
; RUN: FileCheck %s --check-prefix=INVALIDAA
-; INVALIDAA: unable to parse AA pipeline description: patatino
+; INVALIDAA: unknown alias analysis name 'patatino'
diff --git a/test/ELF/lto/opt-remarks.ll b/test/ELF/lto/opt-remarks.ll
index 19b141feb258..bef7e016a1c0 100644
--- a/test/ELF/lto/opt-remarks.ll
+++ b/test/ELF/lto/opt-remarks.ll
@@ -23,9 +23,10 @@
; YAML-NEXT: - Callee: tinkywinky
; YAML-NEXT: - String: ' inlined into '
; YAML-NEXT: - Caller: main
-; YAML-NEXT: - String: ' with cost='
+; YAML-NEXT: - String: ' with '
+; YAML-NEXT: - String: '(cost='
; YAML-NEXT: - Cost: '0'
-; YAML-NEXT: - String: ' (threshold='
+; YAML-NEXT: - String: ', threshold='
; YAML-NEXT: - Threshold: '337'
; YAML-NEXT: - String: ')'
; YAML-NEXT: ...
@@ -39,9 +40,10 @@
; YAML-HOT-NEXT: - Callee: tinkywinky
; YAML-HOT-NEXT: - String: ' inlined into '
; YAML-HOT-NEXT: - Caller: main
-; YAML-HOT-NEXT: - String: ' with cost='
+; YAML-HOT-NEXT: - String: ' with '
+; YAML-HOT-NEXT: - String: '(cost='
; YAML-HOT-NEXT: - Cost: '0'
-; YAML-HOT-NEXT: - String: ' (threshold='
+; YAML-HOT-NEXT: - String: ', threshold='
; YAML-HOT-NEXT: - Threshold: '337'
; YAML-HOT-NEXT: - String: ')'
; YAML-HOT-NEXT: ...
diff --git a/test/ELF/lto/ppc64le.ll b/test/ELF/lto/ppc64le.ll
new file mode 100644
index 000000000000..917b47231843
--- /dev/null
+++ b/test/ELF/lto/ppc64le.ll
@@ -0,0 +1,12 @@
+; REQUIRES: ppc
+
+; RUN: llvm-as %s -o %t.o
+; RUN: ld.lld %t.o -o %t
+
+target datalayout = "e-m:e-i64:64-n32:64"
+target triple = "powerpc64le-unknown-linux-gnu"
+
+define void @__start() {
+ entry:
+ ret void
+}
diff --git a/test/ELF/lto/r600.ll b/test/ELF/lto/r600.ll
new file mode 100644
index 000000000000..1c95edcb4c56
--- /dev/null
+++ b/test/ELF/lto/r600.ll
@@ -0,0 +1,12 @@
+; REQUIRES: amdgpu
+; RUN: llvm-as %s -o %t.o
+; RUN: ld.lld %t.o -o %t
+
+; Make sure the r600 triple is handled
+
+target triple = "r600-mesa-mesa3d"
+target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
+
+define void @_start() {
+ ret void
+}
diff --git a/test/ELF/lto/relocatable.ll b/test/ELF/lto/relocatable.ll
index 2ec9144a37b0..5a0ed4252bfe 100644
--- a/test/ELF/lto/relocatable.ll
+++ b/test/ELF/lto/relocatable.ll
@@ -41,6 +41,15 @@
; CHECK-NEXT: Section: .text.foo
; CHECK-NEXT: }
; CHECK-NEXT: Symbol {
+; CHECK-NEXT: Name:
+; CHECK-NEXT: Value: 0x0
+; CHECK-NEXT: Size: 0
+; CHECK-NEXT: Binding: Local
+; CHECK-NEXT: Type: Section
+; CHECK-NEXT: Other: 0
+; CHECK-NEXT: Section: .llvm_addrsig
+; CHECK-NEXT: }
+; CHECK-NEXT: Symbol {
; CHECK-NEXT: Name: foo
; CHECK-NEXT: Value: 0x0
; CHECK-NEXT: Size: 1
diff --git a/test/ELF/lto/section-name.ll b/test/ELF/lto/section-name.ll
index 483184716a07..0ecc3778aef7 100644
--- a/test/ELF/lto/section-name.ll
+++ b/test/ELF/lto/section-name.ll
@@ -1,9 +1,9 @@
; REQUIRES: x86
; RUN: llvm-as %s -o %t.o
; RUN: ld.lld %t.o -o %t.so -shared
-; RUN: llvm-readelf -s %t.so | FileCheck %s
+; RUN: llvm-readelf -S %t.so | FileCheck %s
; RUN: ld.lld %t.o -o %t.so -shared --gc-sections
-; RUN: llvm-readelf -s %t.so | FileCheck --check-prefix=GC %s
+; RUN: llvm-readelf -S %t.so | FileCheck --check-prefix=GC %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
diff --git a/test/ELF/lto/shlib-undefined.ll b/test/ELF/lto/shlib-undefined.ll
index 6d37bfa6b304..eec40cc2771b 100644
--- a/test/ELF/lto/shlib-undefined.ll
+++ b/test/ELF/lto/shlib-undefined.ll
@@ -6,7 +6,7 @@
; RUN: ld.lld -o %t %t.o %t2.so
; RUN: llvm-readobj -dyn-symbols %t | FileCheck %s
-; CHECK: Name: __progname@
+; CHECK: Name: __progname
; CHECK-NEXT: Value: 0x201010
; CHECK-NEXT: Size: 1
; CHECK-NEXT: Binding: Global (0x1)
diff --git a/test/ELF/lto/symbol-ordering-lto.s b/test/ELF/lto/symbol-ordering-lto.s
index 530b63c669a4..6a35c60772a6 100644
--- a/test/ELF/lto/symbol-ordering-lto.s
+++ b/test/ELF/lto/symbol-ordering-lto.s
@@ -8,7 +8,7 @@
# RUN: echo "pat " >> %t_order_lto.txt
# RUN: ld.lld --symbol-ordering-file %t_order_lto.txt %t.o %t.bc -o %t2.out
-# RUN: llvm-readelf -t %t2.out| FileCheck %s
+# RUN: llvm-readelf --symbols %t2.out| FileCheck %s
# Check that the order is tin -> _start -> pat.
diff --git a/test/ELF/lto/thinlto-obj-path.ll b/test/ELF/lto/thinlto-obj-path.ll
index bb69bb876a28..2806d164a54c 100644
--- a/test/ELF/lto/thinlto-obj-path.ll
+++ b/test/ELF/lto/thinlto-obj-path.ll
@@ -7,7 +7,8 @@
; RUN: rm -f %t4.o
; RUN: ld.lld --plugin-opt=thinlto-index-only --plugin-opt=obj-path=%t4.o -shared %t1.o %t2.o -o %t3
; RUN: llvm-readobj -h %t4.o | FileCheck %s
-; RUN: llvm-nm %t4.o | count 0
+; RUN: llvm-nm %t4.o 2>&1 | FileCheck %s -check-prefix=NO-SYMBOLS
+; NO-SYMBOLS: no symbols
; CHECK: Format: ELF64-x86-64
diff --git a/test/ELF/lto/thinlto-object-suffix-replace.ll b/test/ELF/lto/thinlto-object-suffix-replace.ll
index 05ce942c70f8..c58a1f2ded0e 100644
--- a/test/ELF/lto/thinlto-object-suffix-replace.ll
+++ b/test/ELF/lto/thinlto-object-suffix-replace.ll
@@ -29,12 +29,12 @@
; RUN: -o %t3 2>&1 | FileCheck %s --check-prefix=ERR1
; ERR1: --plugin-opt=thinlto-object-suffix-replace= expects 'old;new' format, but got abc:def
-; Ensure lld generates error if old suffix doesn't exist in file name
-; RUN: rm -f %t1.o
-; RUN: not ld.lld --plugin-opt=thinlto-index-only \
-; RUN: --plugin-opt=thinlto-object-suffix-replace=".abc;.o" -shared %t1.thinlink.bc \
-; RUN: -o %t3 2>&1 | FileCheck %s --check-prefix=ERR2
-; ERR2: error: -thinlto-object-suffix-replace=.abc;.o was given, but {{.*}} does not end with the suffix
+; If filename does not end with old suffix, no suffix change should occur,
+; so ".thinlto.bc" will simply be appended to the input file name.
+; RUN: rm -f %t1.thinlink.bc.thinlto.bc
+; RUN: ld.lld --plugin-opt=thinlto-index-only \
+; RUN: --plugin-opt=thinlto-object-suffix-replace=".abc;.o" -shared %t1.thinlink.bc -o /dev/null
+; RUN: ls %t1.thinlink.bc.thinlto.bc
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
diff --git a/test/ELF/lto/undefined-puts.ll b/test/ELF/lto/undefined-puts.ll
index 6c3dc76be12a..f34abe68206c 100644
--- a/test/ELF/lto/undefined-puts.ll
+++ b/test/ELF/lto/undefined-puts.ll
@@ -25,4 +25,4 @@ declare i32 @printf(i8*, ...)
; CHECK: DynamicSymbols [
; CHECK: Symbol {
-; CHECK: Name: puts@
+; CHECK: Name: puts
diff --git a/test/ELF/lto/version-script.ll b/test/ELF/lto/version-script.ll
index 35a36b5a8d78..eae5a35a6ff4 100644
--- a/test/ELF/lto/version-script.ll
+++ b/test/ELF/lto/version-script.ll
@@ -21,7 +21,7 @@ define void @bar() {
; DSO: DynamicSymbols [
; DSO: Symbol {
-; DSO: Name: @ (0)
+; DSO: Name:
; DSO: Value: 0x0
; DSO: Size: 0
; DSO: Binding: Local
diff --git a/test/ELF/lto/wrap-2.ll b/test/ELF/lto/wrap-2.ll
index 4e82d4a0e8b0..997725fb8def 100644
--- a/test/ELF/lto/wrap-2.ll
+++ b/test/ELF/lto/wrap-2.ll
@@ -28,11 +28,15 @@
; THIN-NEXT: jmp{{.*}}<bar>
; Check that bar and __wrap_bar retain their original binding.
-; BIND: Name: __wrap_bar
+; BIND: Name: bar
; BIND-NEXT: Value:
; BIND-NEXT: Size:
; BIND-NEXT: Binding: Local
-; BIND: Name: bar
+; BIND: Name: __real_bar
+; BIND-NEXT: Value:
+; BIND-NEXT: Size:
+; BIND-NEXT: Binding: Local
+; BIND: Name: __wrap_bar
; BIND-NEXT: Value:
; BIND-NEXT: Size:
; BIND-NEXT: Binding: Local
diff --git a/test/ELF/map-file-i686.s b/test/ELF/map-file-i686.s
index bab2c4b377e2..5c8b15491151 100644
--- a/test/ELF/map-file-i686.s
+++ b/test/ELF/map-file-i686.s
@@ -7,15 +7,15 @@
_start:
nop
-// CHECK: VMA LMA Size Align Out In Symbol
-// CHECK-NEXT: 11000 11000 1 4 .text
-// CHECK-NEXT: 11000 11000 1 4 {{.*}}{{/|\\}}map-file-i686.s.tmp1.o:(.text)
-// CHECK-NEXT: 11000 11000 0 1 _start
-// CHECK-NEXT: 0 0 8 1 .comment
-// CHECK-NEXT: 0 0 8 1 <internal>:(.comment)
-// CHECK-NEXT: 0 0 20 4 .symtab
-// CHECK-NEXT: 0 0 20 4 <internal>:(.symtab)
-// CHECK-NEXT: 0 0 2a 1 .shstrtab
-// CHECK-NEXT: 0 0 2a 1 <internal>:(.shstrtab)
-// CHECK-NEXT: 0 0 8 1 .strtab
-// CHECK-NEXT: 0 0 8 1 <internal>:(.strtab)
+// CHECK: VMA LMA Size Align Out In Symbol
+// CHECK-NEXT: 401000 401000 1 4 .text
+// CHECK-NEXT: 401000 401000 1 4 {{.*}}{{/|\\}}map-file-i686.s.tmp1.o:(.text)
+// CHECK-NEXT: 401000 401000 0 1 _start
+// CHECK-NEXT: 0 0 8 1 .comment
+// CHECK-NEXT: 0 0 8 1 <internal>:(.comment)
+// CHECK-NEXT: 0 0 20 4 .symtab
+// CHECK-NEXT: 0 0 20 4 <internal>:(.symtab)
+// CHECK-NEXT: 0 0 2a 1 .shstrtab
+// CHECK-NEXT: 0 0 2a 1 <internal>:(.shstrtab)
+// CHECK-NEXT: 0 0 8 1 .strtab
+// CHECK-NEXT: 0 0 8 1 <internal>:(.strtab)
diff --git a/test/ELF/merge-string-error.s b/test/ELF/merge-string-error.s
index 70a361b6ccde..a0ffaafde854 100644
--- a/test/ELF/merge-string-error.s
+++ b/test/ELF/merge-string-error.s
@@ -8,4 +8,4 @@
.data
.long .rodata.str1.1 + 4
-// CHECK: merge-string-error.s.tmp.o:(.rodata.str1.1): entry is past the end of the section
+// CHECK: merge-string-error.s.tmp.o:(.rodata.str1.1): offset is outside the section
diff --git a/test/ELF/mergeable-errors.s b/test/ELF/mergeable-errors.s
new file mode 100644
index 000000000000..578589837f07
--- /dev/null
+++ b/test/ELF/mergeable-errors.s
@@ -0,0 +1,8 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: not ld.lld %t.o -o %t1 2>&1 | FileCheck %s
+
+# CHECK: error: {{.*}}.o:(.mergeable): string is not null terminated
+
+.section .mergeable,"MS",@progbits,2
+ .short 0x1122
diff --git a/test/ELF/mips-32.s b/test/ELF/mips-32.s
index 7efcfcd65167..85bc95592edb 100644
--- a/test/ELF/mips-32.s
+++ b/test/ELF/mips-32.s
@@ -41,8 +41,8 @@ v2:
# ^-- v2+4 ^-- v1
# SYM: SYMBOL TABLE:
-# SYM: 00020000 l .data 00000004 v1
-# SYM: 00020004 g .data 00000008 v2
+# SYM: 00020000 l O .data 00000004 v1
+# SYM: 00020004 g O .data 00000008 v2
# REL: Relocations [
# REL-NEXT: Section (7) .rel.dyn {
diff --git a/test/ELF/mips-64.s b/test/ELF/mips-64.s
index e37b75c070ec..70e445f5327a 100644
--- a/test/ELF/mips-64.s
+++ b/test/ELF/mips-64.s
@@ -25,8 +25,8 @@ v2:
# SYM: SYMBOL TABLE:
-# SYM: 00020000 l .data 00000004 v1
-# SYM: 00020008 g .data 00000008 v2
+# SYM: 00020000 l O .data 00000004 v1
+# SYM: 00020008 g O .data 00000008 v2
# CHECK: Relocations [
# CHECK-NEXT: Section (7) .rel.dyn {
diff --git a/test/ELF/mips-dynamic.s b/test/ELF/mips-dynamic.s
index ebc2625970cb..2852b5088374 100644
--- a/test/ELF/mips-dynamic.s
+++ b/test/ELF/mips-dynamic.s
@@ -97,9 +97,9 @@
# DSO-NEXT: Size: 8
# DSO: ]
# DSO: DynamicSymbols [
-# DSO: Name: @
-# DSO: Name: __start@
-# DSO: Name: _foo@
+# DSO: Name:
+# DSO: Name: __start
+# DSO: Name: _foo
# DSO: ]
# DSO: DynamicSection [
# DSO-NEXT: Tag Type Name/Value
diff --git a/test/ELF/mips-dynsym-sort.s b/test/ELF/mips-dynsym-sort.s
index d1b935b63cff..3f98b7cd72e0 100644
--- a/test/ELF/mips-dynsym-sort.s
+++ b/test/ELF/mips-dynsym-sort.s
@@ -36,7 +36,7 @@ __start:
# the MIPS rules. v2 comes first as it is not in the GOT.
# v1 and v3 are sorted according to their order in the GOT.
# CHECK: DynamicSymbols [
-# CHECK: Name: v2@
-# CHECK: Name: v3@
-# CHECK: Name: v1@
+# CHECK: Name: v2
+# CHECK: Name: v3
+# CHECK: Name: v1
# CHECK: ]
diff --git a/test/ELF/mips-gnu-hash.s b/test/ELF/mips-gnu-hash.s
index e66bc893a076..fe4e95fee99b 100644
--- a/test/ELF/mips-gnu-hash.s
+++ b/test/ELF/mips-gnu-hash.s
@@ -7,7 +7,7 @@
# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux %s -o %t-el.o
# RUN: not ld.lld -shared -hash-style=gnu %t-el.o -o /dev/null 2>&1 | FileCheck %s
-# CHECK: the .gnu.hash section is not compatible with the MIPS target.
+# CHECK: the .gnu.hash section is not compatible with the MIPS target
.globl __start
__start:
diff --git a/test/ELF/mips-got-and-copy.s b/test/ELF/mips-got-and-copy.s
index f4640bf30dfa..fed23d1eb762 100644
--- a/test/ELF/mips-got-and-copy.s
+++ b/test/ELF/mips-got-and-copy.s
@@ -32,7 +32,7 @@
# CHECK-NEXT: Value: 0x[[DATA0]]
# CHECK-NEXT: Type: Object
# CHECK-NEXT: Section: .bss
-# CHECK-NEXT: Name: data0@
+# CHECK-NEXT: Name: data0
# CHECK-NEXT: }
# CHECK-NEXT: Entry {
# CHECK-NEXT: Address:
@@ -41,7 +41,7 @@
# CHECK-NEXT: Value: 0x[[DATA1]]
# CHECK-NEXT: Type: Object
# CHECK-NEXT: Section: .bss
-# CHECK-NEXT: Name: data1@
+# CHECK-NEXT: Name: data1
# CHECK-NEXT: }
# CHECK-NEXT: ]
# CHECK-NEXT: Number of TLS and multi-GOT entries: 0
diff --git a/test/ELF/mips-got-extsym.s b/test/ELF/mips-got-extsym.s
index ea57d77a0353..b5063a8559c9 100644
--- a/test/ELF/mips-got-extsym.s
+++ b/test/ELF/mips-got-extsym.s
@@ -43,7 +43,7 @@
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Type: None
# CHECK-NEXT: Section: Undefined
-# CHECK-NEXT: Name: _foo@
+# CHECK-NEXT: Name: _foo
# CHECK-NEXT: }
# CHECK-NEXT: ]
diff --git a/test/ELF/mips-got-relocs.s b/test/ELF/mips-got-relocs.s
index d085df06524a..0465b08b9ed4 100644
--- a/test/ELF/mips-got-relocs.s
+++ b/test/ELF/mips-got-relocs.s
@@ -48,7 +48,7 @@ v1:
# EXE_SYM: SYMBOL TABLE:
# EXE_SYM: 00038000 .got 00000000 .hidden _gp
# ^-- .got + GP offset (0x7ff0)
-# EXE_SYM: 00030000 g .data 00000004 v1
+# EXE_SYM: 00030000 g O .data 00000004 v1
# EXE_GOT_BE: Contents of section .got:
@@ -72,7 +72,7 @@ v1:
# DSO_SYM: SYMBOL TABLE:
# DSO_SYM: 00028000 .got 00000000 .hidden _gp
# ^-- .got + GP offset (0x7ff0)
-# DSO_SYM: 00020000 g .data 00000004 v1
+# DSO_SYM: 00020000 g O .data 00000004 v1
# DSO_GOT_BE: Contents of section .got:
# DSO_GOT_BE: 20010 00000000 80000000 00020000
diff --git a/test/ELF/mips-got16-relocatable.s b/test/ELF/mips-got16-relocatable.s
index 04b7cbb8e904..e1100c2b31b3 100644
--- a/test/ELF/mips-got16-relocatable.s
+++ b/test/ELF/mips-got16-relocatable.s
@@ -14,9 +14,7 @@
# 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: ef ef ef ef <unknown>
-# OBJ-NEXT: c: ef ef ef ef <unknown>
-# OBJ-NEXT: 10: 8f 99 00 00 lw $25, 0($gp)
+# OBJ: 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
@@ -25,9 +23,7 @@
# 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: ef ef ef ef <unknown>
-# SO-NEXT: 1000c: ef ef ef ef <unknown>
-# SO-NEXT: 10010: 8f 99 80 18 lw $25, -32744($gp)
+# SO: 10010: 8f 99 80 18 lw $25, -32744($gp)
# SO-NEXT: 10014: 27 24 00 10 addiu $4, $25, 16
.text
diff --git a/test/ELF/mips-got16.s b/test/ELF/mips-got16.s
index cf0847da53d3..53734ed31bb1 100644
--- a/test/ELF/mips-got16.s
+++ b/test/ELF/mips-got16.s
@@ -96,7 +96,7 @@
# GOT-NEXT: Value: 0x0
# GOT-NEXT: Type: None
# GOT-NEXT: Section: Undefined
-# GOT-NEXT: Name: foo@
+# GOT-NEXT: Name: foo
# GOT-NEXT: }
# GOT-NEXT: ]
# GOT-NEXT: Number of TLS and multi-GOT entries: 0
diff --git a/test/ELF/mips-hilo.s b/test/ELF/mips-hilo.s
index a00ffaa9fb1c..64f41140350b 100644
--- a/test/ELF/mips-hilo.s
+++ b/test/ELF/mips-hilo.s
@@ -47,6 +47,6 @@ g1:
# ^-- %lo(l1-4)
# CHECK: SYMBOL TABLE:
-# CHECK: 0030000 l .data 00000004 l1
-# CHECK: 0020000 .text 00000000 __start
-# CHECK: 0030004 g .data 00000004 g1
+# CHECK: 0030000 l O .data 00000004 l1
+# CHECK: 0020000 .text 00000000 __start
+# CHECK: 0030004 g O .data 00000004 g1
diff --git a/test/ELF/mips-mgot.s b/test/ELF/mips-mgot.s
index 0bb1a76ea8f5..4e364916c814 100644
--- a/test/ELF/mips-mgot.s
+++ b/test/ELF/mips-mgot.s
@@ -18,13 +18,13 @@
# CHECK-NEXT: 60040 00000000 00000000 00000000
# CHECK: SYMBOL TABLE:
-# CHECK: 00000000 l .tdata 00000000 loc0
-# CHECK: 00010000 .text 00000000 foo0
-# CHECK: 00000000 g .tdata 00000000 tls0
-# CHECK: 00010020 .text 00000000 foo1
-# CHECK: 00000004 g .tdata 00000000 tls1
-# CHECK: 00010030 .text 00000000 foo2
-# CHECK: 00000008 g .tdata 00000000 tls2
+# CHECK: 00000000 l O .tdata 00000000 loc0
+# CHECK: 00010000 .text 00000000 foo0
+# CHECK: 00000000 g O .tdata 00000000 tls0
+# CHECK: 00010020 .text 00000000 foo1
+# CHECK: 00000004 g O .tdata 00000000 tls1
+# CHECK: 00010030 .text 00000000 foo2
+# CHECK: 00000008 g O .tdata 00000000 tls2
# GOT: Relocations [
# GOT-NEXT: Section (7) .rel.dyn {
diff --git a/test/ELF/mips-micro-jal.s b/test/ELF/mips-micro-jal.s
index 18d41cf13cbc..f41d7dc3a6ce 100644
--- a/test/ELF/mips-micro-jal.s
+++ b/test/ELF/mips-micro-jal.s
@@ -57,9 +57,7 @@
# EB-NEXT: 20022: 45 f9 jalrs16 $25
# EB-NEXT: 20024: 0f 83 move $gp, $3
# EB-NEXT: 20026: 0c 00 nop
-# EB-NEXT: 20028: 00 00 00 00 nop
-# EB-NEXT: 2002c: 00 00 00 00 nop
-
+# EB-NEXT: ...
# EB-NEXT: 20030: 79 00 3f f7 addiupc $2, 65500
# EB-NEXT: 20034: ff 22 00 00 lw $25, 0($2)
# EB-NEXT: 20038: 45 99 jr16 $25
@@ -76,9 +74,7 @@
# EL-NEXT: 20022: f9 45 jalrs16 $25
# EL-NEXT: 20024: 83 0f move $gp, $3
# EL-NEXT: 20026: 00 0c nop
-# EL-NEXT: 20028: 00 00 00 00 nop
-# EL-NEXT: 2002c: 00 00 00 00 nop
-
+# EL-NEXT: ...
# EL-NEXT: 20030: 00 79 f7 3f addiupc $2, 65500
# EL-NEXT: 20034: 22 ff 00 00 lw $25, 0($2)
# EL-NEXT: 20038: 99 45 jr16 $25
@@ -127,9 +123,7 @@
# MIXED-NEXT: 20032: 45 f9 jalrs16 $25
# MIXED-NEXT: 20034: 0f 83 move $gp, $3
# MIXED-NEXT: 20036: 0c 00 nop
-# MIXED-NEXT: 20038: 00 00 00 00 nop
-# MIXED-NEXT: 2003c: 00 00 00 00 nop
-
+# MIXED-NEXT: ...
# MIXED-NEXT: 20040: 79 00 3f f3 addiupc $2, 65484
# MIXED-NEXT: 20044: ff 22 00 00 lw $25, 0($2)
# MIXED-NEXT: 20048: 45 99 jr16 $25
diff --git a/test/ELF/mips-micro-plt.s b/test/ELF/mips-micro-plt.s
index 6dcd6fbeec2d..24e90ae49a86 100644
--- a/test/ELF/mips-micro-plt.s
+++ b/test/ELF/mips-micro-plt.s
@@ -80,7 +80,7 @@
# CHECK-NEXT: Value: 0x20041
# CHECK-NEXT: Type: Function
# CHECK-NEXT: Section: Undefined
-# CHECK-NEXT: Name: foo0@
+# CHECK-NEXT: Name: foo0
# CHECK-NEXT: }
# CHECK-NEXT: ]
# CHECK-NEXT: }
diff --git a/test/ELF/mips-npic-call-pic-os.s b/test/ELF/mips-npic-call-pic-os.s
index aea0fa1221dc..8799d832994d 100644
--- a/test/ELF/mips-npic-call-pic-os.s
+++ b/test/ELF/mips-npic-call-pic-os.s
@@ -19,37 +19,37 @@
# 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: ef ef ef ef <unknown>
-# CHECK-NEXT: 2003c: ef ef ef ef <unknown>
+
# 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: ef ef ef ef <unknown>
-# CHECK-NEXT: 20058: ef ef ef ef <unknown>
-# CHECK-NEXT: 2005c: ef ef ef ef <unknown>
+
# CHECK: fpic:
# CHECK-NEXT: 20060: 00 00 00 00 nop
-# CHECK-NEXT: 20064: ef ef ef ef <unknown>
-# CHECK-NEXT: 20068: ef ef ef ef <unknown>
-# CHECK-NEXT: 2006c: ef ef ef ef <unknown>
+
# CHECK: fnpic:
# CHECK-NEXT: 20070: 00 00 00 00 nop
# CHECK-NEXT: Disassembly of section differentos:
@@ -79,40 +79,41 @@
# 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: ef ef ef ef <unknown>
-# REVERSE-NEXT: 2003c: ef ef ef ef <unknown>
+
# REVERSE: foo2:
# REVERSE-NEXT: 20040: 00 00 00 00 nop
-# REVERSE-NEXT: 20044: ef ef ef ef <unknown>
-# REVERSE-NEXT: 20048: ef ef ef ef <unknown>
-# REVERSE-NEXT: 2004c: ef ef ef ef <unknown>
+
# 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: ef ef ef ef <unknown>
-# REVERSE-NEXT: 20068: ef ef ef ef <unknown>
-# REVERSE-NEXT: 2006c: ef ef ef ef <unknown>
+
# REVERSE: fnpic:
# REVERSE-NEXT: 20070: 00 00 00 00 nop
-# REVERSE-NEXT: Disassembly of section differentos:
+
+# REVERSE: 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
diff --git a/test/ELF/mips-npic-call-pic-script.s b/test/ELF/mips-npic-call-pic-script.s
index 230704459463..11aa51aca83c 100644
--- a/test/ELF/mips-npic-call-pic-script.s
+++ b/test/ELF/mips-npic-call-pic-script.s
@@ -19,91 +19,28 @@
# 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: ef ef ef ef <unknown>
-# CHECK-NEXT: 2003c: ef ef ef ef <unknown>
+
# CHECK: foo2:
# CHECK-NEXT: 20040: 00 00 00 00 nop
-# CHECK-NEXT: 20044: ef ef ef ef <unknown>
-# CHECK-NEXT: 20048: ef ef ef ef <unknown>
-# CHECK-NEXT: 2004c: ef ef ef ef <unknown>
-# CHECK-NEXT: 20050: ef ef ef ef <unknown>
-# CHECK-NEXT: 20054: ef ef ef ef <unknown>
-# CHECK-NEXT: 20058: ef ef ef ef <unknown>
-# CHECK-NEXT: 2005c: ef ef ef ef <unknown>
-# CHECK-NEXT: 20060: ef ef ef ef <unknown>
-# CHECK-NEXT: 20064: ef ef ef ef <unknown>
-# CHECK-NEXT: 20068: ef ef ef ef <unknown>
-# CHECK-NEXT: 2006c: ef ef ef ef <unknown>
-# CHECK-NEXT: 20070: ef ef ef ef <unknown>
-# CHECK-NEXT: 20074: ef ef ef ef <unknown>
-# CHECK-NEXT: 20078: ef ef ef ef <unknown>
-# CHECK-NEXT: 2007c: ef ef ef ef <unknown>
-# CHECK-NEXT: 20080: ef ef ef ef <unknown>
-# CHECK-NEXT: 20084: ef ef ef ef <unknown>
-# CHECK-NEXT: 20088: ef ef ef ef <unknown>
-# CHECK-NEXT: 2008c: ef ef ef ef <unknown>
-# CHECK-NEXT: 20090: ef ef ef ef <unknown>
-# CHECK-NEXT: 20094: ef ef ef ef <unknown>
-# CHECK-NEXT: 20098: ef ef ef ef <unknown>
-# CHECK-NEXT: 2009c: ef ef ef ef <unknown>
-# CHECK-NEXT: 200a0: ef ef ef ef <unknown>
-# CHECK-NEXT: 200a4: ef ef ef ef <unknown>
-# CHECK-NEXT: 200a8: ef ef ef ef <unknown>
-# CHECK-NEXT: 200ac: ef ef ef ef <unknown>
-# CHECK-NEXT: 200b0: ef ef ef ef <unknown>
-# CHECK-NEXT: 200b4: ef ef ef ef <unknown>
-# CHECK-NEXT: 200b8: ef ef ef ef <unknown>
-# CHECK-NEXT: 200bc: ef ef ef ef <unknown>
-# CHECK-NEXT: 200c0: ef ef ef ef <unknown>
-# CHECK-NEXT: 200c4: ef ef ef ef <unknown>
-# CHECK-NEXT: 200c8: ef ef ef ef <unknown>
-# CHECK-NEXT: 200cc: ef ef ef ef <unknown>
-# CHECK-NEXT: 200d0: ef ef ef ef <unknown>
-# CHECK-NEXT: 200d4: ef ef ef ef <unknown>
-# CHECK-NEXT: 200d8: ef ef ef ef <unknown>
-# CHECK-NEXT: 200dc: ef ef ef ef <unknown>
-# CHECK-NEXT: 200e0: ef ef ef ef <unknown>
-# CHECK-NEXT: 200e4: ef ef ef ef <unknown>
-# CHECK-NEXT: 200e8: ef ef ef ef <unknown>
-# CHECK-NEXT: 200ec: ef ef ef ef <unknown>
-# CHECK-NEXT: 200f0: ef ef ef ef <unknown>
-# CHECK-NEXT: 200f4: ef ef ef ef <unknown>
-# CHECK-NEXT: 200f8: ef ef ef ef <unknown>
-# CHECK-NEXT: 200fc: ef ef ef ef <unknown>
-# CHECK-NEXT: 20100: ef ef ef ef <unknown>
-# CHECK-NEXT: 20104: ef ef ef ef <unknown>
-# CHECK-NEXT: 20108: ef ef ef ef <unknown>
-# CHECK-NEXT: 2010c: ef ef ef ef <unknown>
-# CHECK-NEXT: 20110: ef ef ef ef <unknown>
-# CHECK-NEXT: 20114: ef ef ef ef <unknown>
-# CHECK-NEXT: 20118: ef ef ef ef <unknown>
-# CHECK-NEXT: 2011c: ef ef ef ef <unknown>
-# CHECK-NEXT: 20120: ef ef ef ef <unknown>
-# CHECK-NEXT: 20124: ef ef ef ef <unknown>
-# CHECK-NEXT: 20128: ef ef ef ef <unknown>
-# CHECK-NEXT: 2012c: ef ef ef ef <unknown>
-# CHECK-NEXT: 20130: ef ef ef ef <unknown>
-# CHECK-NEXT: 20134: ef ef ef ef <unknown>
-# CHECK-NEXT: 20138: ef ef ef ef <unknown>
-# CHECK-NEXT: 2013c: ef ef ef ef <unknown>
-# CHECK-NEXT: 20140: ef ef ef ef <unknown>
-# CHECK-NEXT: 20144: ef ef ef ef <unknown>
-# CHECK-NEXT: 20148: ef ef ef ef <unknown>
-# CHECK-NEXT: 2014c: ef ef ef ef <unknown>
+
# CHECK: __start:
# CHECK-NEXT: 20150: 0c 00 80 00 jal 131072 <__LA25Thunk_foo1a>
# CHECK-NEXT: 20154: 00 00 00 00 nop
@@ -117,16 +54,16 @@
# CHECK-NEXT: 20174: 00 00 00 00 nop
# CHECK-NEXT: 20178: 0c 00 80 68 jal 131488 <fnpic>
# CHECK-NEXT: 2017c: 00 00 00 00 nop
+
# CHECK: __LA25Thunk_fpic:
# CHECK-NEXT: 20180: 3c 19 00 02 lui $25, 2
# CHECK-NEXT: 20184: 08 00 80 64 j 131472 <fpic>
# CHECK-NEXT: 20188: 27 39 01 90 addiu $25, $25, 400
# CHECK-NEXT: 2018c: 00 00 00 00 nop
+
# CHECK: fpic:
# CHECK-NEXT: 20190: 00 00 00 00 nop
-# CHECK-NEXT: 20194: ef ef ef ef <unknown>
-# CHECK-NEXT: 20198: ef ef ef ef <unknown>
-# CHECK-NEXT: 2019c: ef ef ef ef <unknown>
+
# CHECK: fnpic:
# CHECK-NEXT: 201a0: 00 00 00 00 nop
@@ -145,6 +82,7 @@ __start:
# RUN: echo "SECTIONS { .text 0x20000 : { *(.text) } }" > %t2.script
# RUN: ld.lld --script %t2.script %t-npic.o %t-pic.o %t-sto-pic.o -o %t2.exe
# RUN: llvm-objdump -d %t2.exe | FileCheck -check-prefix=ORPH1 %s
+
# ORPH1: Disassembly of section .text:
# ORPH1-NEXT: __start:
# ORPH1-NEXT: 20000: 0c 00 80 15 jal 131156 <__LA25Thunk_foo1a>
@@ -159,42 +97,43 @@ __start:
# ORPH1-NEXT: 20024: 00 00 00 00 nop
# ORPH1-NEXT: 20028: 0c 00 80 14 jal 131152 <fnpic>
# ORPH1-NEXT: 2002c: 00 00 00 00 nop
+
# ORPH1: __LA25Thunk_fpic:
# ORPH1-NEXT: 20030: 3c 19 00 02 lui $25, 2
# ORPH1-NEXT: 20034: 08 00 80 10 j 131136 <fpic>
# ORPH1-NEXT: 20038: 27 39 00 40 addiu $25, $25, 64
# ORPH1-NEXT: 2003c: 00 00 00 00 nop
+
# ORPH1: fpic:
# ORPH1-NEXT: 20040: 00 00 00 00 nop
-# ORPH1-NEXT: 20044: ef ef ef ef <unknown>
-# ORPH1-NEXT: 20048: ef ef ef ef <unknown>
-# ORPH1-NEXT: 2004c: ef ef ef ef <unknown>
+
# ORPH1: fnpic:
# ORPH1-NEXT: 20050: 00 00 00 00 nop
+
# ORPH1: __LA25Thunk_foo1a:
# ORPH1-NEXT: 20054: 3c 19 00 02 lui $25, 2
# ORPH1-NEXT: 20058: 08 00 80 20 j 131200 <foo1a>
# ORPH1-NEXT: 2005c: 27 39 00 80 addiu $25, $25, 128
# ORPH1-NEXT: 20060: 00 00 00 00 nop
+
# ORPH1: __LA25Thunk_foo1b:
# ORPH1-NEXT: 20064: 3c 19 00 02 lui $25, 2
# ORPH1-NEXT: 20068: 08 00 80 21 j 131204 <foo1b>
# ORPH1-NEXT: 2006c: 27 39 00 84 addiu $25, $25, 132
# ORPH1-NEXT: 20070: 00 00 00 00 nop
-# ORPH1-NEXT: 20074: ef ef ef ef <unknown>
-# ORPH1-NEXT: 20078: ef ef ef ef <unknown>
-# ORPH1-NEXT: 2007c: ef ef ef ef <unknown>
+
# ORPH1: foo1a:
# ORPH1-NEXT: 20080: 00 00 00 00 nop
+
# ORPH1: foo1b:
# ORPH1-NEXT: 20084: 00 00 00 00 nop
+
# ORPH1: __LA25Thunk_foo2:
# ORPH1-NEXT: 20088: 3c 19 00 02 lui $25, 2
# ORPH1-NEXT: 2008c: 08 00 80 28 j 131232 <foo2>
# ORPH1-NEXT: 20090: 27 39 00 a0 addiu $25, $25, 160
# ORPH1-NEXT: 20094: 00 00 00 00 nop
-# ORPH1-NEXT: 20098: ef ef ef ef <unknown>
-# ORPH1-NEXT: 2009c: ef ef ef ef <unknown>
+
# ORPH1: foo2:
# ORPH1-NEXT: 200a0: 00 00 00 00 nop
@@ -203,6 +142,7 @@ __start:
# RUN: echo "SECTIONS { .out 0x20000 : { *(.text) } }" > %t3.script
# RUN: ld.lld --script %t3.script %t-npic.o %t-pic.o %t-sto-pic.o -o %t3.exe
# RUN: llvm-objdump -d %t3.exe | FileCheck -check-prefix=ORPH2 %s
+
# ORPH2: Disassembly of section .out:
# ORPH2-NEXT: __start:
# ORPH2-NEXT: 20000: 0c 00 80 18 jal 131168 <__LA25Thunk_foo1a>
@@ -217,39 +157,43 @@ __start:
# ORPH2-NEXT: 20024: 00 00 00 00 nop
# ORPH2-NEXT: 20028: 0c 00 80 14 jal 131152 <fnpic>
# ORPH2-NEXT: 2002c: 00 00 00 00 nop
+
# ORPH2: __LA25Thunk_fpic:
# ORPH2-NEXT: 20030: 3c 19 00 02 lui $25, 2
# ORPH2-NEXT: 20034: 08 00 80 10 j 131136 <fpic>
# ORPH2-NEXT: 20038: 27 39 00 40 addiu $25, $25, 64
# ORPH2-NEXT: 2003c: 00 00 00 00 nop
+
# ORPH2: fpic:
# ORPH2-NEXT: 20040: 00 00 00 00 nop
-# ORPH2-NEXT: 20044: ef ef ef ef <unknown>
-# ORPH2-NEXT: 20048: ef ef ef ef <unknown>
-# ORPH2-NEXT: 2004c: ef ef ef ef <unknown>
+
# ORPH2: fnpic:
# ORPH2-NEXT: 20050: 00 00 00 00 nop
# ORPH2-NEXT: Disassembly of section .text:
+
# ORPH2-NEXT: __LA25Thunk_foo1a:
# ORPH2-NEXT: 20060: 3c 19 00 02 lui $25, 2
# ORPH2-NEXT: 20064: 08 00 80 20 j 131200 <foo1a>
# ORPH2-NEXT: 20068: 27 39 00 80 addiu $25, $25, 128
# ORPH2-NEXT: 2006c: 00 00 00 00 nop
+
# ORPH2: __LA25Thunk_foo1b:
# ORPH2-NEXT: 20070: 3c 19 00 02 lui $25, 2
# ORPH2-NEXT: 20074: 08 00 80 21 j 131204 <foo1b>
# ORPH2-NEXT: 20078: 27 39 00 84 addiu $25, $25, 132
# ORPH2-NEXT: 2007c: 00 00 00 00 nop
+
# ORPH2: foo1a:
# ORPH2-NEXT: 20080: 00 00 00 00 nop
+
# ORPH2: foo1b:
# ORPH2-NEXT: 20084: 00 00 00 00 nop
+
# ORPH2: __LA25Thunk_foo2:
# ORPH2-NEXT: 20088: 3c 19 00 02 lui $25, 2
# ORPH2-NEXT: 2008c: 08 00 80 28 j 131232 <foo2>
# ORPH2-NEXT: 20090: 27 39 00 a0 addiu $25, $25, 160
# ORPH2-NEXT: 20094: 00 00 00 00 nop
-# ORPH2-NEXT: 20098: ef ef ef ef <unknown>
-# ORPH2-NEXT: 2009c: ef ef ef ef <unknown>
+
# ORPH2: foo2:
# ORPH2-NEXT: 200a0: 00 00 00 00 nop
diff --git a/test/ELF/mips-npic-call-pic.s b/test/ELF/mips-npic-call-pic.s
index c3c94d783410..5921c9f510fc 100644
--- a/test/ELF/mips-npic-call-pic.s
+++ b/test/ELF/mips-npic-call-pic.s
@@ -51,8 +51,6 @@
# 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: ef ef ef ef <unknown>
-# CHECK-NEXT: 2006c: ef ef ef ef <unknown>
# CHECK: foo2:
# CHECK-NEXT: 20070: 00 00 00 00 nop
@@ -62,15 +60,9 @@
# 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: ef ef ef ef <unknown>
-# CHECK-NEXT: 20088: ef ef ef ef <unknown>
-# CHECK-NEXT: 2008c: ef ef ef ef <unknown>
# CHECK: fpic:
# CHECK-NEXT: 20090: 00 00 00 00 nop
-# CHECK-NEXT: 20094: ef ef ef ef <unknown>
-# CHECK-NEXT: 20098: ef ef ef ef <unknown>
-# CHECK-NEXT: 2009c: ef ef ef ef <unknown>
# CHECK: fnpic:
# CHECK-NEXT: 200a0: 00 00 00 00 nop
@@ -87,27 +79,28 @@
# 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: ef ef ef ef <unknown>
-# REVERSE-NEXT: 2003c: ef ef ef ef <unknown>
+
# REVERSE: foo2:
# REVERSE-NEXT: 20040: 00 00 00 00 nop
-# REVERSE-NEXT: 20044: ef ef ef ef <unknown>
-# REVERSE-NEXT: 20048: ef ef ef ef <unknown>
-# REVERSE-NEXT: 2004c: ef ef ef ef <unknown>
+
# REVERSE: __start:
# REVERSE-NEXT: 20050: 0c 00 80 00 jal 131072 <__LA25Thunk_foo1a>
# REVERSE-NEXT: 20054: 00 00 00 00 nop
@@ -121,16 +114,16 @@
# REVERSE-NEXT: 20074: 00 00 00 00 nop
# REVERSE-NEXT: 20078: 0c 00 80 28 jal 131232 <fnpic>
# REVERSE-NEXT: 2007c: 00 00 00 00 nop
+
# 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: ef ef ef ef <unknown>
-# REVERSE-NEXT: 20098: ef ef ef ef <unknown>
-# REVERSE-NEXT: 2009c: ef ef ef ef <unknown>
+
# REVERSE: fnpic:
# REVERSE-NEXT: 200a0: 00 00 00 00 nop
diff --git a/test/ELF/mips-sto-plt.s b/test/ELF/mips-sto-plt.s
index b4d3ee391414..4bd0d9e7ba44 100644
--- a/test/ELF/mips-sto-plt.s
+++ b/test/ELF/mips-sto-plt.s
@@ -9,7 +9,7 @@
# RUN: llvm-readobj -dt -mips-plt-got %t.exe | FileCheck %s
# CHECK: Symbol {
-# CHECK: Name: foo0@
+# CHECK: Name: foo0
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Global
@@ -18,7 +18,7 @@
# CHECK-NEXT: Section: Undefined
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: foo1@
+# CHECK-NEXT: Name: foo1
# CHECK-NEXT: Value: 0x[[FOO1:[0-9A-F]+]]
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Global
diff --git a/test/ELF/mips-tls-64.s b/test/ELF/mips-tls-64.s
index f000755b4e82..2d0749edc585 100644
--- a/test/ELF/mips-tls-64.s
+++ b/test/ELF/mips-tls-64.s
@@ -28,9 +28,9 @@
# DIS-NEXT: 30040 00000000 00000001 00000000 00000000
# DIS-NEXT: 30050 00000000 00000001 ffffffff ffff8004
-# DIS: 0000000000000000 l .tdata 00000000 loc
-# DIS: 0000000000000004 g .tdata 00000000 bar
-# DIS: 0000000000000000 g *UND* 00000000 foo
+# DIS: 0000000000000000 l O .tdata 00000000 loc
+# DIS: 0000000000000004 g O .tdata 00000000 bar
+# DIS: 0000000000000000 g O *UND* 00000000 foo
# CHECK: Relocations [
# CHECK-NEXT: Section (7) .rel.dyn {
diff --git a/test/ELF/mips-tls-hilo.s b/test/ELF/mips-tls-hilo.s
index ae54602327a9..6b6df17eb97d 100644
--- a/test/ELF/mips-tls-hilo.s
+++ b/test/ELF/mips-tls-hilo.s
@@ -20,7 +20,7 @@
# DIS-NEXT: 2000c: 24 62 90 00 addiu $2, $3, -28672
# %lo(loc0 - .tdata - 0x7000) --^
-# DIS: 00000000 l .tdata 00000000 loc0
+# DIS: 00000000 l O .tdata 00000000 loc0
# CHECK: Relocations [
# CHECK-NEXT: ]
diff --git a/test/ELF/mips-tls-static-64.s b/test/ELF/mips-tls-static-64.s
index 04f18fa57585..23c775fb32f5 100644
--- a/test/ELF/mips-tls-static-64.s
+++ b/test/ELF/mips-tls-static-64.s
@@ -11,8 +11,8 @@
# CHECK-NEXT: 30010 ffff9004
#
# CHECK: SYMBOL TABLE:
-# CHECK: 0000000000020004 .text 00000000 __tls_get_addr
-# CHECK: 0000000000000000 g .tdata 00000000 tls1
+# CHECK: 0000000000020004 .text 00000000 __tls_get_addr
+# CHECK: 0000000000000000 g O .tdata 00000000 tls1
.text
.global __start
diff --git a/test/ELF/mips-tls-static.s b/test/ELF/mips-tls-static.s
index b09f5516bc89..9a1294003f48 100644
--- a/test/ELF/mips-tls-static.s
+++ b/test/ELF/mips-tls-static.s
@@ -13,8 +13,8 @@
# CHECK-NEXT: 30020 ffff8000 00000001 00000000
#
# CHECK: SYMBOL TABLE:
-# CHECK: 0002000c .text 00000000 __tls_get_addr
-# CHECK: 00000000 g .tdata 00000000 tls1
+# CHECK: 0002000c .text 00000000 __tls_get_addr
+# CHECK: 00000000 g O .tdata 00000000 tls1
.text
.global __start
diff --git a/test/ELF/mips-tls.s b/test/ELF/mips-tls.s
index ece55c69b303..5e1f8a957d20 100644
--- a/test/ELF/mips-tls.s
+++ b/test/ELF/mips-tls.s
@@ -26,9 +26,9 @@
# DIS-NEXT: 30020 00000000 00000000 00000001 00000000
# DIS-NEXT: 30030 00000001 ffff8004
-# DIS: 00000000 l .tdata 00000000 loc
-# DIS: 00000004 g .tdata 00000000 bar
-# DIS: 00000000 g *UND* 00000000 foo
+# DIS: 00000000 l O .tdata 00000000 loc
+# DIS: 00000004 g O .tdata 00000000 bar
+# DIS: 00000000 g O *UND* 00000000 foo
# CHECK: Relocations [
# CHECK-NEXT: Section (7) .rel.dyn {
diff --git a/test/ELF/mips-traps.s b/test/ELF/mips-traps.s
new file mode 100644
index 000000000000..783d1f298374
--- /dev/null
+++ b/test/ELF/mips-traps.s
@@ -0,0 +1,22 @@
+# Check trap instruction encoding.
+
+# REQUIRES: mips
+
+# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux -mcpu=mips32r6 -o %t.o %s
+# RUN: ld.lld -r -o %t %t.o %t.o
+# RUN: llvm-objdump -d -r %t | FileCheck --check-prefix=EB %s
+
+# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux -mcpu=mips32r6 -o %t.o %s
+# RUN: ld.lld -r -o %t %t.o %t.o
+# RUN: llvm-objdump -d -r %t | FileCheck --check-prefix=EL %s
+
+# EB: 8: 04 17 00 01 sigrie 1
+# EL: 8: 01 00 17 04 sigrie 1
+
+ .text
+ lw $t9, %got(.data)($gp)
+ addiu $a0, $t9, %lo(.data)
+
+ .data
+data:
+ .word 0
diff --git a/test/ELF/msp430.s b/test/ELF/msp430.s
new file mode 100644
index 000000000000..96820acbc3f9
--- /dev/null
+++ b/test/ELF/msp430.s
@@ -0,0 +1,43 @@
+; REQUIRES: msp430
+; RUN: llvm-mc -filetype=obj -triple=msp430-elf -o %t1.o %s
+; RUN: echo -e '.global _start\n _start: nop' | llvm-mc -filetype=obj -triple=msp430-elf -o %t2.o -
+; RUN: ld.lld -o %t.exe --Tdata=0x2000 --Ttext=0x8000 --defsym=_byte=0x21 %t2.o %t1.o
+; RUN: llvm-objdump -s -d %t.exe | FileCheck %s
+
+;; Check handling of basic msp430 relocation types.
+
+ .text
+ .global foo
+foo:
+;; R_MSP430_10_PCREL
+ jmp _start
+
+; CHECK: Disassembly of section .text:
+; CHECK-NEXT: _start:
+; CHECK-NEXT: 8000: {{.*}} nop
+; CHECK: foo:
+; CHECK-NEXT: 8004: {{.*}} jmp $-4
+
+;; R_MSP430_16_BYTE
+ call #_start
+
+; CHECK: call #32768
+
+;; R_MSP430_16_PCREL_BYTE
+ mov #-1, _start
+
+; CHECK: 800a: {{.*}} mov #-1, -12
+
+ .data
+;; R_MSP430_8
+ .byte _byte
+;; R_MSP430_16
+ .word _start
+;; R_MSP430_32
+ .long _start
+
+; CHECK: Contents of section .data:
+; CHECK-NEXT: 2000 21008000 800000
+
+; RUN: od -x %t.exe | FileCheck -check-prefix=TRAP %s
+; TRAP: 4343 4343 4343 4343 4343 4343 4343 4343
diff --git a/test/ELF/no-obj.s b/test/ELF/no-obj.s
index 1a4bf98c181e..4e8bcee2a1a0 100644
--- a/test/ELF/no-obj.s
+++ b/test/ELF/no-obj.s
@@ -1,5 +1,6 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: rm -f %t.a
// RUN: llvm-ar rcs %t.a %t.o
// RUN: not ld.lld -o /dev/null -u _start %t.a 2>&1 | FileCheck %s
diff --git a/test/ELF/note-first-page.s b/test/ELF/note-first-page.s
new file mode 100644
index 000000000000..a259344a1e5b
--- /dev/null
+++ b/test/ELF/note-first-page.s
@@ -0,0 +1,12 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld %t.o --build-id=md5 --shared -o %t.so
+# RUN: llvm-readelf -S %t.so | FileCheck %s
+
+# Check .note.gnu.build-id is placed before other potentially large sections
+# (.dynsym .dynstr (and .rela.dyn in PIE)). This ensures the note information
+# available in core files because various core dumpers ensure the first page is
+# available.
+
+# CHECK: [ 1] .note.gnu.build-id
+# CHECK: [ 2] .dynsym
diff --git a/test/ELF/oformat-binary.s b/test/ELF/oformat-binary.s
index e68f07c57732..22a25f04c64d 100644
--- a/test/ELF/oformat-binary.s
+++ b/test/ELF/oformat-binary.s
@@ -20,6 +20,7 @@
# ERR: unknown --oformat value: foo
# RUN: ld.lld -o /dev/null %t --oformat elf
+# RUN: ld.lld -o /dev/null %t --oformat elf-foo
.text
.align 4
diff --git a/test/ELF/pack-dyn-relocs-loop.s b/test/ELF/pack-dyn-relocs-loop.s
new file mode 100644
index 000000000000..308ead5cf5f2
--- /dev/null
+++ b/test/ELF/pack-dyn-relocs-loop.s
@@ -0,0 +1,66 @@
+// REQUIRES: arm, aarch64
+
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-android %s -o %t.o
+// RUN: ld.lld -shared %t.o -o %t.so --pack-dyn-relocs=android
+// RUN: llvm-readobj -s %t.so | FileCheck %s
+
+// This test is making sure the Android packed relocation support doesn't
+// cause an infinite loop due to the size of the section oscillating
+// (because the size of the section impacts the layout of the following
+// sections).
+
+// This test is very sensitive to the exact section sizes and offsets,
+// so check that they don't change.
+// CHECK: Name: .rela.dyn (33)
+// CHECK-NEXT: Type: SHT_ANDROID_RELA (0x60000002)
+// CHECK-NEXT: Flags [ (0x2)
+// CHECK-NEXT: SHF_ALLOC (0x2)
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address: 0x210
+// CHECK-NEXT: Offset: 0x210
+// CHECK-NEXT: Size: 21
+
+// CHECK: Name: x (43)
+// CHECK-NEXT: Type: SHT_PROGBITS (0x1)
+// CHECK-NEXT: Flags [ (0x2)
+// CHECK-NEXT: SHF_ALLOC (0x2)
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address: 0x225
+// CHECK-NEXT: Offset: 0x225
+// CHECK-NEXT: Size: 64980
+
+// CHECK: Name: barr (45)
+// CHECK-NEXT: Type: SHT_PROGBITS (0x1)
+// CHECK-NEXT: Flags [ (0x2)
+// CHECK-NEXT: SHF_ALLOC (0x2)
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address: 0xFFFA
+// CHECK-NEXT: Offset: 0xFFFA
+// CHECK-NEXT: Size: 0
+
+// CHECK: Name: foo (62)
+// CHECK-NEXT: Type: SHT_PROGBITS (0x1)
+// CHECK-NEXT: Flags [ (0x3)
+// CHECK-NEXT: SHF_ALLOC (0x2)
+// CHECK-NEXT: SHF_WRITE (0x1)
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address: 0x10004
+// CHECK-NEXT: Offset: 0x10004
+// CHECK-NEXT: Size: 12
+
+
+.data
+.long 0
+
+.section foo,"aw"
+foof:
+.long foof
+.long bar-53
+.long bar
+
+.section x,"a"
+.zero 64980
+
+.section barr,"a"
+.p2align 1
+bar:
diff --git a/test/ELF/pack-dyn-relocs-tls-aarch64.s b/test/ELF/pack-dyn-relocs-tls-aarch64.s
new file mode 100644
index 000000000000..978e2e7b2426
--- /dev/null
+++ b/test/ELF/pack-dyn-relocs-tls-aarch64.s
@@ -0,0 +1,34 @@
+// REQUIRES: aarch64
+
+// RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-linux %s -o %t.o
+// RUN: ld.lld -shared --pack-dyn-relocs=android %t.o -o %t.so
+// RUN: llvm-readobj -relocations %t.so | FileCheck %s
+
+// Bug 37841: Symbol::getVA must work on TLS symbols during the layout loop in
+// finalizeSections.
+
+ .global foo
+foo:
+ adrp x0, :tlsdesc:tlsvar1
+ ldr x1, [x0, :tlsdesc_lo12:tlsvar1]
+ add x0, x0, :tlsdesc_lo12:tlsvar1
+ .tlsdesccall tlsvar1
+
+// Also test an atypical IE access from a shared object to a local TLS symbol.
+
+ .global bar
+bar:
+ adrp x0, :gottprel:tlsvar2
+ ldr x0, [x0, #:gottprel_lo12:tlsvar2]
+
+ .section .tdata,"awT",@progbits
+ .space 0x1234
+tlsvar1:
+ .word 42
+tlsvar2:
+ .word 17
+
+// CHECK: Section ({{.+}}) .rela.dyn {
+// CHECK-NEXT: R_AARCH64_TLSDESC - 0x1234
+// CHECK-NEXT: R_AARCH64_TLS_TPREL64 - 0x1238
+// CHECK-NEXT: }
diff --git a/test/ELF/pack-dyn-relocs-tls-x86-64.s b/test/ELF/pack-dyn-relocs-tls-x86-64.s
new file mode 100644
index 000000000000..491efa6cc1d4
--- /dev/null
+++ b/test/ELF/pack-dyn-relocs-tls-x86-64.s
@@ -0,0 +1,23 @@
+// REQUIRES: x86
+
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: ld.lld -shared --pack-dyn-relocs=android %t.o -o %t.so
+// RUN: llvm-readobj -relocations %t.so | FileCheck %s
+
+// Bug 37841: Symbol::getVA must work on TLS symbols during the layout loop in
+// finalizeSections. This test uses an atypical IE access in a shared object to
+// access a local TLS symbol, because a more typical access would avoid the
+// bug.
+
+ .globl foo
+foo:
+ movq tlsvar@GOTTPOFF(%rip), %rcx
+
+ .section .tdata,"awT",@progbits
+ .space 0x1234
+tlsvar:
+ .word 42
+
+// CHECK: Section ({{.+}}) .rela.dyn {
+// CHECK-NEXT: R_X86_64_TPOFF64 - 0x1234
+// CHECK-NEXT: }
diff --git a/test/ELF/plt-aarch64.s b/test/ELF/plt-aarch64.s
index 8f637bf593f4..f9c53a46f3eb 100644
--- a/test/ELF/plt-aarch64.s
+++ b/test/ELF/plt-aarch64.s
@@ -85,6 +85,8 @@
// foo@plt
// Page(0x30018) - Page(0x10030) = 0x20000 - 0x10000 = 0x10000 = 65536
+// DISASMDSO-EMPTY:
+// DISASMDSO-NEXT: foo@plt:
// DISASMDSO-NEXT: 10030: 90 00 00 90 adrp x16, #65536
// 0x3018 & 0xFFF = 0x18 = 24
// DISASMDSO-NEXT: 10034: 11 0e 40 f9 ldr x17, [x16, #24]
@@ -93,6 +95,8 @@
// bar@plt
// Page(0x30020) - Page(0x10040) = 0x20000 - 0x10000 = 0x10000 = 65536
+// DISASMDSO-EMPTY:
+// DISASMDSO-NEXT: bar@plt:
// DISASMDSO-NEXT: 10040: 90 00 00 90 adrp x16, #65536
// 0x3020 & 0xFFF = 0x20 = 32
// DISASMDSO-NEXT: 10044: 11 12 40 f9 ldr x17, [x16, #32]
@@ -101,6 +105,8 @@
// weak@plt
// Page(0x30028) - Page(0x10050) = 0x20000 - 0x10000 = 0x10000 = 65536
+// DISASMDSO-EMPTY:
+// DISASMDSO-NEXT: weak@plt:
// DISASMDSO-NEXT: 10050: 90 00 00 90 adrp x16, #65536
// 0x3028 & 0xFFF = 0x28 = 40
// DISASMDSO-NEXT: 10054: 11 16 40 f9 ldr x17, [x16, #40]
@@ -113,7 +119,7 @@
// CHECKEXE-NEXT: SHF_ALLOC
// CHECKEXE-NEXT: SHF_EXECINSTR
// CHECKEXE-NEXT: ]
-// CHECKEXE-NEXT: Address: 0x20010
+// CHECKEXE-NEXT: Address: 0x210010
// CHECKEXE-NEXT: Offset:
// CHECKEXE-NEXT: Size: 64
// CHECKEXE-NEXT: Link:
@@ -126,7 +132,7 @@
// CHECKEXE-NEXT: SHF_ALLOC
// CHECKEXE-NEXT: SHF_WRITE
// CHECKEXE-NEXT: ]
-// CHECKEXE-NEXT: Address: 0x30000
+// CHECKEXE-NEXT: Address: 0x220000
// CHECKEXE-NEXT: Offset:
// CHECKEXE-NEXT: Size: 40
// CHECKEXE-NEXT: Link:
@@ -136,59 +142,63 @@
// CHECKEXE: Relocations [
// CHECKEXE-NEXT: Section ({{.*}}) .rela.plt {
-// &(.got.plt[3]) = 0x30000 + 3 * 8 = 0x30018
-// CHECKEXE-NEXT: 0x30018 R_AARCH64_JUMP_SLOT bar 0x0
+// &(.got.plt[3]) = 0x220000 + 3 * 8 = 0x220018
+// CHECKEXE-NEXT: 0x220018 R_AARCH64_JUMP_SLOT bar 0x0
-// &(.got.plt[4]) = 0x30000 + 4 * 8 = 0x30020
-// CHECKEXE-NEXT: 0x30020 R_AARCH64_JUMP_SLOT weak 0x0
+// &(.got.plt[4]) = 0x220000 + 4 * 8 = 0x220020
+// CHECKEXE-NEXT: 0x220020 R_AARCH64_JUMP_SLOT weak 0x0
// CHECKEXE-NEXT: }
// CHECKEXE-NEXT: ]
// DUMPEXE: Contents of section .got.plt:
// .got.plt[0..2] = 0 (reserved)
// .got.plt[3..4] = .plt = 0x40010
-// DUMPEXE-NEXT: 30000 00000000 00000000 00000000 00000000 ................
-// DUMPEXE-NEXT: 30010 00000000 00000000 10000200 00000000 ................
-// DUMPEXE-NEXT: 30020 10000200 00000000 ........
+// DUMPEXE-NEXT: 220000 00000000 00000000 00000000 00000000
+// DUMPEXE-NEXT: 220010 00000000 00000000 10002100 00000000
+// DUMPEXE-NEXT: 220020 10002100 00000000
// DISASMEXE: _start:
-// 0x2000c - 0x20000 = 0xc = 12
-// DISASMEXE-NEXT: 20000: 03 00 00 14 b #12
-// 0x20030 - 0x20004 = 0x2c = 44
-// DISASMEXE-NEXT: 20004: 0b 00 00 14 b #44
-// 0x20040 - 0x20008 = 0x38 = 56
-// DISASMEXE-NEXT: 20008: 0e 00 00 14 b #56
+// 0x21000c - 0x210000 = 0xc = 12
+// DISASMEXE-NEXT: 210000: 03 00 00 14 b #12
+// 0x210030 - 0x210004 = 0x2c = 44
+// DISASMEXE-NEXT: 210004: 0b 00 00 14 b #44
+// 0x210040 - 0x210008 = 0x38 = 56
+// DISASMEXE-NEXT: 210008: 0e 00 00 14 b #56
// DISASMEXE: foo:
-// DISASMEXE-NEXT: 2000c: 1f 20 03 d5 nop
+// DISASMEXE-NEXT: 21000c: 1f 20 03 d5 nop
// DISASMEXE: Disassembly of section .plt:
// DISASMEXE-NEXT: .plt:
-// DISASMEXE-NEXT: 20010: f0 7b bf a9 stp x16, x30, [sp, #-16]!
-// &(.got.plt[2]) = 0x300B0 + 2 * 8 = 0x300C0
-// Page(0x30010) - Page(0x20014) = 0x30000 - 0x20000 = 0x10000 = 65536
-// DISASMEXE-NEXT: 20014: 90 00 00 90 adrp x16, #65536
+// DISASMEXE-NEXT: 210010: f0 7b bf a9 stp x16, x30, [sp, #-16]!
+// &(.got.plt[2]) = 0x2200B0 + 2 * 8 = 0x2200C0
+// Page(0x220010) - Page(0x210014) = 0x220000 - 0x210000 = 0x10000 = 65536
+// DISASMEXE-NEXT: 210014: 90 00 00 90 adrp x16, #65536
// 0x120c0 & 0xFFF = 0xC0 = 192
-// DISASMEXE-NEXT: 20018: 11 0a 40 f9 ldr x17, [x16, #16]
-// DISASMEXE-NEXT: 2001c: 10 42 00 91 add x16, x16, #16
-// DISASMEXE-NEXT: 20020: 20 02 1f d6 br x17
-// DISASMEXE-NEXT: 20024: 1f 20 03 d5 nop
-// DISASMEXE-NEXT: 20028: 1f 20 03 d5 nop
-// DISASMEXE-NEXT: 2002c: 1f 20 03 d5 nop
+// DISASMEXE-NEXT: 210018: 11 0a 40 f9 ldr x17, [x16, #16]
+// DISASMEXE-NEXT: 21001c: 10 42 00 91 add x16, x16, #16
+// DISASMEXE-NEXT: 210020: 20 02 1f d6 br x17
+// DISASMEXE-NEXT: 210024: 1f 20 03 d5 nop
+// DISASMEXE-NEXT: 210028: 1f 20 03 d5 nop
+// DISASMEXE-NEXT: 21002c: 1f 20 03 d5 nop
// bar@plt
-// Page(0x40018) - Page(0x20030) = 0x30000 - 0x20000 = 0x10000 = 65536
-// DISASMEXE-NEXT: 20030: 90 00 00 90 adrp x16, #65536
-// DISASMEXE-NEXT: 20034: 11 0e 40 f9 ldr x17, [x16, #24]
-// DISASMEXE-NEXT: 20038: 10 62 00 91 add x16, x16, #24
-// DISASMEXE-NEXT: 2003c: 20 02 1f d6 br x17
+// Page(0x40018) - Page(0x210030) = 0x220000 - 0x210000 = 0x10000 = 65536
+// DISASMEXE-EMPTY:
+// DISASMEXE-NEXT: bar@plt:
+// DISASMEXE-NEXT: 210030: 90 00 00 90 adrp x16, #65536
+// DISASMEXE-NEXT: 210034: 11 0e 40 f9 ldr x17, [x16, #24]
+// DISASMEXE-NEXT: 210038: 10 62 00 91 add x16, x16, #24
+// DISASMEXE-NEXT: 21003c: 20 02 1f d6 br x17
// weak@plt
-// Page(0x40020) - Page(0x20040) = 0x30000 - 0x20000 = 0x10000 = 65536
-// DISASMEXE-NEXT: 20040: 90 00 00 90 adrp x16, #65536
-// DISASMEXE-NEXT: 20044: 11 12 40 f9 ldr x17, [x16, #32]
-// DISASMEXE-NEXT: 20048: 10 82 00 91 add x16, x16, #32
-// DISASMEXE-NEXT: 2004c: 20 02 1f d6 br x17
+// Page(0x40020) - Page(0x210040) = 0x220000 - 0x210000 = 0x10000 = 65536
+// DISASMEXE-EMPTY:
+// DISASMEXE-NEXT: weak@plt:
+// DISASMEXE-NEXT: 210040: 90 00 00 90 adrp x16, #65536
+// DISASMEXE-NEXT: 210044: 11 12 40 f9 ldr x17, [x16, #32]
+// DISASMEXE-NEXT: 210048: 10 82 00 91 add x16, x16, #32
+// DISASMEXE-NEXT: 21004c: 20 02 1f d6 br x17
.global _start,foo,bar
.weak weak
diff --git a/test/ELF/plt-i686.s b/test/ELF/plt-i686.s
index c24cab20e769..8a5863310eae 100644
--- a/test/ELF/plt-i686.s
+++ b/test/ELF/plt-i686.s
@@ -17,7 +17,7 @@
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: SHF_EXECINSTR
// CHECK-NEXT: ]
-// CHECK-NEXT: Address: 0x11020
+// CHECK-NEXT: Address: 0x401020
// CHECK-NEXT: Offset:
// CHECK-NEXT: Size: 48
// CHECK-NEXT: Link: 0
@@ -30,7 +30,7 @@
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: SHF_WRITE
// CHECK-NEXT: ]
-// CHECK-NEXT: Address: 0x12000
+// CHECK-NEXT: Address: 0x402000
// CHECK-NEXT: Offset: 0x2000
// CHECK-NEXT: Size: 20
// CHECK-NEXT: Link: 0
@@ -42,8 +42,8 @@
// 0x12000 + got.plt.reserved(12) + 4 = 0x12010
// CHECK: Relocations [
// CHECK-NEXT: Section ({{.*}}) .rel.plt {
-// CHECK-NEXT: 0x1200C R_386_JUMP_SLOT bar 0x0
-// CHECK-NEXT: 0x12010 R_386_JUMP_SLOT zed 0x0
+// CHECK-NEXT: 0x40200C R_386_JUMP_SLOT bar 0x0
+// CHECK-NEXT: 0x402010 R_386_JUMP_SLOT zed 0x0
// CHECK-NEXT: }
// CHECK-NEXT: ]
@@ -51,40 +51,44 @@
// values:
// 16 is the size of PLT[0]
-// (0x11010 + 16) - (0x11000 + 1) - 4 = 27
-// (0x11010 + 16) - (0x11005 + 1) - 4 = 22
-// (0x11020 + 16) - (0x1100a + 1) - 4 = 33
+// (0x401010 + 16) - (0x401000 + 1) - 4 = 27
+// (0x401010 + 16) - (0x401005 + 1) - 4 = 22
+// (0x401020 + 16) - (0x40100a + 1) - 4 = 33
// DISASM: local:
-// DISASM-NEXT: 11000: {{.*}}
-// DISASM-NEXT: 11002: {{.*}}
+// DISASM-NEXT: 401000: {{.*}}
+// DISASM-NEXT: 401002: {{.*}}
// DISASM: _start:
-// 0x11013 + 5 - 24 = 0x11000
-// DISASM-NEXT: 11004: e9 27 00 00 00 jmp 39
-// DISASM-NEXT: 11009: e9 22 00 00 00 jmp 34
-// DISASM-NEXT: 1100e: e9 2d 00 00 00 jmp 45
-// DISASM-NEXT: 11013: e9 e8 ff ff ff jmp -24
+// 0x401013 + 5 - 24 = 0x401000
+// DISASM-NEXT: 401004: e9 27 00 00 00 jmp 39
+// DISASM-NEXT: 401009: e9 22 00 00 00 jmp 34
+// DISASM-NEXT: 40100e: e9 2d 00 00 00 jmp 45
+// DISASM-NEXT: 401013: e9 e8 ff ff ff jmp -24
-// 0x11010 - 0x1102b - 5 = -32
-// 0x11010 - 0x1103b - 5 = -48
-// 77828 = 0x13004 = .got.plt (0x13000) + 4
-// 77832 = 0x13008 = .got.plt (0x13000) + 8
-// 77836 = 0x1300C = .got.plt (0x13000) + got.plt.reserved(12)
-// 77840 = 0x13010 = .got.plt (0x13000) + got.plt.reserved(12) + 4
+// 0x401010 - 0x40102b - 5 = -32
+// 0x401010 - 0x40103b - 5 = -48
+// 4202500 = 0x402004 = .got.plt (0x402000) + 4
+// 4202504 = 0x402008 = .got.plt (0x402000) + 8
+// 4202508 = 0x40200C = .got.plt (0x402000) + got.plt.reserved(12)
+// 4202512 = 0x402010 = .got.plt (0x402000) + got.plt.reserved(12) + 4
// DISASM: Disassembly of section .plt:
// DISASM-NEXT: .plt:
-// DISASM-NEXT: 11020: ff 35 04 20 01 00 pushl 73732
-// DISASM-NEXT: 11026: ff 25 08 20 01 00 jmpl *73736
-// DISASM-NEXT: 1102c: 90 nop
-// DISASM-NEXT: 1102d: 90 nop
-// DISASM-NEXT: 1102e: 90 nop
-// DISASM-NEXT: 1102f: 90 nop
-// DISASM-NEXT: 11030: ff 25 0c 20 01 00 jmpl *73740
-// DISASM-NEXT: 11036: 68 00 00 00 00 pushl $0
-// DISASM-NEXT: 1103b: e9 e0 ff ff ff jmp -32 <.plt>
-// DISASM-NEXT: 11040: ff 25 10 20 01 00 jmpl *73744
-// DISASM-NEXT: 11046: 68 08 00 00 00 pushl $8
-// DISASM-NEXT: 1104b: e9 d0 ff ff ff jmp -48 <.plt>
+// DISASM-NEXT: 401020: ff 35 04 20 40 00 pushl 4202500
+// DISASM-NEXT: 401026: ff 25 08 20 40 00 jmpl *4202504
+// DISASM-NEXT: 40102c: 90 nop
+// DISASM-NEXT: 40102d: 90 nop
+// DISASM-NEXT: 40102e: 90 nop
+// DISASM-NEXT: 40102f: 90 nop
+// DISASM-EMPTY:
+// DISASM-NEXT: bar@plt:
+// DISASM-NEXT: 401030: ff 25 0c 20 40 00 jmpl *4202508
+// DISASM-NEXT: 401036: 68 00 00 00 00 pushl $0
+// DISASM-NEXT: 40103b: e9 e0 ff ff ff jmp -32 <.plt>
+// DISASM-EMPTY:
+// DISASM-NEXT: zed@plt:
+// DISASM-NEXT: 401040: ff 25 10 20 40 00 jmpl *4202512
+// DISASM-NEXT: 401046: 68 08 00 00 00 pushl $8
+// DISASM-NEXT: 40104b: e9 d0 ff ff ff jmp -48 <.plt>
// CHECKSHARED: Name: .plt
// CHECKSHARED-NEXT: Type: SHT_PROGBITS
diff --git a/test/ELF/plt.s b/test/ELF/plt.s
index cce60d732063..21f0f12f03ea 100644
--- a/test/ELF/plt.s
+++ b/test/ELF/plt.s
@@ -73,12 +73,18 @@
// DISASM-NEXT: 1020: ff 35 e2 0f 00 00 pushq 4066(%rip)
// DISASM-NEXT: 1026: ff 25 e4 0f 00 00 jmpq *4068(%rip)
// DISASM-NEXT: 102c: 0f 1f 40 00 nopl (%rax)
+// DISASM-EMPTY:
+// DISASM-NEXT: bar@plt:
// DISASM-NEXT: 1030: ff 25 e2 0f 00 00 jmpq *4066(%rip)
// DISASM-NEXT: 1036: 68 00 00 00 00 pushq $0
// DISASM-NEXT: 103b: e9 e0 ff ff ff jmp -32 <.plt>
+// DISASM-EMPTY:
+// DISASM-NEXT: zed@plt:
// DISASM-NEXT: 1040: ff 25 da 0f 00 00 jmpq *4058(%rip)
// DISASM-NEXT: 1046: 68 01 00 00 00 pushq $1
// DISASM-NEXT: 104b: e9 d0 ff ff ff jmp -48 <.plt>
+// DISASM-EMPTY:
+// DISASM-NEXT: _start@plt:
// DISASM-NEXT: 1050: ff 25 d2 0f 00 00 jmpq *4050(%rip)
// DISASM-NEXT: 1056: 68 02 00 00 00 pushq $2
// DISASM-NEXT: 105b: e9 c0 ff ff ff jmp -64 <.plt>
@@ -102,9 +108,13 @@
// DISASM2-NEXT: 201020: ff 35 e2 0f 00 00 pushq 4066(%rip)
// DISASM2-NEXT: 201026: ff 25 e4 0f 00 00 jmpq *4068(%rip)
// DISASM2-NEXT: 20102c: 0f 1f 40 00 nopl (%rax)
+// DISASM2-EMPTY:
+// DISASM2-NEXT: bar@plt:
// DISASM2-NEXT: 201030: ff 25 e2 0f 00 00 jmpq *4066(%rip)
// DISASM2-NEXT: 201036: 68 00 00 00 00 pushq $0
// DISASM2-NEXT: 20103b: e9 e0 ff ff ff jmp -32 <.plt>
+// DISASM2-EMPTY:
+// DISASM2-NEXT: zed@plt:
// DISASM2-NEXT: 201040: ff 25 da 0f 00 00 jmpq *4058(%rip)
// DISASM2-NEXT: 201046: 68 01 00 00 00 pushq $1
// DISASM2-NEXT: 20104b: e9 d0 ff ff ff jmp -48 <.plt>
diff --git a/test/ELF/ppc-relocs.s b/test/ELF/ppc-relocs.s
index 26810008bd12..40536b6f3768 100644
--- a/test/ELF/ppc-relocs.s
+++ b/test/ELF/ppc-relocs.s
@@ -55,6 +55,17 @@ mystr:
# CHECK: .FR_PPC_REL24:
# CHECK: 1101c: 48 00 00 04 b .+4
+.section .R_PPC_REL14,"ax",@progbits
+.globl .FR_PPC_REL14
+.FR_PPC_REL14:
+ beq .Lfooy
+.section .R_PPC_REL14_2,"ax",@progbits
+.Lfooy:
+
+# CHECK: Disassembly of section .R_PPC_REL14:
+# CHECK: .FR_PPC_REL14:
+# CHECK: 11020: {{.*}} bt 2, .+4
+
.section .R_PPC_REL32,"ax",@progbits
.globl .FR_PPC_REL32
.FR_PPC_REL32:
@@ -64,7 +75,7 @@ mystr:
# CHECK: Disassembly of section .R_PPC_REL32:
# CHECK: .FR_PPC_REL32:
-# CHECK: 11020: 00 00 00 04
+# CHECK: 11024: 00 00 00 04
.section .R_PPC_ADDR32,"ax",@progbits
.globl .FR_PPC_ADDR32
@@ -75,7 +86,7 @@ mystr:
# CHECK: Disassembly of section .R_PPC_ADDR32:
# CHECK: .FR_PPC_ADDR32:
-# CHECK: 11024: 00 01 10 28
+# CHECK: 11028: 00 01 10 2c
.align 2
.section .R_PPC_PLTREL24,"ax",@progbits
@@ -87,4 +98,4 @@ mystr:
# CHECK: Disassembly of section .R_PPC_PLTREL24:
# CHECK: .R_PPC_PLTREL24:
-# CHECK: 11028: 48 00 00 04 b .+4
+# CHECK: 1102c: 48 00 00 04 b .+4
diff --git a/test/ELF/ppc64-bsymbolic-toc-restore.s b/test/ELF/ppc64-bsymbolic-toc-restore.s
new file mode 100644
index 000000000000..49d347c48992
--- /dev/null
+++ b/test/ELF/ppc64-bsymbolic-toc-restore.s
@@ -0,0 +1,68 @@
+# REQUIRES: ppc
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t1.o
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-bsymbolic-local-def.s -o %t2.o
+# RUN: ld.lld -Bsymbolic -shared %t1.o %t2.o -o %t
+# RUN: llvm-objdump -d -r %t | FileCheck %s
+# RUN: not ld.lld -shared %t1.o %t2.o -o %t 2>&1 | FileCheck --check-prefix=FAIL %s
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t1.o
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-bsymbolic-local-def.s -o %t2.o
+# RUN: ld.lld -Bsymbolic -shared %t1.o %t2.o -o %t
+# RUN: llvm-objdump -d -r %t | FileCheck %s
+# RUN: not ld.lld -shared %t1.o %t2.o -o %t 2>&1 | FileCheck --check-prefix=FAIL %s
+
+# FAIL: call lacks nop, can't restore toc
+
+# Test to document the toc-restore behavior with -Bsymbolic option. Since
+# -Bsymbolic causes the call to bind to the internal defintion we know the
+# caller and callee share the same TOC base. This means branching to the
+# local entry point of the callee, and no need for a nop to follow the call
+# (since there is no need to restore the TOC-pointer after the call).
+
+ .abiversion 2
+ .section ".text"
+
+ .p2align 2
+ .global caller
+ .type caller, @function
+caller:
+.Lcaller_gep:
+ addis 2, 12, .TOC.-.Lcaller_gep@ha
+ addi 2, 2, .TOC.-.Lcaller_gep@l
+.Lcaller_lep:
+ .localentry caller, .-caller
+ mflr 0
+ std 0, -16(1)
+ stdu 1, -32(1)
+ bl def
+ mr 31, 3
+ bl not_defined
+ nop
+ add 3, 3, 31
+ addi 1, 1, 32
+ ld 0, -16(1)
+ mtlr 0
+ blr
+
+# Note that the bl .+44 is a call to def's local entry, jumping past the first 2
+# instructions. Branching to the global entry would corrupt the TOC pointer
+# since the global entry requires that %r12 hold the address of the function
+# being called.
+
+# CHECK-LABEL: caller
+# CHECK: bl .+44
+# CHECK-NEXT: mr 31, 3
+# CHECK-NEXT: bl .+67108816
+# CHECK-NEXT: ld 2, 24(1)
+# CHECK-NEXT: add 3, 3, 31
+# CHECK-NEXT: addi 1, 1, 32
+# CHECK-NEXT: ld 0, -16(1)
+# CHECK-NEXT: mtlr 0
+# CHECK-NEXT: blr
+# CHECK-EMPTY:
+# CHECK-NEXT: def:
+# CHECK-NEXT: addis 2, 12, 2
+# CHECK-NEXT: addi 2, 2, -32636
+# CHECK-NEXT: li 3, 55
+# CHECK-NEXT: blr
diff --git a/test/ELF/ppc64-call-reach.s b/test/ELF/ppc64-call-reach.s
new file mode 100644
index 000000000000..a02bfa829933
--- /dev/null
+++ b/test/ELF/ppc64-call-reach.s
@@ -0,0 +1,94 @@
+# REQUIRES: ppc
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
+# RUN: ld.lld --defsym callee=0x12010010 --defsym tail_callee=0x12010020 \
+# RUN: %t.o -o %t
+# RUN: llvm-objdump -d %t | FileCheck %s
+# RUN: ld.lld --defsym callee=0x12010010 --defsym tail_callee=0x12010020 \
+# RUN: %t.o -o %t
+# RUN: llvm-objdump -d %t | FileCheck %s
+# RUN: ld.lld --defsym callee=0xE010014 --defsym tail_callee=0xE010024 \
+# RUN: %t.o -o %t
+# RUN: llvm-objdump -d %t | FileCheck --check-prefix=NEGOFFSET %s
+# RUN: ld.lld --defsym callee=0x12010018 --defsym tail_callee=0x12010028 \
+# RUN: %t.o -o %t
+# RUN: llvm-objdump -d %t | FileCheck --check-prefix=THUNK %s
+# RUN: llvm-readelf --sections %t | FileCheck --check-prefix=BRANCHLT %s
+# RUN: not ld.lld --defsym callee=0x1001002D --defsym tail_callee=0x1001002F \
+# RUN: %t.o -o %t 2>&1 | FileCheck --check-prefix=MISSALIGNED %s
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
+# RUN: ld.lld --defsym callee=0x12010010 --defsym tail_callee=0x12010020 \
+# RUN: %t.o -o %t
+# RUN: llvm-objdump -d %t | FileCheck %s
+# RUN: ld.lld --defsym callee=0x12010010 --defsym tail_callee=0x12010020 \
+# RUN: %t.o -o %t
+# RUN: llvm-objdump -d %t | FileCheck %s
+# RUN: ld.lld --defsym callee=0xE010014 --defsym tail_callee=0xE010024 \
+# RUN: %t.o -o %t
+# RUN: llvm-objdump -d %t | FileCheck --check-prefix=NEGOFFSET %s
+# RUN: ld.lld --defsym callee=0x12010018 --defsym tail_callee=0x12010028 \
+# RUN: %t.o -o %t
+# RUN: llvm-objdump -d %t | FileCheck --check-prefix=THUNK %s
+# RUN: llvm-readelf --sections %t | FileCheck --check-prefix=BRANCHLT %s
+# RUN: not ld.lld --defsym callee=0x1001002D --defsym tail_callee=0x1001002F \
+# RUN: %t.o -o %t 2>&1 | FileCheck --check-prefix=MISSALIGNED %s
+
+# MISSALIGNED: ld.lld: error: {{.*}}.o:(.text+0x14): improper alignment for relocation R_PPC64_REL24: 0x19 is not aligned to 4 bytes
+# MISSALIGNED: ld.lld: error: {{.*}}.o:(.text+0x24): improper alignment for relocation R_PPC64_REL24: 0xB is not aligned to 4 bytes
+
+ .global test
+ .p2align 4
+ .type test,@function
+test:
+.Lgep:
+ addis 2, 12, .TOC.-.Lgep@ha
+ addi 2, 2, .TOC.-.Lgep@l
+.Llep:
+ .localentry test, .Llep-.Lgep
+ mflr 0
+ std 0, 16(1)
+ stdu 1, 32(1)
+ bl callee
+ addi 1, 1, 32
+ ld 0, 16(1)
+ mtlr 0
+ b tail_callee
+
+# Check that we are branching to the definitions, and not range-extending
+# thunks.
+# CHECK-LABEL: test
+# CHECK: 10010014: {{.*}} bl .+33554428
+# CHECK: 10010024: {{.*}} b .+33554428
+
+# NEGOFFSET-LABEL: test
+# NEGOFFSET: 10010014: {{.*}} bl .+33554432
+# NEGOFFSET: 10010024: {{.*}} b .+33554432
+
+# .branch_lt[0]
+# THUNK-LABEL: __long_branch_callee:
+# THUNK-NEXT: 10010000: {{.*}} addis 12, 2, -1
+# THUNK-NEXT: ld 12, -32768(12)
+# THUNK-NEXT: mtctr 12
+# THUNK-NEXT: bctr
+
+# .branch_lt[1]
+# THUNK-LABEL: __long_branch_tail_callee:
+# THUNK-NEXT: 10010010: {{.*}} addis 12, 2, -1
+# THUNK-NEXT: ld 12, -32760(12)
+# THUNK-NEXT: mtctr 12
+# THUNK-NEXT: bctr
+
+# Each call now branches to a thunk, and although it is printed as positive
+# the offset is interpreted as a signed 26 bit value so 67108812 is actually
+# -52.
+# THUNK-LABEL: test:
+# THUNK: 10010034: {{.*}} bl .+67108812
+# THUNK: 10010044: {{.*}} b .+67108812
+
+# The offset from the TOC to the .branch_lt section is (-1 << 16) - 32768.
+# Name Type Address Off Size
+# BRANCHLT: .branch_lt PROGBITS 0000000010020000 020000 000010
+# BRANCHLT: .got PROGBITS 0000000010030000 030000 000008
+# BRANCHLT-NOT: .plt
+
diff --git a/test/ELF/ppc64-dq.s b/test/ELF/ppc64-dq.s
new file mode 100644
index 000000000000..b29879d02353
--- /dev/null
+++ b/test/ELF/ppc64-dq.s
@@ -0,0 +1,32 @@
+# REQUIRES: ppc
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
+# RUN: ld.lld %t.o -o %t
+# RUN: llvm-objdump -d %t | FileCheck %s
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
+# RUN: ld.lld %t.o -o %t
+# RUN: llvm-objdump -d %t | FileCheck %s
+
+ .global test
+ .p2align 4
+ .type test,@function
+test:
+.Lgep:
+ addis 2, 12, .TOC.-.Lgep@ha
+ addi 2, 2, .TOC.-.Lgep@l
+.Llep:
+ .localentry test, .Llep-.Lgep
+ addis 3, 2, qword@toc@ha
+ lxv 3, qword@toc@l(3)
+ addis 3, 2, qword@toc@ha
+ stxv 3, qword@toc@l(3)
+ blr
+
+ .comm qword, 16, 16
+
+# Verify that we don't overwrite any of the extended opcode bits on a DQ form
+# instruction.
+# CHECK-LABEL: test
+# CHECK: lxv 3, -32768(3)
+# CHECK: stxv 3, -32768(3)
diff --git a/test/ELF/ppc64-dtprel.s b/test/ELF/ppc64-dtprel.s
index 43922fa80382..e5ac83ac426a 100644
--- a/test/ELF/ppc64-dtprel.s
+++ b/test/ELF/ppc64-dtprel.s
@@ -2,15 +2,15 @@
// RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
// RUN: ld.lld -shared %t.o -o %t.so
-// RUN: llvm-readelf -relocations --wide %t.o | FileCheck --check-prefix=InputRelocs %s
-// RUN: llvm-readelf -relocations --wide %t.so | FileCheck --check-prefix=OutputRelocs %s
+// RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s
+// RUN: llvm-readelf -r %t.so | FileCheck --check-prefix=OutputRelocs %s
// RUN: llvm-objdump -D %t.so | FileCheck --check-prefix=Dis %s
// RUN: llvm-objdump -D %t.so | FileCheck --check-prefix=GotDisLE %s
// RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
// RUN: ld.lld -shared %t.o -o %t.so
-// RUN: llvm-readelf -relocations --wide %t.o | FileCheck --check-prefix=InputRelocs %s
-// RUN: llvm-readelf -relocations --wide %t.so | FileCheck --check-prefix=OutputRelocs %s
+// RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s
+// RUN: llvm-readelf -r %t.so | FileCheck --check-prefix=OutputRelocs %s
// RUN: llvm-objdump -D %t.so | FileCheck --check-prefix=Dis %s
// RUN: llvm-objdump -D %t.so | FileCheck --check-prefix=GotDisBE %s
diff --git a/test/ELF/ppc64_entry_point.s b/test/ELF/ppc64-entry-point.s
index a6f426c7eb10..6dbfc53d9abd 100644
--- a/test/ELF/ppc64_entry_point.s
+++ b/test/ELF/ppc64-entry-point.s
@@ -3,9 +3,11 @@
# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t
# RUN: ld.lld %t -o %t2
# RUN: llvm-objdump -D %t2 | FileCheck %s
+# RUN: llvm-objdump -D %t2 | FileCheck -check-prefix=CHECK-LE %s
# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t
# RUN: ld.lld %t -o %t2
+# RUN: llvm-objdump -D %t2 | FileCheck %s
# RUN: llvm-objdump -D %t2 | FileCheck -check-prefix=CHECK-BE %s
.text
@@ -36,14 +38,11 @@ _start:
// CHECK-NEXT: 10010004: {{.*}} addi 4, 4, 0
// CHECK-NEXT: 10010008: {{.*}} lis 5, 2
// CHECK-NEXT: 1001000c: {{.*}} addi 5, 5, -32768
-// CHECK: Disassembly of section .got:
-// CHECK-NEXT: .got:
-// CHECK-NEXT: 10020000: 00 80 02 10
-
-// CHECK-BE: 10010000: {{.*}} lis 4, 4097
-// CHECK-BE-NEXT: 10010004: {{.*}} addi 4, 4, 0
-// CHECK-BE-NEXT: 10010008: {{.*}} lis 5, 2
-// CHECK-BE-NEXT: 1001000c: {{.*}} addi 5, 5, -32768
+
+// CHECK-LE: Disassembly of section .got:
+// CHECK-LE-NEXT: .got:
+// CHECK-LE-NEXT: 10020000: 00 80 02 10
+
// CHECK-BE: Disassembly of section .got:
// CHECK-BE-NEXT: .got:
// CHECK-BE-NEXT: 10020000: 00 00 00 00 {{.*}}
diff --git a/test/ELF/ppc64-error-missaligned-dq.s b/test/ELF/ppc64-error-missaligned-dq.s
new file mode 100644
index 000000000000..68ad2e5c46f8
--- /dev/null
+++ b/test/ELF/ppc64-error-missaligned-dq.s
@@ -0,0 +1,26 @@
+# REQUIRES: ppc
+#
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
+# RUN: not ld.lld %t.o -o %t 2>&1 | FileCheck %s
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
+# RUN: not ld.lld %t.o -o %t 2>&1 | FileCheck %s
+
+# CHECK: improper alignment for relocation R_PPC64_TOC16_LO_DS: 0x8001 is not aligned to 16 bytes
+
+ .global test
+ .p2align 4
+ .type test,@function
+test:
+.Lgep:
+ addis 2, 12, .TOC.-.Lgep@ha
+ addi 2, 2, .TOC.-.Lgep@l
+.Llep:
+ .localentry test, .Llep-.Lgep
+ addis 3, 2, qword@toc@ha
+ lxv 3, qword@toc@l(3)
+ blr
+
+ .comm pad, 1, 1
+ .comm qword, 16, 1
+
diff --git a/test/ELF/ppc64-error-missaligned-ds.s b/test/ELF/ppc64-error-missaligned-ds.s
new file mode 100644
index 000000000000..deee8f9caa1b
--- /dev/null
+++ b/test/ELF/ppc64-error-missaligned-ds.s
@@ -0,0 +1,26 @@
+# REQUIRES: ppc
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
+# RUN: not ld.lld %t.o -o %t 2>&1 | FileCheck %s
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
+# RUN: not ld.lld %t.o -o %t 2>&1 | FileCheck %s
+
+# CHECK: improper alignment for relocation R_PPC64_TOC16_LO_DS: 0x8001 is not aligned to 4 bytes
+
+ .global test
+ .p2align 4
+ .type test,@function
+test:
+.Lgep:
+ addis 2, 12, .TOC.-.Lgep@ha
+ addi 2, 2, .TOC.-.Lgep@l
+.Llep:
+ .localentry test, .Llep-.Lgep
+ addis 3, 2, word@toc@ha
+ lwa 3, word@toc@l(3)
+ blr
+
+ .comm pad, 1, 1
+ .comm word, 4, 1
+
diff --git a/test/ELF/ppc64-func-entry-points.s b/test/ELF/ppc64-func-entry-points.s
index 640c94fe8cfb..1f23e6650a9c 100644
--- a/test/ELF/ppc64-func-entry-points.s
+++ b/test/ELF/ppc64-func-entry-points.s
@@ -75,6 +75,6 @@ glob:
// CHECK: foo_external_diff:
// CHECK-NEXT: 10010080: {{.*}} addis 2, 12, 2
// CHECK-NEXT: 10010084: {{.*}} addi 2, 2, 32640
-// CHECK-NEXT: 10010088: {{.*}} addis 5, 2, 0
+// CHECK-NEXT: 10010088: {{.*}} nop
// CHECK: foo_external_same:
// CHECK-NEXT: 100100b0: {{.*}} add 3, 4, 3
diff --git a/test/ELF/ppc64-gd-to-ie.s b/test/ELF/ppc64-gd-to-ie.s
index 1a6cc5b5f2a0..121032cafdc8 100644
--- a/test/ELF/ppc64-gd-to-ie.s
+++ b/test/ELF/ppc64-gd-to-ie.s
@@ -5,16 +5,16 @@
# RUN: ld.lld -shared %t2.o -o %t3.so
# RUN: ld.lld %t.o %t3.so -o %t
# RUN: llvm-objdump --section-headers %t | FileCheck --check-prefix=CheckGot %s
-# RUN: llvm-objdump -D %t | FileCheck --check-prefix=Dis %s
-# RUN: llvm-readelf -relocations --wide %t | FileCheck --check-prefix=OutputRelocs %s
+# RUN: llvm-objdump -d %t | FileCheck --check-prefix=Dis %s
+# RUN: llvm-readelf -r %t | FileCheck --check-prefix=OutputRelocs %s
# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-tls.s -o %t2.o
# RUN: ld.lld -shared %t2.o -o %t3.so
# RUN: ld.lld %t.o %t3.so -o %t
# RUN: llvm-objdump --section-headers %t | FileCheck --check-prefix=CheckGot %s
-# RUN: llvm-objdump -D %t | FileCheck --check-prefix=Dis %s
-# RUN: llvm-readelf -relocations --wide %t | FileCheck --check-prefix=OutputRelocs %s
+# RUN: llvm-objdump -d %t | FileCheck --check-prefix=Dis %s
+# RUN: llvm-readelf -r %t | FileCheck --check-prefix=OutputRelocs %s
.text
.abiversion 2
diff --git a/test/ELF/ppc64-general-dynamic-tls.s b/test/ELF/ppc64-general-dynamic-tls.s
index 66dab936575f..8ae25a91a087 100644
--- a/test/ELF/ppc64-general-dynamic-tls.s
+++ b/test/ELF/ppc64-general-dynamic-tls.s
@@ -2,17 +2,17 @@
// RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
// RUN: ld.lld -shared %t.o -o %t.so
-// RUN: llvm-readelf -relocations --wide %t.o | FileCheck --check-prefix=InputRelocs %s
-// RUN: llvm-readelf -relocations --wide %t.so | FileCheck --check-prefix=OutputRelocs %s
+// RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s
+// RUN: llvm-readelf -r %t.so | FileCheck --check-prefix=OutputRelocs %s
// RUN: llvm-objdump --section-headers %t.so | FileCheck --check-prefix=CheckGot %s
-// RUN: llvm-objdump -D %t.so | FileCheck --check-prefix=Dis %s
+// RUN: llvm-objdump -d %t.so | FileCheck --check-prefix=Dis %s
// RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
// RUN: ld.lld -shared %t.o -o %t.so
-// RUN: llvm-readelf -relocations --wide %t.o | FileCheck --check-prefix=InputRelocs %s
-// RUN: llvm-readelf -relocations --wide %t.so | FileCheck --check-prefix=OutputRelocs %s
+// RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s
+// RUN: llvm-readelf -r %t.so | FileCheck --check-prefix=OutputRelocs %s
// RUN: llvm-objdump --section-headers %t.so | FileCheck --check-prefix=CheckGot %s
-// RUN: llvm-objdump -D %t.so | FileCheck --check-prefix=Dis %s
+// RUN: llvm-objdump -d %t.so | FileCheck --check-prefix=Dis %s
.text
.abiversion 2
diff --git a/test/ELF/ppc64-got-indirect.s b/test/ELF/ppc64-got-indirect.s
index 2837582c4d6b..d81700a83dd9 100644
--- a/test/ELF/ppc64-got-indirect.s
+++ b/test/ELF/ppc64-got-indirect.s
@@ -83,8 +83,8 @@ glob:
# CHECK: _start:
# CHECK-NEXT: 10010000: {{.*}} addis 2, 12, 3
# CHECK-NEXT: 10010004: {{.*}} addi 2, 2, -32768
-# CHECK-NEXT: 10010008: {{.*}} addis 3, 2, 0
-# CHECK-NEXT: 1001000c: {{.*}} ld 3, -32760(3)
+# CHECK-NEXT: 10010008: {{.*}} nop
+# CHECK-NEXT: 1001000c: {{.*}} ld 3, -32760(2)
# CHECK: 1001001c: {{.*}} lwa 3, 0(3)
# CHECK-LE: Disassembly of section .data:
diff --git a/test/ELF/ppc64-got-off.s b/test/ELF/ppc64-got-off.s
new file mode 100644
index 000000000000..d3dff2262502
--- /dev/null
+++ b/test/ELF/ppc64-got-off.s
@@ -0,0 +1,67 @@
+# REQUIRES: ppc
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
+# RUN: ld.lld -shared --no-toc-optimize %t.o -o %t
+# RUN: llvm-objdump -d %t | FileCheck %s
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
+# RUN: ld.lld -shared --no-toc-optimize %t.o -o %t
+# RUN: llvm-objdump -d %t | FileCheck %s
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
+# RUN: ld.lld -shared %t.o -o %t
+# RUN: llvm-objdump -d %t | FileCheck --check-prefix=OPT %s
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
+# RUN: ld.lld -shared %t.o -o %t
+# RUN: llvm-objdump -d %t | FileCheck --check-prefix=OPT %s
+
+ .abiversion 2
+ .section ".text"
+
+ .p2align 2
+ .global func
+ .type func, @function
+func:
+.Lfunc_gep:
+ addis 2, 12, .TOC.-.Lfunc_gep@ha
+ addi 2, 2, .TOC.-.Lfunc_gep@l
+.Lfunc_lep:
+ .localentry func, .-func
+ addis 3, 2, a@got@ha
+ ld 3, a@got@l(3)
+ ld 4, a@got(2)
+ lis 5, a@got@h
+ ori 5, 5, a@got@l
+ li 6, 0
+ ori 6, 6, a@got
+ blr
+
+# CHECK-LABEL: func
+# CHECK: addis 3, 2, 0
+# CHECK-NEXT: ld 3, -32760(3)
+# CHECK-NEXT: ld 4, -32760(2)
+# CHECK-NEXT: lis 5, -1
+# CHECK-NEXT: ori 5, 5, 32776
+# CHECK-NEXT: li 6, 0
+# CHECK-NEXT: ori 6, 6, 32776
+
+# OPT-LABEL: func
+# OPT: nop
+# OPT-NEXT: ld 3, -32760(2)
+# OPT-NEXT: ld 4, -32760(2)
+# OPT-NEXT: lis 5, -1
+# OPT-NEXT: ori 5, 5, 32776
+# OPT-NEXT: li 6, 0
+# OPT-NEXT: ori 6, 6, 32776
+
+# Since the got entry for a is .got[1] and the TOC base points to
+# .got + 0x8000, the offset for a@got is -0x7FF8 --> -32760
+
+ .section ".data"
+ .global a
+ .type a, @object
+ .size a, 4
+ .p2align 2
+a:
+ .long 0x1000
diff --git a/test/ELF/ppc64-initial-exec-tls.s b/test/ELF/ppc64-initial-exec-tls.s
index 5218b68828ee..9cdd3e4375c4 100644
--- a/test/ELF/ppc64-initial-exec-tls.s
+++ b/test/ELF/ppc64-initial-exec-tls.s
@@ -4,19 +4,19 @@
// RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-tls.s -o %t2.o
// RUN: ld.lld -shared %t2.o -o %t2.so
// RUN: ld.lld -dynamic-linker /lib64/ld64.so.2 %t.o %t2.so -o %t
-// RUN: llvm-readelf -relocations --wide %t.o | FileCheck --check-prefix=InputRelocs %s
-// RUN: llvm-readelf -relocations --wide %t | FileCheck --check-prefix=OutputRelocs %s
+// RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s
+// RUN: llvm-readelf -r %t | FileCheck --check-prefix=OutputRelocs %s
// RUN: llvm-objdump --section-headers %t | FileCheck --check-prefix=CheckGot %s
-// RUN: llvm-objdump -D %t | FileCheck --check-prefix=Dis %s
+// RUN: llvm-objdump -d %t | FileCheck --check-prefix=Dis %s
// RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
// RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-tls.s -o %t2.o
// RUN: ld.lld -shared %t2.o -o %t2.so
// RUN: ld.lld -dynamic-linker /lib64/ld64.so.2 %t.o %t2.so -o %t
-// RUN: llvm-readelf -relocations --wide %t.o | FileCheck --check-prefix=InputRelocs %s
-// RUN: llvm-readelf -relocations --wide %t | FileCheck --check-prefix=OutputRelocs %s
+// RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s
+// RUN: llvm-readelf -r %t | FileCheck --check-prefix=OutputRelocs %s
// RUN: llvm-objdump --section-headers %t | FileCheck --check-prefix=CheckGot %s
-// RUN: llvm-objdump -D %t | FileCheck --check-prefix=Dis %s
+// RUN: llvm-objdump -d %t | FileCheck --check-prefix=Dis %s
.text
.abiversion 2
diff --git a/test/ELF/ppc64-local-dynamic.s b/test/ELF/ppc64-local-dynamic.s
index 57f324edbc63..6ed3b0fd8f07 100644
--- a/test/ELF/ppc64-local-dynamic.s
+++ b/test/ELF/ppc64-local-dynamic.s
@@ -2,17 +2,17 @@
// RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
// RUN: ld.lld -shared %t.o -o %t.so
-// RUN: llvm-readelf -relocations --wide %t.o | FileCheck --check-prefix=InputRelocs %s
-// RUN: llvm-readelf -relocations --wide %t.so | FileCheck --check-prefix=OutputRelocs %s
+// RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s
+// RUN: llvm-readelf -r %t.so | FileCheck --check-prefix=OutputRelocs %s
// RUN: llvm-objdump --section-headers %t.so | FileCheck --check-prefix=CheckGot %s
-// RUN: llvm-objdump -D %t.so | FileCheck --check-prefix=Dis %s
+// RUN: llvm-objdump -d %t.so | FileCheck --check-prefix=Dis %s
// RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
// RUN: ld.lld -shared %t.o -o %t.so
-// RUN: llvm-readelf -relocations --wide %t.o | FileCheck --check-prefix=InputRelocs %s
-// RUN: llvm-readelf -relocations --wide %t.so | FileCheck --check-prefix=OutputRelocs %s
+// RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s
+// RUN: llvm-readelf -r %t.so | FileCheck --check-prefix=OutputRelocs %s
// RUN: llvm-objdump --section-headers %t.so | FileCheck --check-prefix=CheckGot %s
-// RUN: llvm-objdump -D %t.so | FileCheck --check-prefix=Dis %s
+// RUN: llvm-objdump -d %t.so | FileCheck --check-prefix=Dis %s
.text
.abiversion 2
diff --git a/test/ELF/ppc64-local-exec-tls.s b/test/ELF/ppc64-local-exec-tls.s
index ff8c2b90102c..27e973dc4eb1 100644
--- a/test/ELF/ppc64-local-exec-tls.s
+++ b/test/ELF/ppc64-local-exec-tls.s
@@ -1,8 +1,8 @@
// REQUIRES: ppc
// RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
// RUN: ld.lld %t.o -o %t
-// RUN: llvm-readelf -relocations --wide %t.o | FileCheck --check-prefix=InputRelocs %s
-// RUN: llvm-objdump -D %t | FileCheck --check-prefix=Dis %s
+// RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s
+// RUN: llvm-objdump -d %t | FileCheck --check-prefix=Dis %s
.text
.abiversion 2
diff --git a/test/ELF/ppc64-long-branch.s b/test/ELF/ppc64-long-branch.s
new file mode 100644
index 000000000000..db662d926df0
--- /dev/null
+++ b/test/ELF/ppc64-long-branch.s
@@ -0,0 +1,121 @@
+# REQUIRES: ppc
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-func-global-entry.s -o %t2.o
+# RUN: ld.lld -shared %t2.o -o %t3.so
+# RUN: ld.lld --no-toc-optimize %t.o %t3.so -o %t
+# RUN: llvm-objdump -d -start-address=0x10010000 -stop-address=0x10010018 %t | FileCheck %s -check-prefix=CALLEE_DUMP
+# RUN: llvm-objdump -d -start-address=0x12010020 -stop-address=0x12010084 %t | FileCheck %s -check-prefix=CALLER_DUMP
+# RUN: llvm-objdump -D -start-address=0x12020008 -stop-address=0x12020010 %t | FileCheck %s -check-prefix=BRANCH_LT_LE
+# RUN: llvm-readelf --sections %t | FileCheck %s -check-prefix=SECTIONS
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-func-global-entry.s -o %t2.o
+# RUN: ld.lld -shared %t2.o -o %t3.so
+# RUN: ld.lld --no-toc-optimize %t.o %t3.so -o %t
+# RUN: llvm-objdump -d -start-address=0x10010000 -stop-address=0x10010018 %t | FileCheck %s -check-prefix=CALLEE_DUMP
+# RUN: llvm-objdump -d -start-address=0x12010020 -stop-address=0x12010084 %t | FileCheck %s -check-prefix=CALLER_DUMP
+# RUN: llvm-objdump -D -start-address=0x12020008 -stop-address=0x12020010 %t | FileCheck %s -check-prefix=BRANCH_LT_BE
+# RUN: llvm-readelf --sections %t | FileCheck %s -check-prefix=SECTIONS
+
+ .text
+ .abiversion 2
+ .protected callee
+ .globl callee
+ .p2align 4
+ .type callee,@function
+callee:
+.Lfunc_gep0:
+ addis 2, 12, .TOC.-.Lfunc_gep0@ha
+ addi 2, 2, .TOC.-.Lfunc_gep0@l
+.Lfunc_lep0:
+ .localentry callee, .Lfunc_lep0-.Lfunc_gep0
+ addis 4, 2, .LC0@toc@ha
+ ld 4, .LC0@toc@l(4)
+ lwz 3, 0(4)
+ blr
+
+ .space 0x2000000
+
+ .protected _start
+ .global _start
+ .p2align 4
+ .type _start,@function
+_start:
+.Lfunc_begin1:
+.Lfunc_gep1:
+ addis 2, 12, .TOC.-.Lfunc_gep1@ha
+ addi 2, 2, .TOC.-.Lfunc_gep1@l
+.Lfunc_lep1:
+ .localentry _start, .Lfunc_lep1-.Lfunc_gep1
+ mflr 0
+ std 0, 16(1)
+ stdu 1, -32(1)
+ bl callee
+ bl foo_external_diff
+ nop
+ addi 1, 1, 32
+ ld 0, 16(1)
+ mtlr 0
+
+ addis 4, 2, .LC1@toc@ha
+ ld 4, .LC1@toc@l(4)
+ lwz 4, 0(4)
+ add 3, 3, 4
+ blr
+
+
+ .section .toc,"aw",@progbits
+.LC0:
+ .tc a[TC],a
+.LC1:
+ .tc b[TC],b
+
+
+ .data
+ .type a,@object
+ .globl a
+ .p2align 2
+a:
+ .long 11
+ .size a, 4
+
+ .type b,@object
+ .global b
+ .p2align 2
+b:
+ .long 33
+ .size b, 4
+
+# Verify address of the callee
+# CALLEE_DUMP: callee:
+# CALLEE_DUMP: 10010000: {{.*}} addis 2, 12, 515
+# CALLEE_DUMP: 10010004: {{.*}} addi 2, 2, -32544
+# CALLEE_DUMP: 10010008: {{.*}} addis 4, 2, 0
+
+# Verify the address of _start, and the call to the long-branch thunk.
+# CALLER_DUMP: _start:
+# CALLER_DUMP: 12010020: {{.*}} addis 2, 12, 3
+# CALLER_DUMP: 12010038: {{.*}} bl .+56
+
+# Verify the thunks contents: TOC-pointer + offset = .branch_lt[0]
+# 0x120380e8 + (-2 << 16 + 32552) = 0x12020008
+# CALLER_DUMP: __long_branch_callee:
+# CALLER_DUMP: 12010060: {{.*}} addis 12, 2, -2
+# CALLER_DUMP: 12010064: {{.*}} ld 12, 32552(12)
+# CALLER_DUMP: 12010068: {{.*}} mtctr 12
+# CALLER_DUMP: 1201006c: {{.*}} bctr
+
+# BRANCH_LT_LE: Disassembly of section .branch_lt:
+# BRANCH_LT_LE-NEXT: .branch_lt:
+# BRANCH_LT_LE-NEXT: 12020008: 08 00 01 10
+# BRANCH_LT_LE-NEXT: 1202000c: 00 00 00 00
+
+# BRANCH_LT_BE: Disassembly of section .branch_lt:
+# BRANCH_LT_BE-NEXT: .branch_lt:
+# BRANCH_LT_BE-NEXT: 12020008: 00 00 00 00
+# BRANCH_LT_BE-NEXT: 1202000c: 10 01 00 08
+
+# [Nr] Name Type Address Off Size
+# SECTIONS: [ 9] .branch_lt PROGBITS 0000000012020008 2020008 000008
+# SECTIONS: [11] .got PROGBITS 00000000120300e0 20300e0 000008
diff --git a/test/ELF/ppc64-rel-so-local-calls.s b/test/ELF/ppc64-rel-so-local-calls.s
index 834dbd50aa90..2bc89d554a02 100644
--- a/test/ELF/ppc64-rel-so-local-calls.s
+++ b/test/ELF/ppc64-rel-so-local-calls.s
@@ -1,11 +1,11 @@
// REQUIRES: ppc
// RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
-// RUN: ld.lld -shared -z notext %t.o -o %t.so
+// RUN: ld.lld -shared %t.o -o %t.so
// RUN: llvm-readelf -dyn-relocations %t.so | FileCheck %s
// RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
-// RUN: ld.lld -shared -z notext %t.o -o %t.so
+// RUN: ld.lld -shared %t.o -o %t.so
// RUN: llvm-readelf -dyn-relocations %t.so | FileCheck %s
diff --git a/test/ELF/ppc64-relocs.s b/test/ELF/ppc64-relocs.s
index 88e3d4b13e5d..b439c4446654 100644
--- a/test/ELF/ppc64-relocs.s
+++ b/test/ELF/ppc64-relocs.s
@@ -63,7 +63,7 @@ _start:
# CHECK: Disassembly of section .R_PPC64_TOC16_HA:
# CHECK: .FR_PPC64_TOC16_HA:
-# CHECK: 10010018: {{.*}} addis 1, 2, 0
+# CHECK: 10010018: {{.*}} nop
.section .R_PPC64_REL24,"ax",@progbits
.globl .FR_PPC64_REL24
@@ -76,6 +76,17 @@ _start:
# CHECK: .FR_PPC64_REL24:
# CHECK: 1001001c: {{.*}} b .+4
+.section .R_PPC64_REL14,"ax",@progbits
+.globl .FR_PPC64_REL14
+.FR_PPC64_REL14:
+ beq .Lfooy
+.section .R_PPC64_REL14_2,"ax",@progbits
+.Lfooy:
+
+# CHECK: Disassembly of section .R_PPC64_REL14:
+# CHECK: .FR_PPC64_REL14:
+# CHECK: 10010020: {{.*}} bt 2, .+4
+
.section .R_PPC64_ADDR16_LO,"ax",@progbits
.globl .FR_PPC64_ADDR16_LO
.FR_PPC64_ADDR16_LO:
@@ -83,7 +94,7 @@ _start:
# CHECK: Disassembly of section .R_PPC64_ADDR16_LO:
# CHECK: .FR_PPC64_ADDR16_LO:
-# CHECK: 10010020: {{.*}} li 1, 0
+# CHECK: 10010024: {{.*}} li 1, 0
.section .R_PPC64_ADDR16_HI,"ax",@progbits
.globl .FR_PPC64_ADDR16_HI
@@ -92,7 +103,7 @@ _start:
# CHECK: Disassembly of section .R_PPC64_ADDR16_HI:
# CHECK: .FR_PPC64_ADDR16_HI:
-# CHECK: 10010024: {{.*}} li 1, 4097
+# CHECK: 10010028: {{.*}} li 1, 4097
.section .R_PPC64_ADDR16_HA,"ax",@progbits
.globl .FR_PPC64_ADDR16_HA
@@ -101,7 +112,7 @@ _start:
# CHECK: Disassembly of section .R_PPC64_ADDR16_HA:
# CHECK: .FR_PPC64_ADDR16_HA:
-# CHECK: 10010028: {{.*}} li 1, 4097
+# CHECK: 1001002c: {{.*}} li 1, 4097
.section .R_PPC64_ADDR16_HIGHER,"ax",@progbits
.globl .FR_PPC64_ADDR16_HIGHER
@@ -110,7 +121,7 @@ _start:
# CHECK: Disassembly of section .R_PPC64_ADDR16_HIGHER:
# CHECK: .FR_PPC64_ADDR16_HIGHER:
-# CHECK: 1001002c: {{.*}} li 1, 0
+# CHECK: 10010030: {{.*}} li 1, 0
.section .R_PPC64_ADDR16_HIGHERA,"ax",@progbits
.globl .FR_PPC64_ADDR16_HIGHERA
@@ -119,7 +130,7 @@ _start:
# CHECK: Disassembly of section .R_PPC64_ADDR16_HIGHERA:
# CHECK: .FR_PPC64_ADDR16_HIGHERA:
-# CHECK: 10010030: {{.*}} li 1, 0
+# CHECK: 10010034: {{.*}} li 1, 0
.section .R_PPC64_ADDR16_HIGHEST,"ax",@progbits
.globl .FR_PPC64_ADDR16_HIGHEST
@@ -128,7 +139,7 @@ _start:
# CHECK: Disassembly of section .R_PPC64_ADDR16_HIGHEST:
# CHECK: .FR_PPC64_ADDR16_HIGHEST:
-# CHECK: 10010034: {{.*}} li 1, 0
+# CHECK: 10010038: {{.*}} li 1, 0
.section .R_PPC64_ADDR16_HIGHESTA,"ax",@progbits
.globl .FR_PPC64_ADDR16_HIGHESTA
@@ -137,7 +148,7 @@ _start:
# CHECK: Disassembly of section .R_PPC64_ADDR16_HIGHESTA:
# CHECK: .FR_PPC64_ADDR16_HIGHESTA:
-# CHECK: 10010038: {{.*}} li 1, 0
+# CHECK: 1001003c: {{.*}} li 1, 0
.section .R_PPC64_REL32, "ax",@progbits
.globl .FR_PPC64_REL32
@@ -149,20 +160,20 @@ _start:
# DATALE: Disassembly of section .rodata:
# DATALE: .rodata:
-# DATALE: 10000190: b4 fe 00 00
+# DATALE: 10000190: b8 fe 00 00
# DATABE: Disassembly of section .rodata:
# DATABE: .rodata:
-# DATABE: 10000190: 00 00 fe b4
+# DATABE: 10000190: 00 00 fe b8
# Address of rodata + value stored at rodata entry
# should equal address of LBB0_2.
# 0x10000190 + 0xfeb4 = 0x10010044
# CHECK: Disassembly of section .R_PPC64_REL32:
# CHECK: .FR_PPC64_REL32:
-# CHECK: 1001003c: {{.*}} addis 5, 2, 0
-# CHECK: 10010040: {{.*}} ld 5, -32736(5)
-# CHECK: 10010044: {{.*}} add 3, 3, 4
+# CHECK: 10010040: {{.*}} nop
+# CHECK: 10010044: {{.*}} ld 5, -32736(2)
+# CHECK: 10010048: {{.*}} add 3, 3, 4
.section .R_PPC64_REL64, "ax",@progbits
.globl .FR_PPC64_REL64
@@ -178,16 +189,16 @@ __foo:
# Check that address of eh_frame entry + value stored
# should equal the address of foo. Since it is not aligned,
-# the entry is not stored exactly at 100001a8. It starts at
-# address 0x100001aa and has the value 0xfeaa.
-# 0x100001aa + 0xfeaa = 0x10010054
+# the entry is not stored exactly at 10000198. It starts at
+# address 0x1000019a and has the value 0xfeaa.
+# 0x100001aa + 0xfeae = 0x10010058
# DATALE: Disassembly of section .eh_frame:
# DATALE: .eh_frame:
-# DATALE: 100001a8: {{.*}} aa fe
+# DATALE: 100001a8: {{.*}} ae fe
# DATABE: Disassembly of section .eh_frame:
# DATABE: .eh_frame:
-# DATABE: 100001b0: fe aa {{.*}}
+# DATABE: 100001b0: fe ae {{.*}}
# CHECK: __foo
-# CHECK-NEXT: 10010054: {{.*}} li 3, 0
+# CHECK-NEXT: 10010058: {{.*}} li 3, 0
diff --git a/test/ELF/ppc64-shared-long_branch.s b/test/ELF/ppc64-shared-long_branch.s
new file mode 100644
index 000000000000..34d53147a551
--- /dev/null
+++ b/test/ELF/ppc64-shared-long_branch.s
@@ -0,0 +1,114 @@
+# REQUIRES: ppc
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
+# RUN: ld.lld --no-toc-optimize -shared %t.o -o %t
+# RUN: llvm-objdump -d -start-address=0x10000 -stop-address=0x10018 %t | FileCheck %s -check-prefix=CALLEE_DUMP
+# RUN: llvm-objdump -d -start-address=0x2010020 -stop-address=0x2010070 %t | FileCheck %s -check-prefix=CALLER_DUMP
+# RUN: llvm-readelf --sections %t | FileCheck %s -check-prefix=SECTIONS
+# RUN: llvm-readelf --relocations %t | FileCheck %s -check-prefix=DYNRELOC
+
+
+# _start calls protected function callee. Since callee is protected no plt stub
+# is needed. The binary however has been padded out with space so that the call
+# distance is further then a bl instrution can reach.
+
+ .text
+ .abiversion 2
+ .protected callee
+ .global callee
+ .p2align 4
+ .type callee,@function
+callee:
+.Lfunc_gep0:
+ addis 2, 12, .TOC.-.Lfunc_gep0@ha
+ addi 2, 2, .TOC.-.Lfunc_gep0@l
+.Lfunc_lep0:
+ .localentry callee, .Lfunc_lep0-.Lfunc_gep0
+ addis 4, 2, .LC0@toc@ha
+ ld 4, .LC0@toc@l(4)
+ lwz 3, 0(4)
+ blr
+
+ .space 0x2000000
+
+ .protected _start
+ .globl _start
+ .p2align 4
+ .type _start,@function
+_start:
+.Lfunc_begin1:
+.Lfunc_gep1:
+ addis 2, 12, .TOC.-.Lfunc_gep1@ha
+ addi 2, 2, .TOC.-.Lfunc_gep1@l
+.Lfunc_lep1:
+ .localentry _start, .Lfunc_lep1-.Lfunc_gep1
+ mflr 0
+ std 0, 16(1)
+ stdu 1, -32(1)
+ bl callee
+ bl ext_callee
+ nop
+ addi 1, 1, 32
+ ld 0, 16(1)
+ mtlr 0
+
+ addis 4, 2, .LC1@toc@ha
+ ld 4, .LC1@toc@l(4)
+ lwz 4, 0(4)
+ add 3, 3, 4
+ blr
+
+
+ .section .toc,"aw",@progbits
+.LC0:
+ .tc a[TC],a
+.LC1:
+ .tc b[TC],b
+
+
+ .data
+ .type a,@object
+ .globl a
+ .p2align 2
+a:
+ .long 11
+ .size a, 4
+
+ .type b,@object
+ .globl b
+ .p2align 2
+b:
+ .long 33
+ .size b, 4
+
+# Verify address of the callee
+# CALLEE_DUMP: callee:
+# CALLEE_DUMP: 10000: {{.*}} addis 2, 12, 515
+# CALLEE_DUMP: 10004: {{.*}} addi 2, 2, -32528
+# CALLEE_DUMP: 10008: {{.*}} addis 4, 2, 0
+
+# Verify the address of _start, and the call to the long-branch thunk.
+# CALLER_DUMP: _start:
+# CALLER_DUMP: 2010020: {{.*}} addis 2, 12, 3
+# CALLER_DUMP: 2010038: {{.*}} bl .+56
+
+# Verify the thunks contents: TOC-pointer + offset = .branch_lt[0]
+# 0x20380F0 + 32552 = 0x2040018
+# CALLER_DUMP: __long_branch_callee:
+# CALLER_DUMP: 2010060: {{.*}} addis 12, 2, 0
+# CALLER_DUMP: 2010064: {{.*}} ld 12, 32552(12)
+# CALLER_DUMP: 2010068: {{.*}} mtctr 12
+# CALLER_DUMP: 201006c: {{.*}} bctr
+
+# .got section is at address 0x20300f0 so TOC pointer points to 0x20400F0.
+# .plt section has a 2 entry header and a single entry for the long branch.
+# [Nr] Name Type Address Off Size
+# SECTIONS: [11] .got PROGBITS 00000000020300f0 20300f0 000008
+# SECTIONS: [13] .plt NOBITS 0000000002040000 2030108 000018
+# SECTIONS: [14] .branch_lt NOBITS 0000000002040018 2030108 000008
+
+# There is a relative dynamic relocation for (.plt + 16 bytes), with a base
+# address equal to callees local entry point (0x10000 + 8).
+# DYNRELOC: Relocation section '.rela.dyn' at offset 0x{{[0-9a-f]+}} contains 3 entries:
+# DYNRELOC: Offset Info Type Symbol's Value
+# DYNRELOC: 0000000002040018 0000000000000016 R_PPC64_RELATIVE 10008
diff --git a/test/ELF/ppc64-split-stack-adjust-fail.s b/test/ELF/ppc64-split-stack-adjust-fail.s
new file mode 100644
index 000000000000..4ad1a9994d98
--- /dev/null
+++ b/test/ELF/ppc64-split-stack-adjust-fail.s
@@ -0,0 +1,53 @@
+# REQUIRES: ppc
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t1.o
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-no-split-stack.s -o %t2.o
+
+# RUN: not ld.lld --defsym __morestack=0x10010000 %t1.o %t2.o -o %t 2>&1 | FileCheck %s
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t1.o
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-no-split-stack.s -o %t2.o
+
+# RUN: not ld.lld --defsym __morestack=0x10010000 %t1.o %t2.o -o %t 2>&1 | FileCheck %s
+
+# CHECK: error: {{.*}}.o:(.text): wrong_regs (with -fsplit-stack) calls nss_callee (without -fsplit-stack), but couldn't adjust its prologue
+
+ .abiversion 2
+ .section ".text"
+
+ .p2align 2
+ .global wrong_regs
+ .type wrong_regs, @function
+
+wrong_regs:
+.Lwr_gep:
+ addis 2, 12, .TOC.-.Lwr_gep@ha
+ addi 2, 2, .TOC.-.Lwr_gep@l
+ .localentry wrong_regs, .-wrong_regs
+ ld 0, -0x7040(13)
+ addis 5, 2, -1
+ addi 5, 5, -32
+ addi 12, 1, -32
+ nop
+ cmpld 7, 12, 0
+ blt- 7, .Lwr_alloc_more
+.Lwr_body:
+ mflr 0
+ std 0, 16(1)
+ stdu 1, -32(1)
+ bl nss_callee
+ addi 1, 1, 32
+ ld 0, 16(1)
+ mtlr 0
+ blr
+.Lwr_alloc_more:
+ mflr 0
+ std 0, 16(1)
+ bl __morestack
+ ld 0, 16(1)
+ mtlr 0
+ blr
+ b .Lwr_body
+ .size wrong_regs, .-wrong_regs
+
+ .section .note.GNU-split-stack,"",@progbits
diff --git a/test/ELF/ppc64-split-stack-adjust-overflow.s b/test/ELF/ppc64-split-stack-adjust-overflow.s
new file mode 100644
index 000000000000..874f45cd0e7d
--- /dev/null
+++ b/test/ELF/ppc64-split-stack-adjust-overflow.s
@@ -0,0 +1,64 @@
+# REQUIRES: ppc
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t1.o
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-no-split-stack.s -o %t2.o
+
+# RUN: not ld.lld %t1.o %t2.o -o %t --defsym __morestack=0x10010000 2>&1 | \
+# RUN: FileCheck -check-prefix=OVERFLOW %s
+# RUN: not ld.lld %t1.o %t2.o -o %t --defsym __morestack=0x10010000 \
+# RUN: -split-stack-adjust-size 4097 2>&1 | FileCheck -check-prefix=OVERFLOW %s
+# RUN: ld.lld %t1.o %t2.o -o %t --defsym __morestack=0x10010000 -split-stack-adjust-size 4096
+# RUN: llvm-objdump -d %t | FileCheck %s
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t1.o
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-no-split-stack.s -o %t2.o
+
+# RUN: not ld.lld %t1.o %t2.o -o %t --defsym __morestack=0x10010000 2>&1 | \
+# RUN: FileCheck -check-prefix=OVERFLOW %s
+# RUN: not ld.lld %t1.o %t2.o -o %t --defsym __morestack=0x10010000 \
+# RUN: -split-stack-adjust-size 4097 2>&1 | FileCheck -check-prefix=OVERFLOW %s
+# RUN: ld.lld %t1.o %t2.o -o %t --defsym __morestack=0x10010000 -split-stack-adjust-size 4096
+# RUN: llvm-objdump -d %t | FileCheck %s
+
+# OVERFLOW: error: {{.*}}.o:(function caller: .text+0x8): split-stack prologue adjustment overflows
+
+ .p2align 2
+ .global caller
+ .type caller, @function
+caller:
+.Lcaller_gep:
+ addis 2, 12, .TOC.-.Lcaller_gep@ha
+ addi 2, 2, .TOC.-.Lcaller_gep@l
+ .localentry caller, .-caller
+ ld 0, -0x7040(13)
+ addis 12, 1, -32768
+ addi 12, 12, 4096
+ cmpld 7, 12, 0
+ blt- 7, .Lcaller_alloc_more
+.Lcaller_body:
+ mflr 0
+ std 0, 16(1)
+ stdu 1, -32(1)
+ bl nss_callee
+ addi 1, 1, 32
+ ld 0, 16(1)
+ mtlr 0
+ blr
+.Lcaller_alloc_more:
+ mflr 0
+ std 0, 16(1)
+ bl __morestack
+ ld 0, 16(1)
+ mtlr 0
+ blr
+ b .Lcaller_body
+ .size caller, .-caller
+
+# CHECK-LABEL: caller
+# CHECK: ld 0, -28736(13)
+# CHECK-NEXT: addis 12, 1, -32768
+# CHECK-NEXT: nop
+# CHECK-NEXT: cmpld 7, 12, 0
+# CHECK-NEXT: bt- 28, .+36
+
+.section .note.GNU-split-stack,"",@progbits
diff --git a/test/ELF/ppc64-split-stack-adjust-size-success.s b/test/ELF/ppc64-split-stack-adjust-size-success.s
new file mode 100644
index 000000000000..913d2625e92a
--- /dev/null
+++ b/test/ELF/ppc64-split-stack-adjust-size-success.s
@@ -0,0 +1,108 @@
+# REQUIRES: ppc
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t1.o
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-no-split-stack.s -o %t2.o
+
+# RUN: ld.lld %t1.o %t2.o -o %t --defsym __morestack=0x10010000 -split-stack-adjust-size 32768
+# RUN: llvm-objdump -d %t | FileCheck %s
+# RUN: ld.lld %t1.o %t2.o -o %t --defsym __morestack=0x10010000 -split-stack-adjust-size 4096
+# RUN: llvm-objdump -d %t | FileCheck %s -check-prefix=SMALL
+# RUN: ld.lld %t1.o %t2.o -o %t --defsym __morestack=0x10010000 -split-stack-adjust-size 0
+# RUN: llvm-objdump -d %t | FileCheck %s -check-prefix=ZERO
+# RUN: not ld.lld %t1.o %t2.o -o %t -split-stack-adjust-size -1 2>&1 | FileCheck %s -check-prefix=ERR
+# ERR: error: --split-stack-adjust-size: size must be >= 0
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t1.o
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-no-split-stack.s -o %t2.o
+
+# RUN: ld.lld %t1.o %t2.o -o %t --defsym __morestack=0x10010000 -split-stack-adjust-size 32768
+# RUN: llvm-objdump -d %t | FileCheck %s
+# RUN: ld.lld %t1.o %t2.o -o %t --defsym __morestack=0x10010000 -split-stack-adjust-size 4096
+# RUN: llvm-objdump -d %t | FileCheck %s -check-prefix=SMALL
+# RUN: ld.lld %t1.o %t2.o -o %t --defsym __morestack=0x10010000 -split-stack-adjust-size 0
+# RUN: llvm-objdump -d %t | FileCheck %s -check-prefix=ZERO
+ .p2align 2
+ .global caller
+ .type caller, @function
+caller:
+.Lcaller_gep:
+ addis 2, 12, .TOC.-.Lcaller_gep@ha
+ addi 2, 2, .TOC.-.Lcaller_gep@l
+ .localentry caller, .-caller
+ ld 0, -0x7040(13)
+ addi 12, 1, -32
+ nop
+ cmpld 7, 12, 0
+ blt- 7, .Lcaller_alloc_more
+.Lcaller_body:
+ mflr 0
+ std 0, 16(1)
+ stdu 1, -32(1)
+ bl nss_callee
+ addi 1, 1, 32
+ ld 0, 16(1)
+ mtlr 0
+ blr
+.Lcaller_alloc_more:
+ mflr 0
+ std 0, 16(1)
+ bl __morestack
+ ld 0, 16(1)
+ mtlr 0
+ blr
+ b .Lcaller_body
+ .size caller, .-caller
+
+# CHECK-LABEL: caller
+# CHECK: ld 0, -28736(13)
+# CHECK-NEXT: addis 12, 1, -1
+# CHECK-NEXT: addi 12, 12, 32736
+# CHECK-NEXT: cmpld 7, 12, 0
+# CHECK-NEXT: bt- 28, .+36
+
+# SMALL-LABEL: caller
+# SMALL: ld 0, -28736(13)
+# SMALL-NEXT: addi 12, 1, -4128
+# SMALL-NEXT: nop
+# SMALL-NEXT: cmpld 7, 12, 0
+# SMALL-NEXT: bt- 28, .+36
+
+# ZERO-LABEL: caller
+# ZERO: ld 0, -28736(13)
+# ZERO-NEXT: addi 12, 1, -32
+# ZERO-NEXT: nop
+# ZERO-NEXT: cmpld 7, 12, 0
+# ZERO-NEXT: bt- 28, .+36
+ .p2align 2
+ .global main
+ .type main, @function
+main:
+.Lmain_gep:
+ addis 2,12,.TOC.-.Lmain_gep@ha
+ addi 2,2,.TOC.-.Lmain_gep@l
+ .localentry main,.-main
+ ld 0,-0x7040(13)
+ addi 12,1,-32
+ nop
+ cmpld 7,12,0
+ blt- 7, .Lmain_morestack
+.Lmain_body:
+ mflr 0
+ std 0, 16(1)
+ stdu 1, -32(1)
+ bl caller
+ addi 1, 1, 32
+ ld 0, 16(1)
+ mtlr 0
+ blr
+.Lmain_morestack:
+ mflr 0
+ std 0, 16(1)
+ bl __morestack
+ ld 0, 16(1)
+ mtlr 0
+ blr
+ b .Lmain_body
+ .size main,.-main
+
+ .section .note.GNU-split-stack,"",@progbits
diff --git a/test/ELF/ppc64-split-stack-prologue-adjust-success.s b/test/ELF/ppc64-split-stack-prologue-adjust-success.s
new file mode 100644
index 000000000000..197df150c495
--- /dev/null
+++ b/test/ELF/ppc64-split-stack-prologue-adjust-success.s
@@ -0,0 +1,224 @@
+# REQUIRES: ppc
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t1.o
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-no-split-stack.s -o %t2.o
+# RUN: ld.lld --defsym __morestack=0x10010000 %t1.o %t2.o -o %t
+# RUN: llvm-objdump -d %t | FileCheck %s
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t1.o
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-no-split-stack.s -o %t2.o
+# RUN: ld.lld --defsym __morestack=0x10010000 %t1.o %t2.o -o %t
+# RUN: llvm-objdump -d %t | FileCheck %s
+
+ .abiversion 2
+ .section ".text"
+
+
+# A caller with a stack that is small enough that the addis instruction
+# from the split-stack prologue is unneeded, and after the prologue adjustment
+# the stack size still fits whithin 16 bits.
+ .p2align 2
+ .global caller_small_stack
+ .type caller_small_stack, @function
+caller_small_stack:
+.Lcss_gep:
+ addis 2, 12, .TOC.-.Lcss_gep@ha
+ addi 2, 2, .TOC.-.Lcss_gep@l
+ .localentry caller_small_stack, .-caller_small_stack
+ ld 0, -0x7040(13)
+ addi 12, 1, -32
+ nop
+ cmpld 7, 12, 0
+ blt- 7, .Lcss_alloc_more
+.Lcss_body:
+ mflr 0
+ std 0, 16(1)
+ stdu 1, -32(1)
+ bl nss_callee
+ addi 1, 1, 32
+ ld 0, 16(1)
+ mtlr 0
+ blr
+.Lcss_alloc_more:
+ mflr 0
+ std 0, 16(1)
+ bl __morestack
+ ld 0, 16(1)
+ mtlr 0
+ blr
+ b .Lcss_body
+ .size caller_small_stack, .-caller_small_stack
+
+# CHECK-LABEL: caller_small_stack
+# CHECK: ld 0, -28736(13)
+# CHECK-NEXT: addi 12, 1, -16416
+# CHECK-NEXT: nop
+# CHECK-NEXT: cmpld 7, 12, 0
+# CHECK-NEXT: bt- 28, .+36
+
+# A caller that has a stack size that fits whithin 16 bits, but the adjusted
+# stack size after prologue adjustment now overflows 16 bits needing both addis
+# and addi instructions.
+ .p2align 2
+ .global caller_med_stack
+ .type caller_med_stack, @function
+caller_med_stack:
+.Lcms_gep:
+ addis 2, 12, .TOC.-.Lcms_gep@ha
+ addi 12, 12, .TOC.-.Lcms_gep@l
+ .localentry caller_med_stack, .-caller_med_stack
+ ld 0, -0x7040(13)
+ addi 12, 1, -32764
+ nop
+ cmpld 7, 12, 0
+ blt- 7, .Lcms_alloc_more
+.Lcms_body:
+ mflr 0
+ std 0, 16(1)
+ stdu 1, -32764(1)
+ bl nss_callee
+ addi 1, 1, 32764
+ ld 0, 16(1)
+ mtlr 0
+ blr
+.Lcms_alloc_more:
+ mflr 0
+ std 0, 16(1)
+ bl __morestack
+ ld 0, 16(1)
+ mtlr 0
+ blr
+ b .Lcms_body
+ .size caller_med_stack, .-caller_med_stack
+
+# A caller with a large enough stack frame that both the addis and
+# addi instructions are used in the split-stack prologue.
+ .p2align 2
+ .global caller_large_stack
+ .type caller_large_stack, @function
+caller_large_stack:
+.Lcls_gep:
+ addis 2, 12, .TOC.-.Lcls_gep@ha
+ addi 12, 12, .TOC.-.Lcls_gep@l
+ .localentry caller_large_stack, .-caller_large_stack
+ ld 0, -0x7040(13)
+ addis 12, 1, -1
+ addi 12, 12, -32
+ cmpld 7, 12, 0
+ blt- 7, .Lcls_alloc_more
+.Lcls_body:
+ mflr 0
+ std 0, 16(1)
+ lis 0, -1
+ addi 0, 0, -32
+ stdux 1, 0, 1
+ bl nss_callee
+ ld 1, 0(1)
+ ld 0, 16(1)
+ mtlr 0
+ blr
+.Lcls_alloc_more:
+ mflr 0
+ std 0, 16(1)
+ bl __morestack
+ ld 0, 16(1)
+ mtlr 0
+ blr
+ b .Lcls_body
+ .size caller_large_stack, .-caller_large_stack
+
+# CHECK-LABEL: caller_large_stack
+# CHECK: ld 0, -28736(13)
+# CHECK-NEXT: addis 12, 1, -1
+# CHECK-NEXT: addi 12, 12, -16416
+# CHECK-NEXT: cmpld 7, 12, 0
+# CHECK-NEXT: bt- 28, .+44
+
+# A caller with a stack size that is larger then 16 bits, but aligned such that
+# the addi instruction is unneeded.
+ .p2align 2
+ .global caller_large_aligned_stack
+ .type caller_large_aligned_stack, @function
+caller_large_aligned_stack:
+.Lclas_gep:
+ addis 2, 12, .TOC.-.Lclas_gep@ha
+ addi 12, 12, .TOC.-.Lclas_gep@l
+ .localentry caller_large_aligned_stack, .-caller_large_aligned_stack
+ ld 0, -0x7040(13)
+ addis 12, 1, -2
+ nop
+ cmpld 7, 12, 0
+ blt- 7, .Lclas_alloc_more
+.Lclas_body:
+ mflr 0
+ std 0, 16(1)
+ lis 0, -2
+ stdux 1, 0, 1
+ bl nss_callee
+ ld 1, 0(1)
+ ld 0, 16(1)
+ mtlr 0
+ blr
+.Lclas_alloc_more:
+ mflr 0
+ std 0, 16(1)
+ bl __morestack
+ ld 0, 16(1)
+ mtlr 0
+ blr
+ b .Lclas_body
+ .size caller_large_aligned_stack, .-caller_large_aligned_stack
+
+# CHECK-LABEL: caller_large_aligned_stack
+# CHECK: ld 0, -28736(13)
+# CHECK-NEXT: addis 12, 1, -2
+# CHECK-NEXT: addi 12, 12, -16384
+# CHECK-NEXT: cmpld 7, 12, 0
+# CHECK-NEXT: bt- 28, .+40
+
+# main only calls split-stack functions or __morestack so
+# there should be no adjustment of its split-stack prologue.
+ .p2align 2
+ .global main
+ .type main, @function
+main:
+.Lmain_gep:
+ addis 2, 12,.TOC.-.Lmain_gep@ha
+ addi 2, 2,.TOC.-.Lmain_gep@l
+ .localentry main,.-main
+ ld 0, -0x7040(13)
+ addi 12,1,-32
+ nop
+ cmpld 7, 12,0
+ blt- 7, .Lmain_morestack
+.Lmain_body:
+ mflr 0
+ std 0, 16(1)
+ stdu 1, -32(1)
+ bl caller_small_stack
+ nop
+ bl caller_med_stack
+ nop
+ bl caller_large_stack
+ nop
+ bl caller_large_aligned_stack
+ addi 1, 1, 32
+ ld 0, 16(1)
+ mtlr 0
+ blr
+.Lmain_morestack:
+ mflr 0
+ std 0, 16(1)
+ bl __morestack
+ ld 0, 16(1)
+ mtlr 0
+ blr
+ b .Lmain_body
+ .size main,.-main
+# CHECK-LABEL: main
+# CHECK: ld 0, -28736(13)
+# CHECK-NEXT: addi 12, 1, -32
+# CHECK-NEXT: nop
+# CHECK-NEXT: cmpld 7, 12, 0
+
+ .section .note.GNU-split-stack,"",@progbits
diff --git a/test/ELF/ppc64-tls-gd-le-small.s b/test/ELF/ppc64-tls-gd-le-small.s
new file mode 100644
index 000000000000..f5a1ec6f01d6
--- /dev/null
+++ b/test/ELF/ppc64-tls-gd-le-small.s
@@ -0,0 +1,61 @@
+# REQUIRES: ppc
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
+# RUN: llvm-objdump -d -r %t.o | FileCheck --check-prefix=CHECK-INPUT %s
+# RUN: ld.lld --defsym __tls_get_addr=0x10001000 %t.o -o %t
+# RUN: llvm-objdump -d %t | FileCheck --check-prefix=CHECK-DIS %s
+# RUN: llvm-readelf -relocations %t | FileCheck --check-prefix=DYN-RELOCS %s
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
+# RUN: llvm-objdump -d -r %t.o | FileCheck --check-prefix=CHECK-INPUT %s
+# RUN: ld.lld --defsym __tls_get_addr=0x10001000 %t.o -o %t
+# RUN: llvm-objdump -d %t | FileCheck --check-prefix=CHECK-DIS %s
+# RUN: llvm-readelf -relocations %t | FileCheck --check-prefix=DYN-RELOCS %s
+
+# Test checks the relaxation of a 'small' general-dynamic tls access into a
+# local-exec tls access.
+
+ .text
+ .abiversion 2
+
+ .global test
+ .p2align 4
+ .type test, @function
+
+test:
+.Lgep:
+ addis 2, 12, .TOC.-.Lgep@ha
+ addi 2, 2, .TOC.-.Lgep@l
+ .localentry test, .-test
+ mflr 0
+ std 0, 16(1)
+ stdu 1, -32(1)
+ addi 3, 2, a@got@tlsgd
+ bl __tls_get_addr(a@tlsgd)
+ nop
+ lwz 3, 0(3)
+ addi 1, 1, 32
+ ld 0, 16(1)
+ mtlr 0
+ blr
+
+ .type a, @object
+ .section .tdata,"awT",@progbits
+ .global a
+ .p2align 2
+a:
+ .long 55
+ .size a, 4
+
+# CHECK-INPUT: addi 3, 2, 0
+# CHECK-INPUT-NEXT: R_PPC64_GOT_TLSGD16 a
+# CHECK-INPUT-NEXT: bl .+0
+# CHECK-INPUT-NEXT: R_PPC64_TLSGD a
+# CHECK-INPUT-NEXT: R_PPC64_REL24 __tls_get_addr
+
+# CHECK-DIS: addis 3, 13, 0
+# CHECK-DIS-NEXT: nop
+# CHECK-DIS-NEXT: addi 3, 3, -28672
+# CHECK-DIS-NEXT: lwz 3, 0(3)
+
+# DYN-RELOCS: There are no relocations in this file
diff --git a/test/ELF/ppc64-tls-gd-le.s b/test/ELF/ppc64-tls-gd-le.s
index c55ae5f670c1..7907d1104a2b 100644
--- a/test/ELF/ppc64-tls-gd-le.s
+++ b/test/ELF/ppc64-tls-gd-le.s
@@ -1,16 +1,16 @@
// REQUIRES: ppc
// RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
-// RUN: llvm-readelf -relocations --wide %t.o | FileCheck --check-prefix=InputRelocs %s
+// RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s
// RUN: ld.lld %t.o -o %t
-// RUN: llvm-objdump -D %t | FileCheck --check-prefix=Dis %s
-// RUN: llvm-readelf -relocations --wide %t | FileCheck --check-prefix=OutputRelocs %s
+// RUN: llvm-objdump -d %t | FileCheck --check-prefix=Dis %s
+// RUN: llvm-readelf -r %t | FileCheck --check-prefix=OutputRelocs %s
// RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
-// RUN: llvm-readelf -relocations --wide %t.o | FileCheck --check-prefix=InputRelocs %s
+// RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s
// RUN: ld.lld %t.o -o %t
-// RUN: llvm-objdump -D %t | FileCheck --check-prefix=Dis %s
-// RUN: llvm-readelf -relocations --wide %t | FileCheck --check-prefix=OutputRelocs %s
+// RUN: llvm-objdump -d %t | FileCheck --check-prefix=Dis %s
+// RUN: llvm-readelf -r %t | FileCheck --check-prefix=OutputRelocs %s
.text
.abiversion 2
diff --git a/test/ELF/ppc64-tls-ie-le.s b/test/ELF/ppc64-tls-ie-le.s
new file mode 100644
index 000000000000..358d3e862b62
--- /dev/null
+++ b/test/ELF/ppc64-tls-ie-le.s
@@ -0,0 +1,140 @@
+// REQUIRES: ppc
+
+// RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
+// RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-tls-ie-le.s -o %t2.o
+// RUN: ld.lld -dynamic-linker /lib64/ld64.so.2 %t.o %t2.o -o %t
+// RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s
+// RUN: llvm-readelf -r %t | FileCheck --check-prefix=OutputRelocs %s
+// RUN: llvm-objdump -d %t | FileCheck --check-prefix=Dis %s
+
+// RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
+// RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-tls-ie-le.s -o %t2.o
+// RUN: ld.lld -dynamic-linker /lib64/ld64.so.2 %t.o %t2.o -o %t
+// RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s
+// RUN: llvm-readelf -r %t | FileCheck --check-prefix=OutputRelocs %s
+// RUN: llvm-objdump -d %t | FileCheck --check-prefix=Dis %s
+
+ .text
+ .abiversion 2
+test1: # @test1
+ addis 3, 2, c@got@tprel@ha
+ ld 3, c@got@tprel@l(3)
+ lbzx 3, 3, c@tls
+ blr
+test2: # @test2
+ addis 3, 2, s@got@tprel@ha
+ ld 3, s@got@tprel@l(3)
+ lhzx 3, 3, s@tls
+ blr
+test3: # @test3
+ addis 3, 2, i@got@tprel@ha
+ ld 3, i@got@tprel@l(3)
+ lwzx 3, 3, i@tls
+ blr
+test4: # @test4
+ addis 3, 2, l@got@tprel@ha
+ ld 3, l@got@tprel@l(3)
+ ldx 3, 3, l@tls
+ blr
+test5: # @test5
+ addis 4, 2, c@got@tprel@ha
+ ld 4, c@got@tprel@l(4)
+ stbx 3, 4, c@tls
+ blr
+test6: # @test6
+ addis 4, 2, s@got@tprel@ha
+ ld 4, s@got@tprel@l(4)
+ sthx 3, 4, s@tls
+ blr
+test7: # @test7
+ addis 4, 2, i@got@tprel@ha
+ ld 4, i@got@tprel@l(4)
+ stwx 3, 4, i@tls
+ blr
+test8: # @test8
+ addis 4, 2, l@got@tprel@ha
+ ld 4, l@got@tprel@l(4)
+ stdx 3, 4, l@tls
+ blr
+test9: # @test9
+ addis 3, 2, i@got@tprel@ha
+ ld 3, i@got@tprel@l(3)
+ add 3, 3, i@tls
+ blr
+test_ds: # @test_ds
+ ld 4, l@got@tprel(2)
+ stdx 3, 4, l@tls
+ blr
+
+
+// Verify that the input has initial-exec tls relocation types.
+// InputRelocs: Relocation section '.rela.text'
+// InputRelocs: R_PPC64_GOT_TPREL16_HA {{0+}} c + 0
+// InputRelocs: R_PPC64_GOT_TPREL16_LO_DS {{0+}} c + 0
+// InputRelocs: R_PPC64_TLS {{0+}} c + 0
+// InputRelocs: R_PPC64_GOT_TPREL16_HA {{0+}} s + 0
+// InputRelocs: R_PPC64_GOT_TPREL16_LO_DS {{0+}} s + 0
+// InputRelocs: R_PPC64_TLS {{0+}} s + 0
+// InputRelocs: R_PPC64_GOT_TPREL16_HA {{0+}} i + 0
+// InputRelocs: R_PPC64_GOT_TPREL16_LO_DS {{0+}} i + 0
+// InputRelocs: R_PPC64_TLS {{0+}} i + 0
+// InputRelocs: R_PPC64_GOT_TPREL16_HA {{0+}} l + 0
+// InputRelocs: R_PPC64_GOT_TPREL16_LO_DS {{0+}} l + 0
+// InputRelocs: R_PPC64_TLS {{0+}} l + 0
+// InputRelocs: R_PPC64_GOT_TPREL16_DS {{0+}} l + 0
+// InputRelocs: R_PPC64_TLS {{0+}} l + 0
+
+// Verify that no initial-exec relocations exist for the dynamic linker.
+// OutputRelocs-NOT: R_PPC64_TPREL64 {{0+}} c + 0
+// OutputRelocs-NPT: R_PPC64_TPREL64 {{0+}} s + 0
+// OutputRelocs-NOT: R_PPC64_TPREL64 {{0+}} i + 0
+// OutputRelocs-NOT: R_PPC64_TPREL64 {{0+}} l + 0
+
+// Dis: test1:
+// Dis: nop
+// Dis: addis 3, 13, 0
+// Dis: lbz 3, -28672(3)
+
+// Dis: test2:
+// Dis: nop
+// Dis: addis 3, 13, 0
+// Dis: lhz 3, -28670(3)
+
+// Dis: test3:
+// Dis: nop
+// Dis: addis 3, 13, 0
+// Dis: lwz 3, -28668(3)
+
+// Dis: test4:
+// Dis: nop
+// Dis: addis 3, 13, 0
+// Dis: ld 3, -28664(3)
+
+// Dis: test5:
+// Dis: nop
+// Dis: addis 4, 13, 0
+// Dis: stb 3, -28672(4)
+
+// Dis: test6:
+// Dis: nop
+// Dis: addis 4, 13, 0
+// Dis: sth 3, -28670(4)
+
+// Dis: test7:
+// Dis: nop
+// Dis: addis 4, 13, 0
+// Dis: stw 3, -28668(4)
+
+// Dis: test8:
+// Dis: nop
+// Dis: addis 4, 13, 0
+// Dis: std 3, -28664(4)
+
+// Dis: test9:
+// Dis: nop
+// Dis: addis 3, 13, 0
+// Dis: addi 3, 3, -28668
+
+// Dis: test_ds:
+// Dis: addis 4, 13, 0
+// Dis: std 3, -28664(4)
diff --git a/test/ELF/ppc64-tls-ld-le.s b/test/ELF/ppc64-tls-ld-le.s
index d42d7b983c84..b684515e8b04 100644
--- a/test/ELF/ppc64-tls-ld-le.s
+++ b/test/ELF/ppc64-tls-ld-le.s
@@ -1,16 +1,16 @@
// REQUIRES: ppc
// RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
-// RUN: llvm-readelf -relocations --wide %t.o | FileCheck --check-prefix=InputRelocs %s
+// RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s
// RUN: ld.lld %t.o -o %t
-// RUN: llvm-objdump -D %t | FileCheck --check-prefix=Dis %s
-// RUN: llvm-readelf -relocations --wide %t | FileCheck --check-prefix=OutputRelocs %s
+// RUN: llvm-objdump -d %t | FileCheck --check-prefix=Dis %s
+// RUN: llvm-readelf -r %t | FileCheck --check-prefix=OutputRelocs %s
// RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
-// RUN: llvm-readelf -relocations --wide %t.o | FileCheck --check-prefix=InputRelocs %s
+// RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s
// RUN: ld.lld %t.o -o %t
-// RUN: llvm-objdump -D %t | FileCheck --check-prefix=Dis %s
-// RUN: llvm-readelf -relocations --wide %t | FileCheck --check-prefix=OutputRelocs %s
+// RUN: llvm-objdump -d %t | FileCheck --check-prefix=Dis %s
+// RUN: llvm-readelf -r %t | FileCheck --check-prefix=OutputRelocs %s
.text
.abiversion 2
diff --git a/test/ELF/ppc64-toc-addis-nop-lqsq.s b/test/ELF/ppc64-toc-addis-nop-lqsq.s
new file mode 100644
index 000000000000..da57f38804a4
--- /dev/null
+++ b/test/ELF/ppc64-toc-addis-nop-lqsq.s
@@ -0,0 +1,73 @@
+# REQUIRES: ppc
+
+# RUN: llvm-readelf -relocations --wide %p/Inputs/ppc64le-quadword-ldst.o | FileCheck --check-prefix=QuadInputRelocs %s
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/shared-ppc64.s -o %t2.o
+# RUN: ld.lld -shared %t2.o -o %t2.so
+
+# RUN: ld.lld %t2.so %p/Inputs/ppc64le-quadword-ldst.o -o %t
+# RUN: llvm-objdump -D %t | FileCheck --check-prefix=Dis %s
+
+# RUN: ld.lld --no-toc-optimize %t2.so %p/Inputs/ppc64le-quadword-ldst.o -o %t
+# RUN: llvm-objdump -D %t | FileCheck --check-prefix=NoOpt %s
+
+# QuadInputRelocs: Relocation section '.rela.text'
+# QuadInputRelocs: R_PPC64_TOC16_LO_DS 0000000000000000 quadLd
+# QuadInputRelocs: R_PPC64_TOC16_LO_DS 0000000000000010 quadSt
+
+# The powerpc backend doesn't support the quadword load/store instructions yet.
+# So they are tested by linking against an object file assembled with
+# `as -mpower9 -o ppc64le-quadword-ldst.o in.s` and checking the encoding of
+# the unknown instructions in the dissasembly. Source used as input:
+#quads:
+#.Lbegin_quads:
+#.Lgep_quads:
+# addis 2, 12, .TOC.-.Lgep_quads@ha
+# addi 2, 2, .TOC.-.Lgep_quads@l
+#.Llep_quads:
+#.localentry quads, .Llep_quads-.Lgep_quads
+# addis 3, 2, quadLd@toc@ha
+# lq 4, quadLd@toc@l(3)
+# addis 3, 2, quadSt@toc@ha
+# stq 4, quadSt@toc@l(3)
+# blr
+#
+# .p2align 4
+# .global quadLd
+# .lcomm quadLd, 16
+#
+# .global quadSt
+# .lcomm quadSt, 16
+
+
+# e0 82 7f 70 decodes to | 111000 | 00100 | 00010 | 16-bit imm |
+# | 56 | 4 | 2 | 32624 |
+# which is `lq r4, 32624(r2)`
+# f8 82 7f 82 decodes to | 111110 | 00100 | 00010 | 14-bit imm | 10 |
+# | 62 | 4 | 2 | 8160 | 2 |
+# The immediate represents a word offset so this dissasembles to:
+# `stq r4, 32640(r2)`
+# Dis-LABEL: quads:
+# Dis-NEXT: addis
+# Dis-NEXT: addi
+# Dis-NEXT: nop
+# Dis-NEXT: 70 7f 82 e0 <unknown>
+# Dis-NEXT: nop
+# Dis-NEXT: 82 7f 82 f8 <unknown>
+# Dis-NEXT: blr
+
+# e0 83 7f 70 decodes to | 111000 | 00100 | 00011 | 16-bit imm |
+# | 56 | 4 | 3 | 32624 |
+# `lq r4, 32624(r3)`
+# f8 83 7f 82 decodes to | 111110 | 00100 | 00010 | 14-bit imm | 10 |
+# | 62 | 4 | 2 | 8160 | 2 |
+# `stq r4, 32640(r3)`
+# NoOpt-LABEL: quads:
+# NoOpt-NEXT: addis
+# NoOpt-NEXT: addi
+# NoOpt-NEXT: addis 3, 2, 0
+# NoOpt-NEXT: 70 7f 83 e0 <unknown>
+# NoOpt-NEXT: addis 3, 2, 0
+# NoOpt-NEXT: 82 7f 83 f8 <unknown>
+# NoOpt-NEXT: blr
+
diff --git a/test/ELF/ppc64-toc-addis-nop.s b/test/ELF/ppc64-toc-addis-nop.s
new file mode 100644
index 000000000000..a8c850ca2593
--- /dev/null
+++ b/test/ELF/ppc64-toc-addis-nop.s
@@ -0,0 +1,272 @@
+# REQUIRES: ppc
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
+# RUN: llvm-readelf -relocations --wide %t.o | FileCheck --check-prefix=InputRelocs %s
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/shared-ppc64.s -o %t2.o
+# RUN: ld.lld -shared %t2.o -o %t2.so
+#
+# RUN: ld.lld %t2.so %t.o -o %t
+# RUN: llvm-objdump -D %t | FileCheck --check-prefix=Dis %s
+#
+# RUN: ld.lld --no-toc-optimize %t2.so %t.o -o %t
+# RUN: llvm-objdump -D %t | FileCheck --check-prefix=NoOpt %s
+
+# InputRelocs: Relocation section '.rela.text'
+# InputRelocs: R_PPC64_TOC16_HA
+# InputRelocs: R_PPC64_TOC16_LO
+# InputRelocs: R_PPC64_TOC16_LO_DS
+
+
+ .text
+ .abiversion 2
+
+ .global bytes
+ .p2align 4
+ .type bytes,@function
+bytes:
+.Lbytes_gep:
+ addis 2, 12, .TOC.-.Lbytes_gep@ha
+ addi 2, 2, .TOC.-.Lbytes_gep@l
+.Lbytes_lep:
+ .localentry bytes, .Lbytes_lep-.Lbytes_gep
+ addis 3, 2, byteLd@toc@ha
+ lbz 3, byteLd@toc@l(3)
+ addis 4, 2, byteSt@toc@ha
+ stb 3, byteSt@toc@l(4)
+ blr
+# Dis-LABEL: bytes
+# Dis-NEXT: addis
+# Dis-NEXT: addi
+# Dis-NEXT: nop
+# Dis-NEXT: lbz 3, 32624(2)
+# Dis-NEXT: nop
+# Dis-NEXT: stb 3, 32625(2)
+# Dis-NEXT: blr
+
+# NoOpt-LABEL: bytes
+# NoOpt-NEXT: addis
+# NoOpt-NEXT: addi
+# NoOpt-NEXT: addis 3, 2, 0
+# NoOpt-NEXT: lbz 3, 32624(3)
+# NoOpt-NEXT: addis 4, 2, 0
+# NoOpt-NEXT: stb 3, 32625(4)
+# NoOpt-NEXT: blr
+
+ .global halfs
+ .p2align 4
+ .type halfs,@function
+halfs:
+.Lhalfs_gep:
+ addis 2, 12, .TOC.-.Lhalfs_gep@ha
+ addi 2, 2, .TOC.-.Lhalfs_gep@l
+.Lhalfs_lep:
+ .localentry halfs, .Lhalfs_lep-.Lhalfs_gep
+ addis 3, 2, halfLd@toc@ha
+ lhz 3, halfLd@toc@l(3)
+ addis 4, 2, halfLd@toc@ha
+ lha 4, halfLd@toc@l(4)
+ addis 5, 2, halfSt@toc@ha
+ sth 4, halfSt@toc@l(5)
+ blr
+# Dis-LABEL: halfs
+# Dis-NEXT: addis
+# Dis-NEXT: addi
+# Dis-NEXT: nop
+# Dis-NEXT: lhz 3, 32626(2)
+# Dis-NEXT: nop
+# Dis-NEXT: lha 4, 32626(2)
+# Dis-NEXT: nop
+# Dis-NEXT: sth 4, 32628(2)
+# Dis-NEXT: blr
+
+# NoOpt-LABEL: halfs
+# NoOpt-NEXT: addis
+# NoOpt-NEXT: addi
+# NoOpt-NEXT: addis 3, 2, 0
+# NoOpt-NEXT: lhz 3, 32626(3)
+# NoOpt-NEXT: addis 4, 2, 0
+# NoOpt-NEXT: lha 4, 32626(4)
+# NoOpt-NEXT: addis 5, 2, 0
+# NoOpt-NEXT: sth 4, 32628(5)
+# NoOpt-NEXT: blr
+
+
+ .global words
+ .p2align 4
+ .type words,@function
+words:
+.Lwords_gep:
+ addis 2, 12, .TOC.-.Lwords_gep@ha
+ addi 2, 2, .TOC.-.Lwords_gep@l
+.Lwords_lep:
+ .localentry words, .Lwords_lep-.Lwords_gep
+ addis 3, 2, wordLd@toc@ha
+ lwz 3, wordLd@toc@l(3)
+ addis 4, 2, wordLd@toc@ha
+ lwa 4, wordLd@toc@l(4)
+ addis 5, 2, wordSt@toc@ha
+ stw 4, wordSt@toc@l(5)
+ blr
+# Dis-LABEL: words
+# Dis-NEXT: addis
+# Dis-NEXT: addi
+# Dis-NEXT: nop
+# Dis-NEXT: lwz 3, 32632(2)
+# Dis-NEXT: nop
+# Dis-NEXT: lwa 4, 32632(2)
+# Dis-NEXT: nop
+# Dis-NEXT: stw 4, 32636(2)
+# Dis-NEXT: blr
+
+# NoOpt-LABEL: words
+# NoOpt-NEXT: addis
+# NoOpt-NEXT: addi
+# NoOpt-NEXT: addis 3, 2, 0
+# NoOpt-NEXT: lwz 3, 32632(3)
+# NoOpt-NEXT: addis 4, 2, 0
+# NoOpt-NEXT: lwa 4, 32632(4)
+# NoOpt-NEXT: addis 5, 2, 0
+# NoOpt-NEXT: stw 4, 32636(5)
+# NoOpt-NEXT: blr
+
+ .global doublewords
+ .p2align 4
+ .type doublewords,@function
+doublewords:
+.Ldoublewords_gep:
+ addis 2, 12, .TOC.-.Ldoublewords_gep@ha
+ addi 2, 2, .TOC.-.Ldoublewords_gep@l
+.Ldoublewords_lep:
+ .localentry doublewords, .Ldoublewords_lep-.Ldoublewords_gep
+ addis 3, 2, dwordLd@toc@ha
+ ld 3, dwordLd@toc@l(3)
+ addis 4, 2, dwordSt@toc@ha
+ std 3, dwordSt@toc@l(4)
+ blr
+
+# Dis-LABEL: doublewords
+# Dis-NEXT: addis
+# Dis-NEXT: addi
+# Dis-NEXT: nop
+# Dis-NEXT: ld 3, 32640(2)
+# Dis-NEXT: nop
+# Dis-NEXT: std 3, 32648(2)
+# Dis-NEXT: blr
+
+# NoOpt-LABEL: doublewords
+# NoOpt-NEXT: addis
+# NoOpt-NEXT: addi
+# NoOpt-NEXT: addis 3, 2, 0
+# NoOpt-NEXT: ld 3, 32640(3)
+# NoOpt-NEXT: addis 4, 2, 0
+# NoOpt-NEXT: std 3, 32648(4)
+# NoOpt-NEXT: blr
+
+ .global vec_dq
+ .p2align 4
+ .type vec_dq,@function
+vec_dq:
+.Lvec_dq_gep:
+ addis 2, 12, .TOC.-.Lvec_dq_gep@ha
+ addi 2, 2, .TOC.-.Lvec_dq_gep@l
+.Lvec_dq_lep:
+ .localentry vec_dq, .Lvec_dq_lep-.Lvec_dq_gep
+ addis 3, 2, vecLd@toc@ha
+ lxv 3, vecLd@toc@l(3)
+ addis 3, 2, vecSt@toc@ha
+ stxv 3, vecSt@toc@l(3)
+ blr
+
+# Dis-LABEL: vec_dq
+# Dis-NEXT: addis
+# Dis-NEXT: addi
+# Dis-NEXT: nop
+# Dis-NEXT: lxv 3, 32656(2)
+# Dis-NEXT: nop
+# Dis-NEXT: stxv 3, 32672(2)
+# Dis-NEXT: blr
+
+# NoOpt-LABEL: vec_dq
+# NoOpt-NEXT: addis
+# NoOpt-NEXT: addi
+# NoOpt-NEXT: addis 3, 2, 0
+# NoOpt-NEXT: lxv 3, 32656(3)
+# NoOpt-NEXT: addis 3, 2, 0
+# NoOpt-NEXT: stxv 3, 32672(3)
+# NoOpt-NEXT: blr
+
+ .global vec_ds
+ .p2align 4
+ .type vec_ds,@function
+vec_ds:
+.Lvec_ds_gep:
+ addis 2, 12, .TOC.-.Lvec_ds_gep@ha
+ addi 2, 2, .TOC.-.Lvec_ds_gep@l
+.Lvec_ds_lep:
+ .localentry vec_ds, .Lvec_dq_lep-.Lvec_dq_gep
+ addis 3, 2, vecLd@toc@ha
+ lxsd 3, vecLd@toc@l(3)
+ addis 3, 2, vecSt@toc@ha
+ stxsd 3, vecSt@toc@l(3)
+ addis 3, 2, vecLd@toc@ha
+ lxssp 3, vecLd@toc@l(3)
+ addis 3, 2, vecSt@toc@ha
+ stxssp 3, vecSt@toc@l(3)
+ blr
+# Dis-LABEL: vec_ds
+# Dis-NEXT: addis
+# Dis-NEXT: addi
+# Dis-NEXT: nop
+# Dis-NEXT: lxsd 3, 32656(2)
+# Dis-NEXT: nop
+# Dis-NEXT: stxsd 3, 32672(2)
+# Dis-NEXT: nop
+# Dis-NEXT: lxssp 3, 32656(2)
+# Dis-NEXT: nop
+# Dis-NEXT: stxssp 3, 32672(2)
+# Dis-NEXT: blr
+
+# NoOpt-LABEL: vec_ds
+# NoOpt-NEXT: addis
+# NoOpt-NEXT: addi
+# NoOpt-NEXT: addis 3, 2, 0
+# NoOpt-NEXT: lxsd 3, 32656(3)
+# NoOpt-NEXT: addis 3, 2, 0
+# NoOpt-NEXT: stxsd 3, 32672(3)
+# NoOpt-NEXT: addis 3, 2, 0
+# NoOpt-NEXT: lxssp 3, 32656(3)
+# NoOpt-NEXT: addis 3, 2, 0
+# NoOpt-NEXT: stxssp 3, 32672(3)
+# NoOpt-NEXT: blr
+
+
+ .global byteLd
+ .lcomm byteLd, 1, 1
+
+ .global byteSt
+ .lcomm byteSt, 1, 1
+
+ .global halfLd
+ .lcomm halfLd, 2, 2
+
+ .global halfSt
+ .lcomm halfSt, 2, 2
+
+ .global wordLd
+ .lcomm wordLd, 4, 4
+
+ .global wordSt
+ .lcomm wordSt, 4, 4
+
+ .global dwordLd
+ .lcomm dwordLd, 8, 8
+
+ .global dwordSt
+ .lcomm dwordSt, 8, 8
+
+ .global vecLd
+ .lcomm vecLd, 16, 16
+
+ .global vecSt
+ .lcomm vecSt, 16, 16
diff --git a/test/ELF/ppc64-toc-rel.s b/test/ELF/ppc64-toc-rel.s
index ac156c78b3a4..5769e43fbb91 100644
--- a/test/ELF/ppc64-toc-rel.s
+++ b/test/ELF/ppc64-toc-rel.s
@@ -1,13 +1,15 @@
# REQUIRES: ppc
# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
-# RUN: llvm-readobj -relocations %t.o | FileCheck -check-prefix=RELOCS %s
+# RUN: llvm-readobj -relocations %t.o | FileCheck -check-prefix=RELOCS-LE %s
# RUN: ld.lld %t.o -o %t2
# RUN: llvm-objdump -D %t2 | FileCheck %s
+# RUN: llvm-objdump -D %t2 | FileCheck -check-prefix=CHECK-LE %s
# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
# RUN: llvm-readobj -relocations %t.o | FileCheck -check-prefix=RELOCS-BE %s
# RUN: ld.lld %t.o -o %t2
+# RUN: llvm-objdump -D %t2 | FileCheck %s
# RUN: llvm-objdump -D %t2 | FileCheck -check-prefix=CHECK-BE %s
# Make sure we calculate the offset correctly for a toc-relative access to a
@@ -45,15 +47,15 @@ _start:
# Verify the relocations that get emitted for the global variable are the
# expected ones.
-# RELOCS: Relocations [
-# RELOCS-NEXT: .rela.text {
-# RELOCS: 0x8 R_PPC64_TOC16_HA global_a 0x0
-# RELOCS: 0xC R_PPC64_TOC16_LO global_a 0x0
+# RELOCS-LE: Relocations [
+# RELOCS-LE-NEXT: .rela.text {
+# RELOCS-LE: 0x8 R_PPC64_TOC16_HA global_a 0x0
+# RELOCS-LE: 0xC R_PPC64_TOC16_LO global_a 0x0
# RELOCS-BE: Relocations [
# RELOCS-BE-NEXT: .rela.text {
# RELOCS-BE: 0xA R_PPC64_TOC16_HA global_a 0x0
-# RELOCS-NE: 0xE R_PPC64_TOC16_LO global_a 0x0
+# RELOCS-BE: 0xE R_PPC64_TOC16_LO global_a 0x0
# Want to check _start for the values used to build the offset from the TOC base
# to global_a. The .TOC. symbol is expected at address 0x10030000, and the
@@ -70,19 +72,9 @@ _start:
# CHECK-NEXT: global_a:
# CHECK-NEXT: 10020000: {{.*}}
-# CHECK: Disassembly of section .got:
-# CHECK-NEXT: .got:
-# CHECK-NEXT: 10030000: 00 80 03 10
-
-
-# CHECK-BE: Disassembly of section .text:
-# CHECK-BE-NEXT: _start:
-# CHECK-BE: 10010008: {{.*}} addis 3, 2, -1
-# CHECK-BE-NEXT: 1001000c: {{.*}} addi 3, 3, -32768
-
-# CHECK-BE: Disassembly of section .data:
-# CHECK-BE-NEXT: global_a:
-# CHECK-BE-NEXT: 10020000: {{.*}}
+# CHECK-LE: Disassembly of section .got:
+# CHECK-LE-NEXT: .got:
+# CHECK-LE-NEXT: 10030000: 00 80 03 10
# CHECK-BE: Disassembly of section .got:
# CHECK-BE-NEXT: .got:
diff --git a/test/ELF/ppc64-toc-restore-recursive-call.s b/test/ELF/ppc64-toc-restore-recursive-call.s
new file mode 100644
index 000000000000..4bedcfecf383
--- /dev/null
+++ b/test/ELF/ppc64-toc-restore-recursive-call.s
@@ -0,0 +1,52 @@
+# REQUIRES: ppc
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t1.o
+# RUN: ld.lld -shared %t1.o -o %t
+# RUN: llvm-objdump -d -r %t | FileCheck %s
+
+# For a recursive call that is interposable the linker calls the plt-stub rather
+# then calling the function directly. Since the call is through a plt stub and
+# might be interposed with a different definition at runtime, a toc-restore is
+# required to follow the call.
+
+# The decision to use a plt-stub for the recursive call is not one I feel
+# strongly about either way. It was done because it matches what bfd and gold do
+# for recursive calls as well as keeps the logic for recursive calls consistent
+# with non-recursive calls.
+
+# CHECK-LABEL: __plt_recursive_func:
+# CHECK-NEXT: 10000:
+# CHECK-LABEL: recursive_func
+# CHECK-NEXT: 10014:
+# CHECK: 1003c: {{[0-9a-fA-F ]+}} bl .+67108804
+# CHECK-NEXT: ld 2, 24(1)
+
+ .abiversion 2
+ .section ".text"
+ .p2align 2
+ .global recursive_func
+ .type recursive_func, @function
+recursive_func:
+.Lrf_gep:
+ addis 2, 12, .TOC.-.Lrf_gep@ha
+ addi 2, 2, .TOC.-.Lrf_gep@l
+ .localentry recursive_func, .-recursive_func
+ cmpldi 3, 2
+ blt 0, .Lend
+
+ mflr 0
+ std 0, 16(1)
+ stdu 1, -32(1)
+ addi 5, 3, -1
+ mulld 4, 4, 3
+ mr 3, 5
+ bl recursive_func
+ nop
+ mr 4, 3
+ addi 1, 1, 32
+ ld 0, 16(1)
+ mtlr 0
+
+.Lend:
+ extsw 3, 4
+ blr
diff --git a/test/ELF/ppc64-toc-restore.s b/test/ELF/ppc64-toc-restore.s
index 9efe0e81f5e5..d9e06ca6e596 100644
--- a/test/ELF/ppc64-toc-restore.s
+++ b/test/ELF/ppc64-toc-restore.s
@@ -22,7 +22,7 @@ bar_local:
blr
# Calling external function foo in a shared object needs a nop.
-# Calling local function bar_local doe snot need a nop.
+# Calling local function bar_local doe not need a nop.
.global _start
_start:
bl foo
diff --git a/test/ELF/ppc64-tocopt-option.s b/test/ELF/ppc64-tocopt-option.s
new file mode 100644
index 000000000000..78494346beb5
--- /dev/null
+++ b/test/ELF/ppc64-tocopt-option.s
@@ -0,0 +1,14 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: not ld.lld %t --toc-optimize -o /dev/null 2>&1 | FileCheck %s
+
+# CHECK: error: --toc-optimize is only supported on the PowerPC64 target
+
+ .global __start
+ .type __start,@function
+
+ .text
+ .quad 0
+ __start:
+
diff --git a/test/ELF/pr34660.s b/test/ELF/pr34660.s
index 53998ad0f728..9509b4e9d984 100644
--- a/test/ELF/pr34660.s
+++ b/test/ELF/pr34660.s
@@ -3,7 +3,7 @@
# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-none %s -o %t.o
# RUN: ld.lld --hash-style=sysv -shared %t.o -o %t
# RUN: llvm-objdump %t -d | FileCheck %s --check-prefix=DISASM
-# RUN: llvm-readelf %t -t | FileCheck %s --check-prefix=SYM
+# RUN: llvm-readelf %t --symbols | FileCheck %s --check-prefix=SYM
# It would be much easier to understand/read this test if llvm-objdump would print
# the immediates in hex.
diff --git a/test/ELF/progname.s b/test/ELF/progname.s
index ecd0fd872347..228e3f61e67a 100644
--- a/test/ELF/progname.s
+++ b/test/ELF/progname.s
@@ -17,7 +17,7 @@
// RUN: ld.lld -dynamic-list %t.dynlist -o %t %t.o %t.so
// RUN: llvm-readobj -dyn-symbols %t | FileCheck %s
-// CHECK: Name: __progname@
+// CHECK: Name: __progname
// CHECK-NEXT: Value: 0x201000
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global (0x1)
diff --git a/test/ELF/protected-shared.s b/test/ELF/protected-shared.s
index e69b10899dae..3501162e6153 100644
--- a/test/ELF/protected-shared.s
+++ b/test/ELF/protected-shared.s
@@ -32,7 +32,7 @@ bar:
// CHECK: DynamicSymbols [
// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: @
+// CHECK-NEXT: Name:
// CHECK-NEXT: Value: 0x0
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local (0x0)
@@ -41,7 +41,7 @@ bar:
// CHECK-NEXT: Section: Undefined (0x0)
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: foo@
+// CHECK-NEXT: Name: foo
// CHECK-NEXT: Value: 0x0
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
diff --git a/test/ELF/push-state.s b/test/ELF/push-state.s
index 5a01cd2eeedd..f3d55c3488b3 100644
--- a/test/ELF/push-state.s
+++ b/test/ELF/push-state.s
@@ -32,5 +32,8 @@
// RUN: ld.lld -o %t.exe -L%t.dir -push-state -static -pop-state %t1.o -lfoo
// RUN: not ld.lld -o %t.exe -L%t.dir -push-state -static %t1.o -lfoo
+// RUN: not ld.lld -o %t.exe -pop-state %t.a %t1.o -M 2>&1 | FileCheck -check-prefix=ERR %s
+// ERR: error: unbalanced --push-state/--pop-state
+
.globl _start
_start:
diff --git a/test/ELF/relative-dynamic-reloc-ppc64.s b/test/ELF/relative-dynamic-reloc-ppc64.s
index 83190a270048..d65ea275413c 100644
--- a/test/ELF/relative-dynamic-reloc-ppc64.s
+++ b/test/ELF/relative-dynamic-reloc-ppc64.s
@@ -32,7 +32,7 @@
// CHECK: DynamicSymbols [
// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: @
+// CHECK-NEXT: Name:
// CHECK-NEXT: Value: 0x0
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local
@@ -41,7 +41,7 @@
// CHECK-NEXT: Section: Undefined
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: external@
+// CHECK-NEXT: Name: external
// CHECK-NEXT: Value: 0x0
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
diff --git a/test/ELF/relative-dynamic-reloc.s b/test/ELF/relative-dynamic-reloc.s
index 0ed7e40f7436..24d03f28a43b 100644
--- a/test/ELF/relative-dynamic-reloc.s
+++ b/test/ELF/relative-dynamic-reloc.s
@@ -28,7 +28,7 @@
// CHECK: DynamicSymbols [
// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: @
+// CHECK-NEXT: Name:
// CHECK-NEXT: Value: 0x0
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local
@@ -37,7 +37,7 @@
// CHECK-NEXT: Section: Undefined
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: external@
+// CHECK-NEXT: Name: external
// CHECK-NEXT: Value: 0x0
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
diff --git a/test/ELF/relocatable-bss.s b/test/ELF/relocatable-bss.s
index becfbaed62df..716eb4abf2f6 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: 0xD8
+# CHECK-NEXT: SectionHeaderOffset: 0xE8
# CHECK-NEXT: Flags [
# CHECK-NEXT: ]
# CHECK-NEXT: HeaderSize:
diff --git a/test/ELF/relocatable-comdat-multiple.s b/test/ELF/relocatable-comdat-multiple.s
index bb7a78490fdd..6a8d83357cf0 100644
--- a/test/ELF/relocatable-comdat-multiple.s
+++ b/test/ELF/relocatable-comdat-multiple.s
@@ -8,7 +8,7 @@
# CHECK-NEXT: Group {
# CHECK-NEXT: Name: .group
# CHECK-NEXT: Index: 2
-# CHECK-NEXT: Link: 8
+# CHECK-NEXT: Link: 9
# CHECK-NEXT: Info: 1
# CHECK-NEXT: Type: COMDAT
# CHECK-NEXT: Signature: aaa
@@ -20,7 +20,7 @@
# CHECK-NEXT: Group {
# CHECK-NEXT: Name: .group
# CHECK-NEXT: Index: 5
-# CHECK-NEXT: Link: 8
+# CHECK-NEXT: Link: 9
# CHECK-NEXT: Info: 6
# CHECK-NEXT: Type: COMDAT
# CHECK-NEXT: Signature: bbb
diff --git a/test/ELF/relocatable-comdat.s b/test/ELF/relocatable-comdat.s
index 11aa30c7e6bd..98ef993d5d0d 100644
--- a/test/ELF/relocatable-comdat.s
+++ b/test/ELF/relocatable-comdat.s
@@ -30,7 +30,7 @@
# CHECK-NEXT: Group {
# CHECK-NEXT: Name: .group
# CHECK-NEXT: Index: 2
-# CHECK-NEXT: Link: 5
+# CHECK-NEXT: Link: 6
# CHECK-NEXT: Info: 1
# CHECK-NEXT: Type: COMDAT
# CHECK-NEXT: Signature: abc
diff --git a/test/ELF/relocatable-comdat2.s b/test/ELF/relocatable-comdat2.s
index 27844feae16e..3318fb6f10be 100644
--- a/test/ELF/relocatable-comdat2.s
+++ b/test/ELF/relocatable-comdat2.s
@@ -13,7 +13,7 @@
# CHECK-NEXT: Group {
# CHECK-NEXT: Name: .group
# CHECK-NEXT: Index: 2
-# CHECK-NEXT: Link: 7
+# CHECK-NEXT: Link: 8
# CHECK-NEXT: Info: 1
# CHECK-NEXT: Type: COMDAT
# CHECK-NEXT: Signature: bar
@@ -24,7 +24,7 @@
# CHECK-NEXT: Group {
# CHECK-NEXT: Name: .group
# CHECK-NEXT: Index: 4
-# CHECK-NEXT: Link: 7
+# CHECK-NEXT: Link: 8
# CHECK-NEXT: Info: 2
# CHECK-NEXT: Type: COMDAT
# CHECK-NEXT: Signature: zed
diff --git a/test/ELF/relocatable-compressed-input.s b/test/ELF/relocatable-compressed-input.s
index 47d8c111452d..7ef0cf0b051b 100644
--- a/test/ELF/relocatable-compressed-input.s
+++ b/test/ELF/relocatable-compressed-input.s
@@ -7,7 +7,7 @@
# RUN: ld.lld %t1 -o %t2 -r
# RUN: llvm-readobj -sections -section-data %t2 | FileCheck %s
-## Check we decompress section and remove ".z" prefix specific for zlib-gnu compression.
+## Check we uncompress section and remove ".z" prefix specific for zlib-gnu compression.
# CHECK: Section {
# CHECK: Index:
# CHECK: Name: .debug_str
diff --git a/test/ELF/relocatable-many-sections.s b/test/ELF/relocatable-many-sections.s
index 347f3f784f26..0d84c6bd78ba 100644
--- a/test/ELF/relocatable-many-sections.s
+++ b/test/ELF/relocatable-many-sections.s
@@ -9,8 +9,8 @@
## sections amount is greater than SHN_LORESERVE.
# RUN: llvm-readobj -file-headers %t | FileCheck %s --check-prefix=HDR
# HDR: ElfHeader {
-# HDR: SectionHeaderCount: 0 (65543)
-# HDR-NEXT: StringTableSectionIndex: 65535 (65541)
+# HDR: SectionHeaderCount: 0 (65544)
+# HDR-NEXT: StringTableSectionIndex: 65535 (65542)
## Check that:
## 1) 65541 is the index of .shstrtab section.
@@ -18,13 +18,15 @@
## 3) .symtab_shndxr entry size and alignment == 4.
## 4) .symtab_shndxr has size equal to
## (sizeof(.symtab) / entsize(.symtab)) * entsize(.symtab_shndxr) = 0x4 * 0x180048 / 0x18 == 0x04000c
+
# RUN: llvm-readelf -sections -symbols %t | FileCheck %s
-## [Nr] Name Type Address Off Size ES Flg Lk Inf Al
-# CHECK: [65538] .bar
-# CHECK-NEXT: [65539] .symtab SYMTAB 0000000000000000 000040 180078 18 65542 65539 8
-# CHECK-NEXT: [65540] .symtab_shndxr SYMTAB SECTION INDICES 0000000000000000 1800b8 040014 04 65539 0 4
-# CHECK-NEXT: [65541] .shstrtab STRTAB 0000000000000000 1c00cc 0f0035 00 0 0 1
-# CHECK-NEXT: [65542] .strtab STRTAB 0000000000000000 2b0101 00000c 00
+# [Nr] Name Type Address Off Size ES Flg Lk Inf Al
+# CHECK: [65539] .note.GNU-stack PROGBITS 0000000000000000 000040 000000 00 0 0 1
+# CHECK: [65540] .symtab SYMTAB 0000000000000000 000040 180078 18 65543 65539 8
+# CHECK: [65541] .symtab_shndxr SYMTAB SECTION INDICES 0000000000000000 1800b8 040014 04 65540 0 4
+# CHECK: [65542] .shstrtab STRTAB 0000000000000000 1c00cc 0f0045 00 0 0 1
+# CHECK: [65543] .strtab STRTAB 0000000000000000 2b0111 00000c 00 0 0 1
+
# 5) Check we are able to represent symbol foo with section (.bar) index > 0xFF00 (SHN_LORESERVE).
# CHECK: GLOBAL DEFAULT 65538 foo
diff --git a/test/ELF/relocatable-rel-iplt.s b/test/ELF/relocatable-rel-iplt.s
new file mode 100644
index 000000000000..773a09f52815
--- /dev/null
+++ b/test/ELF/relocatable-rel-iplt.s
@@ -0,0 +1,56 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=i686-- %s -o %t1.o
+# RUN: ld.lld -r %t1.o -o %t2.o
+# RUN: llvm-readobj -t %t2.o | FileCheck %s
+
+// CHECK: Symbols [
+// CHECK-NEXT: Symbol {
+// CHECK-NEXT: Name: (0)
+// CHECK-NEXT: Value: 0x0
+// CHECK-NEXT: Size: 0
+// CHECK-NEXT: Binding: Local (0x0)
+// CHECK-NEXT: Type: None (0x0)
+// CHECK-NEXT: Other: 0
+// CHECK-NEXT: Section: Undefined (0x0)
+// CHECK-NEXT: }
+// CHECK-NEXT: Symbol {
+// CHECK-NEXT: Name: (0)
+// CHECK-NEXT: Value: 0x0
+// CHECK-NEXT: Size: 0
+// CHECK-NEXT: Binding: Local (0x0)
+// CHECK-NEXT: Type: Section (0x3)
+// CHECK-NEXT: Other: 0
+// CHECK-NEXT: Section: .text (0x1)
+// CHECK-NEXT: }
+// CHECK-NEXT: Symbol {
+// CHECK-NEXT: Name: __rel_iplt_end (1)
+// CHECK-NEXT: Value: 0x0
+// CHECK-NEXT: Size: 0
+// CHECK-NEXT: Binding: Weak (0x2)
+// CHECK-NEXT: Type: None (0x0)
+// CHECK-NEXT: Other [ (0x2)
+// CHECK-NEXT: STV_HIDDEN (0x2)
+// CHECK-NEXT: ]
+// CHECK-NEXT: Section: Undefined (0x0)
+// CHECK-NEXT: }
+// CHECK-NEXT: Symbol {
+// CHECK-NEXT: Name: __rel_iplt_start (16)
+// CHECK-NEXT: Value: 0x0
+// CHECK-NEXT: Size: 0
+// CHECK-NEXT: Binding: Weak (0x2)
+// CHECK-NEXT: Type: None (0x0)
+// CHECK-NEXT: Other [ (0x2)
+// CHECK-NEXT: STV_HIDDEN (0x2)
+// CHECK-NEXT: ]
+// CHECK-NEXT: Section: Undefined (0x0)
+// CHECK-NEXT: }
+// CHECK-NEXT: ]
+
+ movl __rel_iplt_start, %eax
+ movl __rel_iplt_end, %eax
+ ret
+
+ .hidden __rel_iplt_start
+ .hidden __rel_iplt_end
+ .weak __rel_iplt_start
+ .weak __rel_iplt_end
diff --git a/test/ELF/relocatable.s b/test/ELF/relocatable.s
index 7cb2a084c935..7235ea03c288 100644
--- a/test/ELF/relocatable.s
+++ b/test/ELF/relocatable.s
@@ -4,6 +4,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/relocatable2.s -o %t3.o
# RUN: ld.lld -r %t1.o %t2.o %t3.o -o %t
# RUN: llvm-readobj -file-headers -sections -program-headers -symbols -r %t | FileCheck %s
+# RUN: llvm-objdump -section-headers %t | FileCheck -check-prefix=SECTION %s
# RUN: llvm-objdump -s -d %t | FileCheck -check-prefix=CHECKTEXT %s
## Test --relocatable alias
@@ -37,8 +38,8 @@
# CHECK-NEXT: ProgramHeaderEntrySize: 0
# CHECK-NEXT: ProgramHeaderCount: 0
# CHECK-NEXT: SectionHeaderEntrySize: 64
-# CHECK-NEXT: SectionHeaderCount: 7
-# CHECK-NEXT: StringTableSectionIndex: 5
+# CHECK-NEXT: SectionHeaderCount: 8
+# CHECK-NEXT: StringTableSectionIndex: 6
# CHECK-NEXT: }
# CHECK: Relocations [
@@ -51,6 +52,17 @@
# CHECK-NEXT: 0x4E R_X86_64_32S yyy 0x0
# CHECK-NEXT: }
+# SECTION: Sections:
+# SECTION: Idx Name Size Address Type
+# SECTION: 0 00000000 0000000000000000
+# SECTION: 1 .text 00000056 0000000000000000 TEXT
+# SECTION: 2 .rela.text 00000090 0000000000000000
+# SECTION: 3 .bss 00000018 0000000000000000 BSS
+# SECTION: 4 .note.GNU-stack 00000000 0000000000000000
+# SECTION: 5 .symtab 00000168 0000000000000000
+# SECTION: 6 .shstrtab 00000041 0000000000000000
+# SECTION: 7 .strtab 0000002d 0000000000000000
+
# CHECKTEXT: Disassembly of section .text:
# CHECKTEXT-NEXT: main:
# CHECKTEXT-NEXT: 0: c7 04 25 00 00 00 00 05 00 00 00 movl $5, 0
diff --git a/test/ELF/relocation-b-aarch64.test b/test/ELF/relocation-b-aarch64.test
index 24bf4b74ef92..152cc39d8ac3 100644
--- a/test/ELF/relocation-b-aarch64.test
+++ b/test/ELF/relocation-b-aarch64.test
@@ -9,9 +9,9 @@
# CHECK: Disassembly of section .text:
# CHECK-NEXT: foo:
-# CHECK-NEXT: 20000: 01 00 00 14 b #4
+# CHECK-NEXT: 210000: 01 00 00 14 b #4
# CHECK: bar:
-# CHECK-NEXT: 20004: ff ff ff 17 b #-4
+# CHECK-NEXT: 210004: ff ff ff 17 b #-4
!ELF
FileHeader:
diff --git a/test/ELF/relocation-before-merge-start.s b/test/ELF/relocation-before-merge-start.s
new file mode 100644
index 000000000000..3550fd2efa65
--- /dev/null
+++ b/test/ELF/relocation-before-merge-start.s
@@ -0,0 +1,9 @@
+// REQUIRES: x86
+// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux
+// RUN: not ld.lld %t.o -o /dev/null -shared 2>&1 | FileCheck %s
+// CHECK: relocation-before-merge-start.s.tmp.o:(.foo): offset is outside the section
+
+.data
+.long .foo - 1
+.section .foo,"aM",@progbits,4
+.quad 0
diff --git a/test/ELF/relocation-common.s b/test/ELF/relocation-common.s
index 71b1ac0e2e24..392c495b1f17 100644
--- a/test/ELF/relocation-common.s
+++ b/test/ELF/relocation-common.s
@@ -1,7 +1,7 @@
-// REQUIRES: x86
-// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
-// RUN: ld.lld %t -o %tout
-// RUN: llvm-objdump -t -d %tout | FileCheck %s
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld %t.o -o %t
+# RUN: llvm-objdump -t -d %t | FileCheck %s
.global _start
_start:
@@ -10,5 +10,5 @@ _start:
.global sym1
.comm sym1,4,4
-// CHECK: 201000: {{.*}} movl $1, 4086(%rip)
-// CHECK: 0000000000202000 g .bss 00000004 sym1
+# CHECK: 201000: {{.*}} movl $1, 4086(%rip)
+# CHECK: 0000000000202000 g O .bss 00000004 sym1
diff --git a/test/ELF/relocation-copy-i686.s b/test/ELF/relocation-copy-i686.s
index f9ee32e2b35e..8b14f9aadde6 100644
--- a/test/ELF/relocation-copy-i686.s
+++ b/test/ELF/relocation-copy-i686.s
@@ -21,7 +21,7 @@ movl $9, z
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: SHF_WRITE
// CHECK-NEXT: ]
-// CHECK-NEXT: Address: 0x13000
+// CHECK-NEXT: Address: 0x403000
// CHECK-NEXT: Offset:
// CHECK-NEXT: Size: 24
// CHECK-NEXT: Link: 0
@@ -52,12 +52,12 @@ movl $9, z
// CHECK-NEXT: }
// CHECK-NEXT: ]
-// 77824 = 0x13000
+// 4206592 = 0x403000
// 16 is alignment here
-// 77840 = 0x13000 + 16
-// 77844 = 0x13000 + 16 + 4
+// 4206608 = 0x403000 + 16
+// 4206612 = 0x403000 + 16 + 4
// CODE: Disassembly of section .text:
// CODE-NEXT: main:
-// CODE-NEXT: 11000: c7 05 00 30 01 00 05 00 00 00 movl $5, 77824
-// CODE-NEXT: 1100a: c7 05 10 30 01 00 07 00 00 00 movl $7, 77840
-// CODE-NEXT: 11014: c7 05 14 30 01 00 09 00 00 00 movl $9, 77844
+// CODE-NEXT: 401000: c7 05 00 30 40 00 05 00 00 00 movl $5, 4206592
+// CODE-NEXT: 40100a: c7 05 10 30 40 00 07 00 00 00 movl $7, 4206608
+// CODE-NEXT: 401014: c7 05 14 30 40 00 09 00 00 00 movl $9, 4206612
diff --git a/test/ELF/relocation-i686.s b/test/ELF/relocation-i686.s
index fdec7caa33be..6ca487c0ab11 100644
--- a/test/ELF/relocation-i686.s
+++ b/test/ELF/relocation-i686.s
@@ -27,14 +27,14 @@ R_386_PC32_2:
// CHECK: Disassembly of section .R_386_32:
// CHECK-NEXT: R_386_32:
-// CHECK-NEXT: 11000: {{.*}} movl $69633, %edx
+// CHECK-NEXT: 401000: {{.*}} movl $4198401, %edx
// CHECK: Disassembly of section .R_386_PC32:
// CHECK-NEXT: R_386_PC32:
-// CHECK-NEXT: 11005: e8 04 00 00 00 calll 4
+// CHECK-NEXT: 401005: e8 04 00 00 00 calll 4
// CHECK: R_386_PC32_2:
-// CHECK-NEXT: 1100e: 90 nop
+// CHECK-NEXT: 40100e: 90 nop
// Create a .got
movl bar@GOT, %eax
@@ -45,7 +45,7 @@ movl bar@GOT, %eax
// ADDR-NEXT: SHF_ALLOC
// ADDR-NEXT: SHF_EXECINSTR
// ADDR-NEXT: ]
-// ADDR-NEXT: Address: 0x11040
+// ADDR-NEXT: Address: 0x401040
// ADDR-NEXT: Offset: 0x1040
// ADDR-NEXT: Size: 32
@@ -55,7 +55,7 @@ movl bar@GOT, %eax
// ADDR-NEXT: SHF_ALLOC
// ADDR-NEXT: SHF_WRITE
// ADDR-NEXT: ]
-// ADDR-NEXT: Address: 0x13078
+// ADDR-NEXT: Address: 0x403078
// ADDR-NEXT: Offset:
// ADDR-NEXT: Size: 8
@@ -63,18 +63,18 @@ movl bar@GOT, %eax
R_386_GOTPC:
movl $_GLOBAL_OFFSET_TABLE_, %eax
-// 0x12078 + 8 - 0x11014 = 4204
+// 0x402078 + 8 - 0x401014 = 4204
// CHECK: Disassembly of section .R_386_GOTPC:
// CHECK-NEXT: R_386_GOTPC:
-// CHECK-NEXT: 11014: {{.*}} movl $8300, %eax
+// CHECK-NEXT: 401014: {{.*}} movl $8300, %eax
.section .dynamic_reloc, "ax",@progbits
call bar
-// addr(.plt) + 16 - (0x11019 + 5) = 50
+// addr(.plt) + 16 - (0x401019 + 5) = 50
// CHECK: Disassembly of section .dynamic_reloc:
// CHECK-NEXT: .dynamic_reloc:
-// CHECK-NEXT: 11019: e8 32 00 00 00 calll 50
+// CHECK-NEXT: 401019: e8 32 00 00 00 calll 50
.section .R_386_GOT32,"ax",@progbits
.global R_386_GOT32
@@ -84,13 +84,13 @@ R_386_GOT32:
movl bar+8@GOT, %eax
movl zed+4@GOT, %eax
-// 4294967288 = 0xFFFFFFF8 = got[0](0x12070) - .got(0x12070) - sizeof(.got)(8)
-// 4294967292 = 0xFFFFFFFC = got[1](0x12074) - .got(0x12070) - sizeof(.got)(8)
+// 4294967288 = 0xFFFFFFF8 = got[0](0x402070) - .got(0x402070) - sizeof(.got)(8)
+// 4294967292 = 0xFFFFFFFC = got[1](0x402074) - .got(0x402070) - sizeof(.got)(8)
// 0xFFFFFFF8 + 8 = 0
// 0xFFFFFFFC + 4 = 0
// CHECK: Disassembly of section .R_386_GOT32:
// CHECK-NEXT: R_386_GOT32:
-// CHECK-NEXT: 1101e: a1 f8 ff ff ff movl 4294967288, %eax
-// CHECK-NEXT: 11023: a1 fc ff ff ff movl 4294967292, %eax
-// CHECK-NEXT: 11028: a1 00 00 00 00 movl 0, %eax
-// CHECK-NEXT: 1102d: a1 00 00 00 00 movl 0, %eax
+// CHECK-NEXT: 40101e: a1 f8 ff ff ff movl 4294967288, %eax
+// CHECK-NEXT: 401023: a1 fc ff ff ff movl 4294967292, %eax
+// CHECK-NEXT: 401028: a1 00 00 00 00 movl 0, %eax
+// CHECK-NEXT: 40102d: a1 00 00 00 00 movl 0, %eax
diff --git a/test/ELF/relocation-past-merge-end.s b/test/ELF/relocation-past-merge-end.s
index a3e7b59a415a..53015bc9013d 100644
--- a/test/ELF/relocation-past-merge-end.s
+++ b/test/ELF/relocation-past-merge-end.s
@@ -1,7 +1,7 @@
// REQUIRES: x86
// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux
// RUN: not ld.lld %t.o -o /dev/null -shared 2>&1 | FileCheck %s
-// CHECK: relocation-past-merge-end.s.tmp.o:(.foo): entry is past the end of the section
+// CHECK: relocation-past-merge-end.s.tmp.o:(.foo): offset is outside the section
.data
.long .foo + 10
diff --git a/test/ELF/relocation-size-shared.s b/test/ELF/relocation-size-shared.s
index f60f0929e705..1aa2222d9494 100644
--- a/test/ELF/relocation-size-shared.s
+++ b/test/ELF/relocation-size-shared.s
@@ -28,20 +28,7 @@
// DISASM-NEXT: 20100c: 00 00
// DISASM-NEXT: 20100e: 00 00
// DISASM-NEXT: 201010: 1b 00
-// DISASM-NEXT: 201012: 00 00
-// DISASM-NEXT: 201014: 00 00
-// DISASM-NEXT: 201016: 00 00
-// DISASM-NEXT: 201018: 00 00
-// DISASM-NEXT: 20101a: 00 00
-// DISASM-NEXT: 20101c: 00 00
-// DISASM-NEXT: 20101e: 00 00
-// DISASM-NEXT: 201020: 00 00
-// DISASM-NEXT: 201022: 00 00
-// DISASM-NEXT: 201024: 00 00
-// DISASM-NEXT: 201026: 00 00
-// DISASM-NEXT: 201028: 00 00
-// DISASM-NEXT: 20102a: 00 00
-// DISASM-NEXT: 20102c: 00 00
+// DISASM-NEXT: ...
// DISASM-NEXT: 20102e: 00 00
// DISASM: _start:
// DISASM-NEXT: 201030: 8b 04 25 19 00 00 00 movl 25, %eax
diff --git a/test/ELF/relocation-size.s b/test/ELF/relocation-size.s
index 525b1e1d1331..c2554a4e4fc1 100644
--- a/test/ELF/relocation-size.s
+++ b/test/ELF/relocation-size.s
@@ -57,18 +57,7 @@
// DISASMSHARED: Disassembly of section test:
// DISASMSHARED-NEXT: _data:
-// DISASMSHARED-NEXT: 1000: 00 00
-// DISASMSHARED-NEXT: 1002: 00 00
-// DISASMSHARED-NEXT: 1004: 00 00
-// DISASMSHARED-NEXT: 1006: 00 00
-// DISASMSHARED-NEXT: 1008: 00 00
-// DISASMSHARED-NEXT: 100a: 00 00
-// DISASMSHARED-NEXT: 100c: 00 00
-// DISASMSHARED-NEXT: 100e: 00 00
-// DISASMSHARED-NEXT: 1010: 00 00
-// DISASMSHARED-NEXT: 1012: 00 00
-// DISASMSHARED-NEXT: 1014: 00 00
-// DISASMSHARED-NEXT: 1016: 00 00
+// DISASMSHARED-NEXT: ...
// DISASMSHARED-NEXT: 1018: 19 00
// DISASMSHARED-NEXT: 101a: 00 00
// DISASMSHARED-NEXT: 101c: 00 00
diff --git a/test/ELF/reproduce-backslash.s b/test/ELF/reproduce-backslash.s
index 7a9964db62aa..39e63ccc121e 100644
--- a/test/ELF/reproduce-backslash.s
+++ b/test/ELF/reproduce-backslash.s
@@ -6,4 +6,4 @@
# RUN: ld.lld %T/foo\\.o --reproduce %T/repro.tar -o /dev/null
# RUN: tar tf %T/repro.tar | FileCheck %s
-# CHECK: repro/{{.*}}/foo\\.o
+# CHECK: repro/{{.*}}/foo\{{[\]?}}.o
diff --git a/test/ELF/retain-symbols-file.s b/test/ELF/retain-symbols-file.s
index 79d569d69cdb..0ab19774b534 100644
--- a/test/ELF/retain-symbols-file.s
+++ b/test/ELF/retain-symbols-file.s
@@ -11,7 +11,7 @@
# CHECK: DynamicSymbols [
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: @
+# CHECK-NEXT: Name:
# CHECK-NEXT: Value:
# CHECK-NEXT: Size:
# CHECK-NEXT: Binding:
diff --git a/test/ELF/riscv-branch.test b/test/ELF/riscv-branch.test
new file mode 100644
index 000000000000..3af9364c5028
--- /dev/null
+++ b/test/ELF/riscv-branch.test
@@ -0,0 +1,119 @@
+# .option norelax
+# .global _start
+# _start:
+# beq x0, x0, _start
+#
+# .section .reloc_max, "ax", @progbits
+# L1:
+# beq x0, x0, L1 + 0xffe
+#
+# .section .reloc_min, "ax", @progbits
+# L2:
+# beq x0, x0, L2 - 0x1000
+#
+# REQUIRES: riscv
+# RUN: yaml2obj %s -o %t.o
+# RUN: ld.lld %t.o -o %t
+# RUN: obj2yaml %t | FileCheck %s
+#
+# CHECK: - Name: .text
+# CHECK: Content: '63000000'
+# 11000: 00000063 beqz zero,11000 <_start>
+#
+# CHECK: - Name: .reloc_max
+# CHECK: Content: E30F007E
+# 11004: 7e000fe3 beqz zero,12002
+#
+# CHECK: - Name: .reloc_min
+# CHECK: Content: '63000080'
+# 11008: 80000063 beqz zero,10008
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_RISCV
+ Flags: [ EF_RISCV_RVC, EF_RISCV_FLOAT_ABI_SOFT ]
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000002
+ Content: '63000000'
+ - Name: .rela.text
+ Type: SHT_RELA
+ Flags: [ SHF_INFO_LINK ]
+ Link: .symtab
+ AddressAlign: 0x0000000000000004
+ Info: .text
+ Relocations:
+ - Offset: 0x0000000000000000
+ Symbol: _start
+ Type: R_RISCV_BRANCH
+ - Name: .data
+ Type: SHT_PROGBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 0x0000000000000001
+ Content: ''
+ - Name: .bss
+ Type: SHT_NOBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 0x0000000000000001
+ - Name: .reloc_max
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000001
+ Content: E30F007E
+ - Name: .rela.reloc_max
+ Type: SHT_RELA
+ Flags: [ SHF_INFO_LINK ]
+ Link: .symtab
+ AddressAlign: 0x0000000000000004
+ Info: .reloc_max
+ Relocations:
+ - Offset: 0x0000000000000000
+ Symbol: L1
+ Type: R_RISCV_BRANCH
+ Addend: 4094
+ - Name: .reloc_min
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000001
+ Content: '63000080'
+ - Name: .rela.reloc_min
+ Type: SHT_RELA
+ Flags: [ SHF_INFO_LINK ]
+ Link: .symtab
+ AddressAlign: 0x0000000000000004
+ Info: .reloc_min
+ Relocations:
+ - Offset: 0x0000000000000000
+ Symbol: L2
+ Type: R_RISCV_BRANCH
+ Addend: -4096
+Symbols:
+ Local:
+ - Name: .text
+ Type: STT_SECTION
+ Section: .text
+ - Name: .data
+ Type: STT_SECTION
+ Section: .data
+ - Name: .bss
+ Type: STT_SECTION
+ Section: .bss
+ - Name: .reloc_max
+ Type: STT_SECTION
+ Section: .reloc_max
+ - Name: L1
+ Section: .reloc_max
+ - Name: .reloc_min
+ Type: STT_SECTION
+ Section: .reloc_min
+ - Name: L2
+ Section: .reloc_min
+ Global:
+ - Name: _start
+ Section: .text
+...
diff --git a/test/ELF/riscv-call.test b/test/ELF/riscv-call.test
new file mode 100644
index 000000000000..d8077d480378
--- /dev/null
+++ b/test/ELF/riscv-call.test
@@ -0,0 +1,95 @@
+# .option norelax
+# .global _start
+# _start:
+# call _start + 4
+#
+# .section .reloc_neg, "ax", @progbits
+# L1:
+# call L1 - 4
+#
+# REQUIRES: riscv
+# RUN: yaml2obj %s -o %t.o
+# RUN: ld.lld %t.o -o %t
+# RUN: obj2yaml %t | FileCheck %s
+#
+# CHECK: - Name: .text
+# CHECK: Content: '97000000E7804000'
+#
+# 11000: 00000097 auipc ra,0x0
+# 11004: 004080e7 jalr 4(ra)
+#
+# CHECK: - Name: .reloc_neg
+# CHECK: Content: 97000000E780C0FF
+#
+# 11008: 00000097 auipc ra,0x0
+# 1100c: ffc080e7 jalr -4(ra)
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_RISCV
+ Flags: [ EF_RISCV_RVC, EF_RISCV_FLOAT_ABI_SOFT ]
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000002
+ Content: '97000000E7800000'
+ - Name: .rela.text
+ Type: SHT_RELA
+ Flags: [ SHF_INFO_LINK ]
+ Link: .symtab
+ AddressAlign: 0x0000000000000004
+ Info: .text
+ Relocations:
+ - Offset: 0x0000000000000000
+ Symbol: _start
+ Type: R_RISCV_CALL
+ Addend: 4
+ - Name: .data
+ Type: SHT_PROGBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 0x0000000000000001
+ Content: ''
+ - Name: .bss
+ Type: SHT_NOBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 0x0000000000000001
+ - Name: .reloc_neg
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000001
+ Content: '97000000E7800000'
+ - Name: .rela.reloc_neg
+ Type: SHT_RELA
+ Flags: [ SHF_INFO_LINK ]
+ Link: .symtab
+ AddressAlign: 0x0000000000000004
+ Info: .reloc_neg
+ Relocations:
+ - Offset: 0x0000000000000000
+ Symbol: L1
+ Type: R_RISCV_CALL
+ Addend: -4
+Symbols:
+ Local:
+ - Name: .text
+ Type: STT_SECTION
+ Section: .text
+ - Name: .data
+ Type: STT_SECTION
+ Section: .data
+ - Name: .bss
+ Type: STT_SECTION
+ Section: .bss
+ - Name: .reloc_neg
+ Type: STT_SECTION
+ Section: .reloc_neg
+ - Name: L1
+ Section: .reloc_neg
+ Global:
+ - Name: _start
+ Section: .text
+...
diff --git a/test/ELF/riscv-hi20-lo12.test b/test/ELF/riscv-hi20-lo12.test
new file mode 100644
index 000000000000..8d21d334dfa1
--- /dev/null
+++ b/test/ELF/riscv-hi20-lo12.test
@@ -0,0 +1,86 @@
+# .option norelax
+# .global _start
+#
+# .section .reloc_12345678, "ax", @progbits
+# _start:
+# foo = 0x12345678
+# lui a0, %hi(foo)
+# addi a0, a0, %lo(foo)
+# lw a0, %lo(foo)(a0)
+#
+# .section .reloc_fedcba98, "ax", @progbits
+# foo = 0xfedcba98
+# lui a0, %hi(foo)
+# addi a0, a0, %lo(foo)
+#
+# REQUIRES: riscv
+# RUN: yaml2obj %s -o %t.o
+# RUN: ld.lld %t.o -o %t
+# RUN: obj2yaml %t | FileCheck %s
+#
+# CHECK: - Name: .reloc_12345678
+# CHECK: Content: '375534121305856703258567'
+# 11000: 12345537 lui a0,0x12345
+# 11004: 67850513 addi a0,a0,1656 # 12345678 <__global_pointer$+0x12332e78>
+# 11008: 67852503 lw a0,1656(a0)
+#
+# CHECK: - Name: .reloc_fedcba98
+# CHECK: Content: 37C5DCFE130585A9
+# 1100c: fedcc537 lui a0,0xfedcc
+# 11010: a9850513 addi a0,a0,-1384 # fedcba98 <__global_pointer$+0xfedb9298>
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_RISCV
+ Flags: [ EF_RISCV_RVC, EF_RISCV_FLOAT_ABI_SOFT ]
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000002
+ Content: ''
+ - Name: .data
+ Type: SHT_PROGBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 0x0000000000000001
+ Content: ''
+ - Name: .bss
+ Type: SHT_NOBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 0x0000000000000001
+ - Name: .reloc_12345678
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000001
+ Content: '375534121305856703258567'
+ - Name: .reloc_fedcba98
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000001
+ Content: 37C5DCFE130585A9
+Symbols:
+ Local:
+ - Name: .text
+ Type: STT_SECTION
+ Section: .text
+ - Name: .data
+ Type: STT_SECTION
+ Section: .data
+ - Name: .bss
+ Type: STT_SECTION
+ Section: .bss
+ - Name: .reloc_12345678
+ Type: STT_SECTION
+ Section: .reloc_12345678
+ - Name: foo
+ Value: 0x00000000FEDCBA98
+ - Name: .reloc_fedcba98
+ Type: STT_SECTION
+ Section: .reloc_fedcba98
+ Global:
+ - Name: _start
+ Section: .reloc_12345678
+...
diff --git a/test/ELF/riscv-jal-error.test b/test/ELF/riscv-jal-error.test
new file mode 100644
index 000000000000..9df95c9cc4ea
--- /dev/null
+++ b/test/ELF/riscv-jal-error.test
@@ -0,0 +1,93 @@
+# .option norelax
+# .global _start
+#
+# _start:
+# L1:
+# jal x0, L1 + 0x100000
+# L2:
+# jal x0, L2 - 0x100002
+# L3:
+# jal x0, L3 + 1
+# L4:
+# c.jal L4 + 1
+#
+# REQUIRES: riscv
+# RUN: yaml2obj %s -o %t.o
+# RUN: not ld.lld %t.o -o %t 2>&1 | FileCheck %s
+#
+# CHECK: {{.*}}(.text+0x0): relocation R_RISCV_JAL out of range
+# CHECK: {{.*}}(.text+0x4): relocation R_RISCV_JAL out of range
+# CHECK: {{.*}}(.text+0x8): improper alignment for relocation R_RISCV_JAL
+# CHECK: {{.*}}(.text+0xC): improper alignment for relocation R_RISCV_RVC_JUMP
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_RISCV
+ Flags: [ EF_RISCV_RVC, EF_RISCV_FLOAT_ABI_SOFT ]
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000002
+ Content: 6F0000806FF0FF7F6F0000000120
+ - Name: .rela.text
+ Type: SHT_RELA
+ Flags: [ SHF_INFO_LINK ]
+ Link: .symtab
+ AddressAlign: 0x0000000000000004
+ Info: .text
+ Relocations:
+ - Offset: 0x0000000000000000
+ Symbol: L1
+ Type: R_RISCV_JAL
+ Addend: 1048576
+ - Offset: 0x0000000000000004
+ Symbol: L2
+ Type: R_RISCV_JAL
+ Addend: -1048578
+ - Offset: 0x0000000000000008
+ Symbol: L3
+ Type: R_RISCV_JAL
+ Addend: 1
+ - Offset: 0x000000000000000C
+ Symbol: L4
+ Type: R_RISCV_RVC_JUMP
+ Addend: 1
+ - Name: .data
+ Type: SHT_PROGBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 0x0000000000000001
+ Content: ''
+ - Name: .bss
+ Type: SHT_NOBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 0x0000000000000001
+Symbols:
+ Local:
+ - Name: .text
+ Type: STT_SECTION
+ Section: .text
+ - Name: .data
+ Type: STT_SECTION
+ Section: .data
+ - Name: .bss
+ Type: STT_SECTION
+ Section: .bss
+ - Name: L1
+ Section: .text
+ - Name: L2
+ Section: .text
+ Value: 0x0000000000000004
+ - Name: L3
+ Section: .text
+ Value: 0x0000000000000008
+ - Name: L4
+ Section: .text
+ Value: 0x000000000000000C
+ Global:
+ - Name: _start
+ Section: .text
+...
diff --git a/test/ELF/riscv-jal.test b/test/ELF/riscv-jal.test
new file mode 100644
index 000000000000..cb40dc6db124
--- /dev/null
+++ b/test/ELF/riscv-jal.test
@@ -0,0 +1,161 @@
+# .option norelax
+# .global _start
+#
+# .section .reloc_zero, "ax", @progbits
+# _start:
+# L1:
+# jal x0, L1
+# L2:
+# c.jal L2
+#
+# .section .reloc_max, "ax", @progbits
+# L3:
+# jal x0, L3 + 0xffffe
+# L4:
+# c.jal L4 + 0x7fe
+#
+# .section .reloc_min, "ax", @progbits
+# L5:
+# jal x0, L5 - 0x100000
+# L6:
+# c.jal L6 - 0x800
+#
+# REQUIRES: riscv
+# RUN: yaml2obj %s -o %t.o
+# RUN: ld.lld %t.o -o %t
+# RUN: obj2yaml %t | FileCheck %s
+#
+# CHECK: - Name: .reloc_zero
+# CHECK: Content: 6F0000000120
+# 11000: 0000006f j 11000
+# 11004: 2001 jal 11004
+#
+# CHECK: - Name: .reloc_max
+# CHECK: Content: 6FF0FF7FFD2F
+# 11006: 7ffff06f j 111004
+# 1100a: 2ffd jal 11808
+#
+# CHECK: - Name: .reloc_min
+# CHECK: Content: 6F0000800130
+# 1100c: 8000006f j fff1100c
+# 11010: 3001 jal 10810
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_RISCV
+ Flags: [ EF_RISCV_RVC, EF_RISCV_FLOAT_ABI_SOFT ]
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000002
+ Content: ''
+ - Name: .data
+ Type: SHT_PROGBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 0x0000000000000001
+ Content: ''
+ - Name: .bss
+ Type: SHT_NOBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 0x0000000000000001
+ - Name: .reloc_zero
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000001
+ Content: 6F0000000120
+ - Name: .rela.reloc_zero
+ Type: SHT_RELA
+ Flags: [ SHF_INFO_LINK ]
+ Link: .symtab
+ AddressAlign: 0x0000000000000004
+ Info: .reloc_zero
+ Relocations:
+ - Offset: 0x0000000000000000
+ Symbol: L1
+ Type: R_RISCV_JAL
+ - Offset: 0x0000000000000004
+ Symbol: L2
+ Type: R_RISCV_RVC_JUMP
+ - Name: .reloc_max
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000001
+ Content: 6FF0FF7FFD2F
+ - Name: .rela.reloc_max
+ Type: SHT_RELA
+ Flags: [ SHF_INFO_LINK ]
+ Link: .symtab
+ AddressAlign: 0x0000000000000004
+ Info: .reloc_max
+ Relocations:
+ - Offset: 0x0000000000000000
+ Symbol: L3
+ Type: R_RISCV_JAL
+ Addend: 1048574
+ - Offset: 0x0000000000000004
+ Symbol: L4
+ Type: R_RISCV_RVC_JUMP
+ Addend: 2046
+ - Name: .reloc_min
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000001
+ Content: 6F0000800130
+ - Name: .rela.reloc_min
+ Type: SHT_RELA
+ Flags: [ SHF_INFO_LINK ]
+ Link: .symtab
+ AddressAlign: 0x0000000000000004
+ Info: .reloc_min
+ Relocations:
+ - Offset: 0x0000000000000000
+ Symbol: L5
+ Type: R_RISCV_JAL
+ Addend: -1048576
+ - Offset: 0x0000000000000004
+ Symbol: L6
+ Type: R_RISCV_RVC_JUMP
+ Addend: -2048
+Symbols:
+ Local:
+ - Name: .text
+ Type: STT_SECTION
+ Section: .text
+ - Name: .data
+ Type: STT_SECTION
+ Section: .data
+ - Name: .bss
+ Type: STT_SECTION
+ Section: .bss
+ - Name: .reloc_zero
+ Type: STT_SECTION
+ Section: .reloc_zero
+ - Name: L1
+ Section: .reloc_zero
+ - Name: L2
+ Section: .reloc_zero
+ Value: 0x0000000000000004
+ - Name: .reloc_max
+ Type: STT_SECTION
+ Section: .reloc_max
+ - Name: L3
+ Section: .reloc_max
+ - Name: L4
+ Section: .reloc_max
+ Value: 0x0000000000000004
+ - Name: .reloc_min
+ Type: STT_SECTION
+ Section: .reloc_min
+ - Name: L5
+ Section: .reloc_min
+ - Name: L6
+ Section: .reloc_min
+ Value: 0x0000000000000004
+ Global:
+ - Name: _start
+ Section: .reloc_zero
+...
diff --git a/test/ELF/riscv-pcrel-hilo.test b/test/ELF/riscv-pcrel-hilo.test
new file mode 100644
index 000000000000..9767e14903c3
--- /dev/null
+++ b/test/ELF/riscv-pcrel-hilo.test
@@ -0,0 +1,103 @@
+# .option norelax
+# .global _start
+#
+# _start:
+# auipc a0, %pcrel_hi(_start + 4)
+# addi a0, a0, %pcrel_lo(_start)
+#
+# .section .reloc_neg, "ax", @progbits
+# L1:
+# auipc a0, %pcrel_hi(L1 - 2)
+# addi a0, a0, %pcrel_lo(L1)
+#
+#
+# REQUIRES: riscv
+# RUN: yaml2obj %s -o %t.o
+# RUN: ld.lld %t.o -o %t
+# RUN: obj2yaml %t | FileCheck %s
+#
+# CHECK: - Name: .text
+# CHECK: Content: '1705000013054500'
+# 11000: 00000517 auipc a0,0x0
+# 11004: 00450513 addi a0,a0,4 # 11004 <_start+0x4>
+#
+# CHECK: - Name: .reloc_neg
+# CHECK: Content: 170500001305E5FF
+# 11008: 00000517 auipc a0,0x0
+# 1100c: ffe50513 addi a0,a0,-2 # 11006 <_start+0x6>
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_RISCV
+ Flags: [ EF_RISCV_RVC, EF_RISCV_FLOAT_ABI_SOFT ]
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000002
+ Content: '1705000013050500'
+ - Name: .rela.text
+ Type: SHT_RELA
+ Flags: [ SHF_INFO_LINK ]
+ Link: .symtab
+ AddressAlign: 0x0000000000000004
+ Info: .text
+ Relocations:
+ - Offset: 0x0000000000000000
+ Symbol: _start
+ Type: R_RISCV_PCREL_HI20
+ Addend: 4
+ - Offset: 0x0000000000000004
+ Symbol: _start
+ Type: R_RISCV_PCREL_LO12_I
+ - Name: .data
+ Type: SHT_PROGBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 0x0000000000000001
+ Content: ''
+ - Name: .bss
+ Type: SHT_NOBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 0x0000000000000001
+ - Name: .reloc_neg
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000001
+ Content: '1705000013050500'
+ - Name: .rela.reloc_neg
+ Type: SHT_RELA
+ Flags: [ SHF_INFO_LINK ]
+ Link: .symtab
+ AddressAlign: 0x0000000000000004
+ Info: .reloc_neg
+ Relocations:
+ - Offset: 0x0000000000000000
+ Symbol: L1
+ Type: R_RISCV_PCREL_HI20
+ Addend: -2
+ - Offset: 0x0000000000000004
+ Symbol: L1
+ Type: R_RISCV_PCREL_LO12_I
+Symbols:
+ Local:
+ - Name: .text
+ Type: STT_SECTION
+ Section: .text
+ - Name: .data
+ Type: STT_SECTION
+ Section: .data
+ - Name: .bss
+ Type: STT_SECTION
+ Section: .bss
+ - Name: .reloc_neg
+ Type: STT_SECTION
+ Section: .reloc_neg
+ - Name: L1
+ Section: .reloc_neg
+ Global:
+ - Name: _start
+ Section: .text
+...
diff --git a/test/ELF/shared.s b/test/ELF/shared.s
index 3a8fedec9240..e00dd9937ff2 100644
--- a/test/ELF/shared.s
+++ b/test/ELF/shared.s
@@ -141,7 +141,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: _DYNAMIC
-// CHECK-NEXT: Value: 0x12000
+// CHECK-NEXT: Value: 0x402000
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local
// CHECK-NEXT: Type: None
@@ -152,7 +152,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: _start
-// CHECK-NEXT: Value: 0x11000
+// CHECK-NEXT: Value: 0x401000
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: None
@@ -181,7 +181,7 @@
// CHECK: DynamicSymbols [
// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: @
+// CHECK-NEXT: Name:
// CHECK-NEXT: Value: 0x0
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local
@@ -190,8 +190,8 @@
// CHECK-NEXT: Section: Undefined
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: _start@
-// CHECK-NEXT: Value: 0x11000
+// CHECK-NEXT: Name: _start
+// CHECK-NEXT: Value: 0x401000
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: Non
@@ -199,7 +199,7 @@
// CHECK-NEXT: Section: .text
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: bar@
+// CHECK-NEXT: Name: bar
// CHECK-NEXT: Value: 0x0
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
@@ -208,7 +208,7 @@
// CHECK-NEXT: Section: Undefined
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: zed@
+// CHECK-NEXT: Name: zed
// CHECK-NEXT: Value: 0x0
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
@@ -220,7 +220,7 @@
// DONT_EXPORT: DynamicSymbols [
// DONT_EXPORT-NEXT: Symbol {
-// DONT_EXPORT-NEXT: Name: @
+// DONT_EXPORT-NEXT: Name:
// DONT_EXPORT-NEXT: Value: 0x0
// DONT_EXPORT-NEXT: Size: 0
// DONT_EXPORT-NEXT: Binding: Local (0x0)
@@ -229,7 +229,7 @@
// DONT_EXPORT-NEXT: Section: Undefined (0x0)
// DONT_EXPORT-NEXT: }
// DONT_EXPORT-NEXT: Symbol {
-// DONT_EXPORT-NEXT: Name: bar@
+// DONT_EXPORT-NEXT: Name: bar
// DONT_EXPORT-NEXT: Value: 0x0
// DONT_EXPORT-NEXT: Size: 0
// DONT_EXPORT-NEXT: Binding: Global
@@ -238,7 +238,7 @@
// DONT_EXPORT-NEXT: Section: Undefined
// DONT_EXPORT-NEXT: }
// DONT_EXPORT-NEXT: Symbol {
-// DONT_EXPORT-NEXT: Name: zed@
+// DONT_EXPORT-NEXT: Name: zed
// DONT_EXPORT-NEXT: Value: 0x0
// DONT_EXPORT-NEXT: Size: 0
// DONT_EXPORT-NEXT: Binding: Global
diff --git a/test/ELF/sort-norosegment.s b/test/ELF/sort-norosegment.s
index cd4fc9ebae16..108713f8d1c8 100644
--- a/test/ELF/sort-norosegment.s
+++ b/test/ELF/sort-norosegment.s
@@ -2,7 +2,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: ld.lld --hash-style=sysv -no-rosegment -o %t %t.o -shared
-# RUN: llvm-readelf -s %t | FileCheck %s
+# RUN: llvm-readelf -S %t | FileCheck %s
# CHECK: .dynsym {{.*}} A
# CHECK-NEXT: .hash {{.*}} A
diff --git a/test/ELF/static-error.s b/test/ELF/static-error.s
new file mode 100644
index 000000000000..1ae98ab2c324
--- /dev/null
+++ b/test/ELF/static-error.s
@@ -0,0 +1,13 @@
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/shared.s -o %t.o
+// RUN: ld.lld -shared -o %t.so %t.o
+
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: ld.lld -o /dev/null %t.o %t.so
+// RUN: not ld.lld -o /dev/null -static %t.o %t.so 2>&1 | FileCheck %s
+
+// CHECK: attempted static link of dynamic object
+
+.global _start
+_start:
+ nop
diff --git a/test/ELF/static-with-export-dynamic.s b/test/ELF/static-with-export-dynamic.s
index f0c67df22623..a718babc2cf6 100644
--- a/test/ELF/static-with-export-dynamic.s
+++ b/test/ELF/static-with-export-dynamic.s
@@ -18,7 +18,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: _start
-// CHECK-NEXT: Value: 0x11000
+// CHECK-NEXT: Value: 0x401000
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: None
diff --git a/test/ELF/strip-debug.s b/test/ELF/strip-debug.s
index 8005cfacee6c..e5295f10d1ec 100644
--- a/test/ELF/strip-debug.s
+++ b/test/ELF/strip-debug.s
@@ -1,4 +1,4 @@
-# REQUIRES: x86
+# REQUIRES: x86, zlib
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: ld.lld %t -o %t2 --strip-debug
# RUN: llvm-readobj -sections %t2 | FileCheck %s
@@ -12,3 +12,5 @@
.section .debug_Foo,"",@progbits
.section .zdebug_Bar,"",@progbits
+.ascii "ZLIB"
+.quad 0
diff --git a/test/ELF/symbol-ordering-file-warnings.s b/test/ELF/symbol-ordering-file-warnings.s
index 71414bf58098..abbafc4e3754 100644
--- a/test/ELF/symbol-ordering-file-warnings.s
+++ b/test/ELF/symbol-ordering-file-warnings.s
@@ -19,11 +19,6 @@
# RUN: --unresolved-symbols=ignore-all --no-warn-symbol-ordering --warn-symbol-ordering 2>&1 | \
# RUN: FileCheck %s --check-prefixes=WARN,MISSING
-# Check that a warning is emitted for undefined symbols.
-# RUN: echo "undefined" > %t-order-undef.txt
-# RUN: ld.lld %t1.o %t3.o -o %t --symbol-ordering-file %t-order-undef.txt \
-# RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,UNDEFINED
-
# Check that a warning is emitted for imported shared symbols.
# RUN: echo "shared" > %t-order-shared.txt
# RUN: ld.lld %t1.o %t.so -o %t --symbol-ordering-file %t-order-shared.txt \
@@ -97,7 +92,7 @@
# RUN: echo "_GLOBAL_OFFSET_TABLE_" >> %t-order-multi.txt
# RUN: echo "_start" >> %t-order-multi.txt
# RUN: ld.lld %t1.o %t3.o %t.so -o %t --symbol-ordering-file %t-order-multi.txt --gc-sections -T %t.script \
-# RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,SAMESYM,ABSOLUTE,SHARED,UNDEFINED,GC,DISCARD,MISSING2,SYNTHETIC
+# RUN: 2>&1 | FileCheck %s --check-prefixes=WARN,SAMESYM,ABSOLUTE,SHARED,UNDEFINED,GC,DISCARD,MISSING2,SYNTHETIC
# WARN-NOT: warning:
# SAMESYM: warning: {{.*}}.txt: duplicate ordered symbol: _start
@@ -115,10 +110,12 @@
# ABSOLUTE: warning: {{.*}}1.o: unable to order absolute symbol: absolute
# WARN-NOT: warning:
# MISSING: warning: symbol ordering file: no such symbol: missing
+# WARN-NOT: warning:
# MISSING2: warning: symbol ordering file: no such symbol: missing_sym
+# WARN-NOT: warning:
# COMDAT: warning: {{.*}}1.o: unable to order discarded symbol: comdat
-# MULTI: warning: {{.*}}3.o: unable to order undefined symbol: multi
-# MULTI-NEXT: warning: {{.*}}2.o: unable to order absolute symbol: multi
+# WARN-NOT: warning:
+# MULTI: warning: {{.*}}2.o: unable to order absolute symbol: multi
# WARN-NOT: warning:
absolute = 0x1234
diff --git a/test/ELF/textrel.s b/test/ELF/textrel.s
new file mode 100644
index 000000000000..fac67d542af7
--- /dev/null
+++ b/test/ELF/textrel.s
@@ -0,0 +1,40 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux-gnu %s -o %t.o
+
+# Without --warn-text-ifunc, lld should run fine:
+# RUN: ld.lld -z notext %t.o -o %t2
+
+# With --warn-text-ifunc, lld should run with warnings:
+# RUN: ld.lld --warn-ifunc-textrel -z notext %t.o -o /dev/null 2>&1 | FileCheck %s
+# CHECK: using ifunc symbols when text relocations are allowed may produce
+# CHECK-SAME: a binary that will segfault, if the object file is linked with
+# CHECK-SAME: old version of glibc (glibc 2.28 and earlier). If this applies to
+# CHECK-SAME: you, consider recompiling the object files without -fPIC and
+# CHECK-SAME: without -Wl,-z,notext option. Use -no-warn-ifunc-textrel to
+# CHECK-SAME: turn off this warning.
+# CHECK: >>> defined in {{.*}}
+# CHECK: >>> referenced by {{.*}}:(.text+0x8)
+
+# Without text relocations, lld should run fine:
+# RUN: ld.lld --fatal-warnings %t.o -o /dev/null
+
+.text
+.globl a_func_impl
+a_func_impl:
+ nop
+
+.globl selector
+.type selector,@function
+selector:
+ movl $a_func_impl, %eax
+ retq
+
+.globl a_func
+.type a_func,@gnu_indirect_function
+.set a_func, selector
+
+.globl _start
+.type _start,@function
+main:
+ callq a_func
+ retq
diff --git a/test/ELF/tls-i686.s b/test/ELF/tls-i686.s
index c411fc74cd68..31c9494c6f24 100644
--- a/test/ELF/tls-i686.s
+++ b/test/ELF/tls-i686.s
@@ -32,16 +32,16 @@ _start:
// DIS: Disassembly of section test:
// DIS-NEXT: _start:
-// DIS-NEXT: 11000: ba 08 00 00 00 movl $8, %edx
-// DIS-NEXT: 11005: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
-// DIS-NEXT: 1100c: 29 d0 subl %edx, %eax
-// DIS-NEXT: 1100e: ba 04 00 00 00 movl $4, %edx
-// DIS-NEXT: 11013: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
-// DIS-NEXT: 1101a: 29 d0 subl %edx, %eax
-// DIS-NEXT: 1101c: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
-// DIS-NEXT: 11023: 8d 81 f8 ff ff ff leal -8(%ecx), %eax
-// DIS-NEXT: 11029: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
-// DIS-NEXT: 11030: 8d 81 77 00 00 00 leal 119(%ecx), %eax
+// DIS-NEXT: 401000: ba 08 00 00 00 movl $8, %edx
+// DIS-NEXT: 401005: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
+// DIS-NEXT: 40100c: 29 d0 subl %edx, %eax
+// DIS-NEXT: 40100e: ba 04 00 00 00 movl $4, %edx
+// DIS-NEXT: 401013: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
+// DIS-NEXT: 40101a: 29 d0 subl %edx, %eax
+// DIS-NEXT: 40101c: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
+// DIS-NEXT: 401023: 8d 81 f8 ff ff ff leal -8(%ecx), %eax
+// DIS-NEXT: 401029: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
+// DIS-NEXT: 401030: 8d 81 77 00 00 00 leal 119(%ecx), %eax
// RELOC: Relocations [
// RELOC-NEXT: ]
diff --git a/test/ELF/tls-in-archive.s b/test/ELF/tls-in-archive.s
index ac1b4cc11ea4..5a8791dd2b3c 100644
--- a/test/ELF/tls-in-archive.s
+++ b/test/ELF/tls-in-archive.s
@@ -1,5 +1,6 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/tls-in-archive.s -o %t1.o
+// RUN: rm -f %t.a
// RUN: llvm-ar cru %t.a %t1.o
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t2.o
// RUN: ld.lld %t2.o %t.a -o /dev/null
diff --git a/test/ELF/tls-opt-gdiele-i686.s b/test/ELF/tls-opt-gdiele-i686.s
index b39f933e2fdb..1baaf111cbfa 100644
--- a/test/ELF/tls-opt-gdiele-i686.s
+++ b/test/ELF/tls-opt-gdiele-i686.s
@@ -8,21 +8,21 @@
// NORELOC: Relocations [
// NORELOC-NEXT: Section ({{.*}}) .rel.dyn {
-// NORELOC-NEXT: 0x12058 R_386_TLS_TPOFF tlsshared0 0x0
-// NORELOC-NEXT: 0x1205C R_386_TLS_TPOFF tlsshared1 0x0
+// NORELOC-NEXT: 0x402058 R_386_TLS_TPOFF tlsshared0 0x0
+// NORELOC-NEXT: 0x40205C R_386_TLS_TPOFF tlsshared1 0x0
// NORELOC-NEXT: }
// NORELOC-NEXT: ]
// DISASM: Disassembly of section .text:
// DISASM-NEXT: _start:
-// DISASM-NEXT: 11000: 65 a1 00 00 00 00 movl %gs:0, %eax
-// DISASM-NEXT: 11006: 03 83 f8 ff ff ff addl -8(%ebx), %eax
-// DISASM-NEXT: 1100c: 65 a1 00 00 00 00 movl %gs:0, %eax
-// DISASM-NEXT: 11012: 03 83 fc ff ff ff addl -4(%ebx), %eax
-// DISASM-NEXT: 11018: 65 a1 00 00 00 00 movl %gs:0, %eax
-// DISASM-NEXT: 1101e: 81 e8 08 00 00 00 subl $8, %eax
-// DISASM-NEXT: 11024: 65 a1 00 00 00 00 movl %gs:0, %eax
-// DISASM-NEXT: 1102a: 81 e8 04 00 00 00 subl $4, %eax
+// DISASM-NEXT: 401000: 65 a1 00 00 00 00 movl %gs:0, %eax
+// DISASM-NEXT: 401006: 03 83 f8 ff ff ff addl -8(%ebx), %eax
+// DISASM-NEXT: 40100c: 65 a1 00 00 00 00 movl %gs:0, %eax
+// DISASM-NEXT: 401012: 03 83 fc ff ff ff addl -4(%ebx), %eax
+// DISASM-NEXT: 401018: 65 a1 00 00 00 00 movl %gs:0, %eax
+// DISASM-NEXT: 40101e: 81 e8 08 00 00 00 subl $8, %eax
+// DISASM-NEXT: 401024: 65 a1 00 00 00 00 movl %gs:0, %eax
+// DISASM-NEXT: 40102a: 81 e8 04 00 00 00 subl $4, %eax
.type tlsexe1,@object
.section .tbss,"awT",@nobits
diff --git a/test/ELF/tls-opt-i686.s b/test/ELF/tls-opt-i686.s
index d8b1d0eca0b7..0f9d4d6ff522 100644
--- a/test/ELF/tls-opt-i686.s
+++ b/test/ELF/tls-opt-i686.s
@@ -10,25 +10,25 @@
// DISASM: Disassembly of section .text:
// DISASM-NEXT: _start:
// LD -> LE:
-// DISASM-NEXT: 11000: 65 a1 00 00 00 00 movl %gs:0, %eax
-// DISASM-NEXT: 11006: 90 nop
-// DISASM-NEXT: 11007: 8d 74 26 00 leal (%esi,%eiz), %esi
-// DISASM-NEXT: 1100b: 8d 90 f8 ff ff ff leal -8(%eax), %edx
-// DISASM-NEXT: 11011: 65 a1 00 00 00 00 movl %gs:0, %eax
-// DISASM-NEXT: 11017: 90 nop
-// DISASM-NEXT: 11018: 8d 74 26 00 leal (%esi,%eiz), %esi
-// DISASM-NEXT: 1101c: 8d 90 fc ff ff ff leal -4(%eax), %edx
+// DISASM-NEXT: 401000: 65 a1 00 00 00 00 movl %gs:0, %eax
+// DISASM-NEXT: 401006: 90 nop
+// DISASM-NEXT: 401007: 8d 74 26 00 leal (%esi,%eiz), %esi
+// DISASM-NEXT: 40100b: 8d 90 f8 ff ff ff leal -8(%eax), %edx
+// DISASM-NEXT: 401011: 65 a1 00 00 00 00 movl %gs:0, %eax
+// DISASM-NEXT: 401017: 90 nop
+// DISASM-NEXT: 401018: 8d 74 26 00 leal (%esi,%eiz), %esi
+// DISASM-NEXT: 40101c: 8d 90 fc ff ff ff leal -4(%eax), %edx
// IE -> LE:
// 4294967288 == 0xFFFFFFF8
// 4294967292 == 0xFFFFFFFC
-// DISASM-NEXT: 11022: 65 a1 00 00 00 00 movl %gs:0, %eax
-// DISASM-NEXT: 11028: c7 c0 f8 ff ff ff movl $4294967288, %eax
-// DISASM-NEXT: 1102e: 65 a1 00 00 00 00 movl %gs:0, %eax
-// DISASM-NEXT: 11034: c7 c0 fc ff ff ff movl $4294967292, %eax
-// DISASM-NEXT: 1103a: 65 a1 00 00 00 00 movl %gs:0, %eax
-// DISASM-NEXT: 11040: 8d 80 f8 ff ff ff leal -8(%eax), %eax
-// DISASM-NEXT: 11046: 65 a1 00 00 00 00 movl %gs:0, %eax
-// DISASM-NEXT: 1104c: 8d 80 fc ff ff ff leal -4(%eax), %eax
+// DISASM-NEXT: 401022: 65 a1 00 00 00 00 movl %gs:0, %eax
+// DISASM-NEXT: 401028: c7 c0 f8 ff ff ff movl $4294967288, %eax
+// DISASM-NEXT: 40102e: 65 a1 00 00 00 00 movl %gs:0, %eax
+// DISASM-NEXT: 401034: c7 c0 fc ff ff ff movl $4294967292, %eax
+// DISASM-NEXT: 40103a: 65 a1 00 00 00 00 movl %gs:0, %eax
+// DISASM-NEXT: 401040: 8d 80 f8 ff ff ff leal -8(%eax), %eax
+// DISASM-NEXT: 401046: 65 a1 00 00 00 00 movl %gs:0, %eax
+// DISASM-NEXT: 40104c: 8d 80 fc ff ff ff leal -4(%eax), %eax
.type tls0,@object
.section .tbss,"awT",@nobits
.globl tls0
diff --git a/test/ELF/tls-opt-iele-i686-nopic.s b/test/ELF/tls-opt-iele-i686-nopic.s
index 50655e34a4ff..704928b2b4dd 100644
--- a/test/ELF/tls-opt-iele-i686-nopic.s
+++ b/test/ELF/tls-opt-iele-i686-nopic.s
@@ -14,7 +14,7 @@
// GOTREL-NEXT: SHF_ALLOC
// GOTREL-NEXT: SHF_WRITE
// GOTREL-NEXT: ]
-// GOTREL-NEXT: Address: 0x12058
+// GOTREL-NEXT: Address: 0x402058
// GOTREL-NEXT: Offset: 0x2058
// GOTREL-NEXT: Size: 8
// GOTREL-NEXT: Link: 0
@@ -24,8 +24,8 @@
// GOTREL-NEXT: }
// GOTREL: Relocations [
// GOTREL-NEXT: Section ({{.*}}) .rel.dyn {
-// GOTREL-NEXT: 0x12058 R_386_TLS_TPOFF tlsshared0 0x0
-// GOTREL-NEXT: 0x1205C R_386_TLS_TPOFF tlsshared1 0x0
+// GOTREL-NEXT: 0x402058 R_386_TLS_TPOFF tlsshared0 0x0
+// GOTREL-NEXT: 0x40205C R_386_TLS_TPOFF tlsshared1 0x0
// GOTREL-NEXT: }
// GOTREL-NEXT: ]
@@ -33,24 +33,24 @@
// DISASM-NEXT: _start:
// 4294967288 = 0xFFFFFFF8
// 4294967292 = 0xFFFFFFFC
-// 73808 = (.got)[0] = 0x12058
-// 73812 = (.got)[1] = 0x1205C
-// DISASM-NEXT: 11000: c7 c1 f8 ff ff ff movl $4294967288, %ecx
-// DISASM-NEXT: 11006: 65 8b 01 movl %gs:(%ecx), %eax
-// DISASM-NEXT: 11009: b8 f8 ff ff ff movl $4294967288, %eax
-// DISASM-NEXT: 1100e: 65 8b 00 movl %gs:(%eax), %eax
-// DISASM-NEXT: 11011: 81 c1 f8 ff ff ff addl $4294967288, %ecx
-// DISASM-NEXT: 11017: 65 8b 01 movl %gs:(%ecx), %eax
-// DISASM-NEXT: 1101a: c7 c1 fc ff ff ff movl $4294967292, %ecx
-// DISASM-NEXT: 11020: 65 8b 01 movl %gs:(%ecx), %eax
-// DISASM-NEXT: 11023: b8 fc ff ff ff movl $4294967292, %eax
-// DISASM-NEXT: 11028: 65 8b 00 movl %gs:(%eax), %eax
-// DISASM-NEXT: 1102b: 81 c1 fc ff ff ff addl $4294967292, %ecx
-// DISASM-NEXT: 11031: 65 8b 01 movl %gs:(%ecx), %eax
-// DISASM-NEXT: 11034: 8b 0d 58 20 01 00 movl 73816, %ecx
-// DISASM-NEXT: 1103a: 65 8b 01 movl %gs:(%ecx), %eax
-// DISASM-NEXT: 1103d: 03 0d 5c 20 01 00 addl 73820, %ecx
-// DISASM-NEXT: 11043: 65 8b 01 movl %gs:(%ecx), %eax
+// 4202584 = (.got)[0] = 0x402058
+// 4202588 = (.got)[1] = 0x40205C
+// DISASM-NEXT: 401000: c7 c1 f8 ff ff ff movl $4294967288, %ecx
+// DISASM-NEXT: 401006: 65 8b 01 movl %gs:(%ecx), %eax
+// DISASM-NEXT: 401009: b8 f8 ff ff ff movl $4294967288, %eax
+// DISASM-NEXT: 40100e: 65 8b 00 movl %gs:(%eax), %eax
+// DISASM-NEXT: 401011: 81 c1 f8 ff ff ff addl $4294967288, %ecx
+// DISASM-NEXT: 401017: 65 8b 01 movl %gs:(%ecx), %eax
+// DISASM-NEXT: 40101a: c7 c1 fc ff ff ff movl $4294967292, %ecx
+// DISASM-NEXT: 401020: 65 8b 01 movl %gs:(%ecx), %eax
+// DISASM-NEXT: 401023: b8 fc ff ff ff movl $4294967292, %eax
+// DISASM-NEXT: 401028: 65 8b 00 movl %gs:(%eax), %eax
+// DISASM-NEXT: 40102b: 81 c1 fc ff ff ff addl $4294967292, %ecx
+// DISASM-NEXT: 401031: 65 8b 01 movl %gs:(%ecx), %eax
+// DISASM-NEXT: 401034: 8b 0d 58 20 40 00 movl 4202584, %ecx
+// DISASM-NEXT: 40103a: 65 8b 01 movl %gs:(%ecx), %eax
+// DISASM-NEXT: 40103d: 03 0d 5c 20 40 00 addl 4202588, %ecx
+// DISASM-NEXT: 401043: 65 8b 01 movl %gs:(%ecx), %eax
.type tlslocal0,@object
.section .tbss,"awT",@nobits
diff --git a/test/ELF/tls-static.s b/test/ELF/tls-static.s
index 3e1aead01a30..61d504b2e850 100644
--- a/test/ELF/tls-static.s
+++ b/test/ELF/tls-static.s
@@ -4,7 +4,6 @@
// RUN: ld.lld -static %t -o %tout
// RUN: ld.lld %t -o %tout
// RUN: ld.lld -shared %tso -o %tshared
-// RUN: ld.lld -static %t %tshared -o %tout
.global _start
_start:
diff --git a/test/ELF/tls-weak-undef.s b/test/ELF/tls-weak-undef.s
index 7aa6ef13a2af..1023aebbc258 100644
--- a/test/ELF/tls-weak-undef.s
+++ b/test/ELF/tls-weak-undef.s
@@ -4,6 +4,7 @@
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux \
// RUN: %p/Inputs/tls-in-archive.s -o %t1.o
+// RUN: rm -f %t.a
// RUN: llvm-ar cru %t.a %t1.o
// RUN: ld.lld %t.o %t.a -o %t
diff --git a/test/ELF/trace-ar.s b/test/ELF/trace-ar.s
index 1d178dc9dd37..0a71f7eba9f4 100644
--- a/test/ELF/trace-ar.s
+++ b/test/ELF/trace-ar.s
@@ -2,6 +2,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.foo.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/trace-ar1.s -o %t.obj1.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/trace-ar2.s -o %t.obj2.o
+# RUN: rm -f %t.boo.a
# RUN: llvm-ar rcs %t.boo.a %t.obj1.o %t.obj2.o
## Check how -t works with achieves
diff --git a/test/ELF/trace-symbols.s b/test/ELF/trace-symbols.s
index b5c1ddc2a558..63004b7c18aa 100644
--- a/test/ELF/trace-symbols.s
+++ b/test/ELF/trace-symbols.s
@@ -8,7 +8,9 @@
# RUN: %p/Inputs/trace-symbols-foo-strong.s -o %t2
# RUN: ld.lld -shared %t1 -o %t1.so
# RUN: ld.lld -shared %t2 -o %t2.so
+# RUN: rm -f %t1.a
# RUN: llvm-ar rcs %t1.a %t1
+# RUN: rm -f %t2.a
# RUN: llvm-ar rcs %t2.a %t2
# RUN: ld.lld -y foo -trace-symbol common -trace-symbol=hsymbol \
diff --git a/test/ELF/undef-broken-debug.test b/test/ELF/undef-broken-debug.test
index b93d399f36c2..c3405ad0b9ed 100644
--- a/test/ELF/undef-broken-debug.test
+++ b/test/ELF/undef-broken-debug.test
@@ -5,7 +5,7 @@
# The debug info has a broken relocation. Check that we don't crash
# and still report the undefined symbol.
-# CHECK: error: unsupported relocation target while parsing debug info
+# CHECK: error: {{.*}}.o: relocation R_X86_64_64 at 0x29 has unsupported target
# CHECK: error: undefined symbol: bar
--- !ELF
diff --git a/test/ELF/undef-version-script.s b/test/ELF/undef-version-script.s
index 712589e2444f..7ef4b7a22ca7 100644
--- a/test/ELF/undef-version-script.s
+++ b/test/ELF/undef-version-script.s
@@ -6,7 +6,7 @@
# CHECK: DynamicSymbols [
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: @
+# CHECK-NEXT: Name:
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Local (0x0)
@@ -15,7 +15,7 @@
# CHECK-NEXT: Section: Undefined (0x0)
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: bar@
+# CHECK-NEXT: Name: bar
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Weak (0x2)
@@ -24,7 +24,7 @@
# CHECK-NEXT: Section: Undefined (0x0)
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: foo@
+# CHECK-NEXT: Name: foo
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Global (0x1)
diff --git a/test/ELF/undef-with-plt-addr-i686.s b/test/ELF/undef-with-plt-addr-i686.s
index 755f0daced2e..cd1b3fdfe2a2 100644
--- a/test/ELF/undef-with-plt-addr-i686.s
+++ b/test/ELF/undef-with-plt-addr-i686.s
@@ -17,7 +17,7 @@ mov $set_data, %eax
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: SHF_EXECINSTR
// CHECK-NEXT: ]
-// CHECK-NEXT: Address: 0x11010
+// CHECK-NEXT: Address: 0x401010
// CHECK: Name: set_data
-// CHECK-NEXT: Value: 0x11020
+// CHECK-NEXT: Value: 0x401020
diff --git a/test/ELF/undef.s b/test/ELF/undef.s
index 07e3b689a236..e6277e36667d 100644
--- a/test/ELF/undef.s
+++ b/test/ELF/undef.s
@@ -3,6 +3,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/undef.s -o %t2.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/undef-debug.s -o %t3.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/undef-bad-debug.s -o %t4.o
+# RUN: rm -f %t2.a
# RUN: llvm-ar rc %t2.a %t2.o
# RUN: not ld.lld %t.o %t2.a %t3.o %t4.o -o %t.exe 2>&1 | FileCheck %s
# RUN: not ld.lld -pie %t.o %t2.a %t3.o %t4.o -o %t.exe 2>&1 | FileCheck %s
@@ -19,6 +20,9 @@
# CHECK: >>> referenced by undef.s
# CHECK: >>> {{.*}}:(.text+0x10)
+# CHECK: error: undefined symbol: vtable for Foo
+# CHECK: the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction)
+
# CHECK: error: undefined symbol: zed2
# CHECK: >>> referenced by {{.*}}.o:(.text+0x0) in archive {{.*}}2.a
@@ -59,3 +63,4 @@ _start:
call bar
call zed1
call _Z3fooi
+ call _ZTV3Foo
diff --git a/test/ELF/verdef-defaultver.s b/test/ELF/verdef-defaultver.s
index c8444c4e0663..db50e7c8f49f 100644
--- a/test/ELF/verdef-defaultver.s
+++ b/test/ELF/verdef-defaultver.s
@@ -8,7 +8,7 @@
# DSO: DynamicSymbols [
# DSO-NEXT: Symbol {
-# DSO-NEXT: Name: @
+# DSO-NEXT: Name:
# DSO-NEXT: Value: 0x0
# DSO-NEXT: Size: 0
# DSO-NEXT: Binding: Local
@@ -61,7 +61,7 @@
# DSO-NEXT: Symbols [
# DSO-NEXT: Symbol {
# DSO-NEXT: Version: 0
-# DSO-NEXT: Name: @
+# DSO-NEXT: Name:
# DSO-NEXT: }
# DSO-NEXT: Symbol {
# DSO-NEXT: Version: 2
@@ -112,7 +112,7 @@
# EXE: DynamicSymbols [
# EXE-NEXT: Symbol {
-# EXE-NEXT: Name: @
+# EXE-NEXT: Name:
# EXE-NEXT: Value: 0x0
# EXE-NEXT: Size: 0
# EXE-NEXT: Binding: Local
@@ -156,7 +156,7 @@
# EXE-NEXT: Symbols [
# EXE-NEXT: Symbol {
# EXE-NEXT: Version: 0
-# EXE-NEXT: Name: @
+# EXE-NEXT: Name:
# EXE-NEXT: }
# EXE-NEXT: Symbol {
# EXE-NEXT: Version: 2
diff --git a/test/ELF/verdef.s b/test/ELF/verdef.s
index b5d12ee3884f..9fc5bdd4f279 100644
--- a/test/ELF/verdef.s
+++ b/test/ELF/verdef.s
@@ -14,7 +14,7 @@
# DSO-NEXT: Symbols [
# DSO-NEXT: Symbol {
# DSO-NEXT: Version: 0
-# DSO-NEXT: Name: @
+# DSO-NEXT: Name:
# DSO-NEXT: }
# DSO-NEXT: Symbol {
# DSO-NEXT: Version: 2
@@ -76,7 +76,7 @@
# MAIN-NEXT: Symbols [
# MAIN-NEXT: Symbol {
# MAIN-NEXT: Version: 0
-# MAIN-NEXT: Name: @
+# MAIN-NEXT: Name:
# MAIN-NEXT: }
# MAIN-NEXT: Symbol {
# MAIN-NEXT: Version: 2
diff --git a/test/ELF/verneed.s b/test/ELF/verneed.s
index 6e87f046e304..e8b65c40663a 100644
--- a/test/ELF/verneed.s
+++ b/test/ELF/verneed.s
@@ -76,7 +76,7 @@
# CHECK: DynamicSymbols [
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: @
+# CHECK-NEXT: Name:
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Local (0x0)
@@ -125,7 +125,7 @@
# CHECK-NEXT: Symbols [
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Version: 0
-# CHECK-NEXT: Name: @
+# CHECK-NEXT: Name:
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Version: 2
diff --git a/test/ELF/version-exclude-libs.s b/test/ELF/version-exclude-libs.s
index 7335c2315eba..a25a08f14b6f 100644
--- a/test/ELF/version-exclude-libs.s
+++ b/test/ELF/version-exclude-libs.s
@@ -1,5 +1,6 @@
// REQUIRES: x86
// RUN: llvm-mc %p/Inputs/versiondef.s -o %t.o -filetype=obj -triple=x86_64-pc-linux
+// RUN: rm -f %t.a
// RUN: llvm-ar -r %t.a %t.o
// RUN: llvm-mc %s -o %t2.o -filetype=obj -triple=x86_64-pc-linux
// RUN: ld.lld %t2.o %t.a --shared --exclude-libs ALL -o %t.so
diff --git a/test/ELF/version-script-complex-wildcards.s b/test/ELF/version-script-complex-wildcards.s
index ce001d0b76c3..1ba34787646d 100644
--- a/test/ELF/version-script-complex-wildcards.s
+++ b/test/ELF/version-script-complex-wildcards.s
@@ -4,14 +4,14 @@
# RUN: echo "FOO { global: extern \"C++\" { ab[c]*; }; };" > %t.script
# RUN: ld.lld --version-script %t.script -shared %t.o -o %t.so
# RUN: llvm-readobj -V %t.so | FileCheck %s --check-prefix=ABC
-# ABC: Name: _Z3abbi@
+# ABC: Name: _Z3abbi
# ABC: Name: _Z3abci@@FOO
# RUN: echo "FOO { global: extern \"C++\" { ab[b]*; }; };" > %t1.script
# RUN: ld.lld --version-script %t1.script -shared %t.o -o %t1.so
# RUN: llvm-readobj -V %t1.so | FileCheck %s --check-prefix=ABB
# ABB: Name: _Z3abbi@@FOO
-# ABB: Name: _Z3abci@
+# ABB: Name: _Z3abci
# RUN: echo "FOO { global: extern \"C++\" { ab[a-b]*; }; };" > %t2.script
# RUN: ld.lld --version-script %t2.script -shared %t.o -o %t2.so
@@ -34,8 +34,8 @@
# RUN: echo "FOO { global: extern \"C++\" { ab[^a-c]*; }; };" > %t6.script
# RUN: ld.lld --version-script %t6.script -shared %t.o -o %t6.so
# RUN: llvm-readobj -V %t6.so | FileCheck %s --check-prefix=NO
-# NO: Name: _Z3abbi@
-# NO: Name: _Z3abci@
+# NO: Name: _Z3abbi
+# NO: Name: _Z3abci
# RUN: echo "FOO { global: extern \"C++\" { ab[^c-z]*; }; };" > %t7.script
# RUN: ld.lld --version-script %t7.script -shared %t.o -o %t7.so
diff --git a/test/ELF/version-script-extern-undefined.s b/test/ELF/version-script-extern-undefined.s
index 518b122ce7cd..8bff4050b621 100644
--- a/test/ELF/version-script-extern-undefined.s
+++ b/test/ELF/version-script-extern-undefined.s
@@ -8,11 +8,11 @@
# CHECK: Symbols [
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Version: 0
-# CHECK-NEXT: Name: @
+# CHECK-NEXT: Name:
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Version: 1
-# CHECK-NEXT: Name: _Z3abbi@
+# CHECK-NEXT: Name: _Z3abbi
# CHECK-NEXT: }
# CHECK-NEXT: ]
diff --git a/test/ELF/version-script-extern-wildcards.s b/test/ELF/version-script-extern-wildcards.s
index 472fc1f7833e..27660b25cb02 100644
--- a/test/ELF/version-script-extern-wildcards.s
+++ b/test/ELF/version-script-extern-wildcards.s
@@ -8,7 +8,7 @@
# CHECK: Version symbols {
# CHECK: Symbols [
-# CHECK: Name: _Z3bari@
+# CHECK: Name: _Z3bari
# CHECK: Name: _Z3fooi@@FOO
# CHECK: Name: _Z3zedi@@BAR
diff --git a/test/ELF/version-script-extern.s b/test/ELF/version-script-extern.s
index 16f400354356..682afb09fa34 100644
--- a/test/ELF/version-script-extern.s
+++ b/test/ELF/version-script-extern.s
@@ -12,7 +12,7 @@
# DSO: DynamicSymbols [
# DSO-NEXT: Symbol {
-# DSO-NEXT: Name: @
+# DSO-NEXT: Name:
# DSO-NEXT: Value: 0x0
# DSO-NEXT: Size: 0
# DSO-NEXT: Binding: Local
@@ -74,7 +74,7 @@
# DSO-NEXT: Symbols [
# DSO-NEXT: Symbol {
# DSO-NEXT: Version: 0
-# DSO-NEXT: Name: @
+# DSO-NEXT: Name:
# DSO-NEXT: }
# DSO-NEXT: Symbol {
# DSO-NEXT: Version: 3
diff --git a/test/ELF/version-script-extern2.s b/test/ELF/version-script-extern2.s
index 834bbe1122e5..245cb0076533 100644
--- a/test/ELF/version-script-extern2.s
+++ b/test/ELF/version-script-extern2.s
@@ -8,7 +8,7 @@
# CHECK: Symbols [
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Version: 0
-# CHECK-NEXT: Name: @
+# CHECK-NEXT: Name:
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Version: 2
diff --git a/test/ELF/version-script-hide-so-symbol.s b/test/ELF/version-script-hide-so-symbol.s
index b4f58be06de7..c84e37a5ac45 100644
--- a/test/ELF/version-script-hide-so-symbol.s
+++ b/test/ELF/version-script-hide-so-symbol.s
@@ -12,7 +12,7 @@
# CHECK: DynamicSymbols [
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: @ (0)
+# CHECK-NEXT: Name:
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Local
diff --git a/test/ELF/version-script-locals-extern.s b/test/ELF/version-script-locals-extern.s
index 12e8771b8eff..ca1d7173eb91 100644
--- a/test/ELF/version-script-locals-extern.s
+++ b/test/ELF/version-script-locals-extern.s
@@ -7,11 +7,11 @@
# ABB: Symbols [
# ABB-NEXT: Symbol {
# ABB-NEXT: Version: 0
-# ABB-NEXT: Name: @
+# ABB-NEXT: Name:
# ABB-NEXT: }
# ABB-NEXT: Symbol {
# ABB-NEXT: Version: 1
-# ABB-NEXT: Name: _Z3abci@
+# ABB-NEXT: Name: _Z3abci
# ABB-NEXT: }
# ABB-NEXT: ]
@@ -26,11 +26,11 @@
# ABC: Symbols [
# ABC-NEXT: Symbol {
# ABC-NEXT: Version: 0
-# ABC-NEXT: Name: @
+# ABC-NEXT: Name:
# ABC-NEXT: }
# ABC-NEXT: Symbol {
# ABC-NEXT: Version: 1
-# ABC-NEXT: Name: _Z3abbi@
+# ABC-NEXT: Name: _Z3abbi
# ABC-NEXT: }
# ABC-NEXT: ]
diff --git a/test/ELF/version-script-symver2.s b/test/ELF/version-script-symver2.s
index 5961d9a7c3a6..8441e1930abc 100644
--- a/test/ELF/version-script-symver2.s
+++ b/test/ELF/version-script-symver2.s
@@ -7,7 +7,7 @@
# CHECK: Symbols [
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Version: 0
-# CHECK-NEXT: Name: @
+# CHECK-NEXT: Name:
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Version: 3
diff --git a/test/ELF/version-script-weak.s b/test/ELF/version-script-weak.s
index cc3df8da5dc5..887d6f94d890 100644
--- a/test/ELF/version-script-weak.s
+++ b/test/ELF/version-script-weak.s
@@ -14,7 +14,7 @@
# CHECK-NEXT: }
# CHECK-NEXT: ]
# CHECK: Symbol {
-# CHECK: Name: foo@
+# CHECK: Name: foo
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Weak
diff --git a/test/ELF/version-script.s b/test/ELF/version-script.s
index 75083ac9a767..5f2f3c44c9b2 100644
--- a/test/ELF/version-script.s
+++ b/test/ELF/version-script.s
@@ -50,7 +50,7 @@
# DSO: DynamicSymbols [
# DSO-NEXT: Symbol {
-# DSO-NEXT: Name: @
+# DSO-NEXT: Name:
# DSO-NEXT: Value: 0x0
# DSO-NEXT: Size: 0
# DSO-NEXT: Binding: Local (0x0)
@@ -59,7 +59,7 @@
# DSO-NEXT: Section: Undefined (0x0)
# DSO-NEXT: }
# DSO-NEXT: Symbol {
-# DSO-NEXT: Name: bar@
+# DSO-NEXT: Name: bar
# DSO-NEXT: Value: 0x0
# DSO-NEXT: Size: 0
# DSO-NEXT: Binding: Global (0x1)
@@ -68,7 +68,7 @@
# DSO-NEXT: Section: Undefined (0x0)
# DSO-NEXT: }
# DSO-NEXT: Symbol {
-# DSO-NEXT: Name: foo1@
+# DSO-NEXT: Name: foo1
# DSO-NEXT: Value: 0x1000
# DSO-NEXT: Size: 0
# DSO-NEXT: Binding: Global (0x1)
@@ -77,7 +77,7 @@
# DSO-NEXT: Section: .text
# DSO-NEXT: }
# DSO-NEXT: Symbol {
-# DSO-NEXT: Name: foo3@
+# DSO-NEXT: Name: foo3
# DSO-NEXT: Value: 0x1007
# DSO-NEXT: Size: 0
# DSO-NEXT: Binding: Global (0x1)
@@ -89,7 +89,7 @@
# DSO2: DynamicSymbols [
# DSO2-NEXT: Symbol {
-# DSO2-NEXT: Name: @
+# DSO2-NEXT: Name:
# DSO2-NEXT: Value: 0x0
# DSO2-NEXT: Size: 0
# DSO2-NEXT: Binding: Local (0x0)
@@ -98,7 +98,7 @@
# DSO2-NEXT: Section: Undefined (0x0)
# DSO2-NEXT: }
# DSO2-NEXT: Symbol {
-# DSO2-NEXT: Name: bar@
+# DSO2-NEXT: Name: bar
# DSO2-NEXT: Value: 0x0
# DSO2-NEXT: Size: 0
# DSO2-NEXT: Binding: Global (0x1)
@@ -110,7 +110,7 @@
# VERDSO: DynamicSymbols [
# VERDSO-NEXT: Symbol {
-# VERDSO-NEXT: Name: @
+# VERDSO-NEXT: Name:
# VERDSO-NEXT: Value: 0x0
# VERDSO-NEXT: Size: 0
# VERDSO-NEXT: Binding: Local
@@ -119,7 +119,7 @@
# VERDSO-NEXT: Section: Undefined
# VERDSO-NEXT: }
# VERDSO-NEXT: Symbol {
-# VERDSO-NEXT: Name: bar@
+# VERDSO-NEXT: Name: bar
# VERDSO-NEXT: Value: 0x0
# VERDSO-NEXT: Size: 0
# VERDSO-NEXT: Binding: Global
@@ -158,7 +158,7 @@
# ALL: DynamicSymbols [
# ALL-NEXT: Symbol {
-# ALL-NEXT: Name: @
+# ALL-NEXT: Name:
# ALL-NEXT: Value: 0x0
# ALL-NEXT: Size: 0
# ALL-NEXT: Binding: Local
@@ -167,7 +167,7 @@
# ALL-NEXT: Section: Undefined
# ALL-NEXT: }
# ALL-NEXT: Symbol {
-# ALL-NEXT: Name: _start@
+# ALL-NEXT: Name: _start
# ALL-NEXT: Value:
# ALL-NEXT: Size: 0
# ALL-NEXT: Binding: Global
@@ -176,7 +176,7 @@
# ALL-NEXT: Section: .text
# ALL-NEXT: }
# ALL-NEXT: Symbol {
-# ALL-NEXT: Name: bar@
+# ALL-NEXT: Name: bar
# ALL-NEXT: Value:
# ALL-NEXT: Size: 0
# ALL-NEXT: Binding: Global
@@ -185,7 +185,7 @@
# ALL-NEXT: Section: Undefined
# ALL-NEXT: }
# ALL-NEXT: Symbol {
-# ALL-NEXT: Name: foo1@
+# ALL-NEXT: Name: foo1
# ALL-NEXT: Value:
# ALL-NEXT: Size: 0
# ALL-NEXT: Binding: Global
@@ -194,7 +194,7 @@
# ALL-NEXT: Section: .text
# ALL-NEXT: }
# ALL-NEXT: Symbol {
-# ALL-NEXT: Name: foo2@
+# ALL-NEXT: Name: foo2
# ALL-NEXT: Value:
# ALL-NEXT: Size: 0
# ALL-NEXT: Binding: Global
@@ -203,7 +203,7 @@
# ALL-NEXT: Section: .text
# ALL-NEXT: }
# ALL-NEXT: Symbol {
-# ALL-NEXT: Name: foo3@
+# ALL-NEXT: Name: foo3
# ALL-NEXT: Value:
# ALL-NEXT: Size: 0
# ALL-NEXT: Binding: Global
diff --git a/test/ELF/version-wildcard.test b/test/ELF/version-wildcard.test
index ac0b7edc6c51..f9a43319a837 100644
--- a/test/ELF/version-wildcard.test
+++ b/test/ELF/version-wildcard.test
@@ -7,7 +7,7 @@
# CHECK: DynamicSymbols [
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: @
+# CHECK-NEXT: Name:
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Local
@@ -52,7 +52,7 @@
# MIX: DynamicSymbols [
# MIX-NEXT: Symbol {
-# MIX-NEXT: Name: @
+# MIX-NEXT: Name:
# MIX-NEXT: Value: 0x0
# MIX-NEXT: Size: 0
# MIX-NEXT: Binding: Local
diff --git a/test/ELF/visibility.s b/test/ELF/visibility.s
index 0582d718e8ee..b9e9b55836a8 100644
--- a/test/ELF/visibility.s
+++ b/test/ELF/visibility.s
@@ -82,7 +82,7 @@
// CHECK: DynamicSymbols [
// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: @
+// CHECK-NEXT: Name:
// CHECK-NEXT: Value: 0x0
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local
diff --git a/test/ELF/weak-undef-export.s b/test/ELF/weak-undef-export.s
index 164bc1730832..561a0571a413 100644
--- a/test/ELF/weak-undef-export.s
+++ b/test/ELF/weak-undef-export.s
@@ -8,7 +8,7 @@
# CHECK: DynamicSymbols [
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: @ (0)
+# CHECK-NEXT: Name:
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Local (0x0)
@@ -17,7 +17,7 @@
# CHECK-NEXT: Section: Undefined (0x0)
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: foo@ (1)
+# CHECK-NEXT: Name: foo
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Weak (0x2)
diff --git a/test/ELF/weak-undef.s b/test/ELF/weak-undef.s
index 09c2a4c4440f..e7905c33876c 100644
--- a/test/ELF/weak-undef.s
+++ b/test/ELF/weak-undef.s
@@ -5,7 +5,7 @@
# CHECK: DynamicSymbols [
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: @
+# CHECK-NEXT: Name:
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Local (0x0)
@@ -14,7 +14,7 @@
# CHECK-NEXT: Section: Undefined (0x0)
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: foo@
+# CHECK-NEXT: Name: foo
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Weak
diff --git a/test/ELF/wrap-entry.s b/test/ELF/wrap-entry.s
new file mode 100644
index 000000000000..c746b8e6d118
--- /dev/null
+++ b/test/ELF/wrap-entry.s
@@ -0,0 +1,13 @@
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+
+// RUN: ld.lld -o %t.exe %t.o -wrap=_start
+// RUN: llvm-readobj -file-headers %t.exe | FileCheck %s
+
+// CHECK: Entry: 0x201001
+
+.global _start, __wrap__start
+_start:
+ nop
+__wrap__start:
+ nop
diff --git a/test/ELF/wrap-no-real.s b/test/ELF/wrap-no-real.s
index 100efa6bbc28..2dba291ac9d4 100644
--- a/test/ELF/wrap-no-real.s
+++ b/test/ELF/wrap-no-real.s
@@ -15,60 +15,14 @@
// CHECK-NEXT: movl $0x11010, %edx
// CHECK-NEXT: movl $0x11000, %edx
-// RUN: llvm-readobj -t %t | FileCheck -check-prefix=SYM %s
+// RUN: llvm-objdump -t %t | FileCheck -check-prefix=SYM %s
-// Test the full symbol table. It is verbose, but lld at times
-// produced duplicated symbols which are hard to test otherwise.
-// SYM: Symbols [
-// SYM-NEXT: Symbol {
-// SYM-NEXT: Name: (0)
-// SYM-NEXT: Value:
-// SYM-NEXT: Size:
-// SYM-NEXT: Binding:
-// SYM-NEXT: Type
-// SYM-NEXT: Other:
-// SYM-NEXT: Section:
-// SYM-NEXT: }
-// SYM-NEXT: Symbol {
-// SYM-NEXT: Name: _DYNAMIC
-// SYM-NEXT: Value:
-// SYM-NEXT: Size:
-// SYM-NEXT: Binding:
-// SYM-NEXT: Type:
-// SYM-NEXT: Other [
-// SYM-NEXT: STV_HIDDEN
-// SYM-NEXT: ]
-// SYM-NEXT: Section: .dynamic
-// SYM-NEXT: }
-// SYM-NEXT: Symbol {
-// SYM-NEXT: Name: foo
-// SYM-NEXT: Value: 0x11000
-// SYM-NEXT: Size:
-// SYM-NEXT: Binding:
-// SYM-NEXT: Type:
-// SYM-NEXT: Other:
-// SYM-NEXT: Section:
-// SYM-NEXT: }
-// SYM-NEXT: Symbol {
-// SYM-NEXT: Name: _start
-// SYM-NEXT: Value:
-// SYM-NEXT: Size:
-// SYM-NEXT: Binding:
-// SYM-NEXT: Type
-// SYM-NEXT: Other:
-// SYM-NEXT: Section:
-// SYM-NEXT: }
-// SYM-NEXT: Symbol {
-// SYM-NEXT: Name: __wrap_foo
-// SYM-NEXT: Value: 0x11010
-// SYM-NEXT: Size:
-// SYM-NEXT: Binding:
-// SYM-NEXT: Type:
-// SYM-NEXT: Other:
-// SYM-NEXT: Section:
-// SYM-NEXT: }
-// SYM-NEXT: ]
+// SYM: 0000000000202000 .dynamic 00000000 .hidden _DYNAMIC
+// SYM-NEXT: 0000000000011000 *ABS* 00000000 __real_foo
+// SYM-NEXT: 0000000000011010 *ABS* 00000000 __wrap_foo
+// SYM-NEXT: 0000000000201000 .text 00000000 _start
+// SYM-NEXT: 0000000000011000 *ABS* 00000000 foo
.global _start
_start:
diff --git a/test/ELF/wrap-plt.s b/test/ELF/wrap-plt.s
new file mode 100644
index 000000000000..71f533dc5a9c
--- /dev/null
+++ b/test/ELF/wrap-plt.s
@@ -0,0 +1,45 @@
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
+
+// RUN: ld.lld -o %t2 %t -wrap foo -shared
+// RUN: llvm-readobj -s -r %t2 | FileCheck %s
+// RUN: llvm-objdump -d %t2 | FileCheck --check-prefix=DISASM %s
+
+// CHECK: Name: .plt
+// CHECK-NEXT: Type: SHT_PROGBITS
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: SHF_ALLOC
+// CHECK-NEXT: SHF_EXECINSTR
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address: 0x1020
+// CHECK-NEXT: Offset:
+// CHECK-NEXT: Size: 48
+// CHECK-NEXT: Link: 0
+// CHECK-NEXT: Info: 0
+// CHECK-NEXT: AddressAlignment: 16
+
+// CHECK: Relocations [
+// CHECK-NEXT: Section ({{.*}}) .rela.plt {
+// CHECK-NEXT: 0x2018 R_X86_64_JUMP_SLOT __wrap_foo 0x0
+// CHECK-NEXT: 0x2020 R_X86_64_JUMP_SLOT _start 0x0
+// CHECK-NEXT: }
+// CHECK-NEXT: ]
+
+// DISASM: _start:
+// DISASM-NEXT: jmp 41
+// DISASM-NEXT: jmp 36
+// DISASM-NEXT: jmp 47
+
+.global foo
+foo:
+ nop
+
+.global __wrap_foo
+__wrap_foo:
+ nop
+
+.global _start
+_start:
+ jmp foo@plt
+ jmp __wrap_foo@plt
+ jmp _start@plt
diff --git a/test/ELF/wrap-with-archive.s b/test/ELF/wrap-with-archive.s
new file mode 100644
index 000000000000..1bfbdcef30dd
--- /dev/null
+++ b/test/ELF/wrap-with-archive.s
@@ -0,0 +1,13 @@
+// REQUIRES: x86
+// 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/wrap-with-archive.s -o %t2
+// RUN: llvm-ar rcs %t3 %t2
+// RUN: ld.lld -o %t4 %t %t3 -wrap get_executable_start
+
+// Regression test for https://bugs.llvm.org/show_bug.cgi?id=40134
+
+.global get_executable_start
+.global _start
+
+_start:
+ jmp get_executable_start
diff --git a/test/ELF/wrap.s b/test/ELF/wrap.s
index a02592e24ebd..1a9726851f7e 100644
--- a/test/ELF/wrap.s
+++ b/test/ELF/wrap.s
@@ -34,7 +34,7 @@
// SYM2-NEXT: STV_PROTECTED
// SYM2-NEXT: ]
// SYM3: Name: __real_foo
-// SYM3-NEXT: Value: 0x11020
+// SYM3-NEXT: Value: 0x11000
// SYM3-NEXT: Size:
// SYM3-NEXT: Binding: Global
// SYM3-NEXT: Type: None
diff --git a/test/ELF/x86-64-combined-dynrel.s b/test/ELF/x86-64-combined-dynrel.s
new file mode 100644
index 000000000000..b1bc697d148b
--- /dev/null
+++ b/test/ELF/x86-64-combined-dynrel.s
@@ -0,0 +1,40 @@
+# REQUIRES: x86
+# RUN: llvm-mc --triple=x86_64-pc-linux -filetype=obj -o %t.o %s
+# RUN: echo "SECTIONS { \
+# RUN: .text : { *(.text) } \
+# RUN: .rela.dyn : { *(.rela.dyn) *(.rela.plt) } \
+# RUN: } " > %t.script
+# RUN: ld.lld %t.o -o %t.so --shared --script %t.script
+# RUN: llvm-readobj --section-headers --dynamic-table %t.so | FileCheck %s
+
+// The linker script above combines the .rela.dyn and .rela.plt into a single
+// table. ELF is clear that the DT_PLTRELSZ should match the subset of
+// relocations that is associated with the PLT. It is less clear about what
+// the value of DT_RELASZ should be. ELF implies that it should be the size
+// of the single table so that DT_RELASZ includes DT_PLTRELSZ. The loader in
+// glibc permits this as long as .rela.plt comes after .rela.dyn in the
+// combined table.
+
+ .text
+ .globl func
+ .type func, %function
+ .globl foo
+ .type foo, %object
+
+ .globl _start
+ .type _start, %function
+_start:
+ call func@plt
+ movq func@GOTPCREL (%rip), %rax
+
+# CHECK: Name: .rela.dyn
+# CHECK-NEXT: Type: SHT_RELA
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: SHF_ALLOC
+# CHECK-NEXT: ]
+# CHECK-NEXT: Address:
+# CHECK-NEXT: Offset:
+# CHECK-NEXT: Size: 48
+
+# CHECK: 0x0000000000000008 RELASZ 48
+# CHECK: 0x0000000000000002 PLTRELSZ 24
diff --git a/test/ELF/x86-64-reloc-error2.s b/test/ELF/x86-64-reloc-error2.s
index d49b67522654..230241b2be5f 100644
--- a/test/ELF/x86-64-reloc-error2.s
+++ b/test/ELF/x86-64-reloc-error2.s
@@ -1,14 +1,18 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-# RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
+# RUN: not ld.lld --entry=func --gc-sections %t.o -o /dev/null 2>&1 | FileCheck %s
## Check we are able to find a function symbol that encloses
## a given location when reporting error messages.
-# CHECK: {{.*}}.o:(function func): relocation R_X86_64_32S out of range: -281474974609408 is not in [-2147483648, 2147483647]
+# CHECK: {{.*}}.o:(function func: .text.func+0x3): relocation R_X86_64_32S out of range: -281474974609408 is not in [-2147483648, 2147483647]
+
+# This mergeable section will be garbage collected. We had a crash issue in that case. Test it.
+.section .rodata.str1,"aMS",@progbits,1
+.asciz "a"
.section .text.func, "ax", %progbits
.globl func
.type func,@function
-.size func, 0x10
func:
- movq func - 0x1000000000000, %rdx
+ movq $func - 0x1000000000000, %rdx
+.size func, .-func
diff --git a/test/ELF/x86-64-reloc-gotoff64.s b/test/ELF/x86-64-reloc-gotoff64.s
index 697ac17917a2..b78d96e00a6e 100644
--- a/test/ELF/x86-64-reloc-gotoff64.s
+++ b/test/ELF/x86-64-reloc-gotoff64.s
@@ -1,7 +1,7 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
// RUN: ld.lld %t.o -shared -o %t.so
-// RUN: llvm-readelf -s %t.so | FileCheck %s -check-prefix=SECTION
+// RUN: llvm-readelf -S %t.so | FileCheck %s -check-prefix=SECTION
// RUN: llvm-objdump -d %t.so | FileCheck %s
// SECTION: .dynamic DYNAMIC 0000000000003000
diff --git a/test/ELF/x86-64-reloc-gotpc64.s b/test/ELF/x86-64-reloc-gotpc64.s
index f07376f41218..9c58217b4586 100644
--- a/test/ELF/x86-64-reloc-gotpc64.s
+++ b/test/ELF/x86-64-reloc-gotpc64.s
@@ -1,7 +1,7 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
// RUN: ld.lld %t.o -shared -o %t.so
-// RUN: llvm-readelf -s %t.so | FileCheck %s -check-prefix=SECTION
+// RUN: llvm-readelf -S %t.so | FileCheck %s -check-prefix=SECTION
// RUN: llvm-objdump -d %t.so | FileCheck %s
// SECTION: .got PROGBITS 0000000000003070 003070 000000
diff --git a/test/ELF/x86-64-reloc-range-debug-loc.s b/test/ELF/x86-64-reloc-range-debug-loc.s
index 8be4df3c5202..08a49607e806 100644
--- a/test/ELF/x86-64-reloc-range-debug-loc.s
+++ b/test/ELF/x86-64-reloc-range-debug-loc.s
@@ -5,7 +5,7 @@
## Check we are able to report file and location from debug information
## when reporting such kind of errors.
-# CHECK: error: test.s:3: relocation R_X86_64_32 out of range: 68719476736 is not in [0, 4294967295]
+# CHECK: error: test.s:3:(.text+0x1): relocation R_X86_64_32 out of range: 68719476736 is not in [0, 4294967295]
.section .text,"ax",@progbits
foo:
diff --git a/test/ELF/x86-64-reloc-range.s b/test/ELF/x86-64-reloc-range.s
index c58a692821ec..87e3379da859 100644
--- a/test/ELF/x86-64-reloc-range.s
+++ b/test/ELF/x86-64-reloc-range.s
@@ -1,6 +1,8 @@
// REQUIRES: x86
// RUN: llvm-mc %s -o %t.o -triple x86_64-pc-linux -filetype=obj
// RUN: not ld.lld %t.o -o /dev/null -shared 2>&1 | FileCheck %s
+// RUN: ld.lld --noinhibit-exec -shared %t.o -o %t 2>&1 | FileCheck %s
+// RUN: ls %t
// CHECK: {{.*}}:(.text+0x3): relocation R_X86_64_PC32 out of range: 2147483648 is not in [-2147483648, 2147483647]
// CHECK-NOT: relocation
diff --git a/test/ELF/x86-64-retpoline-znow-static-iplt.s b/test/ELF/x86-64-retpoline-znow-static-iplt.s
new file mode 100644
index 000000000000..70355c05e2cd
--- /dev/null
+++ b/test/ELF/x86-64-retpoline-znow-static-iplt.s
@@ -0,0 +1,26 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: ld.lld -z retpolineplt -z now %t.o -o %t
+# RUN: llvm-objdump -d -no-show-raw-insn %t | FileCheck %s
+
+#0x201001+5 + 42 = 0x201030 (foo@plt)
+# CHECK: _start:
+# CHECK-NEXT: 201001: callq 42
+
+#Static IPLT header due to -z retpolineplt
+# CHECK: 0000000000201010 .plt:
+# CHECK-NEXT: 201010: callq 11 <.plt+0x10>
+# CHECK-NEXT: 201015: pause
+# CHECK-NEXT: 201017: lfence
+#foo@plt
+# CHECK: 201030: movq 4041(%rip), %r11
+# CHECK-NEXT: 201037: jmp -44 <.plt>
+
+.type foo STT_GNU_IFUNC
+.globl foo
+foo:
+ ret
+
+.globl _start
+_start:
+ call foo
diff --git a/test/ELF/x86-64-split-stack-prologue-adjust-fail.s b/test/ELF/x86-64-split-stack-prologue-adjust-fail.s
index 0ae3de5ea611..b2d21e1595a3 100644
--- a/test/ELF/x86-64-split-stack-prologue-adjust-fail.s
+++ b/test/ELF/x86-64-split-stack-prologue-adjust-fail.s
@@ -1,14 +1,18 @@
# 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 %p/Inputs/x86-64-split-stack-main.s -o %t2.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/x86-64-split-stack-extra.s -o %t2.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/x86-64-split-stack-main.s -o %t3.o
-# RUN: not ld.lld --defsym __morestack=0x100 %t1.o %t2.o -o %t 2>&1 | FileCheck %s
+# RUN: not ld.lld --defsym __morestack=0x100 --defsym __more_stack_nonsplit=0x200 %t1.o %t2.o %t3.o -o %t 2>&1 | FileCheck %s
# An unknown prologue gives a match failure
-# CHECK: unable to adjust the enclosing function's
+# CHECK: error: {{.*}}.o:(.text): unknown_prologue (with -fsplit-stack) calls non_split (without -fsplit-stack), but couldn't adjust its prologue
# RUN: not ld.lld -r --defsym __morestack=0x100 %t1.o %t2.o -o %t 2>&1 | FileCheck %s -check-prefix=RELOCATABLE
-# RELOCATABLE: Cannot mix split-stack and non-split-stack in a relocatable link
+# RELOCATABLE: cannot mix split-stack and non-split-stack in a relocatable link
+
+# RUN: not ld.lld --defsym __morestack=0x100 --defsym _start=0x300 %t1.o %t2.o %t3.o -o %t 2>&1 | FileCheck %s -check-prefix=ERROR
+# ERROR: Mixing split-stack objects requires a definition of __morestack_non_split
.text
diff --git a/test/ELF/x86-64-split-stack-prologue-adjust-shared.s b/test/ELF/x86-64-split-stack-prologue-adjust-shared.s
new file mode 100644
index 000000000000..9da2dde2e208
--- /dev/null
+++ b/test/ELF/x86-64-split-stack-prologue-adjust-shared.s
@@ -0,0 +1,31 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/x86-64-split-stack-extra.s -o %t2.o
+# RUN: ld.lld --defsym __morestack=0x100 --defsym __morestack_non_split=0x200 %t2.o -o %t4.so -shared
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
+# RUN: ld.lld --defsym __morestack=0x100 --defsym __morestack_non_split=0x200 %t1.o %t4.so -o %t
+# RUN: llvm-objdump -d %t | FileCheck %s
+
+# For a cross .so call, make sure lld produced the conservative call to __morestack_non_split.
+# CHECK: prologue1_cross_so_call:
+# CHECK-NEXT: stc{{.*$}}
+# CHECK-NEXT: nopl{{.*$}}
+# CHECK: jae{{.*$}}
+# CHECK-NEXT: callq{{.*}}<__morestack_non_split>
+
+ .text
+
+ .global prologue1_cross_so_call
+ .type prologue1_cross_so_call,@function
+prologue1_cross_so_call:
+ cmp %fs:0x70,%rsp
+ jae 1f
+ callq __morestack
+ retq
+1:
+ callq split
+ retq
+ .size prologue1_cross_so_call,. - prologue1_cross_so_call
+
+ .section .note.GNU-stack,"",@progbits
+ .section .note.GNU-split-stack,"",@progbits
diff --git a/test/ELF/x86-64-split-stack-prologue-adjust-silent.s b/test/ELF/x86-64-split-stack-prologue-adjust-silent.s
index 353eabef0de7..0c82943f8dd1 100644
--- a/test/ELF/x86-64-split-stack-prologue-adjust-silent.s
+++ b/test/ELF/x86-64-split-stack-prologue-adjust-silent.s
@@ -2,7 +2,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/x86-64-split-stack-main.s -o %t2.o
-# RUN: ld.lld --defsym __morestack=0x100 %t1.o %t2.o -o %t
+# RUN: ld.lld --defsym __morestack=0x100 --defsym __morestack_non_split=0x200 %t1.o %t2.o -o %t
# RUN: llvm-objdump -d %t 2>&1 | FileCheck %s
# An unknown prologue ordinarily gives a match failure, except that this
diff --git a/test/ELF/x86-64-split-stack-prologue-adjust-success.s b/test/ELF/x86-64-split-stack-prologue-adjust-success.s
index bad26677f3fd..fb3493f2c3e7 100644
--- a/test/ELF/x86-64-split-stack-prologue-adjust-success.s
+++ b/test/ELF/x86-64-split-stack-prologue-adjust-success.s
@@ -1,8 +1,9 @@
# 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 %p/Inputs/x86-64-split-stack-main.s -o %t2.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/x86-64-split-stack-extra.s -o %t2.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/x86-64-split-stack-main.s -o %t3.o
-# RUN: ld.lld --defsym __morestack=0x100 --defsym __morestack_non_split=0x200 %t1.o %t2.o -o %t -z notext
+# RUN: ld.lld --defsym __morestack=0x100 --defsym __morestack_non_split=0x200 %t1.o %t2.o %t3.o -o %t -z notext
# RUN: llvm-objdump -d %t | FileCheck %s
# Avoid duplicating the prologue for every test via macros.
@@ -25,11 +26,11 @@ prologue1_calls_\function_to_call:
.size prologue1_calls_\function_to_call,. - prologue1_calls_\function_to_call
.endm
-.macro prologue2 function_to_call register
+.macro prologue2 function_to_call register compare_amount
.global prologue2_calls_\function_to_call\register
.type prologue2_calls_\function_to_call\register,@function
prologue2_calls_\function_to_call\register:
- lea -0x200(%rsp),%\register
+ lea -\compare_amount(%rsp),%\register
cmp %fs:0x70,%\register
jae 1f
callq __morestack
@@ -65,20 +66,20 @@ prologue1 split
# calls plain __morestack, that any raw bytes written to the prologue
# make sense, and that the register number is preserved.
# CHECK: prologue2_calls_splitr10:
-# CHECK-NEXT: lea{{.*}} -{{[0-9]+}}(%rsp),{{.*}}%r10
+# CHECK-NEXT: lea{{.*}} -512(%rsp),{{.*}}%r10
# CHECK: cmp{{.*}}%fs:{{[^,]*}},{{.*}}%r{{[0-9]+}}
# CHECK: jae{{.*}}
# CHECK-NEXT: callq{{.*}}<__morestack>
-prologue2 split r10
+prologue2 split r10 0x200
# CHECK: prologue2_calls_splitr11:
-# CHECK-NEXT: lea{{.*}} -{{[0-9]+}}(%rsp),{{.*}}%r11
+# CHECK-NEXT: lea{{.*}} -256(%rsp),{{.*}}%r11
# CHECK: cmp{{.*}}%fs:{{[^,]*}},{{.*}}%r{{[0-9]+}}
# CHECK: jae{{.*}}
# CHECK-NEXT: callq{{.*}}<__morestack>
-prologue2 split r11
+prologue2 split r11 0x100
# For split-stack code calling non-split-stack code, ensure prologue v1
# calls __morestack_non_split, and that any raw bytes written to the prologue
@@ -95,30 +96,20 @@ prologue1 non_split
# calls __morestack_non_split, that any raw bytes written to the prologue
# make sense, and that the register number is preserved
# CHECK: prologue2_calls_non_splitr10:
-# CHECK-NEXT: lea{{.*$}}
+# CHECK-NEXT: lea{{.*}} -16640(%rsp),{{.*}}%r10
# CHECK: cmp{{.*}}%fs:{{[^,]*}},{{.*}}%r10
# CHECK: jae{{.*$}}
# CHECK-NEXT: callq{{.*}}<__morestack_non_split>
-prologue2 non_split r10
+prologue2 non_split r10 0x100
# CHECK: prologue2_calls_non_splitr11:
-# CHECK-NEXT: lea{{.*$}}
+# CHECK-NEXT: lea{{.*}} -16896(%rsp),{{.*}}%r11
# CHECK: cmp{{.*}}%fs:{{[^,]*}},{{.*}}%r11
# CHECK: jae{{.*$}}
# CHECK-NEXT: callq{{.*}}<__morestack_non_split>
-prologue2 non_split r11
-# call foo@plt # for code-coverage.
-
-
-
- .global split
- .type split,@function
-split:
- retq
-
- .size split,. - split
+prologue2 non_split r11 0x200
.section .note.GNU-stack,"",@progbits
.section .note.GNU-split-stack,"",@progbits
diff --git a/test/ELF/znotext-plt-relocations-protected.s b/test/ELF/znotext-plt-relocations-protected.s
index 4fd8065a2873..37724e74db22 100644
--- a/test/ELF/znotext-plt-relocations-protected.s
+++ b/test/ELF/znotext-plt-relocations-protected.s
@@ -4,7 +4,12 @@
# RUN: ld.lld %t2.o -o %t2.so -shared
# RUN: not ld.lld -z notext %t.o %t2.so -o /dev/null 2>&1 | FileCheck %s
-# CHECK: error: cannot preempt symbol: foo
+# CHECK: error: cannot preempt symbol: foo
+# CHECK-NEXT: >>> defined in {{.*}}2.so
+# CHECK-NEXT: >>> referenced by test.cpp
+# CHECK-NEXT: >>> {{.*}}.o:(.text+0x0)
+
+.file "test.cpp"
.global _start
_start:
diff --git a/test/ELF/zstack-size.s b/test/ELF/zstack-size.s
index 23eed0a79ecc..bec2b2057fb7 100644
--- a/test/ELF/zstack-size.s
+++ b/test/ELF/zstack-size.s
@@ -6,6 +6,9 @@
# RUN: ld.lld -z stack-size=0 %t -o %t2
# RUN: llvm-readobj -program-headers %t2 | FileCheck %s -check-prefix=CHECK2
+# RUN: ld.lld -z stack-size=0x2000 -z stack-size=0x1000 %t -o %t3
+# RUN: llvm-readobj -program-headers %t3 | FileCheck %s -check-prefix=CHECK1
+
.global _start
_start:
nop