[PATCH] D111071: [ELF][test] Enhance relative dynamic relocation tests

Andrew Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 4 09:30:08 PDT 2021


andrewng created this revision.
andrewng added reviewers: MaskRay, pcc.
Herald added a subscriber: emaste.
andrewng requested review of this revision.

Add checking of the value of the relocation with an addend. Also check
all relocation offsets.


https://reviews.llvm.org/D111071

Files:
  lld/test/ELF/relative-dynamic-reloc-pie.s
  lld/test/ELF/relative-dynamic-reloc.s


Index: lld/test/ELF/relative-dynamic-reloc.s
===================================================================
--- lld/test/ELF/relative-dynamic-reloc.s
+++ lld/test/ELF/relative-dynamic-reloc.s
@@ -9,11 +9,12 @@
 // CHECK:      Relocations [
 // CHECK-NEXT:   Section ({{.*}}) .rela.dyn {
 // CHECK-NEXT:     0x[[FOO_ADDR:.*]] R_X86_64_RELATIVE - 0x[[FOO_ADDR]]
-// CHECK-NEXT:     0x[[BAR_ADDR:.*]] R_X86_64_RELATIVE - 0x[[BAR_ADDR]]
-// CHECK-NEXT:     0x{{[0-9A-F]+}} R_X86_64_RELATIVE - 0x{{[0-9A-F]+}}
-// CHECK-NEXT:     0x{{.*}} R_X86_64_RELATIVE - 0x[[ZED_ADDR:.*]]
-// CHECK-NEXT:     0x{{.*}} R_X86_64_RELATIVE - 0x[[FOO_ADDR]]
-// CHECK-NEXT:     0x{{[0-9A-F]+}} R_X86_64_64 external 0x0
+// CHECK-NEXT:     0x[[#%X,BAR_ADDR:]] R_X86_64_RELATIVE
+// CHECK-SAME:       - 0x[[#BAR_ADDR]]
+// CHECK-NEXT:     0x[[#BAR_ADDR +  8]] R_X86_64_RELATIVE - 0x[[#BAR_ADDR + 1]]
+// CHECK-NEXT:     0x[[#BAR_ADDR + 16]] R_X86_64_RELATIVE - 0x[[ZED_ADDR:.*]]
+// CHECK-NEXT:     0x[[#BAR_ADDR + 24]] R_X86_64_RELATIVE - 0x[[FOO_ADDR]]
+// CHECK-NEXT:     0x[[#BAR_ADDR + 32]] R_X86_64_64 external 0x0
 // CHECK-NEXT:   }
 // CHECK-NEXT: ]
 
@@ -21,7 +22,7 @@
 // CHECK:        Name: foo
 // CHECK-NEXT:   Value: 0x[[FOO_ADDR]]
 // CHECK:        Name: bar
-// CHECK-NEXT:   Value: 0x[[BAR_ADDR]]
+// CHECK-NEXT:   Value: 0x[[#BAR_ADDR]]
 // CHECK:        Name: zed
 // CHECK-NEXT:   Value: 0x[[ZED_ADDR]]
 // CHECK:      ]
Index: lld/test/ELF/relative-dynamic-reloc-pie.s
===================================================================
--- lld/test/ELF/relative-dynamic-reloc-pie.s
+++ lld/test/ELF/relative-dynamic-reloc-pie.s
@@ -6,9 +6,10 @@
 ## Test that we create R_X86_64_RELATIVE relocations with -pie.
 # CHECK:      Relocations [
 # CHECK-NEXT:   Section ({{.*}}) .rela.dyn {
-# CHECK-NEXT:     0x3368 R_X86_64_RELATIVE - 0x3368
-# CHECK-NEXT:     0x3370 R_X86_64_RELATIVE - 0x3370
-# CHECK-NEXT:     0x3378 R_X86_64_RELATIVE - 0x3371
+# CHECK-NEXT:     0x[[FOO_ADDR:.*]] R_X86_64_RELATIVE - 0x[[FOO_ADDR]]
+# CHECK-NEXT:     0x[[#%X,BAR_ADDR:]] R_X86_64_RELATIVE
+# CHECK-SAME:       - 0x[[#BAR_ADDR]]
+# CHECK-NEXT:     0x[[#BAR_ADDR + 8]] R_X86_64_RELATIVE - 0x[[#BAR_ADDR + 1]]
 # CHECK-NEXT:   }
 # CHECK-NEXT: ]
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111071.376922.patch
Type: text/x-patch
Size: 2233 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211004/deeeef47/attachment.bin>


More information about the llvm-commits mailing list