[llvm-branch-commits] [llvm] 9ed930e - [MC][test] Improve offset.s

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed May 11 14:45:54 PDT 2022


Author: Fangrui Song
Date: 2022-05-11T14:45:04-07:00
New Revision: 9ed930e5cd74011f6d236d6a653138d076a5320f

URL: https://github.com/llvm/llvm-project/commit/9ed930e5cd74011f6d236d6a653138d076a5320f
DIFF: https://github.com/llvm/llvm-project/commit/9ed930e5cd74011f6d236d6a653138d076a5320f.diff

LOG: [MC][test] Improve offset.s

(cherry picked from commit 67acc34e2ad89f18a6d66d72ddc30e77c5aff7d9)

Added: 
    

Modified: 
    llvm/test/MC/ELF/offset.s

Removed: 
    


################################################################################
diff  --git a/llvm/test/MC/ELF/offset.s b/llvm/test/MC/ELF/offset.s
index d98405eda9901..8d7fd3cd1459c 100644
--- a/llvm/test/MC/ELF/offset.s
+++ b/llvm/test/MC/ELF/offset.s
@@ -1,77 +1,54 @@
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj --symbols - | FileCheck %s
+# RUN: llvm-mc -filetype=obj -triple x86_64 %s -o %t
+# RUN: llvm-readelf -s %t | FileCheck %s
+
+## Test that a variable declared with "var = other_var + cst" is in the same
+## section as other_var and its value is the value of other_var + cst.
+## In addition, its st_size inherits from other_var.
+
+# CHECK:      0: {{.*}}
+# CHECK-NEXT:    0000000000000001    42 OBJECT  GLOBAL DEFAULT [[#A:]] a
+# CHECK-NEXT:    0000000000000005     0 NOTYPE  GLOBAL DEFAULT [[#A]]  b
+# CHECK-NEXT:    0000000000000001    42 OBJECT  GLOBAL DEFAULT [[#A]]  a1
+# CHECK-NEXT:    0000000000000002    42 OBJECT  GLOBAL DEFAULT [[#A]]  c
+# CHECK-NEXT:    000000000000000d    42 OBJECT  GLOBAL DEFAULT [[#A]]  d
+# CHECK-NEXT:    000000000000000d    42 OBJECT  GLOBAL DEFAULT [[#A]]  d1
+# CHECK-NEXT:    000000000000000d    42 OBJECT  GLOBAL DEFAULT [[#A]]  d2
+# CHECK-NEXT:    0000000000000001    41 OBJECT  GLOBAL DEFAULT [[#A]]  e
+# CHECK-NEXT:    0000000000000001    42 OBJECT  GLOBAL DEFAULT [[#A]]  e1
+# CHECK-NEXT:    0000000000000001    42 OBJECT  GLOBAL DEFAULT [[#A]]  e2
+# CHECK-NEXT:    0000000000000002    42 OBJECT  GLOBAL DEFAULT [[#A]]  e3
+# CHECK-NEXT:    0000000000000005     0 NOTYPE  GLOBAL DEFAULT [[#A]]  test2_a
+# CHECK-NEXT:    0000000000000005     0 NOTYPE  GLOBAL DEFAULT [[#A]]  test2_b
+# CHECK-NEXT:    0000000000000009     0 NOTYPE  GLOBAL DEFAULT [[#A]]  test2_c
+# CHECK-NEXT:    0000000000000009     0 NOTYPE  GLOBAL DEFAULT [[#A]]  test2_d
+# CHECK-NEXT:    0000000000000004     0 NOTYPE  GLOBAL DEFAULT  ABS    test2_e
+# CHECK-NEXT:    0000000000000001    42 OBJECT  GLOBAL DEFAULT [[#A]]  e at v1
 
-// Test that a variable declared with "var = other_var + cst" is in the same
-// section as other_var and its value is the value of other_var + cst.
 
         .data
-        .globl	sym_a
-        .size sym_a, 42
+        .globl	a
+        .size a, 42
         .byte 42
-        .type sym_a, @object
-sym_a:
-
-// CHECK:       Symbol {
-// CHECK:         Name: sym_a
-// CHECK-NEXT:    Value: 0x1
-// CHECK-NEXT:    Size: 42
-// CHECK-NEXT:    Binding: Global
-// CHECK-NEXT:    Type: Object
-// CHECK-NEXT:    Other: 0
-// CHECK-NEXT:    Section: .data
-// CHECK-NEXT:  }
+        .type a, @object
+a:
 
         .long 42
-        .globl sym_b
-sym_b:
-        .globl sym_c
-sym_c = sym_a
-// CHECK:       Symbol {
-// CHECK:         Name: sym_c
-// CHECK-NEXT:    Value: 0x1
-// CHECK-NEXT:    Size: 42
-// CHECK-NEXT:    Binding: Global
-// CHECK-NEXT:    Type: Object
-// CHECK-NEXT:    Other: 0
-// CHECK-NEXT:    Section: .data
-// CHECK-NEXT:  }
-
-        .globl sym_d
-sym_d = sym_a + 1
-// CHECK:       Symbol {
-// CHECK:         Name: sym_d
-// CHECK-NEXT:    Value: 0x2
-// CHECK-NEXT:    Size: 42
-// CHECK-NEXT:    Binding: Global
-// CHECK-NEXT:    Type: Object
-// CHECK-NEXT:    Other: 0
-// CHECK-NEXT:    Section: .data
-// CHECK-NEXT:  }
+        .globl b, a1, c, d, d1, d2, e, e1, e2, e3
+b:
+a1 = a
+c = a + 1
 
-        .globl sym_e
-sym_e = sym_a + (sym_b - sym_a) * 3
-// CHECK:       Symbol {
-// CHECK:         Name: sym_e
-// CHECK-NEXT:    Value: 0xD
-// CHECK-NEXT:    Size: 42
-// CHECK-NEXT:    Binding: Global
-// CHECK-NEXT:    Type: Object
-// CHECK-NEXT:    Other: 0
-// CHECK-NEXT:    Section: .data
-// CHECK-NEXT:  }
-
-
-        .globl sym_f
-sym_f = sym_a + (1 - 1)
-// CHECK:       Symbol {
-// CHECK:         Name: sym_f
-// CHECK-NEXT:    Value: 0x1
-// CHECK-NEXT:    Size: 42
-// CHECK-NEXT:    Binding: Global
-// CHECK-NEXT:    Type: Object
-// CHECK-NEXT:    Other: 0
-// CHECK-NEXT:    Section: .data
-// CHECK-NEXT:  }
+## These st_size fields inherit from a.
+d = a + (b - a) * 3
+.set d1, d
+d2 = d1
 
+e = a + (1 - 1)
+.size e, 41
+## FIXME These st_size fields inherit from e instead of a.
+.set e1, e
+.set e2, e1
+e3 = e1 + 1
 
         .globl test2_a
         .globl test2_b
@@ -85,48 +62,6 @@ test2_c:
     .long 0
 test2_d = test2_c
 test2_e = test2_d - test2_b
-// CHECK:      Symbol {
-// CHECK:        Name: test2_a
-// CHECK-NEXT:   Value: 0x5
-// CHECK-NEXT:   Size: 0
-// CHECK-NEXT:   Binding: Global
-// CHECK-NEXT:   Type: None
-// CHECK-NEXT:   Other: 0
-// CHECK-NEXT:   Section: .data
-// CHECK-NEXT: }
-// CHECK-NEXT: Symbol {
-// CHECK-NEXT:   Name: test2_b
-// CHECK-NEXT:   Value: 0x5
-// CHECK-NEXT:   Size: 0
-// CHECK-NEXT:   Binding: Global
-// CHECK-NEXT:   Type: None
-// CHECK-NEXT:   Other: 0
-// CHECK-NEXT:   Section: .data
-// CHECK-NEXT: }
-// CHECK-NEXT: Symbol {
-// CHECK-NEXT:   Name: test2_c
-// CHECK-NEXT:   Value: 0x9
-// CHECK-NEXT:   Size: 0
-// CHECK-NEXT:   Binding: Global
-// CHECK-NEXT:   Type: None
-// CHECK-NEXT:   Other: 0
-// CHECK-NEXT:   Section: .data
-// CHECK-NEXT: }
-// CHECK-NEXT: Symbol {
-// CHECK-NEXT:   Name: test2_d
-// CHECK-NEXT:   Value: 0x9
-// CHECK-NEXT:   Size: 0
-// CHECK-NEXT:   Binding: Global
-// CHECK-NEXT:   Type: None
-// CHECK-NEXT:   Other: 0
-// CHECK-NEXT:   Section: .data
-// CHECK-NEXT: }
-// CHECK-NEXT: Symbol {
-// CHECK-NEXT:   Name: test2_e
-// CHECK-NEXT:   Value: 0x4
-// CHECK-NEXT:   Size: 0
-// CHECK-NEXT:   Binding: Global
-// CHECK-NEXT:   Type: None
-// CHECK-NEXT:   Other: 0
-// CHECK-NEXT:   Section: Absolute
-// CHECK-NEXT: }
+
+## e at v1's st_size equals e's st_size.
+.symver e, e at v1


        


More information about the llvm-branch-commits mailing list