| # REQUIRES: x86 |
| # RUN: llvm-mc -filetype=obj -triple=x86_64 %p/Inputs/alignof.s -o %t.o |
| # RUN: ld.lld -o %t --script %s %t.o |
| # RUN: llvm-readelf -s %t | FileCheck %s |
| # CHECK: Value Size Type Bind Vis Ndx Name |
| # CHECK: 0000000000000008 0 NOTYPE GLOBAL DEFAULT ABS _aaa |
| # CHECK-NEXT: 0000000000000010 0 NOTYPE GLOBAL DEFAULT ABS _bbb |
| # CHECK-NEXT: 0000000000000020 0 NOTYPE GLOBAL DEFAULT ABS _ccc |
| |
| SECTIONS { |
| .aaa : { *(.aaa) } |
| .bbb : { *(.bbb) } |
| .ccc : { *(.ccc) } |
| _aaa = ALIGNOF(.aaa); |
| _bbb = ALIGNOF(.bbb); |
| _ccc = ALIGNOF(.ccc); |
| } |
| |
| ## Check that we error out if trying to get alignment of |
| ## section that does not exist. |
| # RUN: echo "SECTIONS { _aaa = ALIGNOF(.foo); }" > %t.script |
| # RUN: not ld.lld -o /dev/null --script %t.script %t.o 2>&1 \ |
| # RUN: | FileCheck -check-prefix=ERR %s |
| # ERR: {{.*}}.script:1: undefined section .foo |