diff options
author | Ulrich Weigand <ulrich.weigand@de.ibm.com> | 2024-03-05 17:48:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-05 17:48:06 +0100 |
commit | a8cb9db5f59dc97c9b3d0370a5879539e7b233d8 (patch) | |
tree | 950785899f4b23c3311006f5706a4e4eb9883864 | |
parent | 6b5888c27f2d7cfc5fce582500a12a7eda16a7e2 (diff) | |
download | llvm-a8cb9db5f59dc97c9b3d0370a5879539e7b233d8.zip llvm-a8cb9db5f59dc97c9b3d0370a5879539e7b233d8.tar.gz llvm-a8cb9db5f59dc97c9b3d0370a5879539e7b233d8.tar.bz2 |
[SystemZ] Use proper relocation for TLS variable debug info (#83975)
Debug info refering to a TLS variable via DW_OP_GNU_push_tls_address
needs to use a R_390_TLS_LDO64 relocation instead of R_390_64.
Fixed by adding a SystemZELFTargetObjectFile override class and proving
a getDebugThreadLocalSymbol implementation.
-rw-r--r-- | llvm/lib/Target/SystemZ/CMakeLists.txt | 1 | ||||
-rw-r--r-- | llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/Target/SystemZ/SystemZTargetObjectFile.cpp | 19 | ||||
-rw-r--r-- | llvm/lib/Target/SystemZ/SystemZTargetObjectFile.h | 27 |
4 files changed, 49 insertions, 1 deletions
diff --git a/llvm/lib/Target/SystemZ/CMakeLists.txt b/llvm/lib/Target/SystemZ/CMakeLists.txt index 0614e07..063e5bc 100644 --- a/llvm/lib/Target/SystemZ/CMakeLists.txt +++ b/llvm/lib/Target/SystemZ/CMakeLists.txt @@ -36,6 +36,7 @@ add_llvm_target(SystemZCodeGen SystemZShortenInst.cpp SystemZSubtarget.cpp SystemZTargetMachine.cpp + SystemZTargetObjectFile.cpp SystemZTargetTransformInfo.cpp SystemZTDC.cpp diff --git a/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp b/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp index 121512d..2491bd2 100644 --- a/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp +++ b/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp @@ -11,6 +11,7 @@ #include "SystemZ.h" #include "SystemZMachineFunctionInfo.h" #include "SystemZMachineScheduler.h" +#include "SystemZTargetObjectFile.h" #include "SystemZTargetTransformInfo.h" #include "TargetInfo/SystemZTargetInfo.h" #include "llvm/ADT/StringRef.h" @@ -83,7 +84,7 @@ static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) { // Note: Some times run with -triple s390x-unknown. // In this case, default to ELF unless z/OS specifically provided. - return std::make_unique<TargetLoweringObjectFileELF>(); + return std::make_unique<SystemZELFTargetObjectFile>(); } static Reloc::Model getEffectiveRelocModel(std::optional<Reloc::Model> RM) { diff --git a/llvm/lib/Target/SystemZ/SystemZTargetObjectFile.cpp b/llvm/lib/Target/SystemZ/SystemZTargetObjectFile.cpp new file mode 100644 index 0000000..4e7e4c8 --- /dev/null +++ b/llvm/lib/Target/SystemZ/SystemZTargetObjectFile.cpp @@ -0,0 +1,19 @@ +//===-- SystemZTargetObjectFile.cpp - SystemZ Object Info -----------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "SystemZTargetObjectFile.h" +#include "llvm/MC/MCExpr.h" +#include "llvm/MC/MCValue.h" +#include "llvm/Target/TargetMachine.h" + +using namespace llvm; + +const MCExpr *SystemZELFTargetObjectFile::getDebugThreadLocalSymbol( + const MCSymbol *Sym) const { + return MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_DTPOFF, getContext()); +} diff --git a/llvm/lib/Target/SystemZ/SystemZTargetObjectFile.h b/llvm/lib/Target/SystemZ/SystemZTargetObjectFile.h new file mode 100644 index 0000000..9d0adbb --- /dev/null +++ b/llvm/lib/Target/SystemZ/SystemZTargetObjectFile.h @@ -0,0 +1,27 @@ +//===-- SystemZTargetObjectFile.h - SystemZ Object Info ---------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETOBJECTFILE_H +#define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETOBJECTFILE_H + +#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" + +namespace llvm { + +/// This implementation is used for SystemZ ELF targets. +class SystemZELFTargetObjectFile : public TargetLoweringObjectFileELF { +public: + SystemZELFTargetObjectFile() {} + + /// Describe a TLS variable address within debug info. + const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const override; +}; + +} // end namespace llvm + +#endif |