Skip to content

Commit a8cb9db

Browse files
authored
[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.
1 parent 6b5888c commit a8cb9db

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

llvm/lib/Target/SystemZ/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ add_llvm_target(SystemZCodeGen
3636
SystemZShortenInst.cpp
3737
SystemZSubtarget.cpp
3838
SystemZTargetMachine.cpp
39+
SystemZTargetObjectFile.cpp
3940
SystemZTargetTransformInfo.cpp
4041
SystemZTDC.cpp
4142

llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "SystemZ.h"
1212
#include "SystemZMachineFunctionInfo.h"
1313
#include "SystemZMachineScheduler.h"
14+
#include "SystemZTargetObjectFile.h"
1415
#include "SystemZTargetTransformInfo.h"
1516
#include "TargetInfo/SystemZTargetInfo.h"
1617
#include "llvm/ADT/StringRef.h"
@@ -83,7 +84,7 @@ static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
8384

8485
// Note: Some times run with -triple s390x-unknown.
8586
// In this case, default to ELF unless z/OS specifically provided.
86-
return std::make_unique<TargetLoweringObjectFileELF>();
87+
return std::make_unique<SystemZELFTargetObjectFile>();
8788
}
8889

8990
static Reloc::Model getEffectiveRelocModel(std::optional<Reloc::Model> RM) {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//===-- SystemZTargetObjectFile.cpp - SystemZ Object Info -----------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "SystemZTargetObjectFile.h"
10+
#include "llvm/MC/MCExpr.h"
11+
#include "llvm/MC/MCValue.h"
12+
#include "llvm/Target/TargetMachine.h"
13+
14+
using namespace llvm;
15+
16+
const MCExpr *SystemZELFTargetObjectFile::getDebugThreadLocalSymbol(
17+
const MCSymbol *Sym) const {
18+
return MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_DTPOFF, getContext());
19+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//===-- SystemZTargetObjectFile.h - SystemZ Object Info ---------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETOBJECTFILE_H
10+
#define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETOBJECTFILE_H
11+
12+
#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
13+
14+
namespace llvm {
15+
16+
/// This implementation is used for SystemZ ELF targets.
17+
class SystemZELFTargetObjectFile : public TargetLoweringObjectFileELF {
18+
public:
19+
SystemZELFTargetObjectFile() {}
20+
21+
/// Describe a TLS variable address within debug info.
22+
const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const override;
23+
};
24+
25+
} // end namespace llvm
26+
27+
#endif

0 commit comments

Comments
 (0)