From b12b974df1ef038d16e5ed5a28679b30c219ad9c Mon Sep 17 00:00:00 2001 From: Dylan McKay Date: Mon, 21 Jan 2019 04:27:08 +0000 Subject: [PATCH] [AVR] Enable emission of debug information Prior to this, the code was missing AVR-specific relocation logic in RelocVisitor.h. This patch teaches RelocVisitor about R_AVR_16 and R_AVR_32. Debug information is emitted in the final object file, and understood by 'avr-readelf --debug-dump' from AVR-GCC. llvm-dwarfdump is yet to understand how to dump AVR DWARF symbols. llvm-svn: 351720 --- include/llvm/Object/RelocVisitor.h | 12 ++++++++++++ lib/Target/AVR/MCTargetDesc/AVRMCAsmInfo.cpp | 1 + 2 files changed, 13 insertions(+) diff --git a/include/llvm/Object/RelocVisitor.h b/include/llvm/Object/RelocVisitor.h index a1696c54daa..1d3d79a2a1a 100644 --- a/include/llvm/Object/RelocVisitor.h +++ b/include/llvm/Object/RelocVisitor.h @@ -100,6 +100,8 @@ private: case Triple::arm: case Triple::armeb: return visitARM(Rel, R, Value); + case Triple::avr: + return visitAVR(Rel, R, Value); case Triple::lanai: return visitLanai(Rel, R, Value); case Triple::mipsel: @@ -258,6 +260,16 @@ private: return 0; } + uint64_t visitAVR(uint32_t Rel, RelocationRef R, uint64_t Value) { + if (Rel == ELF::R_AVR_16) { + return (Value + getELFAddend(R)) & 0xFFFF; + } else if (Rel == ELF::R_AVR_32) { + return (Value + getELFAddend(R)) & 0xFFFFFFFF; + } + HasError = true; + return 0; + } + uint64_t visitLanai(uint32_t Rel, RelocationRef R, uint64_t Value) { if (Rel == ELF::R_LANAI_32) return (Value + getELFAddend(R)) & 0xFFFFFFFF; diff --git a/lib/Target/AVR/MCTargetDesc/AVRMCAsmInfo.cpp b/lib/Target/AVR/MCTargetDesc/AVRMCAsmInfo.cpp index 2830f94a5e4..99b2172c562 100644 --- a/lib/Target/AVR/MCTargetDesc/AVRMCAsmInfo.cpp +++ b/lib/Target/AVR/MCTargetDesc/AVRMCAsmInfo.cpp @@ -23,6 +23,7 @@ AVRMCAsmInfo::AVRMCAsmInfo(const Triple &TT) { PrivateGlobalPrefix = ".L"; UsesELFSectionDirectiveForBSS = true; UseIntegratedAssembler = true; + SupportsDebugInformation = true; } } // end of namespace llvm