[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / linkerscript / sizeof.s
blob45c14284e5bedbdd6d672dca13eb8d679291cc2e
1 # REQUIRES: x86
2 # RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
4 # RUN: echo "SECTIONS { \
5 # RUN: .aaa : { *(.aaa) } \
6 # RUN: .bbb : { *(.bbb) } \
7 # RUN: .ccc : { *(.ccc) } \
8 # RUN: _aaa = SIZEOF(.aaa); \
9 # RUN: _bbb = SIZEOF(.bbb); \
10 # RUN: _ccc = SIZEOF(.ccc); \
11 # RUN: _ddd = SIZEOF(.not_exist); \
12 # RUN: }" > %t.script
13 # RUN: ld.lld -T %t.script %t.o -o %t
14 # RUN: llvm-readelf -S -s %t | FileCheck %s
16 # CHECK: Name Type Address Off Size
17 # CHECK: .aaa PROGBITS 0000000000000000 001000 000008
18 # CHECK-NEXT: .bbb PROGBITS 0000000000000008 001008 000010
19 # CHECK-NEXT: .ccc PROGBITS 0000000000000018 001018 000018
21 # CHECK: Value Size Type Bind Vis Ndx Name
22 # CHECK: 0000000000000008 0 NOTYPE GLOBAL DEFAULT ABS _aaa
23 # CHECK-NEXT: 0000000000000010 0 NOTYPE GLOBAL DEFAULT ABS _bbb
24 # CHECK-NEXT: 0000000000000018 0 NOTYPE GLOBAL DEFAULT ABS _ccc
25 ## SIZEOF(.not_exist) has a value of 0.
26 # CHECK-NEXT: 0000000000000000 0 NOTYPE GLOBAL DEFAULT ABS _ddd
28 .global _start
29 _start:
30 nop
32 .section .aaa,"a"
33 .quad 0
35 .section .bbb,"a"
36 .quad 0
37 .quad 0
39 .section .ccc,"a"
40 .quad 0
41 .quad 0
42 .quad 0