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+ \
15 # --defsym foo2=foo1 2>&1 | FileCheck %s --check-prefix=ERR
16 # ERR: error: --defsym: syntax error: ERR+
18 # CHECK-DAG: 0000000000000123 0 NOTYPE GLOBAL DEFAULT ABS foo1
19 # CHECK-DAG: 0000000000000123 0 NOTYPE GLOBAL DEFAULT ABS foo2
21 ## Check we can use foo2 and it that it is an alias for foo1.
22 # USE: Disassembly of section .text:
25 # USE-NEXT: movl $0x123, %edx
27 # RUN: ld.lld -o %t %t.o --defsym=foo2=1
28 # RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=ABS
30 # ABS: 0000000000000123 0 NOTYPE GLOBAL DEFAULT ABS foo2
32 # RUN: ld.lld -o %t %t.o --defsym=foo2=foo1+5
33 # RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=EXPR
35 # EXPR-DAG: 0000000000000123 0 NOTYPE GLOBAL DEFAULT ABS foo1
36 # EXPR-DAG: 0000000000000128 0 NOTYPE GLOBAL DEFAULT ABS foo2
38 # RUN: not ld.lld -o /dev/null %t.o --defsym=foo2=und 2>&1 | FileCheck %s -check-prefix=ERR1
39 # ERR1: error: --defsym:1: symbol not found: und
41 # RUN: not ld.lld -o /dev/null %t.o --defsym=xxx=yyy,zzz 2>&1 | FileCheck %s -check-prefix=ERR2
42 # ERR2: error: --defsym:1: EOF expected, but got ,
44 # RUN: not ld.lld -o /dev/null %t.o --defsym=foo 2>&1 | FileCheck %s -check-prefix=ERR3
45 # ERR3: error: --defsym: syntax error: foo
47 # RUN: not ld.lld -o /dev/null %t.o --defsym= 2>&1 | FileCheck %s -check-prefix=ERR4
48 # ERR4: error: --defsym: syntax error: