1# REQUIRES: x86 2# RUN: rm -rf %t && split-file %s %t && cd %t 3# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o 4# RUN: ld.lld a.o -T a.lds -o a 5# RUN: llvm-readelf -Ss a | FileCheck %s 6 7# CHECK: .text PROGBITS 0000000000001000 001000 8# CHECK-NEXT: .foo-1 PROGBITS 0000000000001001 001001 9# CHECK-NEXT: .foo-2 PROGBITS 0000000000001101 001101 10# CHECK-NEXT: .foo-3 PROGBITS 0000000000001102 001102 11 12# CHECK: 0000000000001001 0 NOTYPE GLOBAL DEFAULT 1 x1 13# CHECK-NEXT: 0000000000001001 0 NOTYPE GLOBAL DEFAULT 1 x2 14# CHECK-NEXT: 0000000000001000 0 NOTYPE GLOBAL DEFAULT 1 x3 15 16# RUN: not ld.lld a.o -T absent.lds 2>&1 | FileCheck %s --check-prefix=ABSENT --implicit-check-not=error: 17# ABSENT: error: absent.lds:3: undefined section .aaa 18 19# RUN: not ld.lld a.o -T absolute.lds 2>&1 | FileCheck %s --check-prefix=ABSOLUTE --implicit-check-not=error: 20# ABSOLUTE: error: absolute.lds:2: at least one side of the expression must be absolute 21 22#--- a.s 23.globl _start 24_start: nop 25 26.section .foo-1,"a"; .byte 1 27.section .foo-2,"a"; .byte 2 28.section .foo-3,"a"; .byte 3 29 30#--- a.lds 31SECTIONS { 32 . = 0x1000; 33 .text : { 34 *(.text*) 35 x1 = ADDR(.text) + 1; x2 = 1 + ADDR(.text); 36 x3 = ADDR(.text) & 0xffff; 37 } 38 .foo-1 : { *(.foo-1) } 39 .foo-2 ADDR(.foo-1) + 0x100 : { *(.foo-2) } 40 .foo-3 : { *(.foo-3) } 41} 42 43#--- absent.lds 44SECTIONS { 45 . = 0x1000; 46 _aaa = ADDR(.aaa); 47} 48 49#--- absolute.lds 50SECTIONS { 51 foo = ADDR(.text) + ADDR(.text); 52} 53