diff options
| author | Tim Northover <Tim.Northover@arm.com> | 2013-02-11 11:16:02 +0000 |
|---|---|---|
| committer | Tim Northover <Tim.Northover@arm.com> | 2013-02-11 11:16:02 +0000 |
| commit | acaa788be6e777e8604147732fa8dab8d9b59b22 (patch) | |
| tree | 0a227703a27f50d4432b877a91748e185b82df75 | |
| parent | 45a0d77c48798b319c96c86159032803908081ad (diff) | |
| download | bcm5719-llvm-acaa788be6e777e8604147732fa8dab8d9b59b22.tar.gz bcm5719-llvm-acaa788be6e777e8604147732fa8dab8d9b59b22.zip | |
AArch64: Add basic relocation processing for llvm-dwarfdump.
This allows llvm-dwarfdump to handle the relocations needed, at least
for LLVM-produced code.
llvm-svn: 174874
| -rw-r--r-- | llvm/include/llvm/Object/RelocVisitor.h | 30 | ||||
| -rw-r--r-- | llvm/test/DebugInfo/Inputs/dwarfdump-test.elf-aarch64 | bin | 0 -> 3360 bytes | |||
| -rw-r--r-- | llvm/test/DebugInfo/dwarfdump-aarch64.test | 16 |
3 files changed, 46 insertions, 0 deletions
diff --git a/llvm/include/llvm/Object/RelocVisitor.h b/llvm/include/llvm/Object/RelocVisitor.h index edac89914d8..2dcbdf90532 100644 --- a/llvm/include/llvm/Object/RelocVisitor.h +++ b/llvm/include/llvm/Object/RelocVisitor.h @@ -92,6 +92,16 @@ public: HasError = true; return RelocToApply(); } + } else if (FileFormat == "ELF64-aarch64") { + switch (RelocType) { + case llvm::ELF::R_AARCH64_ABS32: + return visitELF_AARCH64_ABS32(R, Value); + case llvm::ELF::R_AARCH64_ABS64: + return visitELF_AARCH64_ABS64(R, Value); + default: + HasError = true; + return RelocToApply(); + } } HasError = true; return RelocToApply(); @@ -172,6 +182,26 @@ private: uint32_t Res = (Value + Addend) & 0xFFFFFFFF; return RelocToApply(Res, 4); } + + // AArch64 ELF + RelocToApply visitELF_AARCH64_ABS32(RelocationRef R, uint64_t Value) { + int64_t Addend; + R.getAdditionalInfo(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); + } + + RelocToApply visitELF_AARCH64_ABS64(RelocationRef R, uint64_t Value) { + int64_t Addend; + R.getAdditionalInfo(Addend); + return RelocToApply(Value + Addend, 8); + } + }; } diff --git a/llvm/test/DebugInfo/Inputs/dwarfdump-test.elf-aarch64 b/llvm/test/DebugInfo/Inputs/dwarfdump-test.elf-aarch64 Binary files differnew file mode 100644 index 00000000000..f5079687c98 --- /dev/null +++ b/llvm/test/DebugInfo/Inputs/dwarfdump-test.elf-aarch64 diff --git a/llvm/test/DebugInfo/dwarfdump-aarch64.test b/llvm/test/DebugInfo/dwarfdump-aarch64.test new file mode 100644 index 00000000000..2f7bc477954 --- /dev/null +++ b/llvm/test/DebugInfo/dwarfdump-aarch64.test @@ -0,0 +1,16 @@ +RUN: llvm-dwarfdump %p/Inputs/dwarfdump-test.elf-aarch64 \ +RUN: | FileCheck %s + +We're mostly checking that relocations are applied correctly +here. Currently R_AARCH64_ABS32 is used for references to debug data +and R_AARCH64_ABS64 is used for program addresses. + +A couple of ABS32s, both at 0 and elsewhere, interpreted correctly: + +CHECK: DW_AT_producer [DW_FORM_strp] ( .debug_str[0x00000000] = "clang version 3.3 ") +CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000013] = "tmp.c") + +A couple of ABS64s similarly: + +CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000) +CHECK: DW_AT_high_pc [DW_FORM_addr] (0x000000000000005c) |

