Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / non-abs-reloc.s
blob04f583ab253472da564973856a3eb0d31f25cff2
1 // REQUIRES: x86
2 // RUN: rm -rf %t && split-file %s %t && cd %t
3 // RUN: llvm-mc -filetype=obj -triple=i386 --defsym X86_32=1 asm -o a.o
4 // RUN: ld.lld -T lds a.o -o a 2>&1 | FileCheck %s --implicit-check-not=warning:
5 // CHECK: warning: {{.*}}.o:(.nonalloc1+0x1): has non-ABS relocation R_386_PC32 against symbol '_start'
6 // CHECK-NEXT: warning: {{.*}}.o:(.nonalloc1+0x6): has non-ABS relocation R_386_PC32 against symbol 'ifunc'
7 // CHECK-NEXT: warning: {{.*}}.o:(.nonalloc1+0xa): has non-ABS relocation R_386_PC32 against symbol ''
9 // RUN: llvm-objdump -D --no-show-raw-insn a | FileCheck --check-prefix=DISASM %s
10 // DISASM: Disassembly of section .nonalloc:
11 // DISASM-EMPTY:
12 // DISASM-NEXT: <.nonalloc>:
13 // DISASM-NEXT: 0: nop
14 // DISASM-NEXT: 1: call{{.}} 0x0
15 // DISASM-NEXT: 6: call{{.}} 0x5
17 /// There is currently no error for -r. See also https://github.com/ClangBuiltLinux/linux/issues/1937
18 // RUN: ld.lld -T lds -r a.o -o /dev/null --fatal-warnings
20 // RUN: llvm-mc -filetype=obj -triple=x86_64 asm -o b.o
21 // RUN: ld.lld -T lds b.o -o b 2>&1 | FileCheck %s --check-prefix=CHECK2 --implicit-check-not=warning:
22 // RUN: llvm-objdump -D --no-show-raw-insn b | FileCheck --check-prefix=DISASM %s
23 // RUN: ld.lld -T lds -r b.o -o /dev/null --fatal-warnings
24 // CHECK2: warning: {{.*}}.o:(.nonalloc1+0x1): has non-ABS relocation R_X86_64_PC32 against symbol '_start'
25 // CHECK2-NEXT: warning: {{.*}}.o:(.nonalloc1+0x6): has non-ABS relocation R_X86_64_PC32 against symbol 'ifunc'
26 // CHECK2-NEXT: warning: {{.*}}.o:(.nonalloc1+0xa): has non-ABS relocation R_X86_64_PC32 against symbol ''
28 //--- lds
29 SECTIONS {
30 .nonalloc 0 : { *(.nonalloc*) }
32 //--- asm
33 .globl _start
34 _start:
35 .L0:
36 nop
38 resolver: ret
39 .type ifunc, @gnu_indirect_function
40 .set ifunc, resolver
42 .section .nonalloc0
43 nop
45 .section .nonalloc1
46 .byte 0xe8
47 .long _start - . - 4
48 .byte 0xe8
49 .long ifunc - .
50 .long .nonalloc0 - .
52 // GCC may relocate DW_AT_GNU_call_site_value with R_386_GOTOFF.
53 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98946
54 .ifdef X86_32
55 .section .debug_random
56 .long .L0@gotoff
57 .endif