[llvm] [Test][JitLink] Correctly generate the R_X86_64_PC8 relocation. (PR #109283)

Xing Guo via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 19 06:45:04 PDT 2024


https://github.com/higuoxing created https://github.com/llvm/llvm-project/pull/109283

Previously, ELF_R_X86_64_PC8.s doesn't produce the R_X86_64_PC8 relocation. This patch helps fix it.

Before:

```
llvm-mc -triple=x86_64-unknown-linux -position-independent -filetype=obj -o - ELF_R_X86_64_PC8.s | llvm-readobj -r -

File: <stdin>
Format: elf64-x86-64
Arch: x86_64
AddressSize: 64bit
LoadName: <Not found>
Relocations [
]
```

After:

```
llvm-mc -triple=x86_64-unknown-linux -position-independent -filetype=obj -o - ELF_R_X86_64_PC8.s | llvm-readobj -r -

File: <stdin>
Format: elf64-x86-64
Arch: x86_64
AddressSize: 64bit
LoadName: <Not found>
Relocations [
  Section (3) .rela.text {
    0x4 R_X86_64_PC8 main 0xFFFFFFFFFFFFFFFF
  }
]
```

>From bc5b9b4e556710eb9bcb4fb154078e0c7b8a05aa Mon Sep 17 00:00:00 2001
From: Xing Guo <higuoxing at gmail.com>
Date: Thu, 19 Sep 2024 21:32:36 +0800
Subject: [PATCH] [Test][JitLink] Correctly generate the R_X86_64_PC8
 relocation.

Previously, ELF_R_X86_64_PC8.s doesn't produce the R_X86_64_PC8
relocation. This patch helps fix it.

Before:

```
llvm-mc -triple=x86_64-unknown-linux -position-independent -filetype=obj -o - ELF_R_X86_64_PC8.s | llvm-readobj -r -

File: <stdin>
Format: elf64-x86-64
Arch: x86_64
AddressSize: 64bit
LoadName: <Not found>
Relocations [
]
```

After:

```
llvm-mc -triple=x86_64-unknown-linux -position-independent -filetype=obj -o - ELF_R_X86_64_PC8.s | llvm-readobj -r -

File: <stdin>
Format: elf64-x86-64
Arch: x86_64
AddressSize: 64bit
LoadName: <Not found>
Relocations [
  Section (3) .rela.text {
    0x4 R_X86_64_PC8 main 0xFFFFFFFFFFFFFFFF
  }
]
```
---
 .../ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_PC8.s     | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_PC8.s b/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_PC8.s
index cac6dd9c612b6f..8bd1904acadb30 100644
--- a/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_PC8.s
+++ b/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_PC8.s
@@ -10,10 +10,4 @@
 main:
 	xorl	%eax, %eax
 	retq
-	.size	main, .-main
-
-	.type	P, at object
-	.globl	P
-P:
-	.byte main-. # Generate R_X86_64_PC8 relocation.
-  .size P, .-P
+	loope main # Generate R_X86_64_PC8 relocation.



More information about the llvm-commits mailing list