[ELF] Refine isExported/isPreemptible condition
[llvm-project.git] / lld / test / ELF / defsym.s
blobeb409cccfc03381e9d7a1ef6a47a3dbcbef33288
1 # REQUIRES: x86
2 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
3 # RUN: ld.lld -o %t %t.o --defsym=foo2=foo1
4 # RUN: llvm-readelf -s %t | FileCheck %s
5 # RUN: llvm-objdump -d --print-imm-hex %t | FileCheck %s --check-prefix=USE
7 ## Check that we accept --defsym foo2=foo1 form.
8 # RUN: ld.lld -o %t2 %t.o --defsym '"foo2"=foo1'
9 # RUN: llvm-readelf -s %t2 | FileCheck %s
10 # RUN: llvm-objdump -d --print-imm-hex %t2 | FileCheck %s --check-prefix=USE
12 ## Check we are reporting the error correctly and don't crash
13 ## when handling the second --defsym.
14 # RUN: not ld.lld -o /dev/null %t.o --defsym ERR+ --defsym foo2=foo1 2>&1 | FileCheck %s --check-prefix=ERR --strict-whitespace
15 # ERR:error: --defsym:1: = expected, but got +
16 # ERR-NEXT:>>> ERR+
17 # ERR-NEXT:>>> ^
19 # CHECK-DAG: 0000000000000123 0 NOTYPE GLOBAL DEFAULT ABS foo1
20 # CHECK-DAG: 0000000000000123 0 NOTYPE GLOBAL DEFAULT ABS foo2
22 ## Check we can use foo2 and it that it is an alias for foo1.
23 # USE: Disassembly of section .text:
24 # USE-EMPTY:
25 # USE-NEXT: <_start>:
26 # USE-NEXT: movl $0x123, %edx
28 # RUN: ld.lld -o %t %t.o --defsym=foo2=1
29 # RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=ABS
31 # ABS: 0000000000000001 0 NOTYPE GLOBAL DEFAULT ABS foo2
33 # RUN: ld.lld -o %t %t.o --defsym=foo2=foo1+5
34 # RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=EXPR
36 # EXPR-DAG: 0000000000000123 0 NOTYPE GLOBAL DEFAULT ABS foo1
37 # EXPR-DAG: 0000000000000128 0 NOTYPE GLOBAL DEFAULT ABS foo2
39 # RUN: not ld.lld -o /dev/null %t.o --defsym=foo2=und 2>&1 | FileCheck %s -check-prefix=ERR1
40 # ERR1: error: --defsym:1: symbol not found: und
42 # RUN: not ld.lld -o /dev/null %t.o --defsym=xxx=yyy,zzz 2>&1 | FileCheck %s -check-prefix=ERR2
43 # ERR2: error: --defsym:1: EOF expected, but got ,
45 # RUN: not ld.lld -o /dev/null %t.o --defsym=foo 2>&1 | FileCheck %s -check-prefix=ERR3
46 # ERR3: error: --defsym:1: unexpected EOF
48 # RUN: not ld.lld -o /dev/null %t.o --defsym= 2>&1 | FileCheck %s -check-prefix=ERR3
50 .globl foo1
51 foo1 = 0x123
53 .global _start
54 _start:
55 movl $foo2, %edx