summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2017-08-16 19:01:22 +0000
committerSimon Atanasyan <simon@atanasyan.com>2017-08-16 19:01:22 +0000
commitcb833076aca55d545cf2b6b3c28b07423bc48085 (patch)
tree89df1f352612a81d6b4aa1c8c3c2051d6884803e
parent69639c24f930a987c1656be56e3b205e182550e5 (diff)
downloadbcm5719-llvm-cb833076aca55d545cf2b6b3c28b07423bc48085.tar.gz
bcm5719-llvm-cb833076aca55d545cf2b6b3c28b07423bc48085.zip
[mips] Handle R_MIPS_TLS_DTPREL32/64 relocations in the RelocVisitor
Debug information for TLS variables on MIPS might have R_MIPS_TLS_DTPREL32 or R_MIPS_TLS_DTPREL64 relocations. This patch adds a support for such relocations in the `RelocVisitor`. llvm-svn: 311031
-rw-r--r--llvm/include/llvm/Object/RelocVisitor.h5
-rw-r--r--llvm/test/DebugInfo/Mips/dwarfdump-tls.ll21
2 files changed, 26 insertions, 0 deletions
diff --git a/llvm/include/llvm/Object/RelocVisitor.h b/llvm/include/llvm/Object/RelocVisitor.h
index c358d399643..35bfc245236 100644
--- a/llvm/include/llvm/Object/RelocVisitor.h
+++ b/llvm/include/llvm/Object/RelocVisitor.h
@@ -169,6 +169,8 @@ private:
return (Value + getELFAddend(R)) & 0xFFFFFFFF;
case ELF::R_MIPS_64:
return Value + getELFAddend(R);
+ case ELF::R_MIPS_TLS_DTPREL64:
+ return Value + getELFAddend(R) - 0x8000;
}
HasError = true;
return 0;
@@ -260,8 +262,11 @@ private:
}
uint64_t visitMips32(uint32_t Rel, RelocationRef R, uint64_t Value) {
+ // FIXME: Take in account implicit addends to get correct results.
if (Rel == ELF::R_MIPS_32)
return Value & 0xFFFFFFFF;
+ if (Rel == ELF::R_MIPS_TLS_DTPREL32)
+ return Value & 0xFFFFFFFF;
HasError = true;
return 0;
}
diff --git a/llvm/test/DebugInfo/Mips/dwarfdump-tls.ll b/llvm/test/DebugInfo/Mips/dwarfdump-tls.ll
new file mode 100644
index 00000000000..54bb7b765f4
--- /dev/null
+++ b/llvm/test/DebugInfo/Mips/dwarfdump-tls.ll
@@ -0,0 +1,21 @@
+; RUN: llc -O0 -march=mips -mcpu=mips32r2 -filetype=obj -o=%t-32.o < %s
+; RUN: llvm-dwarfdump %t-32.o 2>&1 | FileCheck %s
+; RUN: llc -O0 -march=mips64 -mcpu=mips64r2 -filetype=obj -o=%t-64.o < %s
+; RUN: llvm-dwarfdump %t-64.o 2>&1 | FileCheck %s
+
+@x = thread_local global i32 5, align 4, !dbg !0
+
+; CHECK-NOT: error: failed to compute relocation: R_MIPS_TLS_DTPREL
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!7, !8}
+
+!0 = !DIGlobalVariableExpression(var: !1)
+!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
+!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 4.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
+!3 = !DIFile(filename: "tls.c", directory: "/tmp")
+!4 = !{}
+!5 = !{!0}
+!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!7 = !{i32 2, !"Dwarf Version", i32 4}
+!8 = !{i32 2, !"Debug Info Version", i32 3}
OpenPOWER on IntegriCloud