Skip to content

[llvm-dwarfdump] Support R_AARCH64_TLS_DTPREL64 in Object/RelocationResolver.cpp (#187649) - #191108

Closed
xgupta wants to merge 1 commit into
llvm:release/22.xfrom
xgupta:backport-llvm-dwarfdump
Closed

xgupta wants to merge 1 commit into
llvm:release/22.xfrom
xgupta:backport-llvm-dwarfdump

Conversation

@xgupta

@xgupta xgupta commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

In patch #146572 we have plan to emit R_AARCH64_TLS_DTPREL64. This give us the warning while using llvm-dwarfdump for the object file which has tls variables -

warning: failed to compute relocation: R_AARCH64_TLS_DTPREL64, Invalid data was encountered while parsing the file

To fix this warning we have mark the relocation as supported however final absolute address of a TLS variable is determined at runtime, resolving to the symbol's section-relative offset in the object file is mitigate the warning.

(cherry picked from commit fa136df)

…esolver.cpp (llvm#187649)

In patch llvm#146572 we have plan
to emit R_AARCH64_TLS_DTPREL64. This give us the warning while using
llvm-dwarfdump for the object file which has tls variables -

warning: failed to compute relocation: R_AARCH64_TLS_DTPREL64, Invalid
data was encountered while parsing the file

To fix this warning we have mark the relocation as supported however
final absolute address of a TLS variable is determined at runtime,
resolving to the symbol's section-relative offset in the object file is
mitigate the warning.

(cherry picked from commit fa136df)
@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown

🐧 Linux x64 Test Results

  • 168048 tests passed
  • 2993 tests skipped
  • 1 test failed

Failed Tests

(click on a test name to see its output)

LLVM

LLVM.DebugInfo/AArch64/tls-at-location.ll
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llc -O0 -mtriple=aarch64 --aarch64-emit-debug-tls-location -filetype=obj < /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/DebugInfo/AArch64/tls-at-location.ll      | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llvm-dwarfdump - 2>&1 | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/DebugInfo/AArch64/tls-at-location.ll --check-prefix=TLS --implicit-check-not=warning:
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llc -O0 -mtriple=aarch64 --aarch64-emit-debug-tls-location -filetype=obj
# .---command stderr------------
# | llc: Unknown command line argument '--aarch64-emit-debug-tls-location'.  Try: '/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llc --help'
# | llc: Did you mean '--aarch64-elf-ldtls-generation'?
# `-----------------------------
# error: command failed with exit status: 1
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llvm-dwarfdump -
# note: command had no output on stdout or stderr
# error: command failed with exit status: 1
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/DebugInfo/AArch64/tls-at-location.ll --check-prefix=TLS --implicit-check-not=warning:
# .---command stderr------------
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/DebugInfo/AArch64/tls-at-location.ll:14:8: error: TLS: expected string not found in input
# | ; TLS: .debug_info contents:
# |        ^
# | <stdin>:1:1: note: scanning from here
# | error: -: The file was not recognized as a valid object file
# | ^
# | <stdin>:1:16: note: possible intended match here
# | error: -: The file was not recognized as a valid object file
# |                ^
# | 
# | Input file: <stdin>
# | Check file: /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/DebugInfo/AArch64/tls-at-location.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             1: error: -: The file was not recognized as a valid object file 
# | check:14'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
# | check:14'1                    ?                                              possible intended match
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the infrastructure label.

@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown

🪟 Windows x64 Test Results

  • 129457 tests passed
  • 2864 tests skipped
  • 1 test failed

Failed Tests

(click on a test name to see its output)

LLVM

LLVM.DebugInfo/AArch64/tls-at-location.ll
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
c:\_work\llvm-project\llvm-project\build\bin\llc.exe -O0 -mtriple=aarch64 --aarch64-emit-debug-tls-location -filetype=obj < C:\_work\llvm-project\llvm-project\llvm\test\DebugInfo\AArch64\tls-at-location.ll      | c:\_work\llvm-project\llvm-project\build\bin\llvm-dwarfdump.exe - 2>&1 | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\llvm\test\DebugInfo\AArch64\tls-at-location.ll --check-prefix=TLS --implicit-check-not=warning:
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\llc.exe' -O0 -mtriple=aarch64 --aarch64-emit-debug-tls-location -filetype=obj
# .---command stderr------------
# | llc.exe: Unknown command line argument '--aarch64-emit-debug-tls-location'.  Try: 'c:\_work\llvm-project\llvm-project\build\bin\llc.exe --help'
# | llc.exe: Did you mean '--aarch64-elf-ldtls-generation'?
# `-----------------------------
# error: command failed with exit status: 1
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\llvm-dwarfdump.exe' -
# note: command had no output on stdout or stderr
# error: command failed with exit status: 1
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' 'C:\_work\llvm-project\llvm-project\llvm\test\DebugInfo\AArch64\tls-at-location.ll' --check-prefix=TLS --implicit-check-not=warning:
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\llvm\test\DebugInfo\AArch64\tls-at-location.ll:14:8: error: TLS: expected string not found in input
# | ; TLS: .debug_info contents:
# |        ^
# | <stdin>:1:1: note: scanning from here
# | error: -: The file was not recognized as a valid object file
# | ^
# | <stdin>:1:16: note: possible intended match here
# | error: -: The file was not recognized as a valid object file
# |                ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\llvm\test\DebugInfo\AArch64\tls-at-location.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             1: error: -: The file was not recognized as a valid object file 
# | check:14'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
# | check:14'1                    ?                                              possible intended match
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the infrastructure label.

@xgupta
xgupta marked this pull request as ready for review April 9, 2026 09:32
@xgupta xgupta added this to the LLVM 22.x Release milestone Apr 9, 2026
@llvmbot

llvmbot commented Apr 9, 2026

Copy link
Copy Markdown
Member

@llvm/pr-subscribers-llvm-binary-utilities

Author: Shivam Gupta (xgupta)

Changes

In patch #146572 we have plan to emit R_AARCH64_TLS_DTPREL64. This give us the warning while using llvm-dwarfdump for the object file which has tls variables -

warning: failed to compute relocation: R_AARCH64_TLS_DTPREL64, Invalid data was encountered while parsing the file

To fix this warning we have mark the relocation as supported however final absolute address of a TLS variable is determined at runtime, resolving to the symbol's section-relative offset in the object file is mitigate the warning.

(cherry picked from commit fa136df)


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

2 Files Affected:

  • (modified) llvm/lib/Object/RelocationResolver.cpp (+2)
  • (modified) llvm/test/DebugInfo/AArch64/tls-at-location.ll (+30-5)
diff --git a/llvm/lib/Object/RelocationResolver.cpp b/llvm/lib/Object/RelocationResolver.cpp
index d81899334b2b1..edb777d200b0e 100644
--- a/llvm/lib/Object/RelocationResolver.cpp
+++ b/llvm/lib/Object/RelocationResolver.cpp
@@ -79,6 +79,7 @@ static bool supportsAArch64(uint64_t Type) {
   case ELF::R_AARCH64_PREL16:
   case ELF::R_AARCH64_PREL32:
   case ELF::R_AARCH64_PREL64:
+  case ELF::R_AARCH64_TLS_DTPREL64:
     return true;
   default:
     return false;
@@ -91,6 +92,7 @@ static uint64_t resolveAArch64(uint64_t Type, uint64_t Offset, uint64_t S,
   case ELF::R_AARCH64_ABS32:
     return (S + Addend) & 0xFFFFFFFF;
   case ELF::R_AARCH64_ABS64:
+  case ELF::R_AARCH64_TLS_DTPREL64:
     return S + Addend;
   case ELF::R_AARCH64_PREL16:
     return (S + Addend - Offset) & 0xFFFF;
diff --git a/llvm/test/DebugInfo/AArch64/tls-at-location.ll b/llvm/test/DebugInfo/AArch64/tls-at-location.ll
index 20a0afb789771..0136ad4d857a0 100644
--- a/llvm/test/DebugInfo/AArch64/tls-at-location.ll
+++ b/llvm/test/DebugInfo/AArch64/tls-at-location.ll
@@ -1,8 +1,33 @@
-; RUN: llc -filetype=obj -mtriple=aarch64--linux-gnu -o - %s | llvm-dwarfdump -v - | FileCheck %s
-;
-; CHECK: .debug_info contents:
-; CHECK: DW_TAG_variable
-; CHECK-NOT: DW_AT_location
+; RUN: llc -O0 -mtriple=aarch64 --aarch64-emit-debug-tls-location -filetype=obj < %s \
+; RUN:     | llvm-dwarfdump - 2>&1 | FileCheck %s --check-prefix=TLS --implicit-check-not=warning:
+
+; RUN: llc -O0 -mtriple=aarch64 --aarch64-emit-debug-tls-location=false -filetype=obj < %s \
+; RUN:     | llvm-dwarfdump - | FileCheck %s --check-prefix=NO-TLS
+
+; RUN: llc -O0 -mtriple=aarch64 -filetype=obj < %s \
+; RUN:     | llvm-dwarfdump - | FileCheck %s --check-prefix=NO-TLS
+
+; RUN: llc -O0 -mtriple=aarch64 --aarch64-emit-debug-tls-location -filetype=obj < %s -o %t
+; RUN: llvm-objdump -r %t | FileCheck %s --check-prefix=OBJDUMP
+; RUN: llvm-readelf -r %t | FileCheck %s --check-prefix=RELOC
+
+; TLS: .debug_info contents:
+; TLS:  DW_TAG_variable
+; TLS-NEXT:   DW_AT_name      ("var")
+; TLS-NEXT:   DW_AT_type      (0x{{.*}} "int")
+; TLS-NEXT:   DW_AT_external  (true)
+; TLS-NEXT:   DW_AT_decl_file ("{{.*}}tls-at-location.c")
+; TLS-NEXT:   DW_AT_decl_line (1)
+; TLS-NEXT:   DW_AT_location  (DW_OP_const8u 0x0, DW_OP_GNU_push_tls_address)
+
+; NO-TLS: .debug_info contents:
+; NO-TLS: DW_TAG_variable
+; NO-TLS-NEXT:  DW_AT_name	("var")
+; NO-TLS-NOT:   DW_AT_location
+
+; OBJDUMP: R_AARCH64_TLS_DTPREL64   var
+
+; RELOC: R_AARCH64_TLS_DTPREL64 {{0+}} var + 0
 
 @var = thread_local global i32 0, align 4, !dbg !0
 

@llvmbot

llvmbot commented Apr 9, 2026

Copy link
Copy Markdown
Member

@llvm/pr-subscribers-debuginfo

Author: Shivam Gupta (xgupta)

Changes

In patch #146572 we have plan to emit R_AARCH64_TLS_DTPREL64. This give us the warning while using llvm-dwarfdump for the object file which has tls variables -

warning: failed to compute relocation: R_AARCH64_TLS_DTPREL64, Invalid data was encountered while parsing the file

To fix this warning we have mark the relocation as supported however final absolute address of a TLS variable is determined at runtime, resolving to the symbol's section-relative offset in the object file is mitigate the warning.

(cherry picked from commit fa136df)


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

2 Files Affected:

  • (modified) llvm/lib/Object/RelocationResolver.cpp (+2)
  • (modified) llvm/test/DebugInfo/AArch64/tls-at-location.ll (+30-5)
diff --git a/llvm/lib/Object/RelocationResolver.cpp b/llvm/lib/Object/RelocationResolver.cpp
index d81899334b2b1..edb777d200b0e 100644
--- a/llvm/lib/Object/RelocationResolver.cpp
+++ b/llvm/lib/Object/RelocationResolver.cpp
@@ -79,6 +79,7 @@ static bool supportsAArch64(uint64_t Type) {
   case ELF::R_AARCH64_PREL16:
   case ELF::R_AARCH64_PREL32:
   case ELF::R_AARCH64_PREL64:
+  case ELF::R_AARCH64_TLS_DTPREL64:
     return true;
   default:
     return false;
@@ -91,6 +92,7 @@ static uint64_t resolveAArch64(uint64_t Type, uint64_t Offset, uint64_t S,
   case ELF::R_AARCH64_ABS32:
     return (S + Addend) & 0xFFFFFFFF;
   case ELF::R_AARCH64_ABS64:
+  case ELF::R_AARCH64_TLS_DTPREL64:
     return S + Addend;
   case ELF::R_AARCH64_PREL16:
     return (S + Addend - Offset) & 0xFFFF;
diff --git a/llvm/test/DebugInfo/AArch64/tls-at-location.ll b/llvm/test/DebugInfo/AArch64/tls-at-location.ll
index 20a0afb789771..0136ad4d857a0 100644
--- a/llvm/test/DebugInfo/AArch64/tls-at-location.ll
+++ b/llvm/test/DebugInfo/AArch64/tls-at-location.ll
@@ -1,8 +1,33 @@
-; RUN: llc -filetype=obj -mtriple=aarch64--linux-gnu -o - %s | llvm-dwarfdump -v - | FileCheck %s
-;
-; CHECK: .debug_info contents:
-; CHECK: DW_TAG_variable
-; CHECK-NOT: DW_AT_location
+; RUN: llc -O0 -mtriple=aarch64 --aarch64-emit-debug-tls-location -filetype=obj < %s \
+; RUN:     | llvm-dwarfdump - 2>&1 | FileCheck %s --check-prefix=TLS --implicit-check-not=warning:
+
+; RUN: llc -O0 -mtriple=aarch64 --aarch64-emit-debug-tls-location=false -filetype=obj < %s \
+; RUN:     | llvm-dwarfdump - | FileCheck %s --check-prefix=NO-TLS
+
+; RUN: llc -O0 -mtriple=aarch64 -filetype=obj < %s \
+; RUN:     | llvm-dwarfdump - | FileCheck %s --check-prefix=NO-TLS
+
+; RUN: llc -O0 -mtriple=aarch64 --aarch64-emit-debug-tls-location -filetype=obj < %s -o %t
+; RUN: llvm-objdump -r %t | FileCheck %s --check-prefix=OBJDUMP
+; RUN: llvm-readelf -r %t | FileCheck %s --check-prefix=RELOC
+
+; TLS: .debug_info contents:
+; TLS:  DW_TAG_variable
+; TLS-NEXT:   DW_AT_name      ("var")
+; TLS-NEXT:   DW_AT_type      (0x{{.*}} "int")
+; TLS-NEXT:   DW_AT_external  (true)
+; TLS-NEXT:   DW_AT_decl_file ("{{.*}}tls-at-location.c")
+; TLS-NEXT:   DW_AT_decl_line (1)
+; TLS-NEXT:   DW_AT_location  (DW_OP_const8u 0x0, DW_OP_GNU_push_tls_address)
+
+; NO-TLS: .debug_info contents:
+; NO-TLS: DW_TAG_variable
+; NO-TLS-NEXT:  DW_AT_name	("var")
+; NO-TLS-NOT:   DW_AT_location
+
+; OBJDUMP: R_AARCH64_TLS_DTPREL64   var
+
+; RELOC: R_AARCH64_TLS_DTPREL64 {{0+}} var + 0
 
 @var = thread_local global i32 0, align 4, !dbg !0
 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

2 participants