summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-07-06 12:18:44 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-07-06 12:18:44 +0000
commit5504eb79b446d7356c679b96b4defa0082a91729 (patch)
tree108d6b09563a2d823cb9df3f2abd930f3611cc26
parenta5fa4d1d7e9e95a0e0385f4fee7fd102d7db41a9 (diff)
downloadbcm5719-llvm-5504eb79b446d7356c679b96b4defa0082a91729.tar.gz
bcm5719-llvm-5504eb79b446d7356c679b96b4defa0082a91729.zip
Fix handling of ELF::R_MIPS_32 on Mips64.
Thanks to Aboud, Amjad for reporting the regression and providing the testcase. llvm-svn: 241440
-rw-r--r--llvm/include/llvm/Object/RelocVisitor.h15
-rw-r--r--llvm/test/Object/Inputs/elf-mip64-reloc.obin0 -> 3208 bytes
-rw-r--r--llvm/test/Object/Mips/reloc-visit.test6
3 files changed, 17 insertions, 4 deletions
diff --git a/llvm/include/llvm/Object/RelocVisitor.h b/llvm/include/llvm/Object/RelocVisitor.h
index 950e2ed0e33..d5e4258cb0a 100644
--- a/llvm/include/llvm/Object/RelocVisitor.h
+++ b/llvm/include/llvm/Object/RelocVisitor.h
@@ -100,9 +100,9 @@ private:
case Triple::mips64:
switch (RelocType) {
case llvm::ELF::R_MIPS_32:
- return visitELF_MIPS_32(R, Value);
+ return visitELF_MIPS64_32(R, Value);
case llvm::ELF::R_MIPS_64:
- return visitELF_MIPS_64(R, Value);
+ return visitELF_MIPS64_64(R, Value);
default:
HasError = true;
return RelocToApply();
@@ -313,11 +313,18 @@ private:
/// MIPS ELF
RelocToApply visitELF_MIPS_32(RelocationRef R, uint64_t Value) {
- uint32_t Res = (Value)&0xFFFFFFFF;
+ uint32_t Res = Value & 0xFFFFFFFF;
+ return RelocToApply(Res, 4);
+ }
+
+ /// MIPS64 ELF
+ RelocToApply visitELF_MIPS64_32(RelocationRef R, uint64_t Value) {
+ int64_t Addend = getELFAddend(R);
+ uint32_t Res = (Value + Addend) & 0xFFFFFFFF;
return RelocToApply(Res, 4);
}
- RelocToApply visitELF_MIPS_64(RelocationRef R, uint64_t Value) {
+ RelocToApply visitELF_MIPS64_64(RelocationRef R, uint64_t Value) {
int64_t Addend = getELFAddend(R);
uint64_t Res = (Value + Addend);
return RelocToApply(Res, 8);
diff --git a/llvm/test/Object/Inputs/elf-mip64-reloc.o b/llvm/test/Object/Inputs/elf-mip64-reloc.o
new file mode 100644
index 00000000000..5e689254a43
--- /dev/null
+++ b/llvm/test/Object/Inputs/elf-mip64-reloc.o
Binary files differ
diff --git a/llvm/test/Object/Mips/reloc-visit.test b/llvm/test/Object/Mips/reloc-visit.test
new file mode 100644
index 00000000000..d75551a387c
--- /dev/null
+++ b/llvm/test/Object/Mips/reloc-visit.test
@@ -0,0 +1,6 @@
+RUN: llvm-dwarfdump -debug-dump=info %p/../Inputs/elf-mip64-reloc.o 2>&1 | \
+RUN: FileCheck %s
+
+CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000037] = "<stdin>")
+CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000054] = "foo")
+CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000058] = "int")
OpenPOWER on IntegriCloud