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 6 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 11 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+ 17 18# CHECK-DAG: 0000000000000123 0 NOTYPE GLOBAL DEFAULT ABS foo1 19# CHECK-DAG: 0000000000000123 0 NOTYPE GLOBAL DEFAULT ABS foo2 20 21## Check we can use foo2 and it that it is an alias for foo1. 22# USE: Disassembly of section .text: 23# USE-EMPTY: 24# USE-NEXT: <_start>: 25# USE-NEXT: movl $0x123, %edx 26 27# RUN: ld.lld -o %t %t.o --defsym=foo2=1 28# RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=ABS 29 30# ABS: 0000000000000123 0 NOTYPE GLOBAL DEFAULT ABS foo2 31 32# RUN: ld.lld -o %t %t.o --defsym=foo2=foo1+5 33# RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=EXPR 34 35# EXPR-DAG: 0000000000000123 0 NOTYPE GLOBAL DEFAULT ABS foo1 36# EXPR-DAG: 0000000000000128 0 NOTYPE GLOBAL DEFAULT ABS foo2 37 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 40 41# RUN: not ld.lld -o /dev/null %t.o --defsym=xxx=yyy,zzz 2>&1 | FileCheck %s -check-prefix=ERR2 42# ERR2: -defsym:1: EOF expected, but got , 43 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 46 47# RUN: not ld.lld -o /dev/null %t.o --defsym= 2>&1 | FileCheck %s -check-prefix=ERR4 48# ERR4: error: -defsym: syntax error: 49 50.globl foo1 51 foo1 = 0x123 52 53.global _start 54_start: 55 movl $foo2, %edx 56