46 lines · plain
1# REQUIRES: x862# RUN: llvm-mc -filetype=obj -triple=x86_64 %p/Inputs/define.s -o %t.o3# RUN: ld.lld -o %t --defsym vv=1 --script %s %t.o4# RUN: llvm-readelf -S -s %t | FileCheck %s5 6# CHECK: [Nr] Name Type Address Off Size ES Flg Lk Inf Al7# CHECK-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0 08# CHECK-NEXT: [ 1] .foo PROGBITS 0000000000011000 001000 000008 00 A 0 0 19# CHECK-NEXT: [ 2] .bar PROGBITS 0000000000013000 003000 000008 00 A 0 0 110# CHECK-NEXT: [ 3] .test PROGBITS 0000000000015000 005000 000008 00 A 0 0 111# CHECK-NEXT: [ 4] .text PROGBITS 0000000000015008 005008 000000 00 AX 0 0 412 13# CHECK: Value Size Type Bind Vis Ndx Name14# CHECK-DAG: 0000000000000001 0 NOTYPE GLOBAL DEFAULT ABS vv15# CHECK-DAG: 0000000000000009 0 NOTYPE GLOBAL DEFAULT ABS ww16# CHECK-DAG: 0000000000000001 0 NOTYPE GLOBAL DEFAULT ABS x117# CHECK-DAG: 0000000000000002 0 NOTYPE GLOBAL DEFAULT ABS x218# CHECK-DAG: 0000000000000001 0 NOTYPE GLOBAL DEFAULT ABS y119# CHECK-DAG: 0000000000000002 0 NOTYPE GLOBAL DEFAULT ABS y220 21EXTERN(extern_defined)22SECTIONS {23 . = DEFINED(defined) ? 0x11000 : .;24 .foo : { *(.foo*) }25 . = DEFINED(notdefined) ? 0x12000 : 0x13000;26 .bar : { *(.bar*) }27 . = DEFINED(extern_defined) ? 0x14000 : 0x15000;28 29## Take the value from --defsym.30 vv = DEFINED(vv) ? vv : 9;31## 9 as ww is undefined.32 ww = DEFINED(ww) ? ww : 9;33 34## 1 as xx is not yet defined.35 x1 = DEFINED(xx) ? 2 : 1;36 .test : {37 xx = .;38 *(.test*)39 }40 x2 = DEFINED(xx) ? 2 : 1;41 42 y1 = DEFINED(yy) ? 2 : 1;43 yy = .;44 y2 = DEFINED(yy) ? 2 : 1;45}46