1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64 %p/Inputs/alignof.s -o %t.o
3# RUN: ld.lld -o %t --script %s %t.o
4# RUN: llvm-readelf -s %t | FileCheck %s
5# CHECK:         Value         Size Type   Bind   Vis     Ndx Name
6# CHECK:      0000000000000008    0 NOTYPE GLOBAL DEFAULT ABS _aaa
7# CHECK-NEXT: 0000000000000010    0 NOTYPE GLOBAL DEFAULT ABS _bbb
8# CHECK-NEXT: 0000000000000020    0 NOTYPE GLOBAL DEFAULT ABS _ccc
9
10SECTIONS {
11  .aaa : { *(.aaa) }
12  .bbb : { *(.bbb) }
13  .ccc : { *(.ccc) }
14  _aaa = ALIGNOF(.aaa);
15  _bbb = ALIGNOF(.bbb);
16  _ccc = ALIGNOF(.ccc);
17}
18
19## Check that we error out if trying to get alignment of
20## section that does not exist.
21# RUN: echo "SECTIONS { _aaa = ALIGNOF(.foo); }" > %t.script
22# RUN: not ld.lld -o /dev/null --script %t.script %t.o 2>&1 \
23# RUN:  | FileCheck -check-prefix=ERR %s
24# ERR: {{.*}}.script:1: undefined section .foo
25