[llvm] r218407 - Add support for ARM and AArch64 BE object files
Renato Golin
renato.golin at linaro.org
Wed Sep 24 13:07:30 PDT 2014
Author: rengolin
Date: Wed Sep 24 15:07:30 2014
New Revision: 218407
URL: http://llvm.org/viewvc/llvm-project?rev=218407&view=rev
Log:
Add support for ARM and AArch64 BE object files
This change fixes the ARM and AArch64 relocation visitors in
RelocVisitor. They were unconditionally assuming the object data are
little-endian. Tests have been added to ensure that the
llvm-dwarfdump utility does not crash when processing big-endian
object files.
Patch by Charlie Turner.
Added:
llvm/trunk/test/tools/llvm-dwarfdump/AArch64/big-endian-dump.ll
llvm/trunk/test/tools/llvm-dwarfdump/AArch64/lit.local.cfg
llvm/trunk/test/tools/llvm-dwarfdump/ARM/big-endian-dump.ll
llvm/trunk/test/tools/llvm-dwarfdump/ARM/lit.local.cfg
Modified:
llvm/trunk/include/llvm/Object/RelocVisitor.h
Modified: llvm/trunk/include/llvm/Object/RelocVisitor.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/RelocVisitor.h?rev=218407&r1=218406&r2=218407&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/RelocVisitor.h (original)
+++ llvm/trunk/include/llvm/Object/RelocVisitor.h Wed Sep 24 15:07:30 2014
@@ -306,7 +306,8 @@ private:
// AArch64 ELF
RelocToApply visitELF_AARCH64_ABS32(RelocationRef R, uint64_t Value) {
- int64_t Addend = getAddend64LE(R);
+ int64_t Addend;
+ getELFRelocationAddend(R, Addend);
int64_t Res = Value + Addend;
// Overflow check allows for both signed and unsigned interpretation.
@@ -317,7 +318,8 @@ private:
}
RelocToApply visitELF_AARCH64_ABS64(RelocationRef R, uint64_t Value) {
- int64_t Addend = getAddend64LE(R);
+ int64_t Addend;
+ getELFRelocationAddend(R, Addend);
return RelocToApply(Value + Addend, 8);
}
@@ -354,8 +356,15 @@ private:
}
RelocToApply visitELF_ARM_ABS32(RelocationRef R, uint64_t Value) {
- int64_t Addend = getAddend32LE(R);
- return RelocToApply(Value + Addend, 4);
+ int64_t Addend;
+ getELFRelocationAddend(R, Addend);
+ int64_t Res = Value + Addend;
+
+ // Overflow check allows for both signed and unsigned interpretation.
+ if (Res < INT32_MIN || Res > UINT32_MAX)
+ HasError = true;
+
+ return RelocToApply(static_cast<uint32_t>(Res), 4);
}
};
Added: llvm/trunk/test/tools/llvm-dwarfdump/AArch64/big-endian-dump.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/AArch64/big-endian-dump.ll?rev=218407&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/AArch64/big-endian-dump.ll (added)
+++ llvm/trunk/test/tools/llvm-dwarfdump/AArch64/big-endian-dump.ll Wed Sep 24 15:07:30 2014
@@ -0,0 +1,16 @@
+; RUN: llc -O0 -filetype=obj -o %t1 < %s
+; RUN: llvm-dwarfdump %t1
+
+target datalayout = "E-m:e-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64_be-none--eabi"
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4}
+!llvm.ident = !{!5}
+
+!0 = metadata !{i32 786449, metadata !1, i32 12, metadata !"clang version 3.6.0 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !2, metadata !2, metadata !2, metadata !"", i32 1} ; [ DW_TAG_compile_unit ] [/a/empty.c] [DW_LANG_C99]
+!1 = metadata !{metadata !"empty.c", metadata !"/a"}
+!2 = metadata !{}
+!3 = metadata !{i32 2, metadata !"Dwarf Version", i32 4}
+!4 = metadata !{i32 2, metadata !"Debug Info Version", i32 1}
+!5 = metadata !{metadata !"clang version 3.6.0 "}
Added: llvm/trunk/test/tools/llvm-dwarfdump/AArch64/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/AArch64/lit.local.cfg?rev=218407&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/AArch64/lit.local.cfg (added)
+++ llvm/trunk/test/tools/llvm-dwarfdump/AArch64/lit.local.cfg Wed Sep 24 15:07:30 2014
@@ -0,0 +1,2 @@
+if not 'AArch64' in config.root.targets:
+ config.unsupported = True
Added: llvm/trunk/test/tools/llvm-dwarfdump/ARM/big-endian-dump.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/ARM/big-endian-dump.ll?rev=218407&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/ARM/big-endian-dump.ll (added)
+++ llvm/trunk/test/tools/llvm-dwarfdump/ARM/big-endian-dump.ll Wed Sep 24 15:07:30 2014
@@ -0,0 +1,18 @@
+; RUN: llc -O0 -filetype=obj -o %t1 < %s
+; RUN: llvm-dwarfdump %t1
+
+target datalayout = "E-m:e-p:32:32-i64:64-v128:64:128-n32-S64"
+target triple = "armebv8-none--eabi"
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5, !6}
+!llvm.ident = !{!7}
+
+!0 = metadata !{i32 786449, metadata !1, i32 12, metadata !"clang version 3.6.0 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !2, metadata !2, metadata !2, metadata !"", i32 1} ; [ DW_TAG_compile_unit ] [/a/empty.c] [DW_LANG_C99]
+!1 = metadata !{metadata !"empty.c", metadata !"/a"}
+!2 = metadata !{}
+!3 = metadata !{i32 2, metadata !"Dwarf Version", i32 4}
+!4 = metadata !{i32 2, metadata !"Debug Info Version", i32 1}
+!5 = metadata !{i32 1, metadata !"wchar_size", i32 4}
+!6 = metadata !{i32 1, metadata !"min_enum_size", i32 4}
+!7 = metadata !{metadata !"clang version 3.6.0 "}
Added: llvm/trunk/test/tools/llvm-dwarfdump/ARM/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/ARM/lit.local.cfg?rev=218407&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/ARM/lit.local.cfg (added)
+++ llvm/trunk/test/tools/llvm-dwarfdump/ARM/lit.local.cfg Wed Sep 24 15:07:30 2014
@@ -0,0 +1,2 @@
+if not 'ARM' in config.root.targets:
+ config.unsupported = True
More information about the llvm-commits
mailing list