Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MC][NFC] Update tests for GOTTPOFF relocation. #117846

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fzou1
Copy link
Contributor

@fzou1 fzou1 commented Nov 27, 2024

Update tests for GOTTPOFF relocation as LEA instruction is not supported by linkers for GOTTPOFF relocation. Only MOV and ADD instructions are supported.

Update tests for GOTTPOFF relocation as LEA instruction is not supported by
linkers for GOTTPOFF relocation. Only MOV and ADD instructions are supported.
@llvmbot llvmbot added the mc Machine (object) code label Nov 27, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 27, 2024

@llvm/pr-subscribers-mc

Author: Feng Zou (fzou1)

Changes

Update tests for GOTTPOFF relocation as LEA instruction is not supported by linkers for GOTTPOFF relocation. Only MOV and ADD instructions are supported.


Full diff: https://github.com/llvm/llvm-project/pull/117846.diff

2 Files Affected:

  • (modified) llvm/test/MC/ELF/relocation.s (+1-1)
  • (modified) llvm/test/MC/ELF/tls.s (+9-8)
diff --git a/llvm/test/MC/ELF/relocation.s b/llvm/test/MC/ELF/relocation.s
index 25497a003f8538..b84bdcc05dcf6d 100644
--- a/llvm/test/MC/ELF/relocation.s
+++ b/llvm/test/MC/ELF/relocation.s
@@ -18,7 +18,7 @@ bar:
         movl	bar, %edx         # R_X86_64_32S
         movq	bar, %rdx         # R_X86_64_32S
 .long bar                         # R_X86_64_32
-        leaq	foo@GOTTPOFF(%rip), %rax # R_X86_64_GOTTPOFF
+        movq    foo@GOTTPOFF(%rip), %rax # R_X86_64_GOTTPOFF
         movq    foo@GOTTPOFF(%rip), %r31 # R_X86_64_CODE_4_GOTTPOFF
         addq    foo@GOTTPOFF(%rip), %r31 # R_X86_64_CODE_4_GOTTPOFF
         # NDD
diff --git a/llvm/test/MC/ELF/tls.s b/llvm/test/MC/ELF/tls.s
index 560cf138806ec4..9f3ff7c00b8d1b 100644
--- a/llvm/test/MC/ELF/tls.s
+++ b/llvm/test/MC/ELF/tls.s
@@ -2,15 +2,16 @@
 
 // Test that all symbols are of type STT_TLS.
 
-	leaq	foo1@TLSGD(%rip), %rdi
-        leaq    foo2@GOTTPOFF(%rip), %rdi
-        leaq    foo3@TLSLD(%rip), %rdi
-	.long foo4@GOTTPOFF
-	.long foo5@TLSLD
-	.long foo6@TLSGD
-	.section	.zed,"awT",@progbits
+    leaq    foo1@TLSGD(%rip), %rdi
+    movq    foo2@GOTTPOFF(%rip), %rdi
+    leaq    foo3@TLSLD(%rip), %rdi
+
+    .long foo4@GOTTPOFF
+    .long foo5@TLSLD
+    .long foo6@TLSGD
+    .section    .zed,"awT",@progbits
 foobar:
-	.long	43
+    .long    43
 
 // CHECK:        Symbol {
 // CHECK:          Name: foobar

@MaskRay
Copy link
Member

MaskRay commented Nov 27, 2024

leaq foo@GOTTPOFF(%rip), %rax # R_X86_64_GOTTPOFF

gas generates R_X86_64_GOTTPOFF. I don't think we should drop this test. R_X86_64_GOTTPOFF can be generated for multiple instructions and x86-64 lets the linker inspect the opcode to decide whether to perform relocation.
Linkers don't perform TLS optimization doesn't mean that we could dropthis assembler test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mc Machine (object) code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants