[JITLink][ELF][x86-64] Replace R_X86_64_32 yaml testcase with asm version.
authorLang Hames <lhames@gmail.com>
Sun, 16 Apr 2023 02:07:31 +0000 (02:07 +0000)
committerLang Hames <lhames@gmail.com>
Sun, 16 Apr 2023 02:07:31 +0000 (02:07 +0000)
The assembly version of this testcase is shorter and easier to read.

llvm/test/ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_32.s [new file with mode: 0644]
llvm/test/ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_32.yaml [deleted file]

diff --git a/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_32.s b/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_32.s
new file mode 100644 (file)
index 0000000..696d17a
--- /dev/null
@@ -0,0 +1,31 @@
+# RUN: llvm-mc -triple=x86_64-unknown-linux -position-independent \
+# RUN:     -filetype=obj -o %t.o %s
+# RUN: llvm-jitlink -noexec -abs X=0x12345678 -check=%s %t.o
+# RUN: not llvm-jitlink -noexec -abs X=0x123456789 %t.o 2>&1 | \
+# RUN:   FileCheck -check-prefix=CHECK-ERROR %s
+#
+# Check success and failure cases of R_X86_64_32 handling.
+
+# jitlink-check: *{8}P = X
+
+# CHECK-ERROR: relocation target "X" {{.*}} is out of range of Pointer32 fixup
+
+       .text
+       .section        .text.main,"ax",@progbits
+       .globl  main
+       .p2align        4, 0x90
+       .type   main,@function
+main:
+       xorl    %eax, %eax
+       retq
+.Lfunc_end0:
+       .size   main, .Lfunc_end0-main
+
+       .type   P,@object
+       .data
+       .globl  P
+       .p2align        2, 0x0
+P:
+       .long   X    # Using long here generates R_X86_64_32.
+       .long   0
+       .size   P, 8
diff --git a/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_32.yaml b/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_32.yaml
deleted file mode 100644 (file)
index a352855..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-# Check success and failure cases of R_X86_64_32 handling.
-# This file contains a single R_X86_64_32 relocation. We expect the relocation
-# to apply successfully when we assign x an address in the low 32-bits of the
-# address space, and fail if we assign x an address outside that range.
-
-# RUN: yaml2obj -o %t.o %s
-# RUN: llvm-jitlink -abs x=0x12345678 -noexec -check=%s %t.o
-# RUN: not llvm-jitlink -abs x=0x123456789 -noexec %t.o 2>&1 | \
-# RUN:   FileCheck -check-prefix=CHECK-ERROR %s
-
-# jitlink-check: *{8}xptr = x
-
-# CHECK-ERROR: relocation target "x" {{.*}} is out of range of Pointer32 fixup
-
---- !ELF
-FileHeader:
-  Class:           ELFCLASS64
-  Data:            ELFDATA2LSB
-  Type:            ET_REL
-  Machine:         EM_X86_64
-  SectionHeaderStringTable: .strtab
-Sections:
-  - Name:            .text
-    Type:            SHT_PROGBITS
-    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
-    AddressAlign:    0x10
-    Content:         31C0C3
-  - Name:            .data
-    Type:            SHT_PROGBITS
-    Flags:           [ SHF_WRITE, SHF_ALLOC ]
-    AddressAlign:    0x8
-    Content:         '0000000000000000'
-  - Name:            .comment
-    Type:            SHT_PROGBITS
-    Flags:           [ SHF_MERGE, SHF_STRINGS ]
-    AddressAlign:    0x1
-    EntSize:         0x1
-    Content:         00636C616E672076657273696F6E2031372E302E302028676974406769746875622E636F6D3A6C6C766D2F6C6C766D2D70726F6A6563742E67697420393361303461303539316331393538643533343466333534313135376662643862386666373337302900
-  - Name:            .note.GNU-stack
-    Type:            SHT_PROGBITS
-    AddressAlign:    0x1
-  - Name:            .rela.data
-    Type:            SHT_RELA
-    Flags:           [ SHF_INFO_LINK ]
-    Link:            .symtab
-    AddressAlign:    0x8
-    Info:            .data
-    Relocations:
-      - Symbol:          x
-        Type:            R_X86_64_32
-  - Name:            .llvm_addrsig
-    Type:            SHT_LLVM_ADDRSIG
-    Flags:           [ SHF_EXCLUDE ]
-    Link:            .symtab
-    AddressAlign:    0x1
-    Symbols:         [ x ]
-  - Type:            SectionHeaderTable
-    Sections:
-      - Name:            .strtab
-      - Name:            .text
-      - Name:            .data
-      - Name:            .rela.data
-      - Name:            .comment
-      - Name:            .note.GNU-stack
-      - Name:            .llvm_addrsig
-      - Name:            .symtab
-Symbols:
-  - Name:            testcase.c
-    Type:            STT_FILE
-    Index:           SHN_ABS
-  - Name:            main
-    Type:            STT_FUNC
-    Section:         .text
-    Binding:         STB_GLOBAL
-    Size:            0x3
-  - Name:            xptr
-    Type:            STT_OBJECT
-    Section:         .data
-    Binding:         STB_GLOBAL
-    Size:            0x8
-  - Name:            x
-    Binding:         STB_GLOBAL
-...