diff --git a/lld/test/ELF/aarch64-fpic-add_abs_lo12_nc.s b/lld/test/ELF/aarch64-fpic-add_abs_lo12_nc.s index 01095d0b529f..ee2b0533368b 100644 --- a/lld/test/ELF/aarch64-fpic-add_abs_lo12_nc.s +++ b/lld/test/ELF/aarch64-fpic-add_abs_lo12_nc.s @@ -1,9 +1,10 @@ // REQUIRES: aarch64 // RUN: llvm-mc -filetype=obj -triple=aarch64 %s -o %t.o -// RUN: not ld.lld -shared %t.o -o /dev/null 2>&1 | FileCheck %s -// CHECK: error: relocation R_AARCH64_ADD_ABS_LO12_NC cannot be used against symbol 'dat'; recompile with -fPIC -// CHECK: >>> defined in {{.*}}.o -// CHECK: >>> referenced by {{.*}}.o:(.text+0x0) +// RUN: not ld.lld -shared %t.o -o /dev/null 2>&1 | FileCheck %s --implicit-check-not=error: + +// CHECK: error: relocation R_AARCH64_ADD_ABS_LO12_NC cannot be used against symbol 'dat'; recompile with -fPIC +// CHECK-NEXT: >>> defined in {{.*}}.o +// CHECK-NEXT: >>> referenced by {{.*}}.o:(.text+0x0) add x0, x0, :lo12:dat .data diff --git a/lld/test/ELF/abs-conflict.s b/lld/test/ELF/abs-conflict.s deleted file mode 100644 index 4c6a62e96b63..000000000000 --- a/lld/test/ELF/abs-conflict.s +++ /dev/null @@ -1,18 +0,0 @@ -// REQUIRES: x86 -// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -// RUN: ld.lld %t.o %t.o -o %t.so -shared -// RUN: llvm-readobj --dyn-symbols %t.so | FileCheck %s - -// CHECK: Name: foo -// CHECK-NEXT: Value: 0x123 - -.global foo -foo = 0x123 - -// RUN: echo ".global foo; foo = 0x124" > %t2.s -// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %t2.s -o %t2.o -// RUN: not ld.lld %t.o %t2.o -o /dev/null -shared 2>&1 | FileCheck --check-prefix=DUP %s - -// DUP: duplicate symbol: foo -// DUP-NEXT: >>> defined in {{.*}}.o -// DUP-NEXT: >>> defined in {{.*}}2.o diff --git a/lld/test/ELF/conflict-abs.s b/lld/test/ELF/conflict-abs.s new file mode 100644 index 000000000000..033ed046abe1 --- /dev/null +++ b/lld/test/ELF/conflict-abs.s @@ -0,0 +1,18 @@ +// REQUIRES: x86 +// RUN: rm -rf %t && mkdir %t && cd %t +// RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o a.o +// RUN: ld.lld a.o a.o -o a.so -shared +// RUN: llvm-readobj --dyn-symbols a.so | FileCheck %s + +// CHECK: Name: foo +// CHECK-NEXT: Value: 0x123 + +.global foo +foo = 0x123 + +// RUN: echo ".global foo; foo = 0x124" | llvm-mc -filetype=obj -triple=x86_64 - -o b.o +// RUN: not ld.lld a.o b.o -shared 2>&1 | FileCheck --check-prefix=DUP %s --implicit-check-not=error: + +// DUP: error: duplicate symbol: foo +// DUP-NEXT: >>> defined in {{.*}} +// DUP-NEXT: >>> defined in {{.*}} diff --git a/lld/test/ELF/conflict.s b/lld/test/ELF/conflict.s index 66a7f3912dbe..b492508f7cda 100644 --- a/lld/test/ELF/conflict.s +++ b/lld/test/ELF/conflict.s @@ -1,43 +1,44 @@ # REQUIRES: x86 +# RUN: rm -rf %t && mkdir %t && cd %t -# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o -# RUN: not ld.lld %t1.o %t1.o -o /dev/null 2>&1 | FileCheck -check-prefix=DEMANGLE %s +# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o a.o +# RUN: not ld.lld a.o a.o 2>&1 | FileCheck --check-prefix=DEMANGLE %s --implicit-check-not=error: -# DEMANGLE: duplicate symbol: mul(double, double) -# DEMANGLE-NEXT: >>> defined at {{.*}}:(.text+0x0) -# DEMANGLE-NEXT: >>> defined at {{.*}}:(.text+0x0) -# DEMANGLE: duplicate symbol: foo -# DEMANGLE-NEXT: >>> defined at {{.*}}:(.text+0x0) -# DEMANGLE-NEXT: >>> defined at {{.*}}:(.text+0x0) +# DEMANGLE: error: duplicate symbol: mul(double, double) +# DEMANGLE-NEXT: >>> defined at {{.*}}:(.text+0x0) +# DEMANGLE-NEXT: >>> defined at {{.*}}:(.text+0x0) +# DEMANGLE: error: duplicate symbol: foo +# DEMANGLE-NEXT: >>> defined at {{.*}}:(.text+0x0) +# DEMANGLE-NEXT: >>> defined at {{.*}}:(.text+0x0) -# RUN: not ld.lld %t1.o %t1.o -o /dev/null --no-demangle 2>&1 | \ -# RUN: FileCheck -check-prefix=NO_DEMANGLE %s +# RUN: not ld.lld a.o a.o --no-demangle 2>&1 | FileCheck --check-prefix=NO_DEMANGLE %s --implicit-check-not=error: -# NO_DEMANGLE: duplicate symbol: _Z3muldd +# NO_DEMANGLE: error: duplicate symbol: _Z3muldd # NO_DEMANGLE-NEXT: >>> defined at {{.*}}:(.text+0x0) # NO_DEMANGLE-NEXT: >>> defined at {{.*}}:(.text+0x0) -# NO_DEMANGLE: duplicate symbol: foo +# NO_DEMANGLE: error: duplicate symbol: foo # NO_DEMANGLE-NEXT: >>> defined at {{.*}}:(.text+0x0) # NO_DEMANGLE-NEXT: >>> defined at {{.*}}:(.text+0x0) -# RUN: not ld.lld %t1.o %t1.o -o /dev/null --demangle --no-demangle 2>&1 | \ -# RUN: FileCheck -check-prefix=NO_DEMANGLE %s -# RUN: not ld.lld %t1.o %t1.o -o /dev/null --no-demangle --demangle 2>&1 | \ -# RUN: FileCheck -check-prefix=DEMANGLE %s +# RUN: not ld.lld a.o a.o --demangle --no-demangle 2>&1 | FileCheck --check-prefix=NO_DEMANGLE %s --implicit-check-not=error: +# RUN: not ld.lld a.o a.o --no-demangle --demangle 2>&1 | FileCheck --check-prefix=DEMANGLE %s --implicit-check-not=error: -# 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 /dev/null 2>&1 | FileCheck -check-prefix=ARCHIVE %s +# RUN: llvm-mc -filetype=obj -triple=x86_64 %S/Inputs/conflict.s -o b.o +# RUN: rm -f b.a +# RUN: llvm-ar rcs b.a b.o +# RUN: not ld.lld a.o b.a -u baz 2>&1 | FileCheck --check-prefix=ARCHIVE %s --implicit-check-not=error: -# ARCHIVE: duplicate symbol: foo +# ARCHIVE: error: duplicate symbol: mul(double, double) +# ARCHIVE-NEXT: >>> defined at {{.*}}:(.text+0x0) +# ARCHIVE-NEXT: >>> defined at {{.*}}:(.text+0x0) in archive {{.*}}.a +# ARCHIVE: error: duplicate symbol: foo # ARCHIVE-NEXT: >>> defined at {{.*}}:(.text+0x0) # ARCHIVE-NEXT: >>> defined at {{.*}}:(.text+0x0) in archive {{.*}}.a -# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/conflict-debug.s -o %t-dbg.o -# RUN: not ld.lld %t-dbg.o %t-dbg.o -o /dev/null 2>&1 | FileCheck -check-prefix=DBGINFO %s +# RUN: llvm-mc -filetype=obj -triple=x86_64 %S/Inputs/conflict-debug.s -o dbg.o +# RUN: not ld.lld dbg.o dbg.o 2>&1 | FileCheck --check-prefix=DBGINFO %s --implicit-check-not=error: -# DBGINFO: duplicate symbol: zed +# DBGINFO: error: duplicate symbol: zed # DBGINFO-NEXT: >>> defined at conflict-debug.s:4 # DBGINFO-NEXT: >>> {{.*}}:(.text+0x0) # DBGINFO-NEXT: >>> defined at conflict-debug.s:4 diff --git a/lld/test/ELF/eh-frame-dyn-rel.s b/lld/test/ELF/eh-frame-dyn-rel.s index 04828e7b28b4..57d85660dfa4 100644 --- a/lld/test/ELF/eh-frame-dyn-rel.s +++ b/lld/test/ELF/eh-frame-dyn-rel.s @@ -1,10 +1,10 @@ // REQUIRES: x86 -// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -// RUN: not ld.lld %t.o %t.o -o /dev/null -shared 2>&1 | FileCheck %s +// RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o +// RUN: not ld.lld %t.o %t.o -o /dev/null -shared 2>&1 | FileCheck %s --implicit-check-not=error: -// CHECK: error: relocation R_X86_64_64 cannot be used against symbol 'foo'; recompile with -fPIC -// CHECK: >>> defined in {{.*}}.o -// CHECK: >>> referenced by {{.*}}.o:(.eh_frame+0x12) +// CHECK: error: relocation R_X86_64_64 cannot be used against symbol 'foo'; recompile with -fPIC +// CHECK-NEXT: >>> defined in {{.*}}.o +// CHECK-NEXT: >>> referenced by {{.*}}.o:(.eh_frame+0x12) .section bar,"axG",@progbits,foo,comdat .cfi_startproc diff --git a/lld/test/ELF/incompatible-section-flags.s b/lld/test/ELF/incompatible-section-flags.s index 30bbe75d766a..8b52bc44ec80 100644 --- a/lld/test/ELF/incompatible-section-flags.s +++ b/lld/test/ELF/incompatible-section-flags.s @@ -1,13 +1,13 @@ // REQUIRES: x86 -// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -// RUN: not ld.lld -shared %t.o -o /dev/null 2>&1 | FileCheck %s +// RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o +// RUN: not ld.lld -shared %t.o -o /dev/null 2>&1 | FileCheck %s --implicit-check-not=error: // CHECK: error: incompatible section flags for .foo -// CHECK-NEXT: >>> {{.*}}incompatible-section-flags.s.tmp.o:(.foo): 0x3 +// CHECK-NEXT: >>> {{.*}}.o:(.foo): 0x3 // CHECK-NEXT: >>> output section .foo: 0x403 // CHECK: error: incompatible section flags for .bar -// CHECK-NEXT: >>> {{.*}}incompatible-section-flags.s.tmp.o:(.bar): 0x403 +// CHECK-NEXT: >>> {{.*}}.o:(.bar): 0x403 // CHECK-NEXT: >>> output section .bar: 0x3 .section .foo, "awT", @progbits, unique, 1 diff --git a/lld/test/ELF/invalid-cie-length.s b/lld/test/ELF/invalid-cie-length.s index d5465e854409..2ea24c07202a 100644 --- a/lld/test/ELF/invalid-cie-length.s +++ b/lld/test/ELF/invalid-cie-length.s @@ -1,10 +1,9 @@ // REQUIRES: x86 - -// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t -// RUN: not ld.lld %t -o /dev/null 2>&1 | FileCheck %s - -.section .eh_frame,"a",@unwind -.byte 0 +// RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o +// RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s --implicit-check-not=error: // CHECK: error: corrupted .eh_frame: CIE/FDE too small // CHECK-NEXT: >>> defined in {{.*}}:(.eh_frame+0x0) + +.section .eh_frame,"a",@unwind +.byte 0 diff --git a/lld/test/ELF/loongarch-branch.s b/lld/test/ELF/loongarch-branch.s index b223ff95bd89..e099d5d96d88 100644 --- a/lld/test/ELF/loongarch-branch.s +++ b/lld/test/ELF/loongarch-branch.s @@ -1,12 +1,13 @@ # REQUIRES: loongarch +# RUN: rm -rf %t && mkdir %t && cd %t -# RUN: llvm-mc --filetype=obj --triple=loongarch32-unknown-elf %s -o %t.la32.o -# RUN: llvm-mc --filetype=obj --triple=loongarch64-unknown-elf %s -o %t.la64.o +# RUN: llvm-mc --filetype=obj --triple=loongarch32 %s -o 32.o +# RUN: llvm-mc --filetype=obj --triple=loongarch64 %s -o 64.o -# RUN: ld.lld %t.la32.o --defsym foo16=b16+4 --defsym bar16=b16 --defsym foo21=b21+4 --defsym bar21=b21 --defsym foo26=b26+4 --defsym bar26=b26 -o %t.la32 -# RUN: ld.lld %t.la64.o --defsym foo16=b16+4 --defsym bar16=b16 --defsym foo21=b21+4 --defsym bar21=b21 --defsym foo26=b26+4 --defsym bar26=b26 -o %t.la64 -# RUN: llvm-objdump --no-show-raw-insn -d %t.la32 | FileCheck %s --check-prefix=CHECK -# RUN: llvm-objdump --no-show-raw-insn -d %t.la64 | FileCheck %s --check-prefix=CHECK +# RUN: ld.lld 32.o --defsym foo16=b16+4 --defsym bar16=b16 --defsym foo21=b21+4 --defsym bar21=b21 --defsym foo26=b26+4 --defsym bar26=b26 -o 32 +# RUN: ld.lld 64.o --defsym foo16=b16+4 --defsym bar16=b16 --defsym foo21=b21+4 --defsym bar21=b21 --defsym foo26=b26+4 --defsym bar26=b26 -o 64 +# RUN: llvm-objdump --no-show-raw-insn -d 32 | FileCheck %s +# RUN: llvm-objdump --no-show-raw-insn -d 64 | FileCheck %s # CHECK: beq $zero, $zero, 4 # CHECK: bne $zero, $zero, -4 # CHECK: beqz $s8, 4 @@ -14,10 +15,10 @@ # CHECK: b 4 # CHECK: bl -4 -# RUN: ld.lld %t.la32.o --defsym foo16=b16+0x1fffc --defsym bar16=b16+4-0x20000 --defsym foo21=b21+0x3ffffc --defsym bar21=b21+4-0x400000 --defsym foo26=b26+0x7fffffc --defsym bar26=b26+4-0x8000000 -o %t.la32.limits -# RUN: ld.lld %t.la64.o --defsym foo16=b16+0x1fffc --defsym bar16=b16+4-0x20000 --defsym foo21=b21+0x3ffffc --defsym bar21=b21+4-0x400000 --defsym foo26=b26+0x7fffffc --defsym bar26=b26+4-0x8000000 -o %t.la64.limits -# RUN: llvm-objdump --no-show-raw-insn -d %t.la32.limits | FileCheck --check-prefix=LIMITS %s -# RUN: llvm-objdump --no-show-raw-insn -d %t.la64.limits | FileCheck --check-prefix=LIMITS %s +# RUN: ld.lld 32.o --defsym foo16=b16+0x1fffc --defsym bar16=b16+4-0x20000 --defsym foo21=b21+0x3ffffc --defsym bar21=b21+4-0x400000 --defsym foo26=b26+0x7fffffc --defsym bar26=b26+4-0x8000000 -o 32.limits +# RUN: ld.lld 64.o --defsym foo16=b16+0x1fffc --defsym bar16=b16+4-0x20000 --defsym foo21=b21+0x3ffffc --defsym bar21=b21+4-0x400000 --defsym foo26=b26+0x7fffffc --defsym bar26=b26+4-0x8000000 -o 64.limits +# RUN: llvm-objdump --no-show-raw-insn -d 32.limits | FileCheck --check-prefix=LIMITS %s +# RUN: llvm-objdump --no-show-raw-insn -d 64.limits | FileCheck --check-prefix=LIMITS %s # LIMITS: beq $zero, $zero, 131068 # LIMITS-NEXT: bne $zero, $zero, -131072 # LIMITS: beqz $s8, 4194300 @@ -25,32 +26,23 @@ # LIMITS: b 134217724 # LIMITS-NEXT: bl -134217728 -# RUN: not ld.lld %t.la32.o --defsym foo16=b16+0x20000 --defsym bar16=b16+4-0x20004 --defsym foo21=b21+0x400000 --defsym bar21=b21+4-0x400004 --defsym foo26=b26+0x8000000 --defsym bar26=b26+4-0x8000004 -o /dev/null 2>&1 | FileCheck -DFILE=%t.la32.o --check-prefix=ERROR-RANGE %s -# RUN: not ld.lld %t.la64.o --defsym foo16=b16+0x20000 --defsym bar16=b16+4-0x20004 --defsym foo21=b21+0x400000 --defsym bar21=b21+4-0x400004 --defsym foo26=b26+0x8000000 --defsym bar26=b26+4-0x8000004 -o /dev/null 2>&1 | FileCheck -DFILE=%t.la64.o --check-prefix=ERROR-RANGE %s -# ERROR-RANGE: error: [[FILE]]:(.text+0x0): relocation R_LARCH_B16 out of range: 131072 is not in [-131072, 131071]; references 'foo16' -# ERROR-RANGE: error: [[FILE]]:(.text+0x4): relocation R_LARCH_B16 out of range: -131076 is not in [-131072, 131071]; references 'bar16' -# ERROR-RANGE: error: [[FILE]]:(.text+0x8): relocation R_LARCH_B21 out of range: 4194304 is not in [-4194304, 4194303]; references 'foo21' -# ERROR-RANGE: error: [[FILE]]:(.text+0xc): relocation R_LARCH_B21 out of range: -4194308 is not in [-4194304, 4194303]; references 'bar21' -# ERROR-RANGE: error: [[FILE]]:(.text+0x10): relocation R_LARCH_B26 out of range: 134217728 is not in [-134217728, 134217727]; references 'foo26' -# ERROR-RANGE: error: [[FILE]]:(.text+0x14): relocation R_LARCH_B26 out of range: -134217732 is not in [-134217728, 134217727]; references 'bar26' +# RUN: not ld.lld 32.o --defsym foo16=b16+0x20000 --defsym bar16=b16+4-0x20004 --defsym foo21=b21+0x400000 --defsym bar21=b21+4-0x400004 --defsym foo26=b26+0x8000000 --defsym bar26=b26+4-0x8000004 2>&1 | FileCheck --check-prefix=ERROR-RANGE %s --implicit-check-not=error: +# RUN: not ld.lld 64.o --defsym foo16=b16+0x20000 --defsym bar16=b16+4-0x20004 --defsym foo21=b21+0x400000 --defsym bar21=b21+4-0x400004 --defsym foo26=b26+0x8000000 --defsym bar26=b26+4-0x8000004 2>&1 | FileCheck --check-prefix=ERROR-RANGE %s --implicit-check-not=error: +# ERROR-RANGE: error: {{.*}}:(.text+0x0): relocation R_LARCH_B16 out of range: 131072 is not in [-131072, 131071]; references 'foo16' +# ERROR-RANGE: error: {{.*}}:(.text+0x4): relocation R_LARCH_B16 out of range: -131076 is not in [-131072, 131071]; references 'bar16' +# ERROR-RANGE: error: {{.*}}:(.text+0x8): relocation R_LARCH_B21 out of range: 4194304 is not in [-4194304, 4194303]; references 'foo21' +# ERROR-RANGE: error: {{.*}}:(.text+0xc): relocation R_LARCH_B21 out of range: -4194308 is not in [-4194304, 4194303]; references 'bar21' +# ERROR-RANGE: error: {{.*}}:(.text+0x10): relocation R_LARCH_B26 out of range: 134217728 is not in [-134217728, 134217727]; references 'foo26' +# ERROR-RANGE: error: {{.*}}:(.text+0x14): relocation R_LARCH_B26 out of range: -134217732 is not in [-134217728, 134217727]; references 'bar26' -# RUN: not ld.lld %t.la32.o --defsym foo16=b16+1 --defsym bar16=b16-1 --defsym foo21=b21+1 --defsym bar21=b21-1 --defsym foo26=b26+1 --defsym bar26=b26-1 -o /dev/null 2>&1 | FileCheck -DFILE=%t.la32.o --check-prefix=ERROR-ALIGN-1 %s -# RUN: not ld.lld %t.la64.o --defsym foo16=b16+1 --defsym bar16=b16-1 --defsym foo21=b21+1 --defsym bar21=b21-1 --defsym foo26=b26+1 --defsym bar26=b26-1 -o /dev/null 2>&1 | FileCheck -DFILE=%t.la64.o --check-prefix=ERROR-ALIGN-1 %s -# ERROR-ALIGN-1: error: [[FILE]]:(.text+0x0): improper alignment for relocation R_LARCH_B16: 0x1 is not aligned to 4 bytes -# ERROR-ALIGN-1-NEXT: error: [[FILE]]:(.text+0x4): improper alignment for relocation R_LARCH_B16: 0xFFFFFFFFFFFFFFFB is not aligned to 4 bytes -# ERROR-ALIGN-1-NEXT: error: [[FILE]]:(.text+0x8): improper alignment for relocation R_LARCH_B21: 0x1 is not aligned to 4 bytes -# ERROR-ALIGN-1-NEXT: error: [[FILE]]:(.text+0xc): improper alignment for relocation R_LARCH_B21: 0xFFFFFFFFFFFFFFFB is not aligned to 4 bytes -# ERROR-ALIGN-1-NEXT: error: [[FILE]]:(.text+0x10): improper alignment for relocation R_LARCH_B26: 0x1 is not aligned to 4 bytes -# ERROR-ALIGN-1-NEXT: error: [[FILE]]:(.text+0x14): improper alignment for relocation R_LARCH_B26: 0xFFFFFFFFFFFFFFFB is not aligned to 4 bytes - -# RUN: not ld.lld %t.la32.o --defsym foo16=b16+2 --defsym bar16=b16-2 --defsym foo21=b21+2 --defsym bar21=b21-2 --defsym foo26=b26+2 --defsym bar26=b26-2 -o /dev/null 2>&1 | FileCheck -DFILE=%t.la32.o --check-prefix=ERROR-ALIGN-2 %s -# RUN: not ld.lld %t.la64.o --defsym foo16=b16+2 --defsym bar16=b16-2 --defsym foo21=b21+2 --defsym bar21=b21-2 --defsym foo26=b26+2 --defsym bar26=b26-2 -o /dev/null 2>&1 | FileCheck -DFILE=%t.la64.o --check-prefix=ERROR-ALIGN-2 %s -# ERROR-ALIGN-2: error: [[FILE]]:(.text+0x0): improper alignment for relocation R_LARCH_B16: 0x2 is not aligned to 4 bytes -# ERROR-ALIGN-2-NEXT: error: [[FILE]]:(.text+0x4): improper alignment for relocation R_LARCH_B16: 0xFFFFFFFFFFFFFFFA is not aligned to 4 bytes -# ERROR-ALIGN-2-NEXT: error: [[FILE]]:(.text+0x8): improper alignment for relocation R_LARCH_B21: 0x2 is not aligned to 4 bytes -# ERROR-ALIGN-2-NEXT: error: [[FILE]]:(.text+0xc): improper alignment for relocation R_LARCH_B21: 0xFFFFFFFFFFFFFFFA is not aligned to 4 bytes -# ERROR-ALIGN-2-NEXT: error: [[FILE]]:(.text+0x10): improper alignment for relocation R_LARCH_B26: 0x2 is not aligned to 4 bytes -# ERROR-ALIGN-2-NEXT: error: [[FILE]]:(.text+0x14): improper alignment for relocation R_LARCH_B26: 0xFFFFFFFFFFFFFFFA is not aligned to 4 bytes +# RUN: not ld.lld 32.o --defsym foo16=b16+1 --defsym bar16=b16+4+1 --defsym foo21=b21+1 --defsym bar21=b21+4+1 --defsym foo26=b26+1 --defsym bar26=b26+4+1 2>&1 | FileCheck --check-prefix=ERROR-ALIGN %s --implicit-check-not=error: +# RUN: not ld.lld 64.o --defsym foo16=b16+1 --defsym bar16=b16+4+1 --defsym foo21=b21+1 --defsym bar21=b21+4+1 --defsym foo26=b26+1 --defsym bar26=b26+4+1 2>&1 | FileCheck --check-prefix=ERROR-ALIGN %s --implicit-check-not=error: +# ERROR-ALIGN: error: {{.*}}:(.text+0x0): improper alignment for relocation R_LARCH_B16: 0x1 is not aligned to 4 bytes +# ERROR-ALIGN-NEXT: error: {{.*}}:(.text+0x4): improper alignment for relocation R_LARCH_B16: 0x1 is not aligned to 4 bytes +# ERROR-ALIGN-NEXT: error: {{.*}}:(.text+0x8): improper alignment for relocation R_LARCH_B21: 0x1 is not aligned to 4 bytes +# ERROR-ALIGN-NEXT: error: {{.*}}:(.text+0xc): improper alignment for relocation R_LARCH_B21: 0x1 is not aligned to 4 bytes +# ERROR-ALIGN-NEXT: error: {{.*}}:(.text+0x10): improper alignment for relocation R_LARCH_B26: 0x1 is not aligned to 4 bytes +# ERROR-ALIGN-NEXT: error: {{.*}}:(.text+0x14): improper alignment for relocation R_LARCH_B26: 0x1 is not aligned to 4 bytes .global _start .global b16 diff --git a/lld/test/ELF/mips-align-err.s b/lld/test/ELF/mips-align-err.s index be7f6aebf19e..b436763a0cf6 100644 --- a/lld/test/ELF/mips-align-err.s +++ b/lld/test/ELF/mips-align-err.s @@ -1,10 +1,11 @@ # REQUIRES: mips -# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o \ -# RUN: -mcpu=mips32r6 -# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ -# RUN: -mcpu=mips32r6 %S/Inputs/mips-align-err.s -o %t2.o -# RUN: not ld.lld %t.o %t2.o -o /dev/null 2>&1 | FileCheck %s -# CHECK: error: {{.*}}:(.text+0x1): improper alignment for relocation R_MIPS_PC16: 0xB is not aligned to 4 bytes +# RUN: rm -rf %t && mkdir %t && cd %t +# RUN: llvm-mc -filetype=obj -triple=mips -mcpu=mips32r6 %s -o a.o +# RUN: llvm-mc -filetype=obj -triple=mips -mcpu=mips32r6 %S/Inputs/mips-align-err.s -o b.o +# RUN: not ld.lld a.o b.o 2>&1 | FileCheck %s --implicit-check-not=error: + +# CHECK: error: a.o:(.text+0x1): unsupported jump/branch instruction between ISA modes referenced by R_MIPS_PC16 relocation +# CHECK-NEXT: error: a.o:(.text+0x1): improper alignment for relocation R_MIPS_PC16: 0xB is not aligned to 4 bytes .globl __start __start: diff --git a/lld/test/ELF/ppc64-abs32-dyn.s b/lld/test/ELF/ppc64-abs32-dyn.s index 015a6b0f4ed2..a14172f698de 100644 --- a/lld/test/ELF/ppc64-abs32-dyn.s +++ b/lld/test/ELF/ppc64-abs32-dyn.s @@ -1,10 +1,12 @@ # REQUIRES: ppc # RUN: llvm-mc -filetype=obj -triple=powerpc64le %s -o %t.o -# RUN: not ld.lld -shared %t.o -o /dev/null 2>&1 | FileCheck %s +# RUN: not ld.lld -shared %t.o -o /dev/null 2>&1 | FileCheck %s --implicit-check-not=error: ## Test we don't create R_AARCH64_RELATIVE. -# CHECK: error: relocation R_PPC64_ADDR32 cannot be used against symbol 'hidden'; recompile with -fPIC +# CHECK: error: relocation R_PPC64_ADDR32 cannot be used against symbol 'hidden'; recompile with -fPIC +# CHECK-NEXT: >>> defined in {{.*}}.o +# CHECK-NEXT: >>> referenced by {{.*}}.o:(.data+0x0) .globl hidden .hidden hidden diff --git a/lld/test/ELF/ppc64-error-toc-tail-call.s b/lld/test/ELF/ppc64-error-toc-tail-call.s index 7f492a322f84..584509432674 100644 --- a/lld/test/ELF/ppc64-error-toc-tail-call.s +++ b/lld/test/ELF/ppc64-error-toc-tail-call.s @@ -1,17 +1,18 @@ // REQUIRES: ppc +// RUN: rm -rf %t && mkdir %t && cd %t -// RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o -// 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: not ld.lld %t.o %t2.so -o /dev/null 2>&1 | FileCheck %s +// RUN: llvm-mc -filetype=obj -triple=powerpc64le %s -o a.o +// RUN: llvm-mc -filetype=obj -triple=powerpc64le %p/Inputs/shared-ppc64.s -o b.o +// RUN: ld.lld -shared b.o -o b.so +// RUN: not ld.lld a.o b.so 2>&1 | FileCheck %s --implicit-check-not=error: -// RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o -// RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/shared-ppc64.s -o %t2.o -// RUN: ld.lld -shared %t2.o -o %t2.so -// RUN: not ld.lld %t.o %t2.so -o /dev/null 2>&1 | FileCheck %s +// RUN: llvm-mc -filetype=obj -triple=powerpc64 %s -o a.o +// RUN: llvm-mc -filetype=obj -triple=powerpc64 %p/Inputs/shared-ppc64.s -o b.o +// RUN: ld.lld -shared b.o -o b.so +// RUN: not ld.lld a.o b.so 2>&1 | FileCheck %s --implicit-check-not=error: -# A tail call to an external function without a nop should issue an error. -// CHECK: call to foo lacks nop, can't restore toc +/// A tail call to an external function without a nop should issue an error. +// CHECK: error: a.o:(.text+0x0): call to foo lacks nop, can't restore toc // CHECK-NOT: lacks nop .text .abiversion 2 diff --git a/lld/test/ELF/relocation-nocopy.s b/lld/test/ELF/relocation-nocopy.s index 32b9dfe3bd03..1da532a5d0be 100644 --- a/lld/test/ELF/relocation-nocopy.s +++ b/lld/test/ELF/relocation-nocopy.s @@ -1,15 +1,27 @@ // REQUIRES: x86 -// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/relocation-copy.s -o %t2.o +// RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o +// RUN: llvm-mc -filetype=obj -triple=x86_64 %p/Inputs/relocation-copy.s -o %t2.o // RUN: ld.lld -shared %t2.o -o %t.so -// RUN: not ld.lld -z nocopyreloc %t.o %t.so -o /dev/null 2>&1 | FileCheck %s +// RUN: not ld.lld -z nocopyreloc %t.o %t.so -o /dev/null 2>&1 | FileCheck %s --implicit-check-not=error: -// CHECK: error: unresolvable relocation R_X86_64_32S against symbol 'x' -// CHECK: error: unresolvable relocation R_X86_64_32S against symbol 'y' -// CHECK: error: unresolvable relocation R_X86_64_32S against symbol 'z' -// CHECK: error: unresolvable relocation R_X86_64_32 against symbol 'x' -// CHECK: error: unresolvable relocation R_X86_64_32 against symbol 'y' -// CHECK: error: unresolvable relocation R_X86_64_32 against symbol 'z' +// CHECK: error: unresolvable relocation R_X86_64_32S against symbol 'x'; recompile with -fPIC or remove '-z nocopyreloc' +// CHECK-NEXT: >>> defined in {{.*}}.so +// CHECK-NEXT: >>> referenced by {{.*}}.o:(.text+0x{{.*}}) +// CHECK: error: unresolvable relocation R_X86_64_32S against symbol 'y'; recompile with -fPIC or remove '-z nocopyreloc' +// CHECK-NEXT: >>> defined in {{.*}}.so +// CHECK-NEXT: >>> referenced by {{.*}}.o:(.text+0x{{.*}}) +// CHECK: error: unresolvable relocation R_X86_64_32S against symbol 'z'; recompile with -fPIC or remove '-z nocopyreloc' +// CHECK-NEXT: >>> defined in {{.*}}.so +// CHECK-NEXT: >>> referenced by {{.*}}.o:(.text+0x{{.*}}) +// CHECK: error: unresolvable relocation R_X86_64_32 against symbol 'x'; recompile with -fPIC or remove '-z nocopyreloc' +// CHECK-NEXT: >>> defined in {{.*}}.so +// CHECK-NEXT: >>> referenced by {{.*}}.o:(.text+0x{{.*}}) +// CHECK: error: unresolvable relocation R_X86_64_32 against symbol 'y'; recompile with -fPIC or remove '-z nocopyreloc' +// CHECK-NEXT: >>> defined in {{.*}}.so +// CHECK-NEXT: >>> referenced by {{.*}}.o:(.text+0x{{.*}}) +// CHECK: error: unresolvable relocation R_X86_64_32 against symbol 'z'; recompile with -fPIC or remove '-z nocopyreloc' +// CHECK-NEXT: >>> defined in {{.*}}.so +// CHECK-NEXT: >>> referenced by {{.*}}.o:(.text+0x{{.*}}) .text .global _start diff --git a/lld/test/ELF/relocation-past-merge-end.s b/lld/test/ELF/relocation-past-merge-end.s index 9a096651da3a..0aa201c31138 100644 --- a/lld/test/ELF/relocation-past-merge-end.s +++ b/lld/test/ELF/relocation-past-merge-end.s @@ -1,9 +1,10 @@ // 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 -DPREFIX=error -// RUN: ld.lld %t.o -o /dev/null -shared --noinhibit-exec 2>&1 | FileCheck %s -DPREFIX=warning -// CHECK: [[PREFIX]]: {{.*}}:(.foo): offset is outside the section -// CHECK: [[PREFIX]]: {{.*}}:(.rodata.str1.1): offset is outside the section +// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64 +// RUN: not ld.lld %t.o -o /dev/null -shared 2>&1 | FileCheck %s -DPREFIX=error --implicit-check-not=error: +// RUN: ld.lld %t.o -o /dev/null -shared --noinhibit-exec 2>&1 | FileCheck %s -DPREFIX=warning --implicit-check-not=warning: + +// CHECK: [[PREFIX]]: {{.*}}:(.foo): offset is outside the section +// CHECK-NEXT: [[PREFIX]]: {{.*}}:(.rodata.str1.1): offset is outside the section .data .quad .foo + 10 diff --git a/lld/test/ELF/undef-spell-corrector.s b/lld/test/ELF/undef-spell-corrector.s index 264d685178da..7fde6870f528 100644 --- a/lld/test/ELF/undef-spell-corrector.s +++ b/lld/test/ELF/undef-spell-corrector.s @@ -1,23 +1,22 @@ # REQUIRES: x86 - -# RUN: rm -rf %t && split-file %s %t -# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/test.s -o %t/test.o -# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/bcde-abcd-abde.s -o %t/bcde-abcd-abde.o -# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/bbcde-abcdd.s -o %t/bbcde-abcdd.o -# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/aabcde-abcdee.s -o %t/aabcde-abcdee.o -# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/bacde.s -o %t/bacde.o -# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/_Z3fooPi.s -o %t/_Z3fooPi.o -# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/_Z3fooPKi-_Z3fooPi.s -o %t/_Z3fooPKi-_Z3fooPi.o -# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/_Z3FOOPKi.s -o %t/_Z3FOOPKi.o -# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/_Z3fooPKi-_Z3FOOPKi.s -o %t/_Z3fooPKi-_Z3FOOPKi.o +# RUN: rm -rf %t && split-file %s %t && cd %t +# RUN: llvm-mc -filetype=obj -triple=x86_64 test.s -o test.o +# RUN: llvm-mc -filetype=obj -triple=x86_64 bcde-abcd-abde.s -o bcde-abcd-abde.o +# RUN: llvm-mc -filetype=obj -triple=x86_64 bbcde-abcdd.s -o bbcde-abcdd.o +# RUN: llvm-mc -filetype=obj -triple=x86_64 aabcde-abcdee.s -o aabcde-abcdee.o +# RUN: llvm-mc -filetype=obj -triple=x86_64 bacde.s -o bacde.o +# RUN: llvm-mc -filetype=obj -triple=x86_64 _Z3fooPi.s -o _Z3fooPi.o +# RUN: llvm-mc -filetype=obj -triple=x86_64 _Z3fooPKi-_Z3fooPi.s -o _Z3fooPKi-_Z3fooPi.o +# RUN: llvm-mc -filetype=obj -triple=x86_64 _Z3FOOPKi.s -o _Z3FOOPKi.o +# RUN: llvm-mc -filetype=obj -triple=x86_64 _Z3fooPKi-_Z3FOOPKi.s -o _Z3fooPKi-_Z3FOOPKi.o ## Insert a character. ## The spell corrector is enabled for the first two "undefined symbol" diagnostics. -# RUN: not ld.lld %t/test.o %t/bcde-abcd-abde.o -o /dev/null 2>&1 | FileCheck --check-prefix=INSERT %s -DFILE=%t/test.o +# RUN: not ld.lld test.o bcde-abcd-abde.o 2>&1 | FileCheck --check-prefix=INSERT %s -DFILE=test.o --implicit-check-not=error: ## Symbols defined in DSO can be suggested. -# RUN: ld.lld %t/test.o -shared -o %t.so -# RUN: not ld.lld %t.so %t/bcde-abcd-abde.o -o /dev/null 2>&1 | FileCheck --check-prefix=INSERT %s -DFILE=%t.so +# RUN: ld.lld test.o -shared -o test.so +# RUN: not ld.lld test.so bcde-abcd-abde.o 2>&1 | FileCheck --check-prefix=INSERT %s -DFILE=test.so --implicit-check-not=error: # INSERT: error: undefined symbol: bcde # INSERT-NEXT: >>> referenced by {{.*}} @@ -29,10 +28,9 @@ # INSERT-NEXT: >>> defined in: [[FILE]] # INSERT: error: undefined symbol: abde # INSERT-NEXT: >>> referenced by {{.*}} -# INSERT-NOT: >>> ## Substitute a character. -# RUN: not ld.lld %t/test.o %t/bbcde-abcdd.o -o /dev/null 2>&1 | FileCheck --check-prefix=SUBST %s +# RUN: not ld.lld test.o bbcde-abcdd.o 2>&1 | FileCheck --check-prefix=SUBST %s --implicit-check-not=error: # SUBST: error: undefined symbol: bbcde # SUBST-NEXT: >>> referenced by {{.*}} @@ -42,7 +40,7 @@ # SUBST-NEXT: >>> did you mean: abcde ## Delete a character. -# RUN: not ld.lld %t/test.o %t/aabcde-abcdee.o -o /dev/null 2>&1 | FileCheck --check-prefix=DELETE %s +# RUN: not ld.lld test.o aabcde-abcdee.o 2>&1 | FileCheck --check-prefix=DELETE %s --implicit-check-not=error: # DELETE: error: undefined symbol: aabcde # DELETE-NEXT: >>> referenced by {{.*}} @@ -52,24 +50,24 @@ # DELETE-NEXT: >>> did you mean: abcde ## Transpose. -# RUN: not ld.lld %t/test.o %t/bacde.o -o /dev/null 2>&1 | FileCheck --check-prefix=TRANSPOSE %s +# RUN: not ld.lld test.o bacde.o 2>&1 | FileCheck --check-prefix=TRANSPOSE %s --implicit-check-not=error: # TRANSPOSE: error: undefined symbol: bacde # TRANSPOSE-NEXT: >>> referenced by {{.*}} # TRANSPOSE-NEXT: >>> did you mean: abcde ## Missing const qualifier. -# RUN: not ld.lld %t/test.o %t/_Z3fooPi.o -o /dev/null 2>&1 | FileCheck --check-prefix=CONST %s +# RUN: not ld.lld test.o _Z3fooPi.o 2>&1 | FileCheck --check-prefix=CONST %s --implicit-check-not=error: ## Local defined symbols. -# RUN: not ld.lld %t/_Z3fooPKi-_Z3fooPi.o -o /dev/null 2>&1 | FileCheck --check-prefix=CONST %s +# RUN: not ld.lld _Z3fooPKi-_Z3fooPi.o 2>&1 | FileCheck --check-prefix=CONST %s --implicit-check-not=error: # CONST: error: undefined symbol: foo(int*) # CONST-NEXT: >>> referenced by {{.*}} # CONST-NEXT: >>> did you mean: foo(int const*) ## Case mismatch. -# RUN: not ld.lld %t/test.o %t/_Z3FOOPKi.o -o /dev/null 2>&1 | FileCheck --check-prefix=CASE %s -# RUN: not ld.lld %t/_Z3fooPKi-_Z3FOOPKi.o -o /dev/null 2>&1 | FileCheck --check-prefix=CASE %s +# RUN: not ld.lld test.o _Z3FOOPKi.o 2>&1 | FileCheck --check-prefix=CASE %s --implicit-check-not=error: +# RUN: not ld.lld _Z3fooPKi-_Z3FOOPKi.o 2>&1 | FileCheck --check-prefix=CASE %s --implicit-check-not=error: # CASE: error: undefined symbol: FOO(int const*) # CASE-NEXT: >>> referenced by {{.*}} diff --git a/lld/test/ELF/vs-diagnostics-dynamic-relocation.s b/lld/test/ELF/vs-diagnostics-dynamic-relocation.s index 806ed81c438e..cfa2e042d689 100644 --- a/lld/test/ELF/vs-diagnostics-dynamic-relocation.s +++ b/lld/test/ELF/vs-diagnostics-dynamic-relocation.s @@ -1,13 +1,13 @@ // REQUIRES: x86 -// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -// RUN: not ld.lld -shared --vs-diagnostics %t.o -o /dev/null 2>&1 | FileCheck %s +// RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o +// RUN: not ld.lld -shared --vs-diagnostics %t.o -o /dev/null 2>&1 | FileCheck %s --implicit-check-not=error: -// CHECK: dyn.s(15): error: relocation R_X86_64_64 cannot be used against local symbol; recompile with -fPIC +// CHECK: dyn.s(15): error: relocation R_X86_64_64 cannot be used against local symbol; recompile with -fPIC // CHECK-NEXT: >>> defined in {{.*}}.o // CHECK-NEXT: >>> referenced by dyn.s:15 // CHECK-NEXT: >>>{{.*}}.o:(.text+0x{{.+}}) -// CHECK: /tmp{{/|\\}}dyn.s(20): error: relocation R_X86_64_64 cannot be used against local symbol; recompile with -fPIC +// CHECK: /tmp{{/|\\}}dyn.s(20): error: relocation R_X86_64_64 cannot be used against local symbol; recompile with -fPIC // CHECK-NEXT: >>> defined in {{.*}}.o // CHECK-NEXT: >>> referenced by dyn.s:20 (/tmp{{/|\\}}dyn.s:20) // CHECK-NEXT: >>>{{.*}}.o:(.text+0x{{.+}}) diff --git a/lld/test/ELF/x86-64-tls-ie-err.s b/lld/test/ELF/x86-64-tls-ie-err.s index 3cc7cb0d4173..ab0296a62643 100644 --- a/lld/test/ELF/x86-64-tls-ie-err.s +++ b/lld/test/ELF/x86-64-tls-ie-err.s @@ -1,11 +1,11 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o -# RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck -DFILE=%t.o %s +# RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s --implicit-check-not=error: -# CHECK: error: [[FILE]]:(.text+0x2): invalid prefix with R_X86_64_CODE_4_GOTTPOFF! -# CHECK-NEXT: error: [[FILE]]:(.text+0x8): invalid prefix with R_X86_64_CODE_6_GOTTPOFF! -# CHECK-NEXT: error: [[FILE]]:(.text+0x12): R_X86_64_CODE_4_GOTTPOFF must be used in MOVQ or ADDQ instructions only -# CHECK-NEXT: error: [[FILE]]:(.text+0x1a): R_X86_64_CODE_6_GOTTPOFF must be used in ADDQ instructions with NDD/NF/NDD+NF only +# CHECK: error: {{.*}}.o:(.text+0x2): invalid prefix with R_X86_64_CODE_4_GOTTPOFF! +# CHECK-NEXT: error: {{.*}}.o:(.text+0x8): invalid prefix with R_X86_64_CODE_6_GOTTPOFF! +# CHECK-NEXT: error: {{.*}}.o:(.text+0x12): R_X86_64_CODE_4_GOTTPOFF must be used in MOVQ or ADDQ instructions only +# CHECK-NEXT: error: {{.*}}.o:(.text+0x1a): R_X86_64_CODE_6_GOTTPOFF must be used in ADDQ instructions with NDD/NF/NDD+NF only ## These negative tests are to check if the invalid prefix and unsupported ## instructions for TLS relocation types with APX instructions are handled as diff --git a/lld/test/ELF/ztext.s b/lld/test/ELF/ztext.s index 11e89e025e06..37304f1c7db2 100644 --- a/lld/test/ELF/ztext.s +++ b/lld/test/ELF/ztext.s @@ -1,20 +1,30 @@ # REQUIRES: x86 -# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/ztext.s -o %t2.o -# RUN: ld.lld %t2.o -o %t2.so -shared -soname=so +# RUN: rm -rf %t && mkdir %t && cd %t +# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o a.o +# RUN: llvm-mc -filetype=obj -triple=x86_64 %p/Inputs/ztext.s -o b.o +# RUN: ld.lld b.o -o b.so -shared -soname=so -# RUN: ld.lld -z notext %t.o %t2.so -o %t -shared -# RUN: llvm-readobj --dynamic-table -r %t | FileCheck %s -# RUN: ld.lld -z notext %t.o %t2.so -o %t2 -pie -# RUN: llvm-readobj --dynamic-table -r %t2 | FileCheck %s -# RUN: ld.lld -z notext %t.o %t2.so -o %t3 -# RUN: llvm-readobj --dynamic-table -r %t3 | FileCheck --check-prefix=STATIC %s +# RUN: ld.lld -z notext a.o b.so -o out -shared +# RUN: llvm-readobj --dynamic-table -r out | FileCheck %s +# RUN: ld.lld -z notext a.o b.so -o out.pie -pie +# RUN: llvm-readobj --dynamic-table -r out.pie | FileCheck %s +# RUN: ld.lld -z notext a.o b.so -o out.exe +# RUN: llvm-readobj --dynamic-table -r out.exe | FileCheck --check-prefix=STATIC %s -# RUN: not ld.lld %t.o %t2.so -o /dev/null -shared 2>&1 | FileCheck --check-prefix=ERR %s -# RUN: not ld.lld -z text %t.o %t2.so -o /dev/null -shared 2>&1 | FileCheck --check-prefix=ERR %s -# ERR: error: relocation R_X86_64_64 cannot be used against symbol 'bar'; recompile with -fPIC +# RUN: not ld.lld a.o b.so -shared 2>&1 | FileCheck --check-prefix=ERR %s --implicit-check-not=error: +# RUN: not ld.lld -z text a.o b.so -shared 2>&1 | FileCheck --check-prefix=ERR %s --implicit-check-not=error: -# If the preference is to have text relocations, don't create plt of copy relocations. +# ERR: error: relocation R_X86_64_64 cannot be used against local symbol; recompile with -fPIC +# ERR-NEXT: >>> defined in a.o +# ERR-NEXT: >>> referenced by a.o:(.text+0x0) +# ERR: error: relocation R_X86_64_64 cannot be used against symbol 'bar'; recompile with -fPIC +# ERR-NEXT: >>> defined in b.so +# ERR-NEXT: >>> referenced by a.o:(.text+0x8) +# ERR: error: relocation R_X86_64_PC64 cannot be used against symbol 'zed'; recompile with -fPIC +# ERR-NEXT: >>> defined in b.so +# ERR-NEXT: >>> referenced by a.o:(.text+0x10) + +## If the preference is to have text relocations, don't create plt of copy relocations. # CHECK: DynamicSection [ # CHECK: FLAGS TEXTREL