xref: /llvm-project/llvm/test/MC/ELF/offset.s (revision e07dfa5328b0ca1465ae7b749e1ac2d994741e27)
1# RUN: llvm-mc -filetype=obj -triple x86_64 %s -o %t
2# RUN: llvm-readelf -s %t | FileCheck %s
3
4## Test that a variable declared with "var = other_var + cst" is in the same
5## section as other_var and its value is the value of other_var + cst.
6## In addition, its st_size inherits from other_var.
7
8# CHECK:      0: {{.*}}
9# CHECK-NEXT:    0000000000000001    42 OBJECT  GLOBAL DEFAULT [[#A:]] a
10# CHECK-NEXT:    0000000000000005     0 NOTYPE  GLOBAL DEFAULT [[#A]]  b
11# CHECK-NEXT:    0000000000000001    42 OBJECT  GLOBAL DEFAULT [[#A]]  a1
12# CHECK-NEXT:    0000000000000002    42 OBJECT  GLOBAL DEFAULT [[#A]]  c
13# CHECK-NEXT:    000000000000000d    42 OBJECT  GLOBAL DEFAULT [[#A]]  d
14# CHECK-NEXT:    000000000000000d    42 OBJECT  GLOBAL DEFAULT [[#A]]  d1
15# CHECK-NEXT:    000000000000000d    42 OBJECT  GLOBAL DEFAULT [[#A]]  d2
16# CHECK-NEXT:    0000000000000001    41 OBJECT  GLOBAL DEFAULT [[#A]]  e
17# CHECK-NEXT:    0000000000000001    41 OBJECT  GLOBAL DEFAULT [[#A]]  e1
18# CHECK-NEXT:    0000000000000001    41 OBJECT  GLOBAL DEFAULT [[#A]]  e2
19# CHECK-NEXT:    0000000000000002    42 OBJECT  GLOBAL DEFAULT [[#A]]  e3
20# CHECK-NEXT:    0000000000000005     0 NOTYPE  GLOBAL DEFAULT [[#A]]  test2_a
21# CHECK-NEXT:    0000000000000005     0 NOTYPE  GLOBAL DEFAULT [[#A]]  test2_b
22# CHECK-NEXT:    0000000000000009     0 NOTYPE  GLOBAL DEFAULT [[#A]]  test2_c
23# CHECK-NEXT:    0000000000000009     0 NOTYPE  GLOBAL DEFAULT [[#A]]  test2_d
24# CHECK-NEXT:    0000000000000004     0 NOTYPE  GLOBAL DEFAULT  ABS    test2_e
25# CHECK-NEXT:    0000000000000001    41 OBJECT  GLOBAL DEFAULT [[#A]]  e@v1
26
27
28        .data
29        .globl	a
30        .size a, 42
31        .byte 42
32        .type a, @object
33a:
34
35        .long 42
36        .globl b, a1, c, d, d1, d2, e, e1, e2, e3
37b:
38a1 = a
39c = a + 1
40
41## These st_size fields inherit from a.
42d = a + (b - a) * 3
43.set d1, d
44d2 = d1
45
46e = a + (1 - 1)
47.size e, 41
48## These st_size fields inherit from e instead of a.
49## TODO e3's st_size should inherit from e.
50.set e1, e
51.set e2, e1
52e3 = e1 + 1
53
54        .globl test2_a
55        .globl test2_b
56        .globl test2_c
57        .globl test2_d
58        .globl test2_e
59test2_a:
60    .long 0
61test2_b = test2_a
62test2_c:
63    .long 0
64test2_d = test2_c
65test2_e = test2_d - test2_b
66
67## e@v1's st_size equals e's st_size.
68.symver e, e@v1
69