2 # RUN: llvm-mc -filetype=obj -triple=x86_64 %p/Inputs/define.s -o %t.o
3 # RUN: ld.lld -o %t --defsym vv=1 --script %s %t.o
4 # RUN: llvm-readelf -S -s %t | FileCheck %s
6 # CHECK: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
7 # CHECK-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0 0
8 # CHECK-NEXT: [ 1] .foo PROGBITS 0000000000011000 001000 000008 00 A 0 0 1
9 # CHECK-NEXT: [ 2] .bar PROGBITS 0000000000013000 003000 000008 00 A 0 0 1
10 # CHECK-NEXT: [ 3] .test PROGBITS 0000000000015000 005000 000008 00 A 0 0 1
11 # CHECK-NEXT: [ 4] .text PROGBITS 0000000000015008 005008 000000 00 AX 0 0 4
13 # CHECK: Value Size Type Bind Vis Ndx Name
14 # CHECK-DAG: 0000000000000001 0 NOTYPE GLOBAL DEFAULT ABS vv
15 # CHECK-DAG: 0000000000000009 0 NOTYPE GLOBAL DEFAULT ABS ww
16 # CHECK-DAG: 0000000000000001 0 NOTYPE GLOBAL DEFAULT ABS x1
17 # CHECK-DAG: 0000000000000002 0 NOTYPE GLOBAL DEFAULT ABS x2
18 # CHECK-DAG: 0000000000000001 0 NOTYPE GLOBAL DEFAULT ABS y1
19 # CHECK-DAG: 0000000000000002 0 NOTYPE GLOBAL DEFAULT ABS y2
21 EXTERN(extern_defined)
23 . = DEFINED(defined) ? 0x11000 : .;
25 . = DEFINED(notdefined) ? 0x12000 : 0x13000;
27 . = DEFINED(extern_defined) ? 0x14000 : 0x15000;
29 ## Take the value from --defsym.
30 vv = DEFINED(vv) ? vv : 9;
31 ## 9 as ww is undefined.
32 ww = DEFINED(ww) ? ww : 9;
34 ## 1 as xx is not yet defined.
35 x1 = DEFINED(xx) ? 2 : 1;
40 x2 = DEFINED(xx) ? 2 : 1;
42 y1 = DEFINED(yy) ? 2 : 1;
44 y2 = DEFINED(yy) ? 2 : 1;